public Object visit(PropertyIsGreaterThan filter, Object arg1) { Expression[][] expressions = visitBinaryComparisonOperator(filter); List combinedFilters = new ArrayList(expressions.length); for (int i = 0; i < expressions.length; i++) { Expression left = expressions[i][0]; Expression right = expressions[i][1]; Filter unrolled = ff.greater(left, right, filter.isMatchingCase(), filter.getMatchAction()); combinedFilters.add(unrolled); } Filter unrolled = combineOred(combinedFilters); return unrolled; }
isIncludedInThreshold = ff.greater(lookupExp, threshholdExp); } else { isIncludedInThreshold = ff.greaterOrEqual(lookupExp, threshholdExp);
return factory.greater(expr1, expr2);
/** Delegates to FilterFactory2 */ public static boolean greaterThan(Object o1, Object o2) { return getFilterFactory2().greater(ff.literal(o1), ff.literal(o2)).evaluate(null); }
return factory.greater(expr1, expr2);
static PropertyIsGreaterThan propertyFuncIsGreaterThan() { return f.greater(propertyNameIsFunc(), literal()); }
/** * Builds a filter that compares a and b: <code>a compare b</code> * * @param filterType * @param a * @param b * @return */ org.opengis.filter.Filter compare( Class filterType, org.opengis.filter.expression.Expression a, org.opengis.filter.expression.Expression b) { if (filterType == PropertyIsLessThan.class) { return fac.less(a, b); } else if (filterType == PropertyIsLessThanOrEqualTo.class) { return fac.lessOrEqual(a, b); } if (filterType == PropertyIsEqualTo.class) { return fac.equals(a, b); } else if (filterType == PropertyIsGreaterThanOrEqualTo.class) { return fac.greaterOrEqual(a, b); } else if (filterType == PropertyIsGreaterThan.class) { return fac.greater(a, b); } else { throw new IllegalArgumentException("Uknown compare filter type " + filterType); } }
public static PropertyIsGreaterThan propertyIsGreaterThan() { return f.greater(propertyName(), literal()); }
PropertyIsBetween pb = (PropertyIsBetween) simplified; Filter lt = ff.less(pb.getExpression(), pb.getLowerBoundary()); Filter gt = ff.greater(pb.getExpression(), pb.getUpperBoundary()); return ff.or(lt, gt); } else if (simplified instanceof PropertyIsEqualTo) { } else if (simplified instanceof PropertyIsLessThanOrEqualTo) { PropertyIsLessThanOrEqualTo pl = (PropertyIsLessThanOrEqualTo) simplified; return ff.greater(pl.getExpression1(), pl.getExpression2(), pl.isMatchingCase());
static PropertyIsGreaterThan propertyIsGreaterThan() { return f.greater(propertyName(), literal()); }
public Object visit(PropertyIsGreaterThan filter, Object extraData) { Expression expr1 = visit(filter.getExpression1(), extraData); Expression expr2 = visit(filter.getExpression2(), extraData); return getFactory(extraData) .greater(expr1, expr2, filter.isMatchingCase(), filter.getMatchAction()); }
/** Example located on the wiki */ public void testDefaultFilterVisitorPropertyNameExample() { Filter myFilter = ff.greater(ff.add(ff.property("foo"), ff.property("bar")), ff.literal(1)); class FindNames extends DefaultFilterVisitor { public Object visit(PropertyName expression, Object data) { Set set = (Set) data; set.add(expression.getPropertyName()); return set; } } Set set = (Set) myFilter.accept(new FindNames(), new HashSet()); assertTrue(set.contains("foo")); }
@Test public void testOtherFilter() { PropertyName label = ff.property("label"); Filter f1 = ff.greater(label, ff.literal("abc")); Filter f2 = ff.greater(label, ff.literal("adc")); Filter f3 = ff.notEqual(ff.function("random"), ff.property("i")); RangeCombiner rc = new RangeCombiner.And(ff, ft, Arrays.asList(f1, f2, f3)); List<Filter> reduced = rc.getReducedFilters(); assertEquals(2, reduced.size()); assertTrue(reduced.contains(f2)); assertTrue(reduced.contains(f3)); } }
@Override public Object visit(PropertyIsGreaterThan filter, Object extraData) { Class targetType = getTargetType(filter.getExpression1(), filter.getExpression2()); Expression expr1 = optimize(filter.getExpression1(), extraData, targetType); Expression expr2 = optimize(filter.getExpression2(), extraData, targetType); boolean matchCase = filter.isMatchingCase(); return getFactory(extraData).greater(expr1, expr2, matchCase, filter.getMatchAction()); }
public void testSafeConversions() { Literal d = fac.literal(1.1); Literal i = fac.literal(1); Filter f1 = fac.greater(d, i); assertTrue(f1.evaluate(null)); Filter f2 = fac.less(i, d); assertTrue(f2.evaluate(null)); }
public void testLogicFilterDuplication() throws IllegalFilterException { // create a filter PropertyIsGreaterThan greater = fac.greater(fac.literal(2), fac.literal(1)); PropertyIsLessThan less = fac.less(fac.literal(3), fac.literal(4)); And and = fac.and(greater, less); // duplicate it DuplicatingFilterVisitor visitor = new DuplicatingFilterVisitor(); Filter newFilter = (Filter) and.accept(visitor, fac); // compare it assertNotNull(newFilter); assertEquals(and, newFilter); }
private void testLogicFilter(Class<?> filterType) throws Exception { BinaryLogicOperator complexLogicFilter; PropertyIsGreaterThan resultFilter = ff.greater(ff.property("measurement/result"), ff.literal(Integer.valueOf(5)));
@BeforeClass public static void setUpBeforeClass() throws Exception { ff = CommonFactoryFinder.getFilterFactory2(null); filters = new Filters(ff); a = ff.greater(ff.property("zone"), ff.literal(7)); b = ff.like(ff.property("suburb"), "N%"); c = ff.equals(ff.property("Subject"), ff.literal("foo")); d = ff.equals(ff.property("Subject"), ff.literal("bar")); }
@Test public void testLogicFilterAnd() throws Exception { PropertyIsEqualTo equals = ff.equals(ff.property("measurement/result"), ff.literal(1.1)); PropertyIsGreaterThan greater = ff.greater(ff.property("measurement/determinand_description"), ff.literal("desc1")); And logicFilter = ff.and(equals, greater); Filter unrolled = (Filter) logicFilter.accept(visitor, null); assertNotNull(unrolled); assertTrue(unrolled instanceof And); assertNotSame(equals, unrolled); And sourceAnd = (And) unrolled; assertEquals(2, sourceAnd.getChildren().size()); Filter sourceEquals = (Filter) sourceAnd.getChildren().get(0); assertTrue(sourceEquals instanceof PropertyIsEqualTo); Expression left = ((PropertyIsEqualTo) sourceEquals).getExpression1(); Expression right = ((PropertyIsEqualTo) sourceEquals).getExpression2(); assertTrue(left instanceof PropertyName); assertTrue(right instanceof Literal); assertEquals("results_value", ((PropertyName) left).getPropertyName()); assertEquals(new Double(1.1), ((Literal) right).getValue()); Filter sourceGreater = (Filter) sourceAnd.getChildren().get(1); assertTrue(sourceGreater instanceof PropertyIsGreaterThan); left = ((PropertyIsGreaterThan) sourceGreater).getExpression1(); right = ((PropertyIsGreaterThan) sourceGreater).getExpression2(); assertTrue(left instanceof PropertyName); assertTrue(right instanceof Literal); assertEquals("determinand_description", ((PropertyName) left).getPropertyName()); assertEquals("desc1", ((Literal) right).getValue()); }
/** * Test that Filter works over Object as expected, provided there exists a {@link * PropertyAccessor} for the given kind of object. */ public void testEvaluateNonFeatureObject() { MockDataObject object = new MockDataObject(); object.intVal = 5; object.stringVal = "cinco"; org.opengis.filter.Filter f = fac.greater(fac.property("intVal"), fac.literal(3)); assertTrue(f.evaluate(object)); org.opengis.filter.Filter f2 = fac.and(f, fac.equals(fac.property("stringVal"), fac.literal("cinco"))); assertTrue(f2.evaluate(object)); org.opengis.filter.Filter f3 = fac.and(f, fac.equals(fac.property("stringVal"), fac.literal("seis"))); assertFalse(f3.evaluate(object)); org.opengis.filter.Filter f4 = fac.not(fac.and(f, fac.equals(fac.property("stringVal"), fac.literal("cinco")))); assertFalse(f4.evaluate(object)); }