diff artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationState.java @ 9563:3955ecc1a516

Restrict inundation map to selected river range
author gernotbelger
date Mon, 29 Oct 2018 17:57:30 +0100
parents bf6b63208f34
children 63bbd5e45839
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationState.java	Thu Oct 25 17:11:59 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationState.java	Mon Oct 29 17:57:30 2018 +0100
@@ -24,6 +24,10 @@
 import org.dive4elements.river.artifacts.model.map.WMSLayerFacet;
 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact;
 import org.dive4elements.river.artifacts.uinfo.inundationduration.InundationDurationCalculationResult.WmsLayer;
+import org.dive4elements.river.model.RiverAxisKm;
+import org.dive4elements.river.utils.GeometryUtils;
+
+import com.vividsolutions.jts.geom.Envelope;
 
 /**
  * @author Domenico Nardi Tironi
@@ -121,4 +125,31 @@
 
         return new InundationDurationCalculation(context).calculate(artifact);
     }
+
+    /**
+     * The extent is restricted to the selected station range
+     */
+    @Override
+    protected Envelope getExtent(final boolean reproject) {
+
+        final InundationDurationAccess access = new InundationDurationAccess((UINFOArtifact) this.artifact);
+
+        final double lowerKm = access.getLowerKm();
+        final double upperKm = access.getUpperKm();
+
+        final List<RiverAxisKm> axisKms = RiverAxisKm.getRiverAxisKms(getRiverId(), lowerKm, upperKm);
+
+        Envelope max = null;
+
+        for (final RiverAxisKm ax : axisKms) {
+            final Envelope env = ax.getGeom().getEnvelopeInternal();
+
+            if (max == null)
+                max = env;
+            else
+                max.expandToInclude(env);
+        }
+
+        return max != null && reproject ? GeometryUtils.transform(max, getSrid()) : max;
+    }
 }
\ No newline at end of file

http://dive4elements.wald.intevation.org