FF.between( attribute, FF.literal(range.getMinValue()),
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { Expression e = (Expression) node.getChildValue(0); Expression l = (Expression) node.getChildValue(1); Expression u = (Expression) node.getChildValue(2); return factory.between(e, l, u); }
/** * builds PropertyIsBetween filter * * @return PropertyIsBetween * @throws CQLException */ public PropertyIsBetween buildBetween() throws CQLException { try { org.opengis.filter.expression.Expression sup = this.resultStack.popExpression(); org.opengis.filter.expression.Expression inf = this.resultStack.popExpression(); org.opengis.filter.expression.Expression expr = this.resultStack.popExpression(); PropertyIsBetween filter = filterFactory.between(expr, inf, sup); return filter; } catch (IllegalFilterException ife) { throw new CQLException( "Exception building CompareFilter: " + ife.getMessage(), this.cqlSource); } }
public void testEquals() throws Exception { org.opengis.filter.FilterFactory ff = CommonFactoryFinder.getFilterFactory(); PropertyIsBetween f1 = ff.between(ff.property("abc"), ff.literal(10), ff.literal(20)); PropertyIsBetween f2 = ff.between(ff.property("efg"), ff.literal(10), ff.literal(20)); PropertyIsBetween f3 = ff.between(ff.property("abc"), ff.literal(10), ff.literal(20)); assertEquals(f1, f3); assertFalse(f1.equals(f2)); } }
public void testVisitBetweenFilter() throws Exception { PropertyIsBetween filter = ff.between(ff.literal(0), ff.property(numAtt), ff.literal(4)); FilterCapabilities caps = new FilterCapabilities(PropertyIsBetween.class); runTest(filter, caps, numAtt); }
@Test public void testVisitBetweenFilter() throws Exception { PropertyIsBetween filter = ff.between(ff.literal(0), ff.property(numAtt), ff.literal(4)); runTest(filter, newCapabilities(PropertyIsBetween.class), numAtt); }
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 between() { // among two literals PropertyIsBetween source = ff.between(ff.property("i"), ff.literal("10"), ff.literal("20")); PropertyIsBetween bound = (PropertyIsBetween) source.accept(visitor, null); assertEquals(Integer.valueOf(10), ((Literal) bound.getLowerBoundary()).getValue()); assertEquals(Integer.valueOf(20), ((Literal) bound.getUpperBoundary()).getValue()); // among two expression source = ff.between(ff.literal("10"), ff.property("i"), ff.property("i")); bound = (PropertyIsBetween) source.accept(visitor, null); assertEquals(Integer.valueOf(10), ((Literal) bound.getExpression()).getValue()); // among two inconsistent expressions, cannot optimize source = ff.between(ff.literal("10"), ff.property("i"), ff.property("d")); bound = (PropertyIsBetween) source.accept(visitor, null); assertEquals("10", ((Literal) bound.getExpression()).getValue()); } }
private Filter toFilter(FilterFactory ff, Expression variable, Range<T> range) { if (range.getMinValue() == null && range.getMaxValue() == null) { return Filter.INCLUDE; } else if (range.isMinIncluded() && range.isMaxIncluded()) { if (range.getMinValue().equals(range.getMaxValue())) { return ff.equals(variable, ff.literal(range.getMinValue())); } return ff.between( variable, ff.literal(range.getMinValue()), ff.literal(range.getMaxValue())); } else if (range.getMinValue() == null) { return toLessFilter(ff, variable, range); } else if (range.getMaxValue() == null) { return toGreaterFilter(ff, variable, range); } else { Filter less = toLessFilter(ff, variable, range); Filter greater = toGreaterFilter(ff, variable, range); return ff.and(greater, less); } }
assertTrue(list.contains("id")); PropertyIsBetween between = factory.between(name, id, geom); names = DataUtilities.attributeNames(between); assertEquals(3, names.length);
private <T> void testAndOverlappingRangesToBetween(Class<T> type, T min, T mid, T max) throws Exception { SimpleFeatureType schema = DataUtilities.createType("test", "a:" + type.getName()); SimplifyingFilterVisitor visitor = new SimplifyingFilterVisitor(); visitor.setRangeSimplicationEnabled(true); visitor.setFeatureType(schema); // excluding extrema, not possible to turn it into a between filter Filter original = ff.and( Arrays.asList( // (Filter) ff.greaterOrEqual(ff.property("a"), ff.literal(min)), // ff.less(ff.property("a"), ff.literal(max)), // ff.lessOrEqual(ff.property("a"), ff.literal(mid)))); Filter simplified = (Filter) original.accept(visitor, null); assertEquals(ff.between(ff.property("a"), ff.literal(min), ff.literal(mid)), simplified); }
public void testRangeExpression() throws Exception { SimpleFeatureType schema = DataUtilities.createType("test", "pop:String"); SimplifyingFilterVisitor visitor = new SimplifyingFilterVisitor(); visitor.setRangeSimplicationEnabled(true); visitor.setFeatureType(schema); Function func = ff.function("parseLong", ff.property("pop")); Filter f1 = ff.less(func, ff.literal(20000)); Filter f2 = ff.between(func, ff.literal(20000), ff.literal(50000)); Filter or = ff.or(f1, f2); Filter simplified = (Filter) or.accept(visitor, null); assertEquals(ff.lessOrEqual(func, ff.literal(50000)), simplified); }
public void testBetweenNegation() throws Exception { Not filter = ff.not( ff.between( ff.property(aname(B)), ff.property(aname(A)), ff.property(aname(C)))); ContentFeatureSource fs = dataStore.getFeatureSource(tname(ABC)); Query q = new Query(tname(ABC), filter); int count = fs.getCount(q); assertEquals(1, count); SimpleFeature f = DataUtilities.first(fs.getFeatures(q)); assertEquals("n_n_n", f.getAttribute(aname(NAME))); }
public void test() throws Exception { Not filter = ff.not( ff.between( ff.property(aname(B)), ff.property(aname(A)), ff.property(aname(C)))); ContentFeatureSource fs = dataStore.getFeatureSource(tname(ABC)); Query q = new Query(tname(ABC), filter); int count = fs.getCount(q); assertEquals(1, count); SimpleFeature f = DataUtilities.first(fs.getFeatures(q)); assertEquals("n_n_n", f.getAttribute(aname(NAME))); } }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { Expression e = (Expression) node.getChildValue(0); Expression l = (Expression) node.getChildValue(1); Expression u = (Expression) node.getChildValue(2); return factory.between(e, l, u); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { Expression e = (Expression) node.getChildValue(0); Expression l = (Expression) node.getChildValue(1); Expression u = (Expression) node.getChildValue(2); return factory.between(e, l, u); }
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)))); }
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)))); }
org.opengis.filter.Filter betweenFilter() throws ExpressionException { try { org.opengis.filter.expression.Expression right = expression(); org.opengis.filter.expression.Expression middle = expression(); org.opengis.filter.expression.Expression left = expression(); org.opengis.filter.Filter f = factory.between(middle, left, right); return f; } catch (IllegalFilterException ife) { throw new ExpressionException("Exception building CompareFilter",getToken(0),ife); } }
private Filter buildComparisonFilter( FilterDirection direction, Literal qlower, Literal qupper) { PropertyName comparisonAttribute = getComparisonAttribute(direction); if (direction == HIGHEST_AMONG_LOWERS) { if (acceptableRange != null) { Range searchRange = acceptableRange.getSearchRange(qlower.getValue()); return FF.between( comparisonAttribute, FF.literal(searchRange.getMinValue()), qlower); } else { return FF.lessOrEqual(comparisonAttribute, qlower); } } else { if (acceptableRange != null) { Range searchRange = acceptableRange.getSearchRange(qupper.getValue()); return FF.between( comparisonAttribute, qupper, FF.literal(searchRange.getMaxValue())); } else { return FF.greaterOrEqual(comparisonAttribute, qupper); } } }