Example #1
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);
  }