changeset 5798:febeb4bb10a5

StaticWQKmsArtifact: implement WaterLineArtifact .
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 24 Apr 2013 08:21:52 +0200
parents cce12c06466f
children 5a2c7d24fd29
files flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWQKmsArtifact.java
diffstat 1 files changed, 58 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWQKmsArtifact.java	Wed Apr 24 08:17:18 2013 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWQKmsArtifact.java	Wed Apr 24 08:21:52 2013 +0200
@@ -1,5 +1,7 @@
 package de.intevation.flys.artifacts;
 
+import java.awt.geom.Point2D;
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -12,13 +14,20 @@
 
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.ArtifactFactory;
+import de.intevation.artifacts.CallContext;
 import de.intevation.artifacts.CallMeta;
 
 import de.intevation.artifacts.common.utils.XMLUtils;
 
+import de.intevation.flys.artifacts.geom.Lines;
+import de.intevation.flys.artifacts.math.Distance;
+
 import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.model.FastCrossSectionLine;
+import de.intevation.flys.artifacts.model.WKms;
 import de.intevation.flys.artifacts.model.WQKms;
 import de.intevation.flys.artifacts.model.WKmsFactory;
+import de.intevation.flys.artifacts.model.WQKmsFacet;
 import de.intevation.flys.artifacts.model.WQKmsFactory;
 
 import de.intevation.flys.artifacts.states.DefaultState;
@@ -33,7 +42,7 @@
  */
 public class StaticWQKmsArtifact
 extends      StaticFLYSArtifact
-implements   FacetTypes
+implements   FacetTypes, WaterLineArtifact
 {
     /** The logger for this class. */
     private static Logger logger =
@@ -107,9 +116,9 @@
         CallMeta meta)
     {
         logger.debug("StaticWQKmsArtifact.initialize");
-        WINFOArtifact winfo = (WINFOArtifact) artifact;
+        FLYSArtifact flys = (FLYSArtifact) artifact;
         // TODO: The river is of no interest, so far., also use importData
-        importData(winfo, "river");
+        importData(flys, "river");
 
         List<Facet> fs = new ArrayList<Facet>();
 
@@ -150,6 +159,52 @@
         return NAME;
     }
 
+
+    /**
+     * Get points of line describing the surface of water at cross section.
+     *
+     * @param idx Index of facet and in wkms array.
+     * @param csl FastCrossSectionLine to compute water surface agains.
+     * @param next The km of the next crosssectionline.
+     * @param prev The km of the previous crosssectionline.
+     * @param context Ignored in this implementation.
+     *
+     * @return an array holding coordinates of points of surface of water (
+     *         in the form {{x1, x2}, {y1, y2}} ).
+     */
+    @Override
+    public Lines.LineData getWaterLines(int idx, FastCrossSectionLine csl,
+        double next, double prev, CallContext context
+    ) {
+        logger.debug("getWaterLines(" + idx + ")/" + identifier());
+
+        List<Point2D> points = csl.getPoints();
+
+        WKms wkms = getWQKms();
+
+        double km = csl.getKm();
+
+        // Find W at km.
+        double wAtKm;
+
+        // If heightmarks, only deliver if data snaps.
+        /*
+        if (getDataAsString(DATA_HEIGHT_TYPE) != null &&
+            getDataAsString(DATA_HEIGHT_TYPE).equals("true")) {
+            wAtKm = getWAtCloseKm(wkms, km, next, prev);
+        }
+        else {
+        */
+            wAtKm = StaticWKmsArtifact.getWAtKm(wkms, km);
+        //}
+
+        if (wAtKm == -1 || Double.isNaN(wAtKm)) {
+            logger.warn("Waterlevel at km " + km + " unknown.");
+            return new Lines.LineData(new double[][] {{}}, 0d, 0d);
+        }
+
+        return Lines.createWaterLines(points, wAtKm);
+    }
     // TODO implement deepCopy.
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org