changeset 6628:62d6e1d5da47 double-precision

merged changes from default into double-precision branch
author Tom Gottfried <tom@intevation.de>
date Mon, 22 Jul 2013 13:03:42 +0200
parents 49dd3e478ccd (current diff) 0e1f142af397 (diff)
children 5f48541cd544
files
diffstat 79 files changed, 1307 insertions(+), 396 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Fri Jun 28 19:32:43 2013 +0200
+++ b/.hgtags	Mon Jul 22 13:03:42 2013 +0200
@@ -54,3 +54,14 @@
 5733d7f27196c5a8cf18231fbf187738f8fea560 3.0.7
 eec895f6ec801a7faaed96e9f01721e1143e7bb8 3.0.8
 41152c3a532d63a25e9fa348ca4286bdd76069ef 3.0.9
+5f4893db41e4fed644ddbd91bf4cdf0ac7952161 3.0.10
+5f4893db41e4fed644ddbd91bf4cdf0ac7952161 3.0.10
+0000000000000000000000000000000000000000 3.0.10
+0000000000000000000000000000000000000000 3.0.10
+bfcb513c1fdace07ce39616bc9fda3899e8ee914 3.0.10
+63baa1873b1f86a78ab10d19ae4221ec01cc75a2 3.0.11
+3999162f474fb5a6bced33521f81c9ccf274c4e7 3.0.12
+3999162f474fb5a6bced33521f81c9ccf274c4e7 3.0.12
+0000000000000000000000000000000000000000 3.0.12
+0000000000000000000000000000000000000000 3.0.12
+da197a9236fde564d45379c0826510c69a5709ce 3.0.12
--- a/artifacts/doc/conf/artifacts/chart.xml	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/doc/conf/artifacts/chart.xml	Mon Jul 22 13:03:42 2013 +0200
@@ -58,8 +58,18 @@
                         <facet name="w_differences" description="facet.w_differences"/>
                         <facet name="other.wkms" description="facet.other.wkms"/>
                         <facet name="other.wqkms" description="facet.other.wqkms"/>
+                        <facet name="other.wqkms.w"          description="W-Type of data" />
+                        <facet name="other.wqkms.q"          description="Q-Type of data" />
                         <facet name="heightmarks_points" description="facet.other.wkms.heightmarks_points"/>
+                        <facet name="w_differences.manualpoints" description="Manuelle Punkte"/>
                         <facet name="longitudinal_section.annotations" description="facet.longitudinal_section.annotations"/>
+                        <facet name="bedheight_difference.year" description="A facet for bed height differences"/>
+                        <facet name="bedheight_difference.year.filtered" description="A facet for bed height differences"/>
+                        <facet name="bedheight_difference.morph_width" description="A facet for morphologic width"/>
+                        <facet name="bedheight_difference.year.height1" description="A facet for raw heights."/>
+                        <facet name="bedheight_difference.year.height2" description="A facet for raw heights."/>
+                        <facet name="bedheight_difference.year.height1.filtered" description="A facet for raw heights."/>
+                        <facet name="bedheight_difference.year.height2.filtered" description="A facet for raw heights."/>
                     </facets>
                 </outputmode>
             </outputmodes>
--- a/artifacts/doc/conf/artifacts/winfo.xml	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/doc/conf/artifacts/winfo.xml	Mon Jul 22 13:03:42 2013 +0200
@@ -271,6 +271,14 @@
                         <facet name="heightmarks_points" description="facet.other.wkms.heightmarks_points"/>
                         <facet name="w_differences.manualpoints" description="Manuelle Punkte"/>
                         <facet name="longitudinal_section.annotations" description="facet.longitudinal_section.annotations"/>
+                        <facet name="bedheight_difference.year" description="A facet for bed height differences"/>
+                        <facet name="bedheight_difference.year.filtered" description="A facet for bed height differences"/>
+                        <facet name="bedheight_difference.morph_width" description="A facet for morphologic width"/>
+                        <facet name="bedheight_difference.year.height1" description="A facet for raw heights."/>
+                        <facet name="bedheight_difference.year.height2" description="A facet for raw heights."/>
+                        <facet name="bedheight_difference.year.height1.filtered" description="A facet for raw heights."/>
+                        <facet name="bedheight_difference.year.height2.filtered" description="A facet for raw heights."/>
+                        <facet name="morph-width" description="morphologic width, not sounding width!"/>
                     </facets>
                 </outputmode>
                 <outputmode name="w_differences_export" description="output.w_differences.export" mime-type="text/plain" type="export">
@@ -444,10 +452,12 @@
             </outputmodes>
         </state>
 
+        <!-- The brigde to UeSF
         <transition transition="org.dive4elements.river.artifacts.transitions.DefaultTransition">
             <from state="state.winfo.waterlevel"/>
             <to state="state.winfo.uesk.dgm"/>
         </transition>
+        -->
 
         <state id="state.winfo.uesk.wsp" description="state.winfo.uesk.wsp" state="org.dive4elements.river.artifacts.states.WaterlevelSelectState" helpText="help.state.winfo.uesk.wsp">
             <data name="wsp" type="String" />
--- a/artifacts/doc/conf/datacage.sql	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/doc/conf/datacage.sql	Mon Jul 22 13:03:42 2013 +0200
@@ -41,7 +41,7 @@
     artifact_id INT             NOT NULL REFERENCES artifacts(id) ON DELETE CASCADE,
     kind        VARCHAR(256)    NOT NULL,
     k           VARCHAR(256)    NOT NULL,
-    v           VARCHAR(256),   -- Maybe too short
+    v           TEXT,
     UNIQUE (artifact_id, k)
 );
 
--- a/artifacts/doc/conf/meta-data.xml	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/doc/conf/meta-data.xml	Mon Jul 22 13:03:42 2013 +0200
@@ -87,12 +87,15 @@
                   </dc:when>
                   <dc:when test="$out = 'bed_difference_epoch'">
                     <dc:call-macro name="annotations"/>
+                    <dc:call-macro name="basedata_6_delta_w"/>
                   </dc:when>
                   <dc:when test="$out = 'bed_difference_year'">
                     <dc:call-macro name="annotations"/>
+                    <dc:call-macro name="basedata_6_delta_w"/>
                   </dc:when>
                   <dc:when test="$out = 'bed_difference_height_year'">
                     <dc:call-macro name="annotations"/>
+                    <dc:call-macro name="basedata_6_delta_w"/>
                   </dc:when>
                   <dc:when test="$out = 'floodmap'">
                     <dc:call-macro name="flood-map-recommended"/>
@@ -135,6 +138,7 @@
                   </dc:when>
                   <dc:when test="$out = 'w_differences'">
                     <dc:call-macro name="longitudinal-section-prototype"/>
+                    <dc:call-macro name="bedheight_differences"/>
                   </dc:when>
                   <dc:when test="$out = 'discharge_longitudinal_section'">
                     <dc:call-macro name="longitudinal-section-prototype"/>
@@ -268,6 +272,16 @@
                       <dc:call-macro name="bed-heights-epoch"/>
                     </bedheights>
                   </dc:when>
+                  <dc:when test="$out = 'differenceable'">
+                    <dc:if test="$current-state-id != 'state.winfo.uesk.wsp'">
+                      <dc:call-macro name="basedata_0"/>
+                      <dc:call-macro name="basedata_1_additionals"/>
+                      <dc:call-macro name="basedata_2_fixations"/>
+                      <dc:call-macro name="basedata_4_heightmarks-points"/>
+                      <dc:call-macro name="basedata_5_flood-protections"/>
+                      <dc:call-macro name="minfo-heights"/>
+                    </dc:if>
+                  </dc:when>
                   <dc:when test="$out = 'waterlevels'">
                     <dc:if test="$current-state-id != 'state.winfo.uesk.wsp'">
                       <dc:call-macro name="basedata_0"/>
@@ -319,6 +333,7 @@
                     <dc:when test="$out = 'w_differences'">
                       <dc:call-macro name="longitudinal"/>
                       <dc:call-macro name="differences"/>
+                      <dc:call-macro name="bedheight_differences"/>
                     </dc:when>
                     <dc:when test="$out = 'fix_deltawt_curve'">
                       <dc:call-macro name="delta-wt"/>
@@ -344,6 +359,10 @@
                     <dc:when test="$out = 'duration_curve'">
                       <dc:call-macro name="duration-curve"/>
                     </dc:when>
+                    <dc:when test="$out = 'differenceable'">
+                      <dc:call-macro name="differenceable-fix"/>
+                      <dc:call-macro name="differences"/>
+                    </dc:when>
                     <dc:when test="$out = 'waterlevels'">
                       <dc:call-macro name="waterlevels-fix"/>
                     </dc:when>
@@ -375,20 +394,20 @@
                     </dc:when>
                     <dc:when test="$out = 'sedimentload_ls'">
                       <dc:call-macro name="differences"/>
-                      <dc:call-macro name="bedheight-differences"/>
+                      <dc:call-macro name="bedheight_differences"/>
                       <dc:call-macro name="flow-velocity"/>
                       <dc:call-macro name="sediment-load"/>
                     </dc:when>
                     <dc:when test="$out = 'bed_difference_year'">
                       <dc:call-macro name="waterlevels-discharge"/>
-                      <dc:call-macro name="bedheight-differences"/>
+                      <dc:call-macro name="bedheight_differences"/>
                       <dc:call-macro name="differences"/>
                       <dc:call-macro name="waterlevels-fix"/>
                       <dc:call-macro name="delta-wt-ls"/>
                     </dc:when>
                     <dc:when test="$out = 'bed_difference_epoch'">
                       <dc:call-macro name="waterlevels-discharge"/>
-                      <dc:call-macro name="bedheight-differences"/>
+                      <dc:call-macro name="bedheight_differences"/>
                       <dc:call-macro name="differences"/>
                       <dc:call-macro name="waterlevels-fix"/>
                       <dc:call-macro name="delta-wt-ls"/>
@@ -411,9 +430,10 @@
             <dc:for-each>
               <w_differences
                 description="{$facet_description}"
-                factory="winfo" target_out="{$out}"
-                artifact-id="{$aid}"
-                ids="{$aid}"
+                factory="winfo"
+                target_out="{$out}"
+                artifact-id="{$a_gid}"
+                ids="{$facet_num}"
                 out="w_differences"/>
             </dc:for-each>
           </differences>
@@ -710,6 +730,78 @@
       </dc:filter>
     </dc:macro>
 
+    <dc:comment comment="For building differences." />
+    <dc:macro name="differenceable-fix">
+      <dc:comment>
+        No diffs between beddiffs and others, for now.
+        <beddifferences>
+           <dc:call-macro name="bedheight_differences"/>
+        </beddifferences>
+      </dc:comment>
+      <dc:comment comment="Vollmer curves need own factory"/>
+      <dc:filter expr="$a_state = 'state.fix.vollmer.compute' and (($out_name = 'longitudinal_section' and $facet_name = 'longitudinal_section.w') and
+        (not ($current-state-id = 'state.winfo.uesk.wsp' and $ld_m = 'location')))">
+        <dc:if test="dc:has-result()">
+          <vollmer_waterlevels>
+            <dc:group expr="concat($river, ' ', dc:date-format('dd.MM.yyyy - H:m:s', $a_creation), ' ', $collection_name)">
+              <waterlevels description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:choose>
+                    <dc:when test="$ld_m = 'location'">
+                      <dc:variable name="combined_desc" expr="concat($facet_description, ' an KM ', $deffrom)"/>
+                    </dc:when>
+                    <dc:otherwise>
+                      <dc:variable name="combined_desc" expr="concat($facet_description, ' von KM ',
+                        $deffrom, ' bis KM ', $defto)"/>
+                    </dc:otherwise>
+                 </dc:choose>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="description" value="${combined_desc}"/>
+                    <dc:attribute name="ids" value="${facet_num}"/>
+                    <dc:attribute name="factory" value="fixanalysis"/>
+                    <dc:attribute name="target_out" value="${out}"/>
+                    <dc:attribute name="artifact-id" value="${a_gid}"/>
+                    <dc:attribute name="out" value="longitudinal_section"/>
+                  </dc:element>
+                </dc:for-each>
+              </waterlevels>
+            </dc:group>
+          </vollmer_waterlevels>
+        </dc:if>
+      </dc:filter>
+      <dc:filter expr="not($a_state = 'state.fix.vollmer.compute') and (($out_name = 'longitudinal_section' and $facet_name = 'longitudinal_section.w') and
+        (not ($current-state-id = 'state.winfo.uesk.wsp' and $ld_m = 'location')))">
+        <dc:if test="dc:has-result()">
+          <waterlevels>
+            <dc:group expr="concat($river, ' ', dc:date-format('dd.MM.yyyy - H:m:s', $a_creation), ' ', $collection_name)">
+                <waterlevels description="{dc:group-key()}">
+                  <dc:for-each>
+                    <dc:choose>
+                      <dc:when test="$ld_m = 'location'">
+                        <dc:variable name="combined_desc" expr="concat($facet_description, ' an KM ', $deffrom)"/>
+                      </dc:when>
+                      <dc:otherwise>
+                        <dc:variable name="combined_desc" expr="concat($facet_description, ' von KM ',
+                          $deffrom, ' bis KM ', $defto)"/>
+                      </dc:otherwise>
+                    </dc:choose>
+                    <dc:element name="${facet_name}">
+                      <dc:attribute name="description" value="${combined_desc}"/>
+                      <dc:attribute name="ids" value="${facet_num}"/>
+                      <dc:attribute name="factory" value="winfo"/>
+                      <dc:attribute name="target_out" value="${out}"/>
+                      <dc:attribute name="artifact-id" value="${a_gid}"/>
+                      <dc:attribute name="out" value="longitudinal_section"/>
+                    </dc:element>
+                  </dc:for-each>
+                </waterlevels>
+            </dc:group>
+          </waterlevels>
+        </dc:if>
+      </dc:filter>
+    </dc:macro>
+
+
     <dc:macro name="floodmap-hws-user">
       <dc:comment>No grouping in this?</dc:comment>
       <dc:filter expr="$out_name = 'floodmap' and $facet_name = 'floodmap.usershape'">
@@ -877,11 +969,11 @@
       </dc:filter>
     </dc:macro>
 
-    <dc:macro name="bedheight-differences">
+    <dc:macro name="bedheight_differences">
       <dc:filter expr="($out_name = 'bed_difference_year' or $out_name = 'bed_difference_epoch') and
         (starts-with($facet_name, 'bedheight_difference.year') or starts-with($facet_name, 'bedheight_difference.epoch'))">
         <dc:if test="dc:has-result()">
-          <bedheight-differences>
+          <bedheight_differences>
             <dc:group expr="concat($river, ' ', dc:date-format('dd.MM.yyyy - H:m:s', $a_creation), ' ', $collection_name)">
               <difference description="{dc:group-key()}">
                 <dc:for-each>
@@ -889,14 +981,14 @@
                     <dc:attribute name="factory" value="minfo"/>
                     <dc:attribute name="target_out" value="${out}"/>
                     <dc:attribute name="description" value="${facet_description}"/>
-                    <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
-                    <dc:attribute name="artifact-id" value="${a_id}"/>
-                    <dc:attribute name="out" value="${out}"/>
+                    <dc:attribute name="ids" value="${facet_num}"/>
+                    <dc:attribute name="artifact-id" value="${a_gid}"/>
+                    <dc:attribute name="out" value="${out_name}"/>
                   </dc:element>
                 </dc:for-each>
               </difference>
             </dc:group>
-          </bedheight-differences>
+          </bedheight_differences>
         </dc:if>
       </dc:filter>
     </dc:macro>
@@ -2332,8 +2424,8 @@
             <officiallines>
               <dc:for-each>
                 <column name="{$olname}"
-                      ids="additionals-wstv-{$wstcolpos}-{$wstid}"
-                      factory="staticwqkms" target_out="{$out}"/>
+                  ids="official-wstv-{$wstcolpos}-{$wstid}"
+                  factory="staticwqkms" target_out="{$out}"/>
               </dc:for-each>
             </officiallines>
           </dc:if>
--- a/artifacts/doc/conf/themes/default.xml	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/doc/conf/themes/default.xml	Mon Jul 22 13:03:42 2013 +0200
@@ -1399,12 +1399,14 @@
 
     <theme name="FixPoints">
         <inherits>
-            <inherit from="Points" />
+            <inherit from="ColorfulPoints" />
             <inherit from="Label" />
         </inherits>
         <fields>
             <field name="pointsize" type="int" display="Punktdicke"
                 default="3" />
+            <field name="showpointlabel" type="boolean"
+                display="Beschriftung anzeigen" default="true" hints="hidden" />
         </fields>
     </theme>
 
--- a/artifacts/doc/conf/themes/second.xml	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/doc/conf/themes/second.xml	Mon Jul 22 13:03:42 2013 +0200
@@ -1399,12 +1399,14 @@
 
     <theme name="FixPoints">
         <inherits>
-            <inherit from="Points" />
+            <inherit from="ColorfulPoints" />
             <inherit from="Label" />
         </inherits>
         <fields>
             <field name="pointsize" type="int" display="Punktdicke"
                 default="3" />
+            <field name="showpointlabel" type="boolean"
+                display="Beschriftung anzeigen" default="true" hints="hidden" />
         </fields>
     </theme>
 
--- a/artifacts/doc/conf/themes/virtual.xml	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/doc/conf/themes/virtual.xml	Mon Jul 22 13:03:42 2013 +0200
@@ -30,6 +30,17 @@
         </fields>
     </theme>
 
+    <theme name="ColorfulPoints" type="virtual">
+        <fields>
+            <field name="showpoints" type="boolean" display="Punkte anzeigen"
+                default="true" />
+            <field name="pointsize" type="int" display="Punktdicke"
+                default="5" />
+            <field name="showpointlabel" type="boolean"
+                display="Punktbeschriftung anzeigen" default="false"/>
+        </fields>
+    </theme>
+
     <theme name="Label" type="virtual">
         <fields>
             <field name="labelfontface" type="Font"
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/CrossSectionArtifact.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/CrossSectionArtifact.java	Mon Jul 22 13:03:42 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";
 
@@ -140,7 +143,7 @@
         fs.add(new CrossSectionFacet(0, cs.getDescription()));
 
         // Find out if we are newest and become master if so.
-        boolean isNewest = CrossSectionFactory.isNewest(cs);
+        boolean isNewest = cs.shouldBeMaster(getParentKm());
         String newString = (isNewest) ? "1" : "0";
         addStringData(DATA_IS_NEWEST, newString);
         addStringData(DATA_IS_MASTER, newString);
@@ -154,19 +157,18 @@
     /** Copy km where master-artifact "starts". */
     @Override
     protected void initialize(
-        Artifact artifact,
+        Artifact master,
         Object   context,
         CallMeta callMeta)
     {
-        D4EArtifact flys = (D4EArtifact) artifact;
+        D4EArtifact masterArtifact = (D4EArtifact) master;
 
-        RangeAccess rangeAccess = new RangeAccess(flys);
+        RangeAccess rangeAccess = new RangeAccess(masterArtifact);
         double[] range = rangeAccess.getKmRange();
-        double min = 0.0f;
         if (range != null && range.length > 0) {
-            min = range[0];
+            this.addStringData(DATA_KM, Double.toString(range[0]));
+            this.addStringData(PARENT_KM, Double.toString(range[0]));
         }
-        this.addStringData(DATA_KM, Double.toString(min));
     }
 
 
@@ -242,6 +244,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() {
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/MainValuesArtifact.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/MainValuesArtifact.java	Mon Jul 22 13:03:42 2013 +0200
@@ -316,6 +316,21 @@
             return spawnState();
     }
 
+    /**
+     * Access the Gauge that the mainvalues are taken from.
+     * @return Gauge that main values are taken from or null in case of
+     *         invalid parameterization.
+     */
+    protected Gauge getGauge(double km) {
+        River river = RiverUtils.getRiver(this);
+
+        if (river == null) {
+            logger.error("River is null");
+            return null;
+        }
+
+        return river.determineGaugeByPosition(km);
+    }
 
     /**
      * Access the Gauge that the mainvalues are taken from.
@@ -358,6 +373,41 @@
      * Get a list of "Q" main values.
      * @return list of Q main values.
      */
+    public List<NamedDouble> getMainValuesQ(double[] kms) {
+        List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
+        boolean atGauge = false;
+        Gauge gauge = getGauge(kms[0]);
+        WstValueTable interpolator = WstValueTableFactory.getTable(RiverUtils.getRiver(this));
+        Calculation c = new Calculation();
+        double w_out[] = {0.0f};
+        double q_out[] = {0.0f};
+        if (gauge != null) {
+            double gaugeStation = gauge.getStation().doubleValue();
+            atGauge = Math.abs(kms[0] - gaugeStation) < 1e-4;
+            List<MainValue> orig = gauge.getMainValues();
+            for (MainValue mv : orig) {
+                if (mv.getMainValue().getType().getName().equals("Q")) {
+                    if (atGauge) {
+                        q_out[0] = mv.getValue().doubleValue();
+                    }
+                    else {
+                        interpolator.interpolate(mv.getValue().doubleValue(),
+                            gaugeStation, kms, w_out, q_out, c);
+                    }
+                    filteredList.add(new NamedDouble(
+                                mv.getMainValue().getName(),
+                                q_out[0]
+                                ));
+                }
+            }
+        }
+        return filteredList;
+    }
+
+    /**
+     * Get a list of "Q" main values.
+     * @return list of Q main values.
+     */
     public List<NamedDouble> getMainValuesQ(boolean atGauge) {
         List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
         Gauge gauge = getGauge();
@@ -366,8 +416,8 @@
         double w_out[] = {0.0f};
         double q_out[] = {0.0f};
         double kms[] = {getLocation()};
-        double gaugeStation = gauge.getStation().doubleValue();
         if (gauge != null) {
+            double gaugeStation = gauge.getStation().doubleValue();
             List<MainValue> orig = gauge.getMainValues();
             for (MainValue mv : orig) {
                 if (mv.getMainValue().getType().getName().equals("Q")) {
@@ -389,21 +439,26 @@
     }
 
 
-    /**
-     * Get a list of "W" main values.
-     * @param atGauge if true, do not interpolate
-     * @return list of W main values.
-     */
-    public List<NamedDouble> getMainValuesW(boolean atGauge) {
+    /** Get main values of km. */
+    public List<NamedDouble> getMainValuesW(double[] kms) {
         List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
-        Gauge gauge = getGauge();
+        boolean atGauge = false;
+        double gaugeDatum = 0d;
+        Gauge gauge = getGauge(kms[0]);
+        if (gauge == null) {
+            return filteredList;
+        }
+        else if (Math.abs(kms[0] - gauge.getStation().doubleValue()) < 1e-4) {
+            atGauge = true;
+            gaugeDatum = gauge.getDatum().doubleValue();
+        }
+
         WstValueTable interpolator = WstValueTableFactory.getTable(RiverUtils.getRiver(this));
         Calculation c = new Calculation();
 
         double gaugeStation = gauge.getStation().doubleValue();
         double w_out[] = {0.0f};
         double q_out[] = {0.0f};
-        double kms[] = {getLocation()};
         if (gauge != null) {
             List<MainValue> orig = gauge.getMainValues();
             for (MainValue mv : orig) {
@@ -411,6 +466,41 @@
                     if (mv.getMainValue().getType().getName().equals("W")) {
                         filteredList.add(new NamedDouble(mv.getMainValue().getName(),
                                 mv.getValue().doubleValue()));
+                    }
+                } else
+                // We cannot interpolate the W values, so derive them
+                // from given Q values.
+                if (mv.getMainValue().getType().getName().equals("Q")) {
+                    interpolator.interpolate(mv.getValue().doubleValue(),
+                            gaugeStation, kms, w_out, q_out, c);
+
+                    filteredList.add(new NamedDouble(
+                                "W(" + mv.getMainValue().getName() +")",
+                                w_out[0]
+                                ));
+                }
+            }
+        }
+        return filteredList;
+    }
+
+
+    public List<NamedDouble> getMainValuesW(boolean atGauge, double[] kms) {
+        List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
+        Gauge gauge = getGauge();
+        WstValueTable interpolator = WstValueTableFactory.getTable(RiverUtils.getRiver(this));
+        Calculation c = new Calculation();
+
+        double w_out[] = {0.0f};
+        double q_out[] = {0.0f};
+        if (gauge != null) {
+            double gaugeStation = gauge.getStation().doubleValue();
+            List<MainValue> orig = gauge.getMainValues();
+            for (MainValue mv : orig) {
+                if (atGauge) {
+                    if (mv.getMainValue().getType().getName().equals("W")) {
+                        filteredList.add(new NamedDouble(mv.getMainValue().getName(),
+                                mv.getValue().doubleValue()));
 
                     }
                 } else
@@ -431,6 +521,16 @@
 
 
     /**
+     * Get a list of "W" main values.
+     * @param atGauge if true, do not interpolate
+     * @return list of W main values.
+     */
+    public List<NamedDouble> getMainValuesW(boolean atGauge) {
+        return getMainValuesW(atGauge, new double[] {getLocation()});
+    }
+
+
+    /**
      * Returns the name of this artifact ('mainvalue').
      *
      * @return 'mainvalue'
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/StaticWKmsArtifact.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/StaticWKmsArtifact.java	Mon Jul 22 13:03:42 2013 +0200
@@ -310,7 +310,7 @@
             return -1;
         }
 
-        // Do linear interpolation
+        // Do linear interpolation.
         int mod = kmIncreasing ? -1 : +1;
         return Linear.linear(km, wkms.getKm(idx+mod), wkms.getKm(idx), wkms.getW(idx+mod), wkms.getW(idx));
     }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/StaticWQKmsArtifact.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/StaticWQKmsArtifact.java	Mon Jul 22 13:03:42 2013 +0200
@@ -59,6 +59,8 @@
 
     private static final String NAME = "staticwqkms";
 
+    private boolean official = false;
+
     static {
         // TODO: Move to configuration.
         FacetActivity.Registry.getInstance().register(
@@ -85,6 +87,10 @@
 
     /**
      * Gets called from factory, to set things up.
+     *
+     * If the id's string starts with official- it will be treated as
+     * an Artifact containing official data for the according special
+     * case handling.
      */
     @Override
     public void setup(
@@ -106,6 +112,10 @@
         if (code != null) {
             String [] parts = code.split("-");
 
+            if (parts.length >= 1) {
+                official = parts[0].toLowerCase().equals("official");
+            }
+
             if (parts.length >= 4) {
                 int col = Integer.parseInt(parts[2]);
                 int wst = Integer.parseInt(parts[3]);
@@ -222,5 +232,10 @@
         return Lines.createWaterLines(points, wAtKm);
     }
     // TODO implement deepCopy.
+
+    public boolean isOfficial()
+    {
+        return official;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java	Mon Jul 22 13:03:42 2013 +0200
@@ -197,15 +197,26 @@
 
         String calculationMode = getDataAsString("calculation_mode");
 
-        if (calculationMode.equals("calc.discharge.longitudinal.section")
-        ) {
-            return getDischargeLongitudinalSectionData();
-        }
-        else if (calculationMode.equals("calc.extreme.curve")) {
-            return (CalculationResult)
-                this.compute(context, ComputeType.ADVANCE, false);
+        // If this WINFO-Artifact has a calculation trait.
+        if (calculationMode != null) {
+            if (calculationMode.equals("calc.discharge.longitudinal.section")
+            ) {
+                return getDischargeLongitudinalSectionData();
+            }
+            else if (calculationMode.equals("calc.extreme.curve")) {
+                return (CalculationResult)
+                    this.compute(context, ComputeType.ADVANCE, false);
+            }
+            else if (calculationMode.equals("calc.w.differences")) {
+                return (CalculationResult)
+                    this.compute(context, ComputeType.ADVANCE, true);
+            }
+            else {
+                logger.warn("Unhandled calculation_mode " + calculationMode);
+            }
         }
 
+        // Otherwise get it from parameterization.
         River river = RiverUtils.getRiver(this);
         if (river == null) {
             return error(new WQKms[0], "no.river.selected");
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/access/FixAnalysisAccess.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/access/FixAnalysisAccess.java	Mon Jul 22 13:03:42 2013 +0200
@@ -33,6 +33,7 @@
         super(artifact);
     }
 
+    /** Access the reference date period, return null in case of 'errors'. */
     public DateRange getReferencePeriod() {
         if (referencePeriod == null) {
             StateData refStart = artifact.getData("ref_start");
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/Recommendations.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/Recommendations.java	Mon Jul 22 13:03:42 2013 +0200
@@ -173,7 +173,7 @@
 
     /**
      * Append recommendations to \param result.
-     * @param extraParameters parameters (typicall example: 'recommended')
+     * @param extraParameters parameters (typical example: 'recommended')
      */
     public void  recommend(
         D4EArtifact         artifact,
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/CrossSectionFactory.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/CrossSectionFactory.java	Mon Jul 22 13:03:42 2013 +0200
@@ -59,30 +59,6 @@
     }
 
 
-    /**
-     * True if the given section is the "newest" for that river.
-     * @param section Given section
-     * @return true if the section has the most advanced end of its validity interval
-     *         or the most advanced start of its validity interval.
-     */
-    public static boolean isNewest(CrossSection section) {
-        Session session = SessionHolder.HOLDER.get();
-        Query query = session.createQuery(
-            "from CrossSection where river.id = :riverid "
-            + " order by timeInterval.stopTime desc, timeInterval.startTime desc");
-        query.setParameter("riverid", section.getRiver().getId());
-
-        List result = query.list();
-
-        if (result == null || result.isEmpty()) {
-            return true;
-        }
-        else {
-            CrossSection cs = (CrossSection) result.get(0);
-            return section.getId().equals(cs.getId());
-        }
-    }
-
 
     /**
      *  Get a specific CrossSection from db.
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FastCrossSectionChunk.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FastCrossSectionChunk.java	Mon Jul 22 13:03:42 2013 +0200
@@ -19,6 +19,10 @@
 
 import org.apache.log4j.Logger;
 
+/**
+ * Number of FastCrossSectionLines, e.g. to store in cache and retrieve
+ * a single contain CrossSectionLine by its km.
+ */
 public class FastCrossSectionChunk
 implements   Serializable
 {
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MainValuesQFacet.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MainValuesQFacet.java	Mon Jul 22 13:03:42 2013 +0200
@@ -25,6 +25,7 @@
 import org.dive4elements.river.jfree.StickyAxisAnnotation;
 
 import org.dive4elements.river.exports.DurationCurveGenerator;
+import org.dive4elements.river.exports.fixings.FixChartGenerator;
 
 
 /**
@@ -89,7 +90,8 @@
      * Returns the data this facet requires.
      *
      * @param artifact the owner artifact.
-     * @param context  the CallContext (ignored).
+     * @param context  the CallContext (can be used to find out if in
+     *                 navigable fixation-setting, or durationcurve).
      *
      * @return the data.
      */
@@ -105,6 +107,15 @@
             getDataProvider(DurationCurveFacet.BB_DURATIONCURVE);
         if (providers.size() < 1) {
             logger.warn("Could not find durationcurve data provider.");
+            // Do we have a current km in context?
+            // If so, we are likely fetching data for a navigable
+            // diagram (i.e. in fixation branch).
+            if (context.getContextValue(FixChartGenerator.CURRENT_KM) != null) {
+                Double ckm = (Double) context.getContextValue(FixChartGenerator.CURRENT_KM);
+                // Return linearly interpolated values, in m if not at gauge,
+                // in cm if at gauge.
+                qs = mvArtifact.getMainValuesQ(new double[] {ckm});
+            }
         }
         else {
             wqdays = (WQDay) providers.get(0).provideData(
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MainValuesWFacet.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MainValuesWFacet.java	Mon Jul 22 13:03:42 2013 +0200
@@ -23,6 +23,7 @@
 import org.dive4elements.river.artifacts.math.Linear;
 import org.dive4elements.river.jfree.RiverAnnotation;
 import org.dive4elements.river.jfree.StickyAxisAnnotation;
+import org.dive4elements.river.exports.fixings.FixChartGenerator;
 
 
 /**
@@ -85,7 +86,8 @@
      * Returns the data this facet provides.
      *
      * @param artifact the owner artifact.
-     * @param context  the CallContext (ignored).
+     * @param context  the CallContext (can be used to find out if in
+     *                 navigable fixation-setting, or durationcurve).
      *
      * @return the data.
      */
@@ -102,6 +104,15 @@
             getDataProvider(DurationCurveFacet.BB_DURATIONCURVE);
         if (providers.size() < 1) {
             logger.warn("Could not find durationcurve data provider.");
+            // Do we have a current km in context?
+            // If so, we are likely fetching data for a navigable
+            // diagram (i.e. in fixation branch).
+            if (context.getContextValue(FixChartGenerator.CURRENT_KM) != null) {
+                Double ckm = (Double) context.getContextValue(FixChartGenerator.CURRENT_KM);
+                // Return linearly interpolated values, in m if not at gauge,
+                // in cm if at gauge.
+                ws = mvArtifact.getMainValuesW(new double[] {ckm});
+            }
         }
         else {
             wqdays = (WQDay) providers.get(0).provideData(
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/OfficialLineFinder.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/OfficialLineFinder.java	Mon Jul 22 13:03:42 2013 +0200
@@ -10,6 +10,7 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -25,6 +26,7 @@
 import org.dive4elements.river.model.NamedMainValue;
 import org.dive4elements.river.model.OfficialLine;
 import org.dive4elements.river.model.River;
+import org.dive4elements.river.model.TimeInterval;
 import org.dive4elements.river.model.Wst;
 import org.dive4elements.river.model.WstColumn;
 
@@ -46,6 +48,8 @@
         private int    wstId;
         private int    columnPos;
         private String name;
+        private String source;
+        private Date   date;
 
         public ValueRange(
             double start,
@@ -53,13 +57,17 @@
             double value,
             int    wstId,
             int    columnPos,
-            String name
+            String name,
+            String source,
+            Date   date
         ) {
             super(start, end);
             this.value     = value;
             this.wstId     = wstId;
             this.columnPos = columnPos;
             this.name      = name;
+            this.source    = source;
+            this.date      = date;
         }
 
         public boolean sameValue(double value) {
@@ -82,6 +90,14 @@
             return name;
         }
 
+        public String getSource() {
+            return source;
+        }
+
+        public Date getDate() {
+            return date;
+        }
+
         @Override
         public boolean equals(Object o) {
             if (!(o instanceof ValueRange)) {
@@ -96,7 +112,11 @@
             return "[" + name +
                 " value: " + value +
                 " wstId: " + wstId +
-                " pos: " + columnPos + "]";
+                " pos: " + columnPos +
+                " source: " + source +
+                " date: " + date +
+                " from: " + start +
+                " to: " + end + "]";
         }
     }
 
@@ -132,10 +152,13 @@
             new HashMap<String, List<ValueRange>>();
 
         for (OfficialLine line: OfficialLine.fetchAllOfficalLines()) {
-            NamedMainValue nmv = line.getNamedMainValue();
-            Integer   mnvId    = nmv.getId();
-            WstColumn wc       = line.getWstColumn();
-            Wst       wst      = wc.getWst();
+            NamedMainValue nmv    = line.getNamedMainValue();
+            Integer        mnvId  = nmv.getId();
+            WstColumn      wc     = line.getWstColumn();
+            Wst            wst    = wc.getWst();
+            TimeInterval   ti     = wc.getTimeInterval();
+            Date           date   = ti != null ? ti.getStartTime() : null;
+            String         source = wc.getSource();
 
             List<ValueRange> ranges = new ArrayList<ValueRange>();
 
@@ -147,14 +170,14 @@
                     NamedMainValue tnmv = mainValue.getMainValue();
                     if (tnmv.getId().equals(mnvId)) {
                         // found gauge with this main value
-
                         double from  = gauge.getRange().getA().doubleValue();
-                        double to    = gauge.getRange().getA().doubleValue();
+                        double to    = gauge.getRange().getB().doubleValue();
                         double value = mainValue.getValue().doubleValue();
                         int    wstId = wst.getId();
                         int    pos   = wc.getPosition();
                         ValueRange range = new ValueRange(
-                            from, to, value, wstId, pos, nmv.getName());
+                            from, to, value, wstId, pos,
+                            nmv.getName(), source, date);
 
                         if (debug) {
                             log.debug(
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQKms.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQKms.java	Mon Jul 22 13:03:42 2013 +0200
@@ -143,5 +143,15 @@
         double to   = getKm(size()-1);
         return from + " - " + to;
     }
+
+    /**
+     * Returns an array of two double values the first and last kilometer.
+     *
+     * @return a double array with the first and last km
+     */
+    public double[] getFirstLastKM() {
+        /* Behold the first km might be larger then the last! */
+        return new double[] {getKm(0), getKm(size()-1)};
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQKmsResult.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQKmsResult.java	Mon Jul 22 13:03:42 2013 +0200
@@ -12,4 +12,4 @@
 public interface WQKmsResult {
     public WQKms[] getWQKms();
 }
-
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisCalculation.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisCalculation.java	Mon Jul 22 13:03:42 2013 +0200
@@ -172,7 +172,7 @@
                 ArrayList<QWD> allQWDs = new ArrayList<QWD>();
 
                 // for all Q sectors.
-                for (int qSector = qSectorStart; qSector < qSectorEnd; ++qSector) {
+                for (int qSector = qSectorStart; qSector <= qSectorEnd; ++qSector) {
 
                     Filter filter = new AndFilter()
                         .add(kmFilter)
@@ -289,6 +289,7 @@
         return results;
     }
 
+    /** Returns the mapped value of colIdx or the size of the hashmap. */
     private static final int getIndex(TIntIntHashMap map, int colIdx) {
         if (map.containsKey(colIdx)) {
             return map.get(colIdx);
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java	Mon Jul 22 13:03:42 2013 +0200
@@ -18,7 +18,10 @@
 import org.dive4elements.river.artifacts.model.Calculation;
 import org.dive4elements.river.artifacts.model.CalculationResult;
 
-
+/**
+ * Perform calculation of differences of bed height (german Sohlhoehe).
+ * The input are either single year data or epochs.
+ */
 public class BedDiffCalculation
 extends Calculation
 {
@@ -84,6 +87,7 @@
        */
     }
 
+    /** Get two BedHeights from factory. */
     private static BedHeight [] getHeightPair(int [] ids, String type) {
         return new BedHeight [] {
             BedHeightFactory.getHeight(type, ids[0], 0),
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFactory.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFactory.java	Mon Jul 22 13:03:42 2013 +0200
@@ -62,7 +62,7 @@
 
 
     /**
-     * Get WKms for given column and wst_id, caring about the cache.
+     * Get BedHeight for given type and height_id, caring about the cache.
      */
     public static BedHeight getHeight(String type, int height_id, int time) {
         log.debug("BedHeightFactory.getHeight");
@@ -92,7 +92,7 @@
         return values;
     }
 
-    /** Get name for a WKms. */
+    /** Get name for a BedHeight. */
     public static String getHeightName(String type, int height_id) {
         log.debug("BedHeightFactory.getHeightName height_id/" + height_id);
 
@@ -123,10 +123,9 @@
 
 
     /**
-     * Get WKms from db.
-     * @param column the position columns value
-     * @param wst_id database id of the wst
-     * @return according WKms.
+     * Get BedHeight from db.
+     * @param height_id database id of the bed_height
+     * @return according BedHeight.
      */
     public static BedHeight getBedHeightUncached(
         String type,
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadCalculation.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadCalculation.java	Mon Jul 22 13:03:42 2013 +0200
@@ -187,12 +187,28 @@
                 }
             }
             SedimentLoadFraction fr = resLoad.getFraction(km);
-            resLoad.setCoarse(km, fr.getCoarse()/cSum, fr.getCoarseRange());
-            resLoad.setFineMiddle(km, fr.getFineMiddle()/fmSum, fr.getFineMiddleRange());
-            resLoad.setSand(km, fr.getSand()/sSum, fr.getSandRange());
-            resLoad.setSuspSand(km, fr.getSuspSand()/ssSum, fr.getSuspSandRange());
-            resLoad.setSuspSandBed(km, fr.getSuspSandBed()/ssbSum, fr.getSuspSandBedRange());
-            resLoad.setSuspSediment(km, fr.getSuspSediment()/sseSum, fr.getSuspSedimentRange());
+            // Prevent divisions by zero, the fraction defaults to 0d.
+            if (cSum != 0) {
+                resLoad.setCoarse(km, fr.getCoarse()/cSum, fr.getCoarseRange());
+            }
+            if (fmSum != 0) {
+                resLoad.setFineMiddle(km, fr.getFineMiddle()/fmSum,
+                    fr.getFineMiddleRange());
+            }
+            if (sSum != 0) {
+                resLoad.setSand(km, fr.getSand()/sSum, fr.getSandRange());
+            }
+            if (ssSum != 0) {
+                resLoad.setSuspSand(km, fr.getSuspSand()/ssSum,
+                    fr.getSuspSandRange());
+            }
+            if (ssbSum != 0) {
+                resLoad.setSuspSandBed(km, fr.getSuspSandBed()/ssbSum,
+                    fr.getSuspSandBedRange());
+            }
+            if (sseSum != 0) {
+                resLoad.setSuspSediment(km, fr.getSuspSediment()/sseSum, fr.getSuspSedimentRange());
+            }
         }
         resLoad.setDescription("");
         resLoad.setEpoch(true);
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java	Mon Jul 22 13:03:42 2013 +0200
@@ -364,7 +364,7 @@
             Calendar toStart = Calendar.getInstance();
             toStart.set(eyear - 1, 11, 31);
             Calendar toEnd = Calendar.getInstance();
-            toEnd.set(eyear, 11, 30);
+            toEnd.set(eyear+1, 11, 31);
             sqlQuery = session.createSQLQuery(SQL_SELECT_EPOCHS_DATA)
                 .addScalar("description", StandardBasicTypes.STRING)
                 .addScalar("startYear", StandardBasicTypes.DATE)
@@ -436,6 +436,7 @@
             Range range = null;
             if (station == null) {
                 log.warn("No measurement station for " + fraction + " km " + km);
+                continue;
             }
             else {
                 if (nextStation != null)
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/CalculationSelect.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/CalculationSelect.java	Mon Jul 22 13:03:42 2013 +0200
@@ -77,10 +77,11 @@
         CALCULATION_DISCHARGE_CURVE,
         CALCULATION_HISTORICAL_DISCHARGE_CURVE,
         CALCULATION_DURATION_CURVE,
-        CALCULATION_DISCHARGE_LONGITUDINAL_CURVE,
+//        CALCULATION_DISCHARGE_LONGITUDINAL_CURVE,
         CALCULATION_W_DIFFERENCES,
-        CALCULATION_REFERENCE_CURVE,
-        CALCULATION_EXTREME};
+        CALCULATION_REFERENCE_CURVE //,
+//        CALCULATION_EXTREME
+    };
 
 
     /** Error message that is thrown if no mode has been chosen. */
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java	Mon Jul 22 13:03:42 2013 +0200
@@ -18,10 +18,12 @@
 
 import org.dive4elements.artifacts.CallContext;
 import org.dive4elements.artifacts.Artifact;
+import org.dive4elements.river.artifacts.ChartArtifact;
 import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.FixationArtifact;
+import org.dive4elements.river.artifacts.MINFOArtifact;
 import org.dive4elements.river.artifacts.StaticWKmsArtifact;
 import org.dive4elements.river.artifacts.WINFOArtifact;
-import org.dive4elements.river.artifacts.ChartArtifact;
 
 import org.dive4elements.river.artifacts.math.WKmsOperation;
 
@@ -29,15 +31,16 @@
 import org.dive4elements.river.artifacts.model.DataFacet;
 import org.dive4elements.river.artifacts.model.DifferenceCurveFacet;
 import org.dive4elements.river.artifacts.model.EmptyFacet;
-
 import org.dive4elements.river.artifacts.model.FacetTypes;
 import org.dive4elements.river.artifacts.model.WKms;
 import org.dive4elements.river.artifacts.model.WQKms;
 
+import org.dive4elements.river.artifacts.model.fixings.FixRealizingResult;
+
 import org.dive4elements.river.utils.RiverUtils;
 import org.dive4elements.river.utils.StringUtil;
 
-
+/** State of a WINFOArtifact to get differences of data of other artifacts. */
 public class WDifferencesState
 extends      DefaultState
 implements   FacetTypes
@@ -76,9 +79,10 @@
 
 
     /**
-     * Access the data (wkms).
+     * Access the data (wkms) of an artifact, coded in mingle.
      */
     protected WKms getWKms(String mingle, CallContext context) {
+        logger.debug("WDifferencesState.getWKms " + mingle);
         String[] def  = mingle.split(";");
         String   uuid = def[0];
         String   name = def[1];
@@ -96,23 +100,45 @@
             return wkms;
         }
 
-        WINFOArtifact flys = (WINFOArtifact) RiverUtils.getArtifact(
+        D4EArtifact d4eArtifact = RiverUtils.getArtifact(
             uuid,
             context);
 
-        if (flys == null) {
+        if (d4eArtifact == null) {
             logger.warn("One of the artifacts (1) for diff calculation could not be loaded");
             return null;
         }
-        else{
-            WQKms[] wqkms = (WQKms[]) flys.getWaterlevelData().
+
+        if (d4eArtifact instanceof WINFOArtifact) {
+            logger.debug("Get WKms from WINFOArtifact");
+            WINFOArtifact flys = (WINFOArtifact) d4eArtifact;
+
+            WKms[] wkms = (WKms[]) flys.getWaterlevelData(context).
                                               getData();
-            if (wqkms == null)
-            logger.warn("not  waterlevels in artifact");
-            else if (wqkms.length < idx)
-            logger.warn("not enough waterlevels in artifact");
-            return wqkms[idx];
+            if (wkms == null || wkms.length == 0) {
+                logger.warn("no waterlevels in artifact");
+            }
+            else if (wkms.length < idx+1) {
+                logger.warn("Not enough waterlevels in artifact.");
+                return new WQKms();
+            }
+            return wkms[idx];
         }
+        else if (d4eArtifact instanceof MINFOArtifact) {
+            logger.debug("Get WKms from MINFOArtifact");
+            CalculationResult r = (CalculationResult)
+                d4eArtifact.compute(context, ComputeType.ADVANCE, false);
+        }
+        else if (d4eArtifact instanceof FixationArtifact) {
+            logger.debug ("Get WKms from FixationArtifact.");
+            CalculationResult r = (CalculationResult)
+                d4eArtifact.compute(context, ComputeType.ADVANCE, false);
+            FixRealizingResult frR = (FixRealizingResult) r.getData();
+            return frR.getWQKms()[idx];
+        }
+
+        logger.error("Do not know how to handle (getWKms) minuend/subtrahend");
+        return null;
     }
 
 
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelState.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelState.java	Mon Jul 22 13:03:42 2013 +0200
@@ -8,6 +8,7 @@
 
 package org.dive4elements.river.artifacts.states;
 
+import java.util.Date;
 import java.util.List;
 
 import org.apache.log4j.Logger;
@@ -125,8 +126,8 @@
                 report.addProblem(Resources.format(
                     cc.getMeta(),
                     "official.line.found",
-                    "Found official line for {0}.",
-                    ol.getName()));
+                    "Found official line for {0} from year {1,date,yyyy} from {2}.",
+                    ol.getName(), nn(ol.getDate()), nn(ol.getSource())));
             }
         }
 
@@ -137,6 +138,14 @@
         return res;
     }
 
+    /** Returns empty String if argument is null, argument itself otherwise. */
+    private static final String nn(String s) {
+        return s != null ? s : "";
+    }
+
+    private static final Date nn(Date d) {
+        return d != null ? d : new Date();
+    }
 
     /**
      * @param context Ignored.
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixRealizingCompute.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixRealizingCompute.java	Mon Jul 22 13:03:42 2013 +0200
@@ -29,7 +29,6 @@
 import org.dive4elements.river.artifacts.model.fixings.FixRealizingCalculation;
 import org.dive4elements.river.artifacts.model.fixings.FixRealizingResult;
 import org.dive4elements.river.artifacts.model.fixings.FixEventFacet;
-import org.dive4elements.river.artifacts.model.fixings.FixReferenceEventsFacet;
 import org.dive4elements.river.artifacts.model.fixings.FixWQCurveFacet;
 import org.dive4elements.river.artifacts.model.fixings.FixWaterlevelFacet;
 import org.dive4elements.river.artifacts.resources.Resources;
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/DifferencesState.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/DifferencesState.java	Mon Jul 22 13:03:42 2013 +0200
@@ -37,6 +37,7 @@
 import org.dive4elements.river.utils.Formatter;
 
 /**
+ * State for BedDifferences.
  * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
  */
 public class DifferencesState
--- a/artifacts/src/main/java/org/dive4elements/river/collections/D4EArtifactCollection.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/collections/D4EArtifactCollection.java	Mon Jul 22 13:03:42 2013 +0200
@@ -628,6 +628,30 @@
         return persistent != null ? persistent.getArtifact() : null;
     }
 
-
+    /**
+     * Returns artifacts that name facetName.
+     *
+     * @param name The Artifact name to search
+     * @param context The CallContext
+     *
+     * @return a list of artifacts matching this name.
+     */
+    public List<Artifact> getArtifactsByName(String name, CallContext context)
+    {
+        log.debug("Searching for Artifacts: " + name);
+        List<Artifact> ret =  new ArrayList<Artifact>();
+        try {
+            for (String uuid: getArtifactUUIDs(context)) {
+                D4EArtifact subArt = (D4EArtifact)getArtifact(uuid, context);
+                if (subArt.getName() != null && subArt.getName().equals(name)) {
+                    ret.add(subArt);
+                }
+            }
+        } catch (ArtifactDatabaseException e) {
+            log.error("Unexpected Error!", e);
+        } finally {
+            return ret;
+        }
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveGenerator.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveGenerator.java	Mon Jul 22 13:03:42 2013 +0200
@@ -20,17 +20,15 @@
 import org.dive4elements.river.jfree.StickyAxisAnnotation;
 import org.dive4elements.river.jfree.StyledXYSeries;
 
-import org.dive4elements.river.model.Gauge;
 import org.dive4elements.river.utils.RiverUtils;
 
-import org.dive4elements.artifacts.Artifact;
-
 import java.awt.Font;
 
 import java.util.ArrayList;
 import java.util.List;
 
 import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.plot.XYPlot;
 import org.jfree.data.xy.XYSeries;
 
 import org.apache.log4j.Logger;
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java	Mon Jul 22 13:03:42 2013 +0200
@@ -88,6 +88,17 @@
     }
 
 
+    /** Overriden to show second axis also if no visible data present. */
+    @Override
+    protected void adjustAxes(XYPlot plot) {
+        super.adjustAxes(plot);
+        if (getCurrentGaugeDatum() != 0d) {
+            // Show the W[*m] axis even if there is no data.
+            plot.setRangeAxis(1, createYAxis(YAXIS.W.idx));
+        }
+    }
+
+
     public DischargeCurveGenerator() {
         super();
     }
@@ -142,6 +153,7 @@
         return zoomin;
     }
 
+    /** Translate River annotations if a gauge. */
     public void translateRiverAnnotation(RiverAnnotation riverAnnotation) {
         if (getCurrentGaugeDatum() == 0d) {
             return;
--- a/artifacts/src/main/java/org/dive4elements/river/exports/OutputHelper.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/OutputHelper.java	Mon Jul 22 13:03:42 2013 +0200
@@ -71,7 +71,7 @@
         boolean debug = log.isDebugEnabled();
 
         if (debug) {
-            log.debug("D4EArtifactCollection.doOut: " + outName);
+            log.debug("OutputHelper.doOut: " + outName);
         }
 
         ThemeList themeList = new ThemeList(attributes);
@@ -154,7 +154,7 @@
 
         if (debug) {
             log.debug(
-                "D4EArtifactCollection.getFacetThemeFromAttribute(facet="
+                "OutputHelper.getFacetThemeFromAttribute(facet="
                 + facet + ", index=" + index + ")");
         }
 
@@ -235,7 +235,7 @@
         Theme       t,
         CallContext context)
     {
-        log.debug("D4EArtifactCollection.addThemeToAttribute: " + uuid);
+        log.debug("OutputHelper.addThemeToAttribute: " + uuid);
 
         if (t == null) {
             log.warn("Theme is empty - cancel adding it to attribute!");
@@ -380,7 +380,7 @@
     protected Artifact getArtifact(String uuid, CallContext context)
     throws    ArtifactDatabaseException
     {
-        log.debug("D4EArtifactCollection.getArtifact");
+        log.debug("OutputHelper.getArtifact");
 
         Backend backend               = Backend.getInstance();
         PersistentArtifact persistent = backend.getArtifact(uuid);
@@ -409,7 +409,7 @@
         boolean debug = log.isDebugEnabled();
 
         if (debug) {
-            log.debug("D4EArtifactCollection.initItemAttribute");
+            log.debug("OutputHelper.initItemAttribute");
         }
 
         Theme t = getThemeForFacet(uuid, facet, pattern, index, outName, context);
@@ -447,7 +447,7 @@
         String outName,
         CallContext context)
     {
-        log.info("D4EArtifactCollection.getThemeForFacet: " + facet);
+        log.info("OutputHelper.getThemeForFacet: " + facet);
 
         RiverContext flysContext = context instanceof RiverContext
             ? (RiverContext) context
--- a/artifacts/src/main/java/org/dive4elements/river/exports/WDifferencesCurveGenerator.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/WDifferencesCurveGenerator.java	Mon Jul 22 13:03:42 2013 +0200
@@ -8,11 +8,28 @@
 
 package org.dive4elements.river.exports;
 
+import org.apache.log4j.Logger;
+
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifactdatabase.state.Facet;
+
 import org.dive4elements.river.artifacts.model.FacetTypes;
 import org.dive4elements.river.artifacts.model.WKms;
 
+import org.dive4elements.river.exports.StyledSeriesBuilder;
+import org.dive4elements.river.jfree.StyledXYSeries;
+import org.dive4elements.river.artifacts.model.minfo.MorphologicWidth;
+
+
+import org.dive4elements.river.exports.process.BedDiffYearProcessor;
+import org.dive4elements.river.exports.process.BedDiffHeightYearProcessor;
+import org.dive4elements.river.exports.process.BedheightProcessor;
+import org.dive4elements.river.exports.process.Processor;
+
 import org.jfree.chart.JFreeChart;
 import org.jfree.chart.plot.XYPlot;
+import org.jfree.data.xy.XYSeries;
+import org.w3c.dom.Document;
 
 
 /**
@@ -22,6 +39,9 @@
 extends      LongitudinalSectionGenerator
 implements   FacetTypes
 {
+    /** The logger that is used in this generator. */
+    private static Logger logger = Logger.getLogger(WDifferencesCurveGenerator.class);
+
     public enum YAXIS {
         W(0),
         D(1),
@@ -85,8 +105,46 @@
     }
 
 
+    /** Handle additional facets (beddifferences). */
+    @Override
+    public void doOut(ArtifactAndFacet bundle, Document attr, boolean visible) {
+        super.doOut(bundle, attr, visible);
+
+        String name = bundle.getFacetName();
+        logger.debug("doOut: " + name);
+
+        if (name == null) {
+            logger.error("No facet name for doOut(). No output generated!");
+            return;
+        }
+
+        Facet facet = bundle.getFacet();
+
+        if (facet == null) {
+            return;
+        }
+
+        Processor bedp = new BedheightProcessor();
+        Processor bdyProcessor = new BedDiffYearProcessor();
+        Processor bdhyProcessor = new BedDiffHeightYearProcessor();
+
+        if (bedp.canHandle(name)) {
+           bedp.doOut(this, bundle, attr, visible, YAXIS.W.idx);
+        }
+        else if (bdyProcessor.canHandle(name)) {
+           bdyProcessor.doOut(this, bundle, attr, visible, YAXIS.W.idx);
+        }
+        else if (bdhyProcessor.canHandle(name)) {
+           bdhyProcessor.doOut(this, bundle, attr, visible, YAXIS.W.idx);
+        }
+        else {
+            logger.warn("WDifferencesCurveGenerator.doOut: unknown facet type " + name);
+        }
+    }
+
+
     /**
-     *
+     * Sets the zero base line visible.
      */
     @Override
     public JFreeChart generateChart() {
--- a/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java	Mon Jul 22 13:03:42 2013 +0200
@@ -34,6 +34,7 @@
 import net.sf.jasperreports.engine.JasperPrint;
 import net.sf.jasperreports.engine.JRException;
 
+import org.dive4elements.artifacts.Artifact;
 import org.dive4elements.artifacts.CallContext;
 import org.dive4elements.artifacts.CallMeta;
 import org.dive4elements.artifacts.common.utils.Config;
@@ -45,6 +46,7 @@
 import org.dive4elements.river.artifacts.FixationArtifact;
 import org.dive4elements.river.artifacts.D4EArtifact;
 import org.dive4elements.river.artifacts.WINFOArtifact;
+import org.dive4elements.river.artifacts.StaticWQKmsArtifact;
 import org.dive4elements.river.artifacts.model.CalculationResult;
 import org.dive4elements.river.artifacts.model.Segment;
 import org.dive4elements.river.artifacts.model.WQCKms;
@@ -70,6 +72,9 @@
 
     public static final String FACET_WST = "wst";
 
+    /* This should be the same as in the StaticWQKmsArtifact */
+    public static final String STATICWQKMSNAME = "staticwqkms";
+
     public static final String CSV_KM_HEADER =
         "export.waterlevel.csv.header.km";
 
@@ -134,9 +139,11 @@
     public static final String PDF_HEADER_MODE = "export.waterlevel.pdf.mode";
     public static final String JASPER_FILE     = "export.waterlevel.pdf.file";
 
-    /** The storage that contains all WQKms objects for the different facets.*/
+    /** The storage that contains all WQKms objects that are calculated.*/
     protected List<WQKms[]> data;
 
+    /** The storage that contains official fixings if available.*/
+    protected List<WQKms> officalFixings;
 
     public void init(Document request, OutputStream out, CallContext context) {
         logger.debug("WaterlevelExporter.init");
@@ -153,6 +160,37 @@
     {
         logger.debug("WaterlevelExporter.generate");
 
+        /* Check for official fixings. They should also be included in the
+         * export but only the calculation result is added with addData */
+
+        officalFixings = new ArrayList<WQKms>();
+
+        for (Artifact art: collection.getArtifactsByName(STATICWQKMSNAME, context)) {
+            if (art instanceof StaticWQKmsArtifact) {
+                StaticWQKmsArtifact sart = (StaticWQKmsArtifact) art;
+                if (!sart.isOfficial()) {
+                    continue;
+                }
+
+                /* Check that we add the data only once */
+                WQKms toAdd = sart.getWQKms();
+                String newName = toAdd.getName();
+
+                boolean exists = false;
+                for (WQKms wqkm: officalFixings) {
+                    /* The same official fixing could be in two
+                       artifacts/outs so let's deduplicate */
+                    if (wqkm.getName().equals(newName)) {
+                        exists = true;
+                    }
+                }
+                if (!exists) {
+                    officalFixings.add(toAdd);
+                    logger.debug("Adding additional offical fixing: " + newName);
+                }
+            }
+        }
+
         if (facet != null && facet.equals(AbstractExporter.FACET_CSV)) {
             generateCSV();
         }
@@ -183,7 +221,7 @@
 
 
     /**
-     * This method is used to prepare the column titles of waterlevel exports.
+     * Prepare the column titles of waterlevel exports.
      * Titles in this export include the Q value. If a Q value matches a named
      * main value (as HQ100 or MNQ) this named main value should be used as
      * title. This method resets the name of the <i>wqkms</i> object if such
@@ -294,11 +332,80 @@
         writeCSVMeta(writer);
         writeCSVHeader(writer, atGauge, isQ);
 
+        Double first = Double.NaN;
+        Double last = Double.NaN;
+
         for (WQKms[] tmp: data) {
             for (WQKms wqkms: tmp) {
                 wQKms2CSV(writer, wqkms, atGauge, isQ);
+                double[] firstLast = wqkms.getFirstLastKM();
+                if (first.isNaN()) {
+                    /* Initialize */
+                    first = firstLast[0];
+                    last = firstLast[1];
+                }
+                if (firstLast[0] > firstLast[1]) {
+                    /* Calculating upstream we assert that it is
+                     * impossible that the direction changes during this
+                     * loop */
+                    first = Math.max(first, firstLast[0]);
+                    last = Math.min(last, firstLast[1]);
+                } else if (firstLast[0] < firstLast[1]) {
+                    first = Math.min(first, firstLast[0]);
+                    last = Math.max(last, firstLast[1]);
+                } else {
+                    first = last = firstLast[0];
+                }
             }
         }
+        /* Append the official fixing at the bottom */
+        for (WQKms wqkms: officalFixings) {
+            wQKms2CSV(writer, filterWQKms(wqkms, first, last), atGauge, isQ);
+        }
+    }
+
+
+    /** Filter a wqkms object to a distance.
+     *
+     * To handle upstream / downstream and to limit
+     * the officialFixings to the calculation distance
+     * we create a new wqkms object here and fill it only
+     * with the relevant data.
+     *
+     * @param wqkms: The WQKms Object to filter
+     * @param first: The fist kilometer of the range
+     * @param last: The last kilometer of the range
+     *
+     * @return A new WQKms with the relevant data sorted by direction
+     */
+    private WQKms filterWQKms(WQKms wqkms, Double first, Double last) {
+        if (first.isNaN() || last.isNaN()) {
+            logger.warn("Filtering official fixing without valid first/last.");
+            return wqkms;
+        }
+        int firstIdx = first > last ? wqkms.size() - 1 : 0;
+        int lastIdx  = first > last ? 0 : wqkms.size() -1;
+        WQKms filtered = new WQKms (wqkms.size());
+        filtered.setReferenceSystem(wqkms.getReferenceSystem());
+        filtered.setName(wqkms.getName());
+        double [] dp = new double [3];
+
+        if (first > last) {
+            for (int i = wqkms.size() - 1; i >= 0; i--) {
+                dp = wqkms.get(i, dp);
+                if (dp[2] <= first + 1E-5 && dp[2] > last - 1E-5) {
+                    filtered.add(dp[0], dp[1], dp[2]);
+                }
+            }
+        } else {
+            for (int i = 0; i < wqkms.size(); i++) {
+                dp = wqkms.get(i, dp);
+                if (dp[2] < last + 1E-5 && dp[2] > first - 1E-5) {
+                    filtered.add(dp[0], dp[1], dp[2]);
+                }
+            }
+        }
+        return filtered;
     }
 
 
@@ -484,13 +591,12 @@
         NumberFormat kmf = getKmFormatter();
         NumberFormat wf  = getWFormatter();
         NumberFormat qf  = getQFormatter();
-
-       writer.writeNext(new String[] {
-           kmf.format(wqkm[2]),
-           wf.format(wqkm[0]),
-           qf.format(wqkm[1]),
-           RiverUtils.getLocationDescription(flys, wqkm[2])
-       });
+        writer.writeNext(new String[] {
+            kmf.format(wqkm[2]),
+            wf.format(wqkm[0]),
+            qf.format(wqkm[1]),
+            RiverUtils.getLocationDescription(flys, wqkm[2])
+        });
     }
 
 
@@ -511,6 +617,38 @@
         });
     }
 
+    private String getDesc(WQKms wqkms, boolean isQ)
+    {
+        D4EArtifact flys = (D4EArtifact) master;
+        String colDesc = "";
+
+        if (flys instanceof WINFOArtifact && isQ) {
+            colDesc = getCSVRowTitle((WINFOArtifact)flys, wqkms);
+        }
+        else if (!isQ) {
+            Double value = RiverUtils.getValueFromWQ(wqkms);
+            colDesc = (value != null) ?
+                Formatter.getWaterlevelW(context).format(value) : null;
+        }
+
+        if (flys instanceof WINFOArtifact) {
+            if (wqkms != null && wqkms.getRawValue() != null) {
+                WINFOArtifact winfo = (WINFOArtifact) flys;
+                colDesc = RiverUtils.getNamedMainValue(winfo, wqkms.getRawValue());
+                // For 'W am Pegel' s
+                if (colDesc == null) {
+                    colDesc = ((D4EArtifact)master).getDataAsString("wq_single");
+                }
+            }
+        }
+        if (colDesc != null) {
+            /* Quick hack. Can be removed when database strings are
+             * adapted or left in here as it should never be harmful. */
+            colDesc = colDesc.replace("Amtl.Festlegung_", "Amtl. ");
+        }
+
+        return colDesc == null ? "" : colDesc;
+    }
 
     /**
      * Write "rows" of csv data from wqkms with writer.
@@ -543,35 +681,16 @@
         String       notinrange = msg(
             CSV_NOT_IN_GAUGE_RANGE,
             DEFAULT_CSV_NOT_IN_GAUGE_RANGE);
+        List<Segment> segments = null;
+        boolean isFixRealize = false;
 
         double a = gauge.getRange().getA().doubleValue();
         double b = gauge.getRange().getB().doubleValue();
-
-        if (flys instanceof WINFOArtifact && isQ) {
-            desc = getCSVRowTitle((WINFOArtifact)flys, wqkms);
-        }
-        else if (!isQ) {
-            Double value = RiverUtils.getValueFromWQ(wqkms);
-            desc         = value != null
-                ? Formatter.getWaterlevelW(context).format(value) : null;
-        }
-
         long startTime = System.currentTimeMillis();
 
-        String colDesc = desc;
-        List<Segment> segments = null;
-        boolean isFixRealize = false;
-        if (flys instanceof WINFOArtifact) {
-            if (wqkms != null && wqkms.getRawValue() != null) {
-                WINFOArtifact winfo = (WINFOArtifact) flys;
-                colDesc = RiverUtils.getNamedMainValue(winfo, wqkms.getRawValue());
-                // For 'W am Pegel' s
-                if (colDesc == null) {
-                    colDesc = ((D4EArtifact)master).getDataAsString("wq_single");
-                }
-            }
-        }
-        else if (flys instanceof FixationArtifact) {
+        desc = getDesc(wqkms, isQ);
+
+        if (flys instanceof FixationArtifact) {
             // Get W/Q input per gauge for this case.
             FixRealizingAccess fixAccess = new FixRealizingAccess(flys);
             segments = fixAccess.getSegments();
@@ -601,7 +720,7 @@
                         : findSegment(km, segments);
 
                     if (found != null) {
-                        colDesc = nf.format(found.getValues()[0]);
+                        desc = nf.format(found.getValues()[0]);
                     }
                     lastSegment = found;
                 }
@@ -622,7 +741,7 @@
                         ? gaugeName
                         : notinrange;
                 }
-                writeRow6(writer, result, colDesc, flys, gaugeN);
+                writeRow6(writer, result, desc, flys, gaugeN);
             }
         }
         else { // Not at gauge.
@@ -693,7 +812,7 @@
 
 
     /**
-     * This method is used to register a new column at <i>writer</i>. The name /
+     * Register a new column at <i>writer</i>. The name /
      * title of the column depends on the Q or W value of <i>wqkms</i>. If a Q
      * was selected and the Q fits to a named main value, the title is set to
      * the named main value. Otherwise, the name returned by
@@ -715,9 +834,6 @@
     }
 
 
-    /**
-     *
-     */
     @Override
     protected void writePDF(OutputStream out) {
         logger.debug("write PDF");
@@ -751,12 +867,38 @@
         boolean atGauge = mode == WQ_MODE.QGAUGE || mode == WQ_MODE.WGAUGE;
         boolean isQ     = mode == WQ_MODE.QGAUGE || mode == WQ_MODE.QFREE;
 
+        Double first = Double.NaN;
+        Double last = Double.NaN;
+
         addMetaData(source);
         for (WQKms[] tmp: data) {
             for (WQKms wqkms: tmp) {
                 addWKmsData(wqkms, atGauge, isQ, source);
+                double[] firstLast = wqkms.getFirstLastKM();
+                if (first.isNaN()) {
+                    /* Initialize */
+                    first = firstLast[0];
+                    last = firstLast[1];
+                }
+                if (firstLast[0] > firstLast[1]) {
+                    /* Calculating upstream we assert that it is
+                     * impossible that the direction changes during this
+                     * loop */
+                    first = Math.max(first, firstLast[0]);
+                    last = Math.min(last, firstLast[1]);
+                } else if (firstLast[0] < firstLast[1]) {
+                    first = Math.min(first, firstLast[0]);
+                    last = Math.max(last, firstLast[1]);
+                } else {
+                    first = last = firstLast[0];
+                }
             }
         }
+
+        /* Append the official fixing at the bottom */
+        for (WQKms wqkms: officalFixings) {
+            addWKmsData(filterWQKms(wqkms, first, last), atGauge, isQ, source);
+        }
         return source;
     }
 
@@ -815,15 +957,7 @@
         double a = gauge.getRange().getA().doubleValue();
         double b = gauge.getRange().getB().doubleValue();
 
-        if (flys instanceof WINFOArtifact && isQ) {
-            desc = getCSVRowTitle((WINFOArtifact)flys, wqkms);
-        }
-        else if (!isQ) {
-            Double value = RiverUtils.getValueFromWQ(wqkms);
-            desc         = value != null
-                ? Formatter.getWaterlevelW(context).format(value) : null;
-        }
-
+        desc = getDesc(wqkms, isQ);
         long startTime = System.currentTimeMillis();
 
         for (int i = 0; i < size; i ++) {
--- a/artifacts/src/main/java/org/dive4elements/river/exports/extreme/ExtremeWQCurveGenerator.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/extreme/ExtremeWQCurveGenerator.java	Mon Jul 22 13:03:42 2013 +0200
@@ -14,6 +14,7 @@
 import org.jfree.chart.JFreeChart;
 import org.jfree.chart.plot.Marker;
 import org.jfree.chart.plot.ValueMarker;
+import org.jfree.chart.plot.XYPlot;
 import org.jfree.chart.title.TextTitle;
 import org.jfree.data.xy.XYSeries;
 import org.w3c.dom.Document;
@@ -92,6 +93,16 @@
         return false;
     }
 
+    /** Overriden to show second axis also if no visible data present. */
+    @Override
+    protected void adjustAxes(XYPlot plot) {
+        super.adjustAxes(plot);
+        if (getCurrentGaugeDatum() != 0d) {
+            // Show the W[*m] axis even if there is no data.
+            plot.setRangeAxis(1, createYAxis(YAXIS.W.idx));
+        }
+    }
+
     /** Do Extreme Curve nonextrapolated points out. */
     protected void doExtremeCurveBaseOut(ArtifactAndFacet aaf, Document theme, boolean visible) {
         logger.debug("doExtremeCurveBaseOut");
--- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java	Mon Jul 22 13:03:42 2013 +0200
@@ -21,6 +21,7 @@
 import org.jfree.chart.axis.NumberAxis;
 import org.jfree.chart.plot.Marker;
 import org.jfree.chart.plot.ValueMarker;
+import org.jfree.chart.plot.XYPlot;
 import org.jfree.chart.title.TextTitle;
 import org.jfree.data.xy.XYSeries;
 import org.jfree.ui.RectangleAnchor;
@@ -153,15 +154,43 @@
         return axis;
     }
 
+    /** Returns value != 0 if the current km is not at a gauge. */
     public double getCurrentGaugeDatum() {
         if (context.getContextValue(CURRENT_KM) != null) {
             return DischargeCurveGenerator.getCurrentGaugeDatum(
                 (Double) context.getContextValue(CURRENT_KM),
-                (D4EArtifact) getMaster(), 0.1d);
+                (D4EArtifact) getMaster(), 1e-4);
         }
         else return 0d;
     }
 
+    /** Overriden to show second axis also if no visible data present. */
+    @Override
+    protected void adjustAxes(XYPlot plot) {
+        super.adjustAxes(plot);
+        if (getCurrentGaugeDatum() != 0d) {
+            // Show the W[*m] axis even if there is no data.
+            plot.setRangeAxis(1, createYAxis(YAXIS.W.idx));
+        }
+    }
+
+    /** Translate River annotations if not at gauge. */
+    public void translateRiverAnnotation(RiverAnnotation riverAnnotation) {
+        if (getCurrentGaugeDatum() == 0d) {
+            return;
+        }
+        logger.debug("Translate some river annotation.");
+        double translate = getCurrentGaugeDatum();
+        double factor    = 100d;
+        for (StickyAxisAnnotation annotation: riverAnnotation.getAxisTextAnnotations()){
+            if (!annotation.atX()) {
+                annotation.setPos((annotation.getPos() - translate)*factor);
+            }
+        }
+        for (XYTextAnnotation annotation: riverAnnotation.getTextAnnotations()) {
+            annotation.setY((annotation.getY() - translate)*factor);
+        }
+    }
 
     @Override
     public void doOut(ArtifactAndFacet aaf, Document doc, boolean visible) {
@@ -226,8 +255,10 @@
                     visible);
         }
         else if (name.equals(MAINVALUES_W) || name.equals(MAINVALUES_Q)) {
+            RiverAnnotation mainValues = (RiverAnnotation) aaf.getData(context);
+            translateRiverAnnotation(mainValues);
             doAnnotations(
-                ((RiverAnnotation) aaf.getData(context)),
+                mainValues,
                 aaf,
                 doc,
                 visible);
@@ -341,6 +372,17 @@
             if (Math.abs(kms[i] - ckm) <= EPSILON) {
                 series.add(wqkms.getQ(i), wqkms.getW(i));
                 addAxisSeries(series, YAXIS.W.idx, visible);
+                if(visible && ThemeUtil.parseShowPointLabel(theme)) {
+                    List<XYTextAnnotation> textAnnos = new ArrayList<XYTextAnnotation>();
+                    XYTextAnnotation anno = new CollisionFreeXYTextAnnotation(
+                            title,
+                            wqkms.getQ(i),
+                            wqkms.getW(i));
+                    textAnnos.add(anno);
+                    RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, theme);
+                    flysAnno.setTextAnnotations(textAnnos);
+                    addAnnotations(flysAnno);
+                }
                 return;
             }
         }
@@ -385,6 +427,14 @@
                 addAxisSeries(series, YAXIS.W.idx, visible);
             }
             else {
+                StyledXYSeries series2 = JFreeUtil.sampleFunction2D(
+                        func.getFunction(),
+                        doc,
+                        aaf.getFacetDescription(),
+                        500,   // number of samples
+                        0.0 ,  // start
+                        maxQ); // end
+                addAxisSeries(series2, YAXIS.W.idx, false);
                 // Use second axis at cm if at gauge.
                 for (int i = 0; i < series.getItemCount(); i++) {
                     series.updateByIndex(i, new Double(factor*(series.getY(i).doubleValue()-gaugeDatum)));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffBaseGenerator.java	Mon Jul 22 13:03:42 2013 +0200
@@ -0,0 +1,59 @@
+/* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.exports.minfo;
+
+import org.apache.log4j.Logger;
+
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.river.artifacts.model.minfo.BedDifferencesResult;
+import org.dive4elements.river.jfree.Bounds;
+import org.dive4elements.river.jfree.DoubleBounds;
+import org.dive4elements.river.exports.fixings.FixChartGenerator;
+
+/** Base for BedDiff*Year*Generators, to avoid duplicate code of setContextBounds. */
+public abstract class BedDiffBaseGenerator
+extends FixChartGenerator
+{
+    /** The logger that is used in this generator. */
+    private static Logger logger = Logger.getLogger(BedDiffBaseGenerator.class);
+
+    /** Set context values for something. */
+    public void setContextBounds(ArtifactAndFacet bundle) {
+        Bounds xBounds = getXBounds(0);
+        if (xBounds != null && getDomainAxisRange() != null) {
+            Bounds bounds =
+                calculateZoom(xBounds, getDomainAxisRange());
+            context.putContextValue("startkm", bounds.getLower());
+            context.putContextValue("endkm", bounds.getUpper());
+        }
+        else if (xBounds != null && getDomainAxisRange() == null) {
+            context.putContextValue("startkm", xBounds.getLower());
+            context.putContextValue("endkm", xBounds.getUpper());
+        }
+        else if (xBounds == null && getDomainAxisRange() == null) {
+            BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context);
+            if (data.getKms().size() > 0) {
+                context.putContextValue("startkm", data.getKms().min());
+                context.putContextValue("endkm", data.getKms().max());
+            }
+            else {
+                logger.warn("No data to define start and end km");
+            }
+        }
+        else if (xBounds == null && getDomainAxisRange() != null){
+            BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context);
+            Bounds b = new DoubleBounds(data.getKms().min(), data.getKms().max());
+            Bounds bounds =
+                calculateZoom(b, getDomainAxisRange());
+            context.putContextValue("startkm", bounds.getLower());
+            context.putContextValue("endkm", bounds.getUpper());
+        }
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.java	Mon Jul 22 13:03:42 2013 +0200
@@ -15,20 +15,16 @@
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
 import org.dive4elements.artifactdatabase.state.Facet;
 import org.dive4elements.river.artifacts.model.FacetTypes;
-import org.dive4elements.river.artifacts.model.minfo.BedDiffYearResult;
 import org.dive4elements.river.artifacts.model.minfo.BedDifferencesResult;
 import org.dive4elements.river.exports.StyledSeriesBuilder;
-import org.dive4elements.river.exports.fixings.FixChartGenerator;
+import org.dive4elements.river.exports.process.BedDiffHeightYearProcessor;
 import org.dive4elements.river.exports.process.KMIndexProcessor;
 import org.dive4elements.river.exports.process.Processor;
-import org.dive4elements.river.jfree.Bounds;
-import org.dive4elements.river.jfree.DoubleBounds;
 import org.dive4elements.river.jfree.RiverAnnotation;
-import org.dive4elements.river.jfree.StyledXYSeries;
 
 
 public class BedDiffHeightYearGenerator
-extends FixChartGenerator
+extends BedDiffBaseGenerator
 implements FacetTypes
 {
     public enum YAXIS {
@@ -91,42 +87,12 @@
         }
 
         if (bundle.getData(context) instanceof BedDifferencesResult) {
-            if (getXBounds(0) != null && getDomainAxisRange() != null) {
-                Bounds bounds =
-                    calculateZoom(getXBounds(0), getDomainAxisRange());
-                context.putContextValue("startkm", bounds.getLower());
-                context.putContextValue("endkm", bounds.getUpper());
-            }
-            else if (getXBounds(0) != null && getDomainAxisRange() == null) {
-                context.putContextValue("startkm", getXBounds(0).getLower());
-                context.putContextValue("endkm", getXBounds(0).getUpper());
-            }
-            else if (getXBounds(0) == null && getDomainAxisRange() == null) {
-                BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context);
-                context.putContextValue("startkm", data.getKms().min());
-                context.putContextValue("endkm", data.getKms().max());
-            }
-            else if (getXBounds(0) == null && getDomainAxisRange() != null){
-                BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context);
-                Bounds b = new DoubleBounds(data.getKms().min(), data.getKms().max());
-                Bounds bounds =
-                    calculateZoom(b, getDomainAxisRange());
-                context.putContextValue("startkm", bounds.getLower());
-                context.putContextValue("endkm", bounds.getUpper());
-            }
+            setContextBounds(bundle);
         }
+
         Processor processor = new KMIndexProcessor();
-        if (name.equals(BED_DIFFERENCE_HEIGHT_YEAR)) {
-            doBedDifferenceYearOut(
-                (BedDiffYearResult) bundle.getData(context),
-                bundle, attr, visible);
-        }
-        else if (name.equals(BED_DIFFERENCE_HEIGHT_YEAR_FILTERED)) {
-            doBedDifferenceYearOut(
-                (BedDiffYearResult) bundle.getData(context),
-                bundle, attr, visible);
-        }
-        else if (name.equals(LONGITUDINAL_ANNOTATION)) {
+        Processor bdyProcessor = new BedDiffHeightYearProcessor();
+        if (name.equals(LONGITUDINAL_ANNOTATION)) {
             doAnnotations(
                 (RiverAnnotation) bundle.getData(context),
                  bundle,
@@ -136,11 +102,15 @@
         else if (processor.canHandle(name)) {
             processor.doOut(this, bundle, attr, visible, YAXIS.dW.idx);
         }
+        else if (bdyProcessor.canHandle(name)) {
+            bdyProcessor.doOut(this, bundle, attr, visible, YAXIS.D.idx);
+        }
         else {
             logger.warn("Unknown facet name " + name);
         }
     }
 
+
     @Override
     protected String getDefaultChartTitle() {
         return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT);
@@ -163,13 +133,4 @@
         }
         return "default";
     }
-
-    protected void doBedDifferenceYearOut(BedDiffYearResult data,
-        ArtifactAndFacet aandf, Document theme, boolean visible) {
-
-        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
-        StyledSeriesBuilder.addPoints(series, data.getHeightPerYearData(), true);
-
-        addAxisSeries(series, YAXIS.D.idx, visible);
-    }
 }
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDifferenceYearGenerator.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDifferenceYearGenerator.java	Mon Jul 22 13:03:42 2013 +0200
@@ -22,11 +22,11 @@
 import org.dive4elements.river.artifacts.model.minfo.MorphologicWidth;
 import org.dive4elements.river.exports.StyledSeriesBuilder;
 import org.dive4elements.river.exports.fixings.FixChartGenerator;
+import org.dive4elements.river.exports.process.BedDiffYearProcessor;
+import org.dive4elements.river.exports.process.BedDiffHeightYearProcessor;
 import org.dive4elements.river.exports.process.KMIndexProcessor;
 import org.dive4elements.river.exports.process.Processor;
 import org.dive4elements.river.exports.process.WOutProcessor;
-import org.dive4elements.river.jfree.Bounds;
-import org.dive4elements.river.jfree.DoubleBounds;
 import org.dive4elements.river.jfree.RiverAnnotation;
 import org.dive4elements.river.jfree.StyledXYSeries;
 import org.dive4elements.river.utils.DataUtil;
@@ -34,11 +34,11 @@
 
 
 public class BedDifferenceYearGenerator
-extends FixChartGenerator
+extends BedDiffBaseGenerator
 implements FacetTypes
 {
     public enum YAXIS {
-        D(0), M(1), H(2),  dW(3), W(4);
+        D(0), M(1), H(2), dW(3), W(4);
 
         protected int idx;
 
@@ -86,6 +86,7 @@
         };
     }
 
+
     @Override
     public void doOut(ArtifactAndFacet bundle, Document attr, boolean visible) {
         String name = bundle.getFacetName();
@@ -103,66 +104,19 @@
             return;
         }
 
-        if (getXBounds(0) != null && getDomainAxisRange() != null) {
-            Bounds bounds =
-                calculateZoom(getXBounds(0), getDomainAxisRange());
-            context.putContextValue("startkm", bounds.getLower());
-            context.putContextValue("endkm", bounds.getUpper());
-        }
-        else if (getXBounds(0) != null && getDomainAxisRange() == null) {
-            context.putContextValue("startkm", getXBounds(0).getLower());
-            context.putContextValue("endkm", getXBounds(0).getUpper());
+        if (bundle.getData(context) instanceof BedDifferencesResult) {
+            setContextBounds(bundle);
         }
-        else if (getXBounds(0) == null && getDomainAxisRange() == null) {
-            BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context);
-            context.putContextValue("startkm", data.getKms().min());
-            context.putContextValue("endkm", data.getKms().max());
-        }
-        else if (getXBounds(0) == null && getDomainAxisRange() != null){
-            BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context);
-            Bounds b = new DoubleBounds(data.getKms().min(), data.getKms().max());
-            Bounds bounds =
-                calculateZoom(b, getDomainAxisRange());
-            context.putContextValue("startkm", bounds.getLower());
-            context.putContextValue("endkm", bounds.getUpper());
-        }
+
         Processor processor = new KMIndexProcessor();
         Processor woutp = new WOutProcessor();
-        if (name.equals(BED_DIFFERENCE_YEAR)) {
-            doBedDifferenceYearOut(
-                (BedDiffYearResult) bundle.getData(context),
-                bundle, attr, visible);
-        }
-        else if (name.equals(BED_DIFFERENCE_MORPH_WIDTH)) {
+        Processor bdhyProcessor = new BedDiffHeightYearProcessor();
+        Processor bdyProcessor = new BedDiffYearProcessor();
+        if (name.equals(BED_DIFFERENCE_MORPH_WIDTH)) {
             doBedDifferenceMorphWidthOut(
                 (BedDiffYearResult) bundle.getData(context),
                 bundle, attr, visible);
         }
-        else if (name.equals(BED_DIFFERENCE_YEAR_HEIGHT1)) {
-            doBedDifferenceHeightsOut(
-                (BedDiffYearResult)bundle.getData(context),
-                bundle, attr, visible, 0);
-        }
-        else if (name.equals(BED_DIFFERENCE_YEAR_HEIGHT2)) {
-            doBedDifferenceHeightsOut(
-                (BedDiffYearResult)bundle.getData(context),
-                bundle, attr, visible, 1);
-        }
-        else if (name.equals(BED_DIFFERENCE_YEAR_FILTERED)) {
-            doBedDifferenceYearOut(
-                (BedDiffYearResult) bundle.getData(context),
-                bundle, attr, visible);
-        }
-        else if (name.equals(BED_DIFFERENCE_YEAR_HEIGHT1_FILTERED)) {
-            doBedDifferenceHeightsOut(
-                (BedDiffYearResult)bundle.getData(context),
-                bundle, attr, visible, 0);
-        }
-        else if (name.equals(BED_DIFFERENCE_YEAR_HEIGHT2_FILTERED)) {
-            doBedDifferenceHeightsOut(
-                (BedDiffYearResult)bundle.getData(context),
-                bundle, attr, visible, 1);
-        }
         else if (name.equals(MORPHOLOGIC_WIDTH)) {
             doMorphologicWidthOut(
                 (MorphologicWidth)bundle.getData(context),
@@ -181,6 +135,12 @@
                  attr,
                  visible);
         }
+        else if (bdyProcessor.canHandle(name)) {
+            bdyProcessor.doOut(this, bundle, attr, visible, YAXIS.H.idx);
+        }
+        else if (bdhyProcessor.canHandle(name)) {
+            bdhyProcessor.doOut(this, bundle, attr, visible, YAXIS.D.idx);
+        }
         else if (woutp.canHandle(name)) {
             woutp.doOut(this, bundle, attr, visible, YAXIS.W.idx);
         }
@@ -208,24 +168,6 @@
         addAxisSeries(series, YAXIS.M.idx, visible);
     }
 
-    private void doBedDifferenceHeightsOut(
-        BedDiffYearResult data,
-        ArtifactAndFacet bundle,
-        Document attr,
-        boolean visible,
-        int idx) {
-         logger.debug("doBedDifferenceYearOut()");
-
-        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), attr);
-        if (idx == 0) {
-            StyledSeriesBuilder.addPoints(series, data.getHeights1Data(), true);
-        }
-        else {
-            StyledSeriesBuilder.addPoints(series, data.getHeights2Data(), true);
-        }
-
-        addAxisSeries(series, YAXIS.H.idx, visible);
-    }
 
     @Override
     protected String getDefaultChartTitle() {
@@ -267,15 +209,6 @@
         return label;
     }
 
-    protected void doBedDifferenceYearOut(BedDiffYearResult data,
-        ArtifactAndFacet aandf, Document theme, boolean visible) {
-        logger.debug("doBedDifferenceYearOut()");
-
-        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
-        StyledSeriesBuilder.addPoints(series, data.getDifferencesData(), true);
-
-        addAxisSeries(series, YAXIS.D.idx, visible);
-    }
 
     protected void doBedDifferenceMorphWidthOut(BedDiffYearResult data,
         ArtifactAndFacet aandf, Document theme, boolean visible) {
@@ -307,3 +240,4 @@
         }
     }
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadLSGenerator.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadLSGenerator.java	Mon Jul 22 13:03:42 2013 +0200
@@ -73,8 +73,6 @@
     public static final String I18N_YAXIS_D_LABEL_DEFAULT = "delta S [m]";
     public static final String I18N_YAXIS_V_LABEL_DEFAULT = "Geschwindigkeit v [m/s]";
 
-    private String yLabel = "";
-
     @Override
     protected YAxisWalker getYAxisWalker() {
         return new YAxisWalker() {
@@ -106,14 +104,6 @@
         Facet facet = bundle.getFacet();
         D4EArtifact artifact = (D4EArtifact)bundle.getArtifact();
 
-        SedimentLoadAccess slaccess = new SedimentLoadAccess(artifact);
-        String unit = slaccess.getUnit();
-        if (unit != null && unit.equals("m3_per_a")) {
-            yLabel = msg(I18N_YAXIS_LABEL_2, I18N_YAXIS_LABEL_DEFAULT_2);
-        }
-        else {
-            yLabel = msg(I18N_YAXIS_LABEL_1, I18N_YAXIS_LABEL_DEFAULT_1);
-        }
         if (facet == null) {
             return;
         }
@@ -242,7 +232,15 @@
     protected String getDefaultYAxisLabel(int pos) {
         String label = "default";
         if (pos == YAXIS.L.idx) {
-            label = yLabel;
+            SedimentLoadAccess slaccess =
+                new SedimentLoadAccess((D4EArtifact) getMaster());
+            String unit = slaccess.getUnit();
+            if (unit != null && unit.equals("m3_per_a")) {
+                label = msg(I18N_YAXIS_LABEL_2, I18N_YAXIS_LABEL_DEFAULT_2);
+            }
+            else {
+                label = msg(I18N_YAXIS_LABEL_1, I18N_YAXIS_LABEL_DEFAULT_1);
+            }
         }
         else if (pos == YAXIS.V.idx) {
             label = msg(I18N_YAXIS_V_LABEL, I18N_YAXIS_V_LABEL_DEFAULT);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffHeightYearProcessor.java	Mon Jul 22 13:03:42 2013 +0200
@@ -0,0 +1,70 @@
+/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.exports.process;
+
+import org.apache.log4j.Logger;
+import org.jfree.data.xy.XYSeries;
+import org.w3c.dom.Document;
+
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.artifacts.model.minfo.BedDiffYearResult;
+import org.dive4elements.river.exports.StyledSeriesBuilder;
+import org.dive4elements.river.exports.XYChartGenerator;
+import org.dive4elements.river.jfree.StyledXYSeries;
+
+
+public class BedDiffHeightYearProcessor implements Processor, FacetTypes {
+
+    private final static Logger logger =
+            Logger.getLogger(BedDiffHeightYearProcessor.class);
+
+    @Override
+    public void doOut(
+            XYChartGenerator generator,
+            ArtifactAndFacet aandf,
+            Document theme,
+            boolean visible,
+            int index
+    ) {
+        CallContext context = generator.getCallContext();
+        Object data = aandf.getData(context);
+        if (data instanceof BedDiffYearResult) {
+            doBedDifferenceYearOut(
+               generator,
+               (BedDiffYearResult) data,
+               aandf, theme, visible, index);
+            return;
+        }
+        logger.error("Can't process " + data.getClass().getName() + " objects");
+    }
+
+    @Override
+    public boolean canHandle(String facetType) {
+        return BED_DIFFERENCE_HEIGHT_YEAR.equals(facetType) // from BedDiffYearHeight
+            || BED_DIFFERENCE_HEIGHT_YEAR_FILTERED.equals(facetType) // from BedDiffYearHeight
+            || BED_DIFFERENCE_YEAR.equals(facetType) // from BedDifferencesYear
+            || BED_DIFFERENCE_YEAR_FILTERED.equals(facetType); // from BedDifferencesYear
+    }
+
+    protected void doBedDifferenceYearOut(XYChartGenerator generator,
+        BedDiffYearResult data,
+        ArtifactAndFacet aandf,
+        Document theme,
+        boolean visible,
+        int axidx) {
+
+        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
+        StyledSeriesBuilder.addPoints(series, data.getHeightPerYearData(), true);
+
+        generator.addAxisSeries(series, axidx, visible);
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java	Mon Jul 22 13:03:42 2013 +0200
@@ -0,0 +1,83 @@
+/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.exports.process;
+
+import org.apache.log4j.Logger;
+import org.jfree.data.xy.XYSeries;
+import org.w3c.dom.Document;
+
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.artifacts.model.minfo.BedDiffYearResult;
+import org.dive4elements.river.exports.StyledSeriesBuilder;
+import org.dive4elements.river.exports.XYChartGenerator;
+import org.dive4elements.river.jfree.StyledXYSeries;
+
+
+public class BedDiffYearProcessor implements Processor, FacetTypes {
+
+    private final static Logger logger =
+            Logger.getLogger(BedDiffYearProcessor.class);
+
+    @Override
+    public void doOut(
+            XYChartGenerator generator,
+            ArtifactAndFacet aandf,
+            Document theme,
+            boolean visible,
+            int axidx
+    ) {
+        CallContext context = generator.getCallContext();
+        Object data = aandf.getData(context);
+        if (data instanceof BedDiffYearResult) {
+            String facetType = aandf.getFacetName();
+            int index = 
+               (BED_DIFFERENCE_YEAR_HEIGHT1.equals(facetType)
+               || BED_DIFFERENCE_YEAR_HEIGHT1_FILTERED.equals(facetType))?0:1;
+            doBedDifferenceHeightsOut(
+               generator,
+               (BedDiffYearResult) data,
+               aandf, theme, visible, index, axidx);
+            return;
+        }
+        logger.error("Can't process " + data.getClass().getName() + " objects");
+    }
+
+    @Override
+    public boolean canHandle(String facetType) {
+        return
+               BED_DIFFERENCE_YEAR_HEIGHT1.equals(facetType)
+            || BED_DIFFERENCE_YEAR_HEIGHT2.equals(facetType)
+            || BED_DIFFERENCE_YEAR_HEIGHT1_FILTERED.equals(facetType)
+            || BED_DIFFERENCE_YEAR_HEIGHT2_FILTERED.equals(facetType);
+    }
+
+    private void doBedDifferenceHeightsOut(
+        XYChartGenerator generator,
+        BedDiffYearResult data,
+        ArtifactAndFacet bundle,
+        Document attr,
+        boolean visible,
+        int idx,
+        int axidx) {
+         logger.debug("doBedDifferenceHeightsOut()");
+
+        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), attr);
+        if (idx == 0) {
+            StyledSeriesBuilder.addPoints(series, data.getHeights1Data(), true);
+        }
+        else {
+            StyledSeriesBuilder.addPoints(series, data.getHeights2Data(), true);
+        }
+
+        generator.addAxisSeries(series, axidx, visible);
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/KMIndexProcessor.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/KMIndexProcessor.java	Mon Jul 22 13:03:42 2013 +0200
@@ -148,3 +148,4 @@
         generator.addAxisDataset(col, idx, visible);
     }
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/utils/RiverUtils.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/utils/RiverUtils.java	Mon Jul 22 13:03:42 2013 +0200
@@ -178,7 +178,7 @@
 
 
     /**
-     * This method returns an WQ_MODE enum which is based on the parameters
+     * Returns an WQ_MODE enum which is based on the parameters
      * stored in <i>flys</i> Artifact. If there is no <i>wq_isq</i> parameter
      * existing, WQ_MODE.NONE is returned.
      *
@@ -340,7 +340,7 @@
             return ((WINFOArtifact) flys).getQs();
         }
 
-        logger.warn("This method currently supports WINFOArtifact only!");
+        logger.warn("This method (getQs) currently supports WINFOArtifact only!");
 
         return null;
     }
@@ -360,7 +360,7 @@
             return ((WINFOArtifact) flys).getWs();
         }
 
-        logger.warn("This method currently supports WINFOArtifact only!");
+        logger.warn("This method (getWs) currently supports WINFOArtifact only!");
 
         return null;
     }
@@ -697,7 +697,7 @@
 
 
     /**
-     * This method returns the description for a given <i>km</i> for a specific
+     * Returns the description for a given <i>km</i> for a specific
      * river. The river is provided by the D4EArtifact <i>flys</i>.
      *
      * @param flys The D4EArtifact that provides a river.
@@ -718,7 +718,7 @@
 
 
     /**
-     * This method returns the differences for a w-differences calculation.
+     * Returns the differences for a w-differences calculation.
      *
      * @param winfo The WINFOArtifact.
      * @param context The context.
@@ -806,7 +806,7 @@
 
 
     /**
-     * This method transform a string into an int array. Therefore, the string
+     * Transform a string into an int array. Therefore, the string
      * <i>raw</i> must consist of int values separated by a <i>';'</i>.
      *
      * @param raw The raw integer array as string separated by a ';'.
@@ -837,7 +837,7 @@
 
 
     /**
-     * This method transform a string into a long array. Therefore, the string
+     * Transform a string into a long array. Therefore, the string
      * <i>raw</i> must consist of int values separated by a <i>';'</i>.
      *
      * @param raw The raw long array as string separated by a ';'.
@@ -868,7 +868,7 @@
 
 
     /**
-     * This method transform a string into an double array. Therefore, the
+     * Transform a string into an double array. Therefore, the
      * string <i>raw</i> must consist of double values separated by a
      * <i>';'</i>.
      *
--- a/artifacts/src/main/resources/messages.properties	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/resources/messages.properties	Mon Jul 22 13:03:42 2013 +0200
@@ -436,7 +436,7 @@
 wsplgen.job.queued = WSPLGEN job in queue.
 wsplgen.job.error = An unexpected error while starting WSPLGEN occured.
 
-official.line.found = Found official line for {0}.
+official.line.found = Found official line for {0} from year {1,date,yyyy} from {2}.
 
 wsp.selected.string = {0}
 
--- a/artifacts/src/main/resources/messages_de.properties	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Mon Jul 22 13:03:42 2013 +0200
@@ -330,7 +330,7 @@
 export.waterlevel.csv.meta.gauge = # Bezugspegel: {0}
 export.waterlevel.csv.meta.q = # Q (m\u00b3/s): {0}
 export.waterlevel.csv.meta.w = # W (NN + m): {0} - {1}
-export.waterlevel.csv.not.in.gauge.range = au\u00dferhalb gew\u00e4hlter Bezugspegels
+export.waterlevel.csv.not.in.gauge.range = au\u00dferh. d. Bez.pegels
 export.computed.discharge.curve.csv.header.w = W [{0}]
 export.computed.discharge.curve.csv.header.q = Q [m\u00b3/s]
 export.duration.curve.csv.header.duration = D [Tagen]
@@ -436,7 +436,7 @@
 wsplgen.job.queued = WSPLGEN Berechnung befindet sich in Warteschlange.
 wsplgen.job.error = Ein unerwarteter Fehler beim Starten von WSPLGEN ist aufgetreten.
 
-official.line.found = Es existiert eine amtliche Festlegung f\u00fcr {0}.
+official.line.found = F\u00fcr {0} existiert eine amtlich festgelegte Wasserspiegellage aus dem Jahr {1,date,yyyy} von {2}.
 
 wsp.selected.string = {0}
 
--- a/artifacts/src/main/resources/messages_de_DE.properties	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/resources/messages_de_DE.properties	Mon Jul 22 13:03:42 2013 +0200
@@ -328,7 +328,7 @@
 export.waterlevel.csv.meta.gauge = # Bezugspegel: {0}
 export.waterlevel.csv.meta.q = # Q (m\u00b3/s): {0}
 export.waterlevel.csv.meta.w = # W (NN + m): {0} - {1}
-export.waterlevel.csv.not.in.gauge.range = au\u00dferhalb gew\u00e4hlter Bezugspegels
+export.waterlevel.csv.not.in.gauge.range = au\u00dferh. d. Bez.pegels
 export.computed.discharge.curve.csv.header.w = W [{0}]
 export.computed.discharge.curve.csv.header.q = Q [m\u00b3/s]
 export.duration.curve.csv.header.duration = D [Tagen]
@@ -433,7 +433,7 @@
 wsplgen.job.queued = WSPLGEN Berechnung befindet sich in Warteschlange.
 wsplgen.job.error = Ein unerwarteter Fehler beim Starten von WSPLGEN ist aufgetreten.
 
-official.line.found = Es existiert eine amtliche Festlegung f\u00fcr {0}.
+official.line.found = F\u00fcr {0} existiert eine amtlich festgelegte Wasserspiegellage aus dem Jahr {1,date,yyyy} von {2}.
 
 wsp.selected.string = {0}
 
--- a/artifacts/src/main/resources/messages_en.properties	Fri Jun 28 19:32:43 2013 +0200
+++ b/artifacts/src/main/resources/messages_en.properties	Mon Jul 22 13:03:42 2013 +0200
@@ -438,7 +438,7 @@
 wsplgen.job.queued = WSPLGEN job in queue.
 wsplgen.job.error = An unexpected error while starting WSPLGEN occured.
 
-official.line.found = Found official line for {0}.
+official.line.found = Found official line for {0} from year {1,date,yyyy} from {2}.
 
 wsp.selected.string = {0}
 
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/W80CSVParser.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/W80CSVParser.java	Mon Jul 22 13:03:42 2013 +0200
@@ -192,8 +192,9 @@
 
     /**
      * Add a Point (YZ,Index) to the current cross section line.
-     * @param y The y coordinate of new point.
-     * @param z The z coordinate of new point.
+     * @param y The y coordinate of new point in GK.
+     * @param z The z coordinate of new point in GK.
+     * @param height The hight (3rd coord) of point, in meter.
      * @param idx Ignored, the parameter of new point.
      * @return true if point could been added, false otherwise (e.g. not
      *         parsable y or z values.
--- a/backend/src/main/java/org/dive4elements/river/model/CrossSection.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/CrossSection.java	Mon Jul 22 13:03:42 2013 +0200
@@ -38,11 +38,16 @@
 
 import org.dive4elements.river.backend.SessionHolder;
 
+import org.apache.log4j.Logger;
+
 @Entity
 @Table(name = "cross_sections")
 public class CrossSection
 implements   Serializable
 {
+    private static Logger logger =
+        Logger.getLogger(CrossSection.class);
+
     public static final MathContext PRECISION = new MathContext(6);
 
     public static final String SQL_FAST_CROSS_SECTION_LINES =
@@ -53,6 +58,20 @@
         "km between :from_km AND :to_km " +
         "ORDER BY csl.km, csl.id, csp.col_pos";
 
+    public static final String SQL_MIN_MAX =
+        "SELECT * FROM ( "+
+            "SELECT cross_section_id, MIN(km) AS minkm, MAX(km) AS maxkm " +
+            "FROM cross_section_lines " +
+            "WHERE cross_section_id IN " +
+            " (SELECT id FROM cross_sections WHERE river_id = :river_id) " +
+            "  GROUP BY cross_section_id" +
+        ") cs_ranges " +
+        "JOIN cross_sections cs ON cs_ranges.cross_section_id = cs.id " +
+        "LEFT OUTER JOIN time_intervals ON cs.time_interval_id = time_intervals.id " +
+        "WHERE :km BETWEEN minkm AND maxkm " +
+        "ORDER BY stop_time desc, start_time asc, :km - minkm";
+    // Order by time interval missing.
+
     private Integer                id;
     private River                  river;
     private TimeInterval           timeInterval;
@@ -203,5 +222,31 @@
 
         return lines;
     }
+
+    /**
+     * True if the given section is the "newest" for that river and has values at km.
+     * @param km Given station.
+     * @return true if the section has the most advanced end of its validity interval
+     *         or the most advanced start of its validity interval.
+     */
+    public boolean shouldBeMaster(double km) {
+        Session session = SessionHolder.HOLDER.get();
+
+        SQLQuery sqlQuery = session.createSQLQuery(SQL_MIN_MAX)
+            .addScalar("cross_section_id", StandardBasicTypes.INTEGER);
+
+        sqlQuery
+            .setInteger("river_id", getRiver().getId())
+            .setDouble("km", km);
+
+        List<Integer> results = sqlQuery.list();
+
+        for (Integer result: results) {
+            if (result == getId()) {
+                return true;
+            }
+        }
+        return false;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/backend/src/main/java/org/dive4elements/river/model/Wst.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/Wst.java	Mon Jul 22 13:03:42 2013 +0200
@@ -33,6 +33,7 @@
 import org.dive4elements.river.backend.SessionHolder;
 
 
+/** DB-mapped WST. */
 @Entity
 @Table(name = "wsts")
 public class Wst
--- a/contrib/make_flys_release/make_release.sh	Fri Jun 28 19:32:43 2013 +0200
+++ b/contrib/make_flys_release/make_release.sh	Mon Jul 22 13:03:42 2013 +0200
@@ -367,6 +367,11 @@
 mv $WORK_DIR/datacagedb $WORK_DIR/server/
 
 echo "INFO: create tarball"
+if [ -d "$WORK_DIR/flys-$VERSION" ]; then
+    echo "INFO: removing old directory"
+    rm -rf "$WORK_DIR/flys-$VERSION"
+fi
+
 mkdir $WORK_DIR/flys-$VERSION
 mv $WORK_DIR/server $WORK_DIR/client $WORK_DIR/flys-$VERSION
 cd $WORK_DIR
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java	Mon Jul 22 13:03:42 2013 +0200
@@ -822,6 +822,12 @@
 
     String waterlevels();
 
+    String beddifferences();
+
+    String bedheight_differences();
+
+    String vollmer_waterlevels();
+
     String old_calculations();
 
     String officiallines();
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties	Mon Jul 22 13:03:42 2013 +0200
@@ -422,6 +422,9 @@
 
 # data cage
 waterlevels = Waterlevels
+beddifferences = Bedheight Differences
+bedheight_differences = Bedheight Differences
+vollmer_waterlevels = Vollmer Waterlevels
 old_calculations = Former Calculations
 officiallines = Official lines
 datacageAdd = Add data
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties	Mon Jul 22 13:03:42 2013 +0200
@@ -426,6 +426,9 @@
 
 # data cage
 waterlevels = Wasserst\u00e4nde
+beddifferences = Sohlh\u00f6hendifferenzen
+bedheight_differences = Sohlh\u00f6hendifferenzen
+vollmer_waterlevels = Ausgelagerte WSPL.
 old_calculations = Fr\u00fchere Berechnungen
 officiallines = Amtliche Linien
 datacageAdd = Daten laden
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_en.properties	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_en.properties	Mon Jul 22 13:03:42 2013 +0200
@@ -424,6 +424,9 @@
 
 # data cage
 waterlevels = Waterlevels
+beddifferences = Bedheight Differences
+bedheight_differences = Bedheight Differences
+vollmer_waterlevels = Vollmer Waterlevels
 old_calculations = Former Calculations
 officiallines = Official lines
 datacageAdd = Add data
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/CollectionView.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/CollectionView.java	Mon Jul 22 13:03:42 2013 +0200
@@ -393,7 +393,8 @@
     }
 
     /**
-     * Loads all information of a collection
+     * Loads all information of a collection.
+     * If 'recommendations' present, load these.
      * @param c the Collection
      */
     private void loadCollection(Collection c) {
@@ -641,7 +642,7 @@
             );
         }
         else {
-            // Create new collection and add artifact
+            // Create new collection and add artifact.
             final Artifact art = artifact;
             createCollectionService.create(
                 locale,
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DatacageTwinPanel.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DatacageTwinPanel.java	Mon Jul 22 13:03:42 2013 +0200
@@ -175,7 +175,7 @@
         VLayout layout       = new VLayout();
         HLayout helperLayout = new HLayout();
         helperLayout.addMember(new DatacagePairWidget(this.artifact,
-            user, "waterlevels", differencesList));
+            user, "differenceable", differencesList));
 
         layout.addMember(widget);
         layout.addMember(submit);
@@ -277,6 +277,29 @@
         this.removedPairs.add(pr);
     }
 
+    /**
+     * Set factory of recommendation such that the correct artifacts will
+     * be cloned for difference calculations.
+     */
+    public void adjustRecommendation(Recommendation recommendation) {
+        if (recommendation.getIDs() != null) {
+            GWT.log("Setting staticwkms factory for rec with ID "
+                + recommendation.getIDs());
+            recommendation.setFactory("staticwkms");
+        }
+        /*
+        // So far, we do not need to rewrite the factory anymore,
+        // except for staticwkms; probably other cases will pop up later.
+        else if (recommendation.getFactory().equals("winfo")) {
+            GWT.log("Setting waterlevel factory for a winfo rec.");
+            recommendation.setFactory("waterlevel");
+        }
+        */
+        else {
+           GWT.log("Leave rec. id " + recommendation.getIDs() + ", factory "
+               + recommendation.getFactory() + " untouched.");
+        }
+    }
 
     /**
      * Validates data, does nothing if invalid, otherwise clones new selected
@@ -308,29 +331,10 @@
                 // Check whether one of those is a dike or similar.
                 // TODO differentiate and merge: new clones, new, old.
                 Recommendation firstR = r.getFirst();
-                if(firstR.getIDs() != null) {
-                    GWT.log("First IDs: " + firstR.getIDs() + " factory: "
-                            + firstR.getFactory());
-                }
-                if(firstR.getIDs() != null) {
-                    // These do not get cloned but loaded ("spawned").
-                    firstR.setFactory("staticwkms");
-                }
-                else {
-                    firstR.setFactory("waterlevel");
-                }
+                adjustRecommendation(firstR);
+
                 Recommendation secondR = r.getSecond();
-                if(secondR.getIDs() != null) {
-                    GWT.log("Second IDs: " + secondR.getIDs() + " factory: "
-                            + secondR.getFactory());
-                }
-                if (secondR.getIDs() != null) {
-                    // These do not get cloned but loaded ("spawned").
-                    secondR.setFactory("staticwkms");
-                }
-                else {
-                    secondR.setFactory("waterlevel");
-                }
+                adjustRecommendation(secondR);
 
                 ar.add(firstR);
                 ar.add(secondR);
@@ -389,6 +393,7 @@
         }
 
         // Clone new ones (and spawn statics), go forward.
+        parameterList.lockUI();
         loadArtifactService.loadMany(
             this.collection,
             toClone,
@@ -399,6 +404,7 @@
                 @Override
                 public void onFailure(Throwable caught) {
                     GWT.log("Failure of cloning with factories!");
+                    parameterList.unlockUI();
                 }
                 @Override
                 public void onSuccess(Artifact[] artifacts) {
@@ -407,6 +413,7 @@
 
                     fireStepForwardEvent(new StepForwardEvent(
                         getData(toClone, artifacts, toUse)));
+                    parameterList.unlockUI();
                 }
             });
     }
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/FLYSHeader.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/FLYSHeader.java	Mon Jul 22 13:03:42 2013 +0200
@@ -12,6 +12,7 @@
 import com.google.gwt.i18n.client.LocaleInfo;
 import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.HTML;
 import com.smartgwt.client.types.Alignment;
 import com.smartgwt.client.types.VerticalAlignment;
 import com.smartgwt.client.util.BooleanCallback;
@@ -135,14 +136,30 @@
         info.addClickHandler(new ClickHandler() {
             @Override
             public void onClick(ClickEvent event) {
-                GWT.log("Clicked 'info' button.");
                 String wikiLink = Config.getInstance().getWikiUrl() + "/Info";
-                Window.open(wikiLink, "_blank", null);
+
+                // Create a form which contains the SAML session
+                // for the user which is currently logged in
+                String html = WikiLinks.imageLinkForm(
+                        getFlys(), wikiLink, "", "wikiLinkForm");
+                HTML htmlObj = new HTML(html);
+                info.addChild(htmlObj);
+                fireWikiLinkSubmit();
+                htmlObj.removeFromParent();
             }
         });
         init();
     }
 
+    /**
+     * Calls the JS submit() function on the dynamically added
+     * wikiLinkForm. This is a workaround for a SmartGWT issue(?) that
+     * clears all form fields when using DynamicForm.submit() or .submitForm().
+     */
+    protected native void fireWikiLinkSubmit() /*-{
+        $doc.wikiLinkForm.submit();
+    }-*/;
+
     public void init() {
         setStyleName("header");
         setWidth100();
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ImgLink.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ImgLink.java	Mon Jul 22 13:03:42 2013 +0200
@@ -12,6 +12,7 @@
 import com.smartgwt.client.widgets.HTMLPane;
 
 
+/** An image wrapped in a clickable link. */
 public class ImgLink extends HTMLPane {
 
     protected int width;
@@ -59,3 +60,4 @@
         update();
     }
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/MultiPeriodPanel.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/MultiPeriodPanel.java	Mon Jul 22 13:03:42 2013 +0200
@@ -36,7 +36,7 @@
 import java.util.List;
 
 /**
- * This UIProvider creates a panel for location or distance input.
+ * This UIProvider creates a panel for input of multiple time periods.
  *
  * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
  */
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterList.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterList.java	Mon Jul 22 13:03:42 2013 +0200
@@ -83,7 +83,7 @@
 
     public static final String STYLENAME_OLD_PARAMETERS = "oldParameters";
 
-    /** The message class that provides i18n strings.*/
+    /** The message class that provides i18n strings. */
     protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
 
     /** The ArtifactService used to communicate with the Artifact server. */
@@ -103,7 +103,7 @@
         GWT.create(ReportService.class);
 
 
-    /** The list of ParameterizationChangeHandler.*/
+    /** The list of ParameterizationChangeHandler. */
     protected List<ParameterChangeHandler> parameterHandlers;
 
     protected FLYS flys;
@@ -568,7 +568,7 @@
 
 
     /**
-     * This method refreshes the part displaying the data of the current state.
+     * Refreshes the part displaying the data of the current state.
      * The UI is created using the UIProvider stored in the Data object.
      */
     public void refreshCurrent() {
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/QSegmentedInputPanel.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/QSegmentedInputPanel.java	Mon Jul 22 13:03:42 2013 +0200
@@ -428,14 +428,14 @@
             new AsyncCallback<WQInfoObject[]>() {
                 @Override
                 public void onFailure(Throwable caught) {
-                    GWT.log("Could not recieve wq informations.");
+                    GWT.log("Could not receive wq informations.");
                     SC.warn(caught.getMessage());
                 }
 
                 @Override
                 public void onSuccess(WQInfoObject[] wqi) {
                     int num = wqi != null ? wqi.length :0;
-                    GWT.log("Recieved " + num + " wq informations.");
+                    GWT.log("Received " + num + " wq informations.");
 
                     if (num == 0) {
                         return;
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java	Mon Jul 22 13:03:42 2013 +0200
@@ -99,7 +99,7 @@
             MSG.gauge_river_url() + number :
             MSG.gauge_river_url();
         String wikiBaseUrl = Config.getInstance().getWikiUrl();
-        DynamicForm infoLink = WikiLinks.linkHTML(this.flys, wikiBaseUrl + url,
+        DynamicForm infoLink = WikiLinks.linkDynamicForm(this.flys, wikiBaseUrl + url,
                                         MSG.gauge_river_info_link());
         infoLink.setTop(5);
         LinkItem item = (LinkItem)infoLink.getField("saml");
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WQInputPanel.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WQInputPanel.java	Mon Jul 22 13:03:42 2013 +0200
@@ -1811,14 +1811,14 @@
             new AsyncCallback<WQInfoObject[]>() {
                 @Override
                 public void onFailure(Throwable caught) {
-                    GWT.log("Could not recieve wq informations.");
+                    GWT.log("Could not receive wq informations.");
                     SC.warn(caught.getMessage());
                 }
 
                 @Override
                 public void onSuccess(WQInfoObject[] wqi) {
                     int num = wqi != null ? wqi.length :0;
-                    GWT.log("Recieved " + num + " wq informations.");
+                    GWT.log("Received " + num + " wq informations.");
 
                     if (num == 0) {
                         return;
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WQSimpleArrayPanel.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WQSimpleArrayPanel.java	Mon Jul 22 13:03:42 2013 +0200
@@ -265,13 +265,13 @@
             new AsyncCallback<WQInfoObject[]>() {
                 @Override
                 public void onFailure(Throwable caught) {
-                    GWT.log("Could not recieve wq informations.");
+                    GWT.log("Could not receive wq informations.");
                 }
 
                 @Override
                 public void onSuccess(WQInfoObject[] wqi) {
                     int num = wqi != null ? wqi.length :0;
-                    GWT.log("Recieved " + num + " wq informations.");
+                    GWT.log("Received " + num + " wq informations.");
 
                     if (num == 0) {
                         return;
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiImgLink.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiImgLink.java	Mon Jul 22 13:03:42 2013 +0200
@@ -24,7 +24,7 @@
 
     @Override
     protected void update() {
-        setContents(WikiLinks.imageLinkHTML(instance, href, imgUrl));
+        setContents(WikiLinks.imageLinkForm(instance, href, imgUrl, "wikiImgLink" + toString()));
         setWidth(width);
         setHeight(height);
         setOverflow(Overflow.VISIBLE);
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java	Mon Jul 22 13:03:42 2013 +0200
@@ -8,20 +8,21 @@
 
 package org.dive4elements.river.client.client.ui;
 
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.safehtml.shared.SafeHtmlUtils;
 import com.smartgwt.client.types.FormMethod;
 import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.HiddenItem;
 import com.smartgwt.client.widgets.form.fields.LinkItem;
 import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
 import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
-import com.smartgwt.client.widgets.grid.CellFormatter;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.google.gwt.safehtml.shared.SafeHtmlUtils;
 
 import org.dive4elements.river.client.client.FLYS;
+import org.dive4elements.river.client.shared.model.User;
 
 public class WikiLinks
 {
-    public static String imageLinkHTML(FLYS instance, String url, String imageUrl) {
+    public static String imageLinkForm(FLYS instance, String url, String imageUrl, String formName) {
         String saml = null;
         if (instance != null && instance.getCurrentUser() != null) {
             saml = instance.getCurrentUser().getSamlXMLBase64();
@@ -31,7 +32,7 @@
 
         if (saml != null) {
             return "<form method=\"POST\" target=\"_blank\" action=\""
-                + quotedUrl + "\">"
+                + quotedUrl + "\" " + "name=\"" + formName + "\">"
                 + "<input type=\"hidden\" name=\"saml\" value=\""
                 + SafeHtmlUtils.htmlEscape(saml) + "\">"
                 + "<input type=\"image\" src=\""+ quotedImage + "\">"
@@ -42,11 +43,13 @@
         }
     }
 
-    public static DynamicForm linkHTML(FLYS flys, String url, String text) {
-        String saml = flys.getCurrentUser().getSamlXMLBase64();
+    public static DynamicForm linkDynamicForm(FLYS flys, String url, String text) {
+        User currentUser = flys.getCurrentUser();
         String quotedUrl = SafeHtmlUtils.htmlEscape(url);
         String quotedText = SafeHtmlUtils.htmlEscape(text);
-        if (saml != null) {
+
+        if (currentUser != null) {
+            String saml = currentUser.getSamlXMLBase64();
             final DynamicForm form = new DynamicForm();
             form.setMethod(FormMethod.POST);
             form.setTarget("_blank");
@@ -73,4 +76,33 @@
             return form;
         }
     }
+
+    public static DynamicForm dynamicForm(FLYS flys, String url) {
+        User currentUser = flys.getCurrentUser();
+        String quotedUrl = SafeHtmlUtils.htmlEscape(url);
+
+        if (currentUser != null) {
+            String saml = currentUser.getSamlXMLBase64();
+            saml = SafeHtmlUtils.htmlEscape(saml);
+            GWT.log("saml=" + saml);
+            DynamicForm form = new DynamicForm();
+            form.setID("wikiDynamicForm");
+            form.setMethod(FormMethod.POST);
+            form.setTarget("_blank");
+            form.setAction(quotedUrl);
+            form.setCanSubmit(true);
+            HiddenItem item = new HiddenItem("saml");
+            item.setDefaultValue(saml);
+            item.setValue(saml);
+            form.setFields(item);
+            //form.setValue("saml", saml);
+            return form;
+        }
+        else {
+            DynamicForm form = new DynamicForm();
+            form.setTarget("_blank");
+            form.setAction(quotedUrl);
+            return form;
+        }
+    }
 }
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WspDatacagePanel.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WspDatacagePanel.java	Mon Jul 22 13:03:42 2013 +0200
@@ -78,7 +78,7 @@
 
     /**
      * We need to override this method (defined in AbstractUIProvider) because
-     * we have to create a new Artifact specified by  the Datacage selection via
+     * we have to create a new Artifact specified by the Datacage selection via
      * Async request.
      *
      * @param e The ClickEvent.
@@ -144,6 +144,7 @@
     }
 
 
+    /** Returns a Data Array with one default item. */
     protected Data[] getData(Recommendation r, Artifact newArtifact) {
         String uuid = newArtifact.getUuid();
         r.setMasterArtifact(uuid);
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/chart/ChartPropertiesEditor.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/chart/ChartPropertiesEditor.java	Mon Jul 22 13:03:42 2013 +0200
@@ -188,6 +188,17 @@
         PropertyGroup origPg = (PropertyGroup)orig;
 
         if (pg.getName().equals("axis")) {
+            // Certain axis shall be skipped (W/Q-Diagrams cm-axis especially).
+            String outputName = tab.getOutputName();
+            if (outputName.equals("fix_wq_curve") || outputName.equals("computed_discharge_curve")
+                || outputName.equals("extreme_wq_curve")) {
+                String labelString = ((StringProperty)origPg.getPropertyByName("label")).getValue();
+                if(labelString.equals("W [cm]")) {
+                    VLayout layout = new VLayout();
+                    layout.setHeight(0);
+                    return layout;
+                }
+            }
             Label scale = new Label(MSG.scale() + " :");
             scale.setHeight(25);
             scale.setMargin(2);
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/chart/CrossSectionChartThemePanel.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/chart/CrossSectionChartThemePanel.java	Mon Jul 22 13:03:42 2013 +0200
@@ -312,7 +312,7 @@
 
 
     /**
-     * Feed a single artifact with the km of the crosssection to display.
+     * Feed artifacts with the km of the crosssection to display.
      * If its the selected master, also feed the collectionmaster.
      *
      * @param artifacts List of artifacts to feed.
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/FixGaugeSelectPanel.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/FixGaugeSelectPanel.java	Mon Jul 22 13:03:42 2013 +0200
@@ -30,7 +30,8 @@
 import java.util.List;
 
 /**
- * This UIProvider creates a panel for location or distance input.
+ * This UIProvider creates a panel to select discharge classes / sectors
+ * (german Abflussklassen).
  *
  * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
  */
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/InfoListGrid.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/InfoListGrid.java	Mon Jul 22 13:03:42 2013 +0200
@@ -46,7 +46,7 @@
     ) {
         String name = this.getFieldName(colNum);
         if (name.equals("infolink")) {
-            return WikiLinks.linkHTML(
+            return WikiLinks.linkDynamicForm(
                 flys,
                 record.getAttribute("link"),
                 record.getLinkText());
--- a/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/DefaultCollection.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/DefaultCollection.java	Mon Jul 22 13:03:42 2013 +0200
@@ -284,6 +284,10 @@
     }
 
 
+    /**
+     * Returns true if a recommendation with given factory and id
+     * is already member of this collection.
+     */
     public boolean loadedRecommendation(Recommendation recommendation) {
         String factory = recommendation.getFactory();
         String dbids   = recommendation.getIDs();
@@ -307,7 +311,7 @@
     }
 
     /**
-     * Returns the name of the collection or uuid if no name is set
+     * Returns the name of the collection or uuid if no name is set.
      */
     @Override
     public String getDisplayName() {
--- a/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/ToLoad.java	Fri Jun 28 19:32:43 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/ToLoad.java	Mon Jul 22 13:03:42 2013 +0200
@@ -20,6 +20,7 @@
 public class ToLoad implements Serializable
 {
 
+    /** Two strings. */
     public class StringPair {
         public String first;
         public String second;
@@ -51,16 +52,17 @@
         }
         return key;
     }
-   public void add(
-        String artifactName,
-        String factory,
-        String out,
-        String name,
-        String ids,
-        String displayName
-    ) {
-       add(artifactName, factory, out, name, ids, displayName, null);
-    }
+
+    public void add(
+         String artifactName,
+         String factory,
+         String out,
+         String name,
+         String ids,
+         String displayName
+     ) {
+        add(artifactName, factory, out, name, ids, displayName, null);
+     }
 
     public void add(
         String artifactName,
@@ -114,7 +116,7 @@
             for (Map.Entry<StringPair, ArtifactFilter> entry:
                 all.getValue().entrySet()
             ) {
-                StringPair pair         = entry.getKey();
+                StringPair pair = entry.getKey();
                 String factory = pair.first;
                 ArtifactFilter artifactFilter = entry.getValue();
 

http://dive4elements.wald.intevation.org