public Object evaluate(Object feature) { double arg0; try { // attempt to get value and perform conversion arg0 = (getExpression(0).evaluate(feature, Double.class)).doubleValue(); } catch (Exception e) { // probably a type error throw new IllegalArgumentException( "Filter Function problem for function ceil argument #0 - expected type double"); } return new Double(Math.ceil(arg0)); } }
(FilterFunction_ceil) ff.function("ceil", org.opengis.filter.expression.Expression.NIL); assertEquals("Name is, ", "ceil", ceil.getName()); assertEquals("Number of arguments, ", 1, ceil.getFunctionName().getArgumentCount());
public void testGetFeatureReaderFilterWithAttributesNotRequested2() throws Exception { SimpleFeatureType type = dataStore.getSchema(tname("river")); FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); FilterFunction_ceil ceil = new FilterFunction_ceil(); ceil.setParameters((List) Collections.singletonList(ff.property(aname("flow")))); PropertyIsEqualTo f = ff.equals(ceil, ff.literal(5)); Query q = new Query(tname("river")); q.setPropertyNames(new String[] {aname("geom")}); q.setFilter(f); // with GEOT-1069 an exception is thrown here try (Transaction t = new DefaultTransaction(); FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(q, t)) { assertTrue(reader.hasNext()); assertEquals(1, reader.getFeatureType().getAttributeCount()); reader.next(); assertFalse(reader.hasNext()); } }
public Object evaluate(Object feature) { double arg0; try { // attempt to get value and perform conversion arg0 = (getExpression(0).evaluate(feature,Double.class)).doubleValue(); } catch (Exception e) { // probably a type error throw new IllegalArgumentException( "Filter Function problem for function ceil argument #0 - expected type double"); } return new Double(Math.ceil(arg0)); } }
public Object evaluate(Object feature) { double arg0; try { // attempt to get value and perform conversion arg0 = ((Number) getExpression(0).evaluate(feature)).doubleValue(); } catch (Exception e) { // probably a type error throw new IllegalArgumentException( "Filter Function problem for function ceil argument #0 - expected type double"); } return new Double(Math.ceil(arg0)); } }