[PATCH 2 of 4] issue1157: Store parents initial km at CrossSectionArtifact

Wald Commits scm-commit at wald.intevation.org
Thu Jul 4 12:03:18 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1372931313 -7200
# Node ID f2722602936c10c70522d73df575db416a5f4f92
# Parent  c155f8f57b7ec4714cdcf0605903f4ec1bde5c18
issue1157: Store parents initial km at CrossSectionArtifact.

diff -r c155f8f57b7e -r f2722602936c artifacts/src/main/java/org/dive4elements/river/artifacts/CrossSectionArtifact.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/CrossSectionArtifact.java	Wed Jul 03 16:09:51 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/CrossSectionArtifact.java	Thu Jul 04 11:48:33 2013 +0200
@@ -53,6 +53,9 @@
     /** Name of data item keeping the position. */
     public static final String DATA_KM = "cross_section.km";
 
+    /** Name of data item keeping the 'parents' km. */
+    public static final String PARENT_KM = "cross_section.parent.km";
+
     /** Name of data item keeping the database id of this c.s.. */
     public static final String DATA_DBID = "cross_section.dbid";
 
@@ -242,6 +245,20 @@
 
 
     /**
+     * Return position (km) from parent (initial km), 0 if not found.
+     */
+    private double getParentKm() {
+        String val = getDataAsString(PARENT_KM);
+        try {
+            return Double.valueOf(val);
+        }
+        catch (NumberFormatException e) {
+            logger.warn("Could not get data " + PARENT_KM + " as double", e);
+            return 0;
+        }
+    }
+
+    /**
      * Return position (km) from data, 0 if not found.
      */
     protected double getKm() {


More information about the Dive4elements-commits mailing list