예제 #1
0
  @Test
  public void testFeatureReaderWithFilterBBoxPOST()
      throws NoSuchElementException, IllegalAttributeException, IOException, SAXException,
          IllegalFilterException {
    if (url == null) return;

    Map m = new HashMap();
    m.put(WFSDataStoreFactory.URL.key, url);
    m.put(WFSDataStoreFactory.TIMEOUT.key, new Integer(100000));
    DataStore post = (WFS_1_0_0_DataStore) (new WFSDataStoreFactory()).createDataStore(m);

    String typeName = post.getTypeNames()[0];
    Envelope bbox = post.getFeatureSource(typeName).getBounds();

    WFSDataStoreReadTest.doFeatureReaderWithBBox(url, true, false, 0, bbox);
  }
예제 #2
0
  @Test
  public void testTypes() throws IOException, NoSuchElementException {
    if (url == null) return;
    WFS_1_0_0_DataStore wfs;
    try {
      wfs = WFSDataStoreReadTest.getDataStore(url);
    } catch (ConnectException e) {
      e.printStackTrace(System.err);
      return;
    } catch (UnknownHostException e) {
      e.printStackTrace(System.err);
      return;
    } catch (NoRouteToHostException e) {
      e.printStackTrace(System.err);
      return;
    }
    String types[] = wfs.getTypeNames();
    String typeName = "unknown";
    for (int i = 0; i < types.length; i++) {
      typeName = types[i];
      if (typeName.equals("topp:geometrytype")) continue;
      SimpleFeatureType type = wfs.getSchema(typeName);
      type.getTypeName();
      type.getName().getNamespaceURI();

      SimpleFeatureSource source = wfs.getFeatureSource(typeName);
      source.getBounds();

      SimpleFeatureCollection features = source.getFeatures();
      features.getBounds();
      features.getSchema();
      // features.getFeatureType();

      Query query = new Query(typeName, Filter.INCLUDE, 20, Query.ALL_NAMES, "work already");
      features = source.getFeatures(query);
      features.size();
      SimpleFeatureIterator iterator = features.features();
      try {
        while (iterator.hasNext()) {
          SimpleFeature feature = (SimpleFeature) iterator.next();
        }
      } finally {
        iterator.close();
      }
    }
  }
예제 #3
0
  @Test
  public void testSingleType() throws IOException, NoSuchElementException {
    if (url == null) return;
    WFS_1_0_0_DataStore wfs;
    try {
      wfs = WFSDataStoreReadTest.getDataStore(url);
    } catch (ConnectException e) {
      e.printStackTrace(System.err);
      return;
    } catch (UnknownHostException e) {
      e.printStackTrace(System.err);
      return;
    } catch (NoRouteToHostException e) {
      e.printStackTrace(System.err);
      return;
    }
    String typeName = "tiger:poi";
    SimpleFeatureType type = wfs.getSchema(typeName);
    type.getTypeName();
    type.getName().getNamespaceURI();

    SimpleFeatureSource source = wfs.getFeatureSource(typeName);
    source.getBounds();

    SimpleFeatureCollection features = source.getFeatures();
    features.getBounds();
    features.getSchema();
    // features.getFeatureType();

    Query query = new Query(typeName, Filter.INCLUDE, 20, Query.ALL_NAMES, "work already");
    features = source.getFeatures(query);
    features.size();

    SimpleFeatureIterator iterator = features.features();
    while (iterator.hasNext()) {
      SimpleFeature feature = iterator.next();
    }
    iterator.close();
  }
예제 #4
0
 @Test
 public void testFeatureReaderWithFilterPOST()
     throws NoSuchElementException, IllegalAttributeException, IOException, SAXException {
   WFSDataStoreReadTest.doFeatureReaderWithQuery(url, false, true, 0);
 }
예제 #5
0
  /** {@link BBOX} support? */
  @Test
  public void testDataStoreSupportsPlainBBOXInterface() throws Exception {
    if (url == null) return;
    final WFS_1_0_0_DataStore wfs = WFSDataStoreReadTest.getDataStore(url);
    final SimpleFeatureType ft = wfs.getSchema(TO_EDIT_TYPE);
    final ReferencedEnvelope bounds = wfs.getFeatureSource(TO_EDIT_TYPE).getBounds();

    final FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(GeoTools.getDefaultHints());
    final BBOX bbox =
        ff.bbox(
            "the_geom",
            bounds.getMinX(),
            bounds.getMinY(),
            bounds.getMaxX(),
            bounds.getMaxY(),
            null);

    /** This one does not implement the deprecated geotools filter interfaces */
    final BBOX strictBBox =
        new BBOX() {

          public boolean evaluate(Object object) {
            return bbox.evaluate(object);
          }

          public Object accept(FilterVisitor visitor, Object extraData) {
            return bbox.accept(visitor, extraData);
          }

          public Expression getExpression2() {
            return bbox.getExpression2();
          }

          public Expression getExpression1() {
            return bbox.getExpression1();
          }

          public String getSRS() {
            return bbox.getSRS();
          }

          public String getPropertyName() {
            return bbox.getPropertyName();
          }

          public double getMinY() {
            return bbox.getMinY();
          }

          public double getMinX() {
            return bbox.getMinX();
          }

          public double getMaxY() {
            return bbox.getMaxY();
          }

          public double getMaxX() {
            return bbox.getMaxX();
          }

          public MatchAction getMatchAction() {
            return MatchAction.ANY;
          }

          public BoundingBox getBounds() {
            return bbox.getBounds();
          }
        };

    final Query query = new Query(ft.getTypeName());
    query.setFilter(strictBBox);

    FeatureReader<SimpleFeatureType, SimpleFeature> reader;

    reader = wfs.getFeatureReaderGet(query, Transaction.AUTO_COMMIT);
    assertNotNull(reader);

    reader = wfs.getFeatureReaderPost(query, Transaction.AUTO_COMMIT);
    assertNotNull(reader);
  }
예제 #6
0
 @Test
 public void testFeatureReader()
     throws NoSuchElementException, IOException, IllegalAttributeException, SAXException {
   WFSDataStoreReadTest.doFeatureReader(url, true, true, 0);
 }
예제 #7
0
 public void XtestFeatureType() throws NoSuchElementException, IOException, SAXException {
   WFSDataStoreReadTest.doFeatureType(url, true, true, 0);
 }