/** * Calculate median (using FeatureCalc) - only one parameter is used. * * @param collection collection to calculate the median * @param expression Single Expression argument * @return An object containing the median value of the attributes * @throws IllegalFilterException * @throws IOException */ static CalcResult calculateMedian( FeatureCollection<? extends FeatureType, ? extends Feature> collection, Expression expression) throws IllegalFilterException, IOException { MedianVisitor medianVisitor = new MedianVisitor(expression); collection.accepts(medianVisitor, null); return medianVisitor.getResult(); }
CalcResult medianResult1 = medianVisitor1.getResult(); CalcResult medianResult2 = medianVisitor2.getResult(); assertEquals(2, medianResult1.toInt()); assertEquals(1.5, medianResult2.toDouble(), 0); medianResult1 = medianVisitor1.getResult(); try { medianResult3 = medianResult5.merge(medianResult1); assertEquals(CalcResult.NULL_RESULT, medianVisitor1.getResult()); assertSame(medianResult2, medianVisitor1.getResult().merge(medianResult2)); assertSame(medianResult2, medianResult2.merge(medianVisitor1.getResult()));
/** * Calculate median (using FeatureCalc) - only one parameter is used. * * @param collection collection to calculate the median * @param expression Single Expression argument * * @return An object containing the median value of the attributes * * @throws IllegalFilterException * @throws IOException */ static CalcResult calculateMedian(FeatureCollection<? extends FeatureType, ? extends Feature> collection, Expression expression) throws IllegalFilterException, IOException { MedianVisitor medianVisitor = new MedianVisitor(expression); collection.accepts(medianVisitor, null); return medianVisitor.getResult(); }
/** * Calculate median (using FeatureCalc) - only one parameter is used. * * @param collection collection to calculate the median * @param expression Single Expression argument * * @return An object containing the median value of the attributes * * @throws IllegalFilterException * @throws IOException */ public static CalcResult calculateMedian(FeatureCollection collection, Expression expression) throws IllegalFilterException, IOException { MedianVisitor medianVisitor = new MedianVisitor(expression); collection.accepts(medianVisitor, null); return medianVisitor.getResult(); }