@Test public void testSplitFiltersOr() { Capabilities caps = new Capabilities(); caps.addAll(Capabilities.LOGICAL); caps.addAll(Capabilities.SIMPLE_COMPARISONS); caps.addName(Intersects.NAME); caps.addName(BBOX.NAME); caps.addName(Crosses.NAME); final Geometry geom = new GeometryFactory().createPoint(new Coordinate(0, 0)); FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); Filter intersects = ff.intersects(ff.property("geom"), ff.literal(geom)); Filter bbox = ff.bbox(ff.property("geom"), 0, 0, 1, 1, "EPSG:4326"); Filter filter = ff.or(intersects, bbox); Filter[] splitted = strategy.splitFilters(caps, filter); Filter supported = splitted[0]; Filter unsupported = splitted[1]; assertEquals(Filter.INCLUDE, supported); assertEquals(filter, unsupported); }
@Override public Filter[] splitFilters(final Capabilities caps, final Filter queryFilter) { if (!(queryFilter instanceof BinaryLogicOperator)) { return super.splitFilters(caps, queryFilter); } int spatialFiltersCount = 0; List<Filter> children = ((BinaryLogicOperator) queryFilter).getChildren(); for (Filter f : children) { if (f instanceof BinarySpatialOperator) { spatialFiltersCount++; } } if (spatialFiltersCount <= 1) { return super.splitFilters(caps, queryFilter); } Filter serverFilter; Filter postFilter; if (queryFilter instanceof Or) { serverFilter = Filter.INCLUDE; postFilter = queryFilter; } else { List<Filter> serverChild = new ArrayList<Filter>(); List<Filter> postChild = new ArrayList<Filter>(); boolean spatialAdded = false; for (Filter f : children) { if (f instanceof BinarySpatialOperator) { if (spatialAdded) { postChild.add(f); } else { serverChild.add(f); spatialAdded = true; } } else { serverChild.add(f); } } FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); serverFilter = ff.and(serverChild); postFilter = ff.and(postChild); SimplifyingFilterVisitor sfv = new SimplifyingFilterVisitor(); serverFilter = (Filter) serverFilter.accept(sfv, null); postFilter = (Filter) postFilter.accept(sfv, null); } return new Filter[] { serverFilter, postFilter }; }
CubeWerxStrategy extends DefaultWFSStrategy { @Override public Filter[] splitFilters(final Capabilities caps, final Filter queryFilter) { if (!(queryFilter instanceof BinaryLogicOperator)) { return super.splitFilters(caps, queryFilter); } int spatialFiltersCount = 0; List<Filter> children = ((BinaryLogicOperator) queryFilter).getChildren(); for (Filter f : children) { if (f instanceof BinarySpatialOperator) { spatialFiltersCount++; } } if (spatialFiltersCount <= 1) { return super.splitFilters(caps, queryFilter); } Filter serverFilter; Filter postFilter; if (queryFilter instanceof Or) { serverFilter = Filter.INCLUDE; postFilter = queryFilter; } else { List<Filter> serverChild = new ArrayList<Filter>(); List<Filter> postChild = new ArrayList<Filter>(); boolean spatialAdded = false; for (Filter f : children) { if (f instanceof BinarySpatialOperator) { if (spatialAdded) { postChild.add(f); } else { serverChild.add(f); spatialAdded = true; } } else { serverChild.add(f); } } FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); serverFilter = ff.and(serverChild); postFilter = ff.and(postChild); SimplifyingFilterVisitor sfv = new SimplifyingFilterVisitor(); serverFilter = (Filter) serverFilter.accept(sfv, null); postFilter = (Filter) postFilter.accept(sfv, null); } return new Filter[] { serverFilter, postFilter }; } }
CubeWerxStrategy extends DefaultWFSStrategy { @Override public Filter[] splitFilters(final Capabilities caps, final Filter queryFilter) { if (!(queryFilter instanceof BinaryLogicOperator)) { return super.splitFilters(caps, queryFilter); } int spatialFiltersCount = 0; List<Filter> children = ((BinaryLogicOperator) queryFilter).getChildren(); for (Filter f : children) { if (f instanceof BinarySpatialOperator) { spatialFiltersCount++; } } if (spatialFiltersCount <= 1) { return super.splitFilters(caps, queryFilter); } Filter serverFilter; Filter postFilter; if (queryFilter instanceof Or) { serverFilter = Filter.INCLUDE; postFilter = queryFilter; } else { List<Filter> serverChild = new ArrayList<Filter>(); List<Filter> postChild = new ArrayList<Filter>(); boolean spatialAdded = false; for (Filter f : children) { if (f instanceof BinarySpatialOperator) { if (spatialAdded) { postChild.add(f); } else { serverChild.add(f); spatialAdded = true; } } else { serverChild.add(f); } } FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); serverFilter = ff.and(serverChild); postFilter = ff.and(postChild); SimplifyingFilterVisitor sfv = new SimplifyingFilterVisitor(); serverFilter = (Filter) serverFilter.accept(sfv, null); postFilter = (Filter) postFilter.accept(sfv, null); } return new Filter[] { serverFilter, postFilter }; }  }
CubeWerxStrategy extends DefaultWFSStrategy { @Override public Filter[] splitFilters(final Capabilities caps, final Filter queryFilter) { if (!(queryFilter instanceof BinaryLogicOperator)) { return super.splitFilters(caps, queryFilter); } int spatialFiltersCount = 0; List<Filter> children = ((BinaryLogicOperator) queryFilter).getChildren(); for (Filter f : children) { if (f instanceof BinarySpatialOperator) { spatialFiltersCount++; } } if (spatialFiltersCount <= 1) { return super.splitFilters(caps, queryFilter); } Filter serverFilter; Filter postFilter; if (queryFilter instanceof Or) { serverFilter = Filter.INCLUDE; postFilter = queryFilter; } else { List<Filter> serverChild = new ArrayList<Filter>(); List<Filter> postChild = new ArrayList<Filter>(); boolean spatialAdded = false; for (Filter f : children) { if (f instanceof BinarySpatialOperator) { if (spatialAdded) { postChild.add(f); } else { serverChild.add(f); spatialAdded = true; } } else { serverChild.add(f); } } FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); serverFilter = ff.and(serverChild); postFilter = ff.and(postChild); SimplifyingFilterVisitor sfv = new SimplifyingFilterVisitor(); serverFilter = (Filter) serverFilter.accept(sfv, null); postFilter = (Filter) postFilter.accept(sfv, null); } return new Filter[] { serverFilter, postFilter }; }  @SuppressWarnings("nls") @Override RequestComponents createGetFeatureRequest(WFSProtocol wfs, GetFeature query); @Override Filter[] splitFilters(final Capabilities caps, final Filter queryFilter); }
CubeWerxStrategy extends DefaultWFSStrategy { @Override public Filter[] splitFilters(final Capabilities caps, final Filter queryFilter) { if (!(queryFilter instanceof BinaryLogicOperator)) { return super.splitFilters(caps, queryFilter); } int spatialFiltersCount = 0; List<Filter> children = ((BinaryLogicOperator) queryFilter).getChildren(); for (Filter f : children) { if (f instanceof BinarySpatialOperator) { spatialFiltersCount++; } } if (spatialFiltersCount <= 1) { return super.splitFilters(caps, queryFilter); } Filter serverFilter; Filter postFilter; if (queryFilter instanceof Or) { serverFilter = Filter.INCLUDE; postFilter = queryFilter; } else { List<Filter> serverChild = new ArrayList<Filter>(); List<Filter> postChild = new ArrayList<Filter>(); boolean spatialAdded = false; for (Filter f : children) { if (f instanceof BinarySpatialOperator) { if (spatialAdded) { postChild.add(f); } else { serverChild.add(f); spatialAdded = true; } } else { serverChild.add(f); } } FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); serverFilter = ff.and(serverChild); postFilter = ff.and(postChild); SimplifyingFilterVisitor sfv = new SimplifyingFilterVisitor(); serverFilter = (Filter) serverFilter.accept(sfv, null); postFilter = (Filter) postFilter.accept(sfv, null); } return new Filter[] { serverFilter, postFilter }; }  @SuppressWarnings("nls") @Override RequestComponents createGetFeatureRequest(WFSProtocol wfs, GetFeature query); @Override Filter[] splitFilters(final Capabilities caps, final Filter queryFilter);  }