changeset 2036:c03aeb0cf46b

Initialize km of cross-section artifact to a better value (not all cases covered, yet). flys-artifacts/trunk@3509 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 21 Dec 2011 11:29:59 +0000
parents 3ebbe497d7f7
children 986820795c3b
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java
diffstat 2 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Dec 21 09:17:23 2011 +0000
+++ b/flys-artifacts/ChangeLog	Wed Dec 21 11:29:59 2011 +0000
@@ -1,3 +1,10 @@
+2011-12-21	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java:
+	  (initialize): Eat ld_from from master artifact.
+	  (setup): Set cross_section.km to either masters km or the lowest
+		   defined cross-section line, whatever is bigger.
+
 2011-12-21  Ingo Weinzierl <ingo@intevation.de>
 
 	flys/issue252 (W-INFO: Wasserspiegellagenberechnung / Mitführung der Jährlichkeiten in der Diagramm-/Ergbnisausgabe)
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java	Wed Dec 21 09:17:23 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java	Wed Dec 21 11:29:59 2011 +0000
@@ -84,12 +84,19 @@
             throw new IllegalArgumentException("No attribute 'ids' found!");
         }
 
-        // Assume we start at km 0.
-        addStringData(DATA_KM, "0");
+        
         addStringData(DATA_IS_MASTER, "0");
 
         List<Facet> fs = new ArrayList<Facet>();
         CrossSection cs = CrossSectionFactory.getCrossSection(Integer.valueOf(ids));
+        CrossSectionLine csl = cs.getLines().get(0);
+        // Find min-km of cross sections, than set DATA_KM to min(DATA_KM, minCross).
+        if (csl != null) {
+            double masterKm = Double.valueOf(getDataAsString(DATA_KM));
+            if (masterKm < csl.getKm().doubleValue()) {
+                addStringData(DATA_KM, csl.getKm().toString());
+            }
+        }
         fs.add(new CrossSectionFacet(0, cs.getDescription()));
 
         StaticState state = (StaticState) getCurrentState(context);
@@ -100,14 +107,15 @@
     }
 
 
-    /** Do not copy data from daddyfact. */
+    /** Copy km where master-artifact "starts". */
     @Override
     protected void initialize(
         Artifact artifact,
         Object   context,
         CallMeta callMeta)
     {
-        // do nothing
+        WINFOArtifact winfo = (WINFOArtifact) artifact;
+        this.addStringData(DATA_KM, winfo.getDataAsString("ld_from"));
     }
 
 

http://dive4elements.wald.intevation.org