dq.setFilter(ff.greater(ff.property("PERSONS"), ff.literal(20000000))); FeatureCollection fc = fs.getFeatures(dq); if (fc.size() != 1) {
private Filter toGreaterFilter(FilterFactory ff, Expression variable, Range<T> range) { if (range.isMinIncluded()) { return ff.greaterOrEqual(variable, ff.literal(range.getMinValue())); } else { return ff.greater(variable, ff.literal(range.getMinValue())); } }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { Expression e1 = (Expression) node.getChildValue(0); Expression e2 = (Expression) node.getChildValue(1); return filterfactory.greater(e1, e2); } }
public void testSimplifyStaticExclude() { assertEquals(Filter.EXCLUDE, simplify(ff.greater(ff.literal(3), ff.literal(5)))); assertEquals(Filter.EXCLUDE, simplify(ff.greaterOrEqual(ff.literal(3), ff.literal(5)))); assertEquals(Filter.EXCLUDE, simplify(ff.less(ff.literal(5), ff.literal(3)))); assertEquals(Filter.EXCLUDE, simplify(ff.lessOrEqual(ff.literal(5), ff.literal(3)))); assertEquals(Filter.EXCLUDE, simplify(ff.equal(ff.literal(5), ff.literal(3), true))); assertEquals( Filter.EXCLUDE, simplify(ff.between(ff.literal(3), ff.literal(1), ff.literal(2)))); }
/** * @return PropertyIsGreaterThan * @throws CQLException */ public PropertyIsGreaterThan buildGreater() throws CQLException { Expression right = this.resultStack.popExpression(); Expression left = this.resultStack.popExpression(); return filterFactory.greater(left, right); }
public void testSimplifyStaticInclude() { assertEquals(Filter.INCLUDE, simplify(ff.less(ff.literal(3), ff.literal(5)))); assertEquals(Filter.INCLUDE, simplify(ff.lessOrEqual(ff.literal(3), ff.literal(5)))); assertEquals(Filter.INCLUDE, simplify(ff.greater(ff.literal(5), ff.literal(3)))); assertEquals(Filter.INCLUDE, simplify(ff.greaterOrEqual(ff.literal(5), ff.literal(3)))); assertEquals(Filter.INCLUDE, simplify(ff.equal(ff.literal(5), ff.literal(5), true))); assertEquals( Filter.INCLUDE, simplify(ff.between(ff.literal(3), ff.literal(1), ff.literal(4)))); }
/** * creates PropertyIsGreaterThan end date of period * * @return PropertyIsGreaterThan * @throws CQLException */ public PropertyIsGreaterThan buildPropertyIsGTLastDate() throws CQLException { Result node = this.resultStack.popResult(); PeriodNode period = (PeriodNode) node.getBuilt(); org.opengis.filter.expression.Literal date = period.getEnding(); org.opengis.filter.expression.Expression property = this.resultStack.popExpression(); PropertyIsGreaterThan filter = filterFactory.greater(property, date); return filter; }
public void testCoalesheNestedAnd() { Filter eq = ff.equal(ff.property("A"), ff.literal("3"), true); Filter gt = ff.greater(ff.property("b"), ff.literal("3")); Filter lt = ff.less(ff.property("c"), ff.literal("5")); And nested = ff.and(Arrays.asList(ff.and(Arrays.asList(eq, gt)), lt)); And simplified = (And) nested.accept(simpleVisitor, null); assertEquals(3, simplified.getChildren().size()); assertEquals(ff.and(Arrays.asList(eq, gt, lt)), simplified); }
public void testCoalesheNestedOr() { Filter eq = ff.equal(ff.property("A"), ff.literal("3"), true); Filter gt = ff.greater(ff.property("b"), ff.literal("3")); Filter lt = ff.less(ff.property("c"), ff.literal("5")); Or nested = ff.or(Arrays.asList(ff.or(Arrays.asList(eq, gt)), lt)); Or simplified = (Or) nested.accept(simpleVisitor, null); assertEquals(3, simplified.getChildren().size()); assertEquals(ff.or(Arrays.asList(eq, gt, lt)), simplified); }
private Query energyConsumptionGreaterThan(double value) { FilterFactory filterFactory = dataStore.getFilterFactory(); Filter filter = filterFactory.greater( filterFactory.property(aname("energy_consumption")), filterFactory.literal(value)); return new Query(tname("buildings"), filter); }
public void testAfter() throws Exception { FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); Expression left = ff.literal(2); Expression right = ff.literal(1); PropertyIsGreaterThan filter = ff.greater(left, right); assertTrue(filter.evaluate(null)); assertTrue(filter instanceof PropertyIsGreaterThan); } }
public void testNegateBetween() { PropertyName prop = ff.property("prop"); Literal l10 = ff.literal(10); Literal l20 = ff.literal(20); Filter f = ff.not(ff.between(prop, l10, l20)); Filter result = (Filter) f.accept(simpleVisitor, null); assertEquals( ff.or(Arrays.asList((Filter) ff.less(prop, l10), ff.greater(prop, l20))), result); }
@Test public void testPlainFilter() { Filter f = ff.greater(ff.property("attribute"), ff.literal(10)); Rule r = sb.createRule(sb.createPointSymbolizer()); r.setFilter(f); StyleAttributeExtractor extractor = new StyleAttributeExtractor(); r.accept(extractor); Set<String> atts = extractor.getAttributeNameSet(); assertTrue(atts.contains("attribute")); assertEquals(1, atts.size()); assertTrue(extractor.getDefaultGeometryUsed()); }
private <T> void testOrDisjointRanges(Class<T> type, T max, T min) throws Exception { SimpleFeatureType schema = DataUtilities.createType("test", "a:" + type.getName()); SimplifyingFilterVisitor visitor = new SimplifyingFilterVisitor(); visitor.setFeatureType(schema); Filter original = ff.or( ff.greater(ff.property("a"), ff.literal(max)), ff.less(ff.property("a"), ff.literal(min))); Filter simplified = (Filter) original.accept(visitor, null); assertEquals(original, simplified); }
public void testUniqueWithFilter() throws Exception { FilterFactory ff = dataStore.getFilterFactory(); PropertyName p = ff.property(aname("stringProperty")); UniqueVisitor v = new MyUniqueVisitor(p); Filter f = ff.greater(ff.property(aname("doubleProperty")), ff.literal(1)); Query q = new Query(tname("ft1"), f); dataStore.getFeatureSource(tname("ft1")).accepts(q, v, null); assertFalse(visited); Set result = v.getResult().toSet(); assertEquals(2, result.size()); assertTrue(result.contains("one")); assertTrue(result.contains("two")); }
public void testNegateGreater() { Filter f = ff.not(ff.greater(ff.property("prop"), ff.literal(10))); Filter result = (Filter) f.accept(simpleVisitor, null); assertEquals(ff.lessOrEqual(ff.property("prop"), ff.literal(10)), result); // not simplified for complex features result = (Filter) f.accept(complexVisitor, null); assertEquals(f, result); }
public void testNegateLessOrEqual() { Filter f = ff.not(ff.lessOrEqual(ff.property("prop"), ff.literal(10))); Filter result = (Filter) f.accept(simpleVisitor, null); assertEquals(ff.greater(ff.property("prop"), ff.literal(10)), result); // not simplified for complex features result = (Filter) f.accept(complexVisitor, null); assertEquals(f, result); }
public void testNegateOr() throws Exception { // not(a > 3 or b = 5 or c < 0) Filter fa = ff.greater(ff.property(aname(A)), ff.literal(3)); Filter fb = ff.equal(ff.property(aname(B)), ff.literal(5), false); Filter fc = ff.less(ff.property(aname(C)), ff.literal(0)); Not filter = ff.not(ff.and(Arrays.asList(fa, fb, fc))); ContentFeatureSource fs = dataStore.getFeatureSource(tname(ABC)); Query q = new Query(tname(ABC), filter); int count = fs.getCount(q); assertEquals(2, count); }
public void testGreater() throws IOException { FilterFactory ff = dataStore.getFilterFactory(); Function function = ff.function( "in", ff.property(aname("intProperty")), ff.literal("1"), ff.literal("2")); Filter filter = ff.greater(function, ff.literal("false"), false); SimpleFeatureSource fs = dataStore.getFeatureSource(tname("ft1")); SimpleFeatureCollection fc = fs.getFeatures(filter); assertEquals(getCaseInsensitiveSet("ft1.1", "ft1.2"), collectFeatureIds(fc)); }
public void testMinWithFilter() throws Exception { FilterFactory ff = dataStore.getFilterFactory(); PropertyName p = ff.property(aname("doubleProperty")); MinVisitor v = new MyMinVisitor(p); Filter f = ff.greater(ff.property(aname("doubleProperty")), ff.literal(1)); Query q = new Query(tname("ft1"), f); dataStore.getFeatureSource(tname("ft1")).accepts(q, v, null); assertFalse(visited); assertEquals(1.1, v.getResult().toDouble(), 0.01); }