changeset 1857:7fc87a67e6f7

Added new WMSFloodplainArtifact for displaying floodplains in maps. flys-artifacts/trunk@3204 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 09 Nov 2011 16:49:58 +0000
parents 410e40b88c7a
children 94871b7ce9e9
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/winfo.xml flys-artifacts/doc/conf/conf.xml flys-artifacts/doc/conf/meta-data.xml flys-artifacts/doc/conf/themes.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSFloodplainArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java flys-artifacts/src/main/resources/messages.properties flys-artifacts/src/main/resources/messages_de.properties flys-artifacts/src/main/resources/messages_de_DE.properties flys-artifacts/src/main/resources/messages_en.properties
diffstat 11 files changed, 217 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Nov 09 16:28:29 2011 +0000
+++ b/flys-artifacts/ChangeLog	Wed Nov 09 16:49:58 2011 +0000
@@ -1,3 +1,26 @@
+2011-11-09  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/WMSFloodplainArtifact.java: New
+	  Artifact that is used to create WMS layers for floodplains in maps.
+
+	* doc/conf/conf.xml: Registered the new WMSFloodplainArtifact.
+
+	* src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java: Added
+	  a new type 'floodmap.floodplain'.
+
+	* doc/conf/artifacts/winfo.xml: Registered the 'floodmap.floodplain' facet
+	  for floodmaps.
+
+	* doc/conf/themes.xml: Added a theme for 'floodmap.floodplain' facets.
+
+	* doc/conf/meta-data.xml: Added configuration for 'floodplain'.
+
+	* src/main/resources/messages.properties,
+	  src/main/resources/messages_de_DE.properties,
+	  src/main/resources/messages_en.properties,
+	  src/main/resources/messages_de.properties: Added facet titles for
+	  'floodmap.floodplain' facets.
+
 2011-11-09  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/WMSCatchmentArtifact.java: New
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml	Wed Nov 09 16:28:29 2011 +0000
+++ b/flys-artifacts/doc/conf/artifacts/winfo.xml	Wed Nov 09 16:49:58 2011 +0000
@@ -376,6 +376,7 @@
                         <facet name="floodmap.qps"/>
                         <facet name="floodmap.hws"/>
                         <facet name="floodmap.catchment"/>
+                        <facet name="floodmap.floodplain"/>
                     </facets>
                 </outputmode>
                 <outputmode name="wsplgen_report" description="output.wsplgen_report" mime-type="text/xml" type="report">
--- a/flys-artifacts/doc/conf/conf.xml	Wed Nov 09 16:28:29 2011 +0000
+++ b/flys-artifacts/doc/conf/conf.xml	Wed Nov 09 16:49:58 2011 +0000
@@ -29,6 +29,9 @@
             <artifact-factory name="wmscatchmentfactory" description="Factory to create an artifact that generates WMS facets for CrossSectionTracks."
                 ttl="3600000"
                 artifact="de.intevation.flys.artifacts.WMSCatchmentArtifact">de.intevation.artifactdatabase.DefaultArtifactFactory</artifact-factory>
+            <artifact-factory name="wmsfloodplainfactory" description="Factory to create an artifact that generates WMS facets for CrossSectionTracks."
+                ttl="3600000"
+                artifact="de.intevation.flys.artifacts.WMSFloodplainArtifact">de.intevation.artifactdatabase.DefaultArtifactFactory</artifact-factory>
             <artifact-factory name="wmsbackground" description="Factory to create an artifact to be used in WINFO"
                 ttl="3600000"
                 artifact="de.intevation.flys.artifacts.WMSBackgroundArtifact">de.intevation.artifactdatabase.DefaultArtifactFactory</artifact-factory>
--- a/flys-artifacts/doc/conf/meta-data.xml	Wed Nov 09 16:28:29 2011 +0000
+++ b/flys-artifacts/doc/conf/meta-data.xml	Wed Nov 09 16:49:58 2011 +0000
@@ -565,6 +565,22 @@
                   </dc:elements>
                 </dc:context>
               </dc:macro>
+              <dc:macro name="flood-map-floodplain">
+                <dc:context>
+                  <dc:statement>
+                    SELECT count(*) as km_exists
+                    FROM floodplain WHERE river_id = ${river_id}
+                  </dc:statement>
+                   <dc:elements>
+                    <dc:if test="$km_exists>0">
+                      <floodplain>
+                        <dc:attribute name="factory" value="wmsfloodplainfactory"/>
+                        <dc:attribute name="ids" value="${river_id}"/>
+                      </floodplain>
+                    </dc:if>
+                  </dc:elements>
+                </dc:context>
+              </dc:macro>
               <dc:macro name="flood-map-complete">
                   <kilometrage>
                       <riveraxis>
@@ -575,6 +591,7 @@
                     <dc:call-macro name="flood-map-qps"/>
                     <dc:call-macro name="flood-map-hws"/>
                     <dc:call-macro name="flood-map-catchments"/>
+                    <dc:call-macro name="flood-map-floodplain"/>
                   </kilometrage>
                   <rastermap>
                       <background>
--- a/flys-artifacts/doc/conf/themes.xml	Wed Nov 09 16:28:29 2011 +0000
+++ b/flys-artifacts/doc/conf/themes.xml	Wed Nov 09 16:49:58 2011 +0000
@@ -752,6 +752,13 @@
         </fields>
     </theme>
 
+    <theme name="Floodplain">
+        <fields>
+            <field name="linecolor" type="Color" display="Linienfarbe" default="140, 200, 130"/>
+            <field name="linesize"  type="int"   display="Liniendicke" default="5" hints="h"/>
+        </fields>
+    </theme>
+
 
     <!--
       Mappings are following now. A mapping maps between a name of a facet
@@ -837,6 +844,7 @@
         <mapping from="floodmap.qps" to="Qps"/>
         <mapping from="floodmap.hws" to="Hws"/>
         <mapping from="floodmap.catchment" to="Catchment"/>
+        <mapping from="floodmap.floodplain" to="Floodplain"/>
         <mapping from="other.wkms" to="WKms"/>
         <mapping from="other.wqkms" to="WQKms"/>
         <mapping from="heightmarks_points" to="heightmarks_points"/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSFloodplainArtifact.java	Wed Nov 09 16:49:58 2011 +0000
@@ -0,0 +1,160 @@
+package de.intevation.flys.artifacts;
+
+import java.util.List;
+
+import org.w3c.dom.Document;
+
+import org.apache.log4j.Logger;
+
+import com.vividsolutions.jts.geom.Envelope;
+
+import de.intevation.artifacts.ArtifactFactory;
+import de.intevation.artifacts.CallMeta;
+
+import de.intevation.artifactdatabase.state.DefaultOutput;
+import de.intevation.artifactdatabase.state.Facet;
+import de.intevation.artifactdatabase.state.State;
+
+import de.intevation.flys.model.Floodplain;
+import de.intevation.flys.model.River;
+
+import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.RiverFactory;
+import de.intevation.flys.artifacts.resources.Resources;
+import de.intevation.flys.utils.FLYSUtils;
+
+
+public class WMSFloodplainArtifact extends WMSDBArtifact {
+
+    public static final String NAME = "floodplain";
+
+
+    private static final Logger logger =
+        Logger.getLogger(WMSFloodplainArtifact.class);
+
+
+    @Override
+    public void setup(
+        String          identifier,
+        ArtifactFactory factory,
+        Object          context,
+        CallMeta        callMeta,
+        Document        data)
+    {
+        logger.debug("WMSFloodplainArtifact.setup");
+
+        super.setup(identifier, factory, context, callMeta, data);
+    }
+
+
+    @Override
+    public String getName() {
+        return NAME;
+    }
+
+
+    @Override
+    public State getCurrentState(Object cc) {
+        State s = new FloodplainState(this);
+
+        List<Facet> fs = facets.get(getCurrentStateId());
+
+        DefaultOutput o = new DefaultOutput(
+            "floodmap",
+            "floodmap",
+            "image/png",
+            fs,
+            "map");
+
+        s.getOutputs().add(o);
+
+        return s;
+    }
+
+
+    public static class FloodplainState extends WMSDBState implements FacetTypes
+    {
+        private static final Logger logger =
+            Logger.getLogger(FloodplainState.class);
+
+        protected int riverId;
+
+        public FloodplainState(WMSDBArtifact artifact) {
+            super(artifact);
+            riverId = 0;
+        }
+
+        public int getRiverId() {
+            if (riverId == 0) {
+                String ids = artifact.getDataAsString("ids");
+
+                try {
+                    riverId = Integer.valueOf(ids);
+                }
+                catch (NumberFormatException nfe) {
+                    logger.error("Cannot parse river id from '" + ids + "'");
+                }
+            }
+
+            return riverId;
+        }
+
+        protected River getRiver() {
+            return RiverFactory.getRiver(getRiverId());
+        }
+
+        @Override
+        protected String getFacetType() {
+            return FLOODMAP_FLOODPLAIN;
+        }
+
+        @Override
+        protected String getTitle(CallMeta meta) {
+            return Resources.getMsg(
+                meta,
+                FLOODMAP_FLOODPLAIN,
+                FLOODMAP_FLOODPLAIN);
+        }
+
+        @Override
+        protected String getUrl() {
+            return FLYSUtils.getUserWMSUrl(artifact.identifier());
+        }
+
+        @Override
+        protected String getSrid() {
+            River river = getRiver();
+            return FLYSUtils.getRiverSrid(river.getName());
+        }
+
+        @Override
+        protected Envelope getExtent() {
+            River      river = getRiver();
+            Floodplain plain = Floodplain.getFloodplain(river.getName());
+            return plain.getGeom().getEnvelopeInternal();
+        }
+
+        @Override
+        protected String getFilter() {
+            return "river_id=" + String.valueOf(getRiverId());
+        }
+
+        @Override
+        protected String getDataString() {
+            String srid = getSrid();
+
+            if (FLYSUtils.isUsingOracle()) {
+                return "geom FROM floodplain USING SRID " + srid;
+            }
+            else {
+                return "geom FROM floodplain USING UNIQUE id USING SRID " +srid;
+            }
+        }
+
+        @Override
+        protected String getGeometryType() {
+            return "POLYGON";
+        }
+    } // end of WMSKmState
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Wed Nov 09 16:28:29 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Wed Nov 09 16:49:58 2011 +0000
@@ -10,6 +10,7 @@
     String FLOODMAP_QPS           = "floodmap.qps";
     String FLOODMAP_HWS           = "floodmap.hws";
     String FLOODMAP_CATCHMENT     = "floodmap.catchment";
+    String FLOODMAP_FLOODPLAIN    = "floodmap.floodplain";
 
     String DISCHARGE_LONGITUDINAL_W = "discharge_longitudinal_section.w";
     String DISCHARGE_LONGITUDINAL_Q = "discharge_longitudinal_section.q";
--- a/flys-artifacts/src/main/resources/messages.properties	Wed Nov 09 16:28:29 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages.properties	Wed Nov 09 16:49:58 2011 +0000
@@ -90,6 +90,7 @@
 floodmap.qps = Crosssection Tracks
 floodmap.hws = Flood Control Works
 floodmap.catchment = Catchment
+floodmap.floodplain = Floodplain
 
 wsplgen.job.queued = WSPLGEN job in queue.
 wsplgen.job.error = An unexpected error while starting WSPLGEN occured.
--- a/flys-artifacts/src/main/resources/messages_de.properties	Wed Nov 09 16:28:29 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_de.properties	Wed Nov 09 16:49:58 2011 +0000
@@ -90,6 +90,7 @@
 floodmap.qps = Querprofilspuren
 floodmap.hws = Hochwasserschutzanlagen
 floodmap.catchment = Einzugsgebiet
+floodmap.floodplain = Talaue
 
 wsplgen.job.queued = WSPLGEN Berechnung befindet sich in Warteschlange.
 wsplgen.job.error = Ein unerwarteter Fehler beim Starten von WSPLGEN ist aufgetreten.
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties	Wed Nov 09 16:28:29 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_de_DE.properties	Wed Nov 09 16:49:58 2011 +0000
@@ -90,6 +90,7 @@
 floodmap.qps = Querprofilspuren
 floodmap.hws = Hochwasserschutzanlagen
 floodmap.catchment = Einzugsgebiet
+floodmap.floodplain = Talaue
 
 wsplgen.job.queued = WSPLGEN Berechnung befindet sich in Warteschlange.
 wsplgen.job.error = Ein unerwarteter Fehler beim Starten von WSPLGEN ist aufgetreten.
--- a/flys-artifacts/src/main/resources/messages_en.properties	Wed Nov 09 16:28:29 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_en.properties	Wed Nov 09 16:49:58 2011 +0000
@@ -88,6 +88,7 @@
 floodmap.qps = Crosssection Tracks
 floodmap.hws = Flood Control Works
 floodmap.catchment = Catchment
+floodmap.floodplain = Floodplain
 
 wsplgen.job.queued = WSPLGEN job in queue.
 wsplgen.job.error = An unexpected error while starting WSPLGEN occured.

http://dive4elements.wald.intevation.org