diff artifacts/src/main/java/org/dive4elements/river/artifacts/common/AbstractCalculationResult.java @ 9425:3f49835a00c3

Extended CrossSectionFacet so it may fetch different data from within the artifact result. Also allows to have acces to the potentially already computed artifact result via its normal computation cache.
author gernotbelger
date Fri, 17 Aug 2018 15:31:02 +0200
parents e5367900dd6d
children aa6ee96071b7
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/common/AbstractCalculationResult.java	Fri Aug 17 14:29:05 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/common/AbstractCalculationResult.java	Fri Aug 17 15:31:02 2018 +0200
@@ -52,6 +52,21 @@
         return getPoints(GeneralResultType.station, yType, TruePredicate.INSTANCE);
     }
 
+    /**
+     * Return the row with the given station (within the given tolerance) by linear search.
+     * Returns <code>null</code>, if no such station was found.
+     */
+    protected final ResultRow getRowForStation(final double searchStation, final double stationTolerance) {
+
+        for (final ResultRow row : this.rows) {
+            final double station = row.getDoubleValue(GeneralResultType.station);
+            if (Math.abs(station - searchStation) < stationTolerance)
+                return row;
+        }
+
+        return null;
+    }
+
     public final double[][] getPoints(final IResultType typeX, final IResultType typeY, final Predicate rowFilter) {
 
         final TDoubleArrayList xPoints = new TDoubleArrayList(this.rows.size());

http://dive4elements.wald.intevation.org