public void testSum() throws Exception { FilterFactory ff = dataStore.getFilterFactory(); PropertyName p = ff.property(aname("doubleProperty")); SumVisitor v = new MySumVisitor(p); dataStore.getFeatureSource(tname("ft1")).accepts(Query.ALL, v, null); assertFalse(visited); assertEquals(3.3, v.getResult().toDouble(), 0.01); }
public void testSumWithFilter() throws Exception { FilterFactory ff = dataStore.getFilterFactory(); PropertyName p = ff.property(aname("doubleProperty")); SumVisitor v = new MySumVisitor(p); Filter f = ff.less(ff.property(aname("doubleProperty")), ff.literal(2)); Query q = new DefaultQuery(tname("ft1"), f); dataStore.getFeatureSource(tname("ft1")).accepts(q, v, null); assertFalse(visited); assertEquals(1.1, v.getResult().toDouble(), 0.01); }
public void testSumWithLimitOffset() throws Exception { if (!dataStore.getSQLDialect().isLimitOffsetSupported()) { return; } FilterFactory ff = dataStore.getFilterFactory(); PropertyName p = ff.property(aname("doubleProperty")); SumVisitor v = new MySumVisitor(p); DefaultQuery q = new DefaultQuery(tname("ft1")); q.setStartIndex(0); q.setMaxFeatures(2); dataStore.getFeatureSource(tname("ft1")).accepts(q, v, null); assertFalse(visited); assertEquals(1.1, v.getResult().toDouble(), 0.01); }
public void visit(SimpleFeature feature) { super.visit(feature); visited = true; }