[Dive4elements-commits] [PATCH 2 of 6] StaticWQKmsArtifact: implement WaterLineArtifact

Wald Commits scm-commit at wald.intevation.org
Wed Apr 24 08:55:53 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1366784512 -7200
# Node ID febeb4bb10a59cb9c11afc1ba3d0a9d9e7bd3578
# Parent  cce12c06466fcd83dcb87507f088bf4d9caf8544
StaticWQKmsArtifact: implement WaterLineArtifact .

diff -r cce12c06466f -r febeb4bb10a5 flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWQKmsArtifact.java
--- 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 :


More information about the Dive4elements-commits mailing list