@Test public void testEvaluateNumericalWithPercentagesAndOutlier() throws SchemaException { SimpleFeatureType dataType = DataUtilities.createType("classification.test1", "id:0,foo:int,geom:Point"); int iVal[] = new int[] {1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16}; FeatureCollection featureCollection = new ListFeatureCollection(dataType); GeometryFactory fac = new GeometryFactory(); featureCollection = new ListFeatureCollection(dataType); for (int i = 0; i < iVal.length; i++) { SimpleFeature feature = SimpleFeatureBuilder.build( dataType, new Object[] { Integer.valueOf(i + 1), Integer.valueOf(iVal[i]), fac.createPoint(new Coordinate(iVal[i], iVal[i])) }, "classification.t" + (i + 1)); ((ListFeatureCollection) featureCollection).add(feature); } Literal classes = ff.literal(3); PropertyName name = ff.property("foo"); Function func = ff.function("EqualInterval", name, classes, ff.literal(true)); Object classifier = func.evaluate(featureCollection); assertTrue(classifier instanceof RangedClassifier); RangedClassifier ranged = (RangedClassifier) classifier; double[] percentages = ranged.getPercentages(); assertEquals(3, percentages.length); assertEquals(33.0, Math.floor(percentages[0])); assertEquals(26.0, Math.floor(percentages[1])); assertEquals(39.0, Math.floor(percentages[2])); }
public RangedClassifier evaluate(Object object) { if (!(object instanceof FeatureCollection)) { return null; } return calculate((SimpleFeatureCollection) object); }
EqualIntervalFunction extends ClassificationFunction { public RangedClassifier evaluate(Object object) { if (!(object instanceof FeatureCollection)) { return null; } return calculate((SimpleFeatureCollection) object); } }
EqualIntervalFunction extends ClassificationFunction { public RangedClassifier evaluate(Object object) { if (!(object instanceof FeatureCollection)) { return null; } return calculate((SimpleFeatureCollection) object); } EqualIntervalFunction(); }
EqualIntervalFunction extends ClassificationFunction { public RangedClassifier evaluate(Object object) { if (!(object instanceof FeatureCollection)) { return null; } return calculate((SimpleFeatureCollection) object); } EqualIntervalFunction(); RangedClassifier evaluate(Object object); }
EqualIntervalFunction extends ClassificationFunction { public RangedClassifier evaluate(Object object) { if (!(object instanceof FeatureCollection)) { return null; } return calculate((SimpleFeatureCollection) object); } EqualIntervalFunction(); RangedClassifier evaluate(Object object); static FunctionName NAME; }