Refine search
/** Set up parameters for the Interpolate function with a set of input data and output values */ private void setupParameters(Object[] data, Object[] values) { if (data.length != values.length) { throw new IllegalArgumentException("data and values arrays should be the same length"); } parameters = new ArrayList<Expression>(); parameters.add(ff2.property("value")); for (int i = 0; i < data.length; i++) { parameters.add(ff2.literal(data[i])); parameters.add(ff2.literal(values[i])); } }
private void setupParameters(Object[] categories, Object[] thresholds) { if (thresholds.length != categories.length - 1) { throw new IllegalArgumentException("should be n thresholds and n+1 categories"); } parameters = new ArrayList<Expression>(); parameters.add(ff2.property("value")); for (int i = 0; i < thresholds.length; i++) { parameters.add(ff2.literal(categories[i])); parameters.add(ff2.literal(thresholds[i])); } parameters.add(ff2.literal(categories[categories.length - 1])); }
@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 testNoThresholds() throws Exception { // System.out.println(" testNoThresholds"); final int categoryValue = 42; parameters.add(ff2.property("value")); parameters.add(ff2.literal(categoryValue)); Function fn = finder.findFunction("categorize", parameters); Integer result = fn.evaluate(feature(0), Integer.class); assertEquals(categoryValue, result.intValue()); }
public void testNullComparison() { PropertyName exp = ff.property("not_there"); Function func = ff.function(FUNCTION_NAME, exp, ff.literal(1), ff.literal(null)); Object result = func.evaluate(feature); assertEquals(true, result); func = ff.function(FUNCTION_NAME, exp, ff.literal("1"), ff.literal(2)); result = func.evaluate(feature); assertEquals(false, result); }
public void testSetNumberOfClasses() throws Exception { LOGGER.finer("testSetNumberOfClasses"); Literal classes = ff.literal(3); PropertyName exp = ff.property("foo"); StandardDeviationFunction func = (StandardDeviationFunction) ff.function("StandardDeviation", exp, classes); assertEquals(3, func.getClasses()); classes = ff.literal(12); func = (StandardDeviationFunction) ff.function("StandardDeviation", exp, classes); assertEquals(12, func.getClasses()); }
public void testConstantValuesString() { Function function = ff.function("quantile", ff.property("s"), ff.literal(12)); ExplicitClassifier classifier = (ExplicitClassifier) function.evaluate(constantCollection); assertNotNull(classifier); assertEquals(1, classifier.getSize()); assertEquals(1, classifier.getValues(0).size()); assertEquals("abc", classifier.getValues(0).iterator().next()); } }