changeset 2581:afebbe9c2fce

Added a new Artifact for loading existing 'floodmaps' via datacage. flys-artifacts/trunk@4130 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 08 Mar 2012 13:44:51 +0000
parents 3d240200364c
children 631dabad9b48
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/winfo.xml flys-artifacts/doc/conf/conf.xml flys-artifacts/doc/conf/themes.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSFloodmapsArtifact.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 10 files changed, 225 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Mar 08 13:06:11 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu Mar 08 13:44:51 2012 +0000
@@ -1,3 +1,25 @@
+2012-03-08  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/WMSFloodmapsArtifact.java: New.
+	  This Artifacts allows loading 'floodmaps'.
+
+	* src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java: Added a
+	  new Facet type "floodmap.floodmaps" which are created by
+	  WMSFloodmapsArtifact.
+
+	* doc/conf/artifacts/winfo.xml: Registered the "floodmap.floodmaps" facet
+	  for "floodmap" output.
+
+	* doc/conf/conf.xml: Registered the new WMSFloodmapsArtifact.
+
+	* doc/conf/themes.xml: Added a theme for the "floodmap.floodmaps" facet.
+
+	* 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 i18n string for
+	  "floodmap.floodmaps" title.
+
 2012-03-08  Ingo Weinzierl <ingo@intevation.de>
 
 	* doc/conf/meta-data.xml: Improved datacage configuration to serve
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml	Thu Mar 08 13:06:11 2012 +0000
+++ b/flys-artifacts/doc/conf/artifacts/winfo.xml	Thu Mar 08 13:44:51 2012 +0000
@@ -464,6 +464,7 @@
                         <facet name="floodmap.lines"/>
                         <facet name="floodmap.buildings"/>
                         <facet name="floodmap.fixpoints"/>
+                        <facet name="floodmap.floodmaps"/>
                         <facet name="floodmap.externalwms"/>
                     </facets>
                 </outputmode>
--- a/flys-artifacts/doc/conf/conf.xml	Thu Mar 08 13:06:11 2012 +0000
+++ b/flys-artifacts/doc/conf/conf.xml	Thu Mar 08 13:44:51 2012 +0000
@@ -46,6 +46,9 @@
                 artifact="de.intevation.flys.artifacts.WMSBuildingsArtifact">de.intevation.artifactdatabase.DefaultArtifactFactory</artifact-factory>
             <artifact-factory name="wmsfixpointsfactory" description="Factory to create an artifact to be used in WINFO"
                 ttl="3600000"
+                artifact="de.intevation.flys.artifacts.WMSFloodmapsArtifact">de.intevation.artifactdatabase.DefaultArtifactFactory</artifact-factory>
+            <artifact-factory name="wmsfloodmapsfactory" description="Factory to create an artifact to be used in WINFO"
+                ttl="3600000"
                 artifact="de.intevation.flys.artifacts.WMSFixpointsArtifact">de.intevation.artifactdatabase.DefaultArtifactFactory</artifact-factory>
             <artifact-factory name="wmsbackground" description="Factory to create an artifact to be used in WINFO"
                 ttl="3600000"
--- a/flys-artifacts/doc/conf/themes.xml	Thu Mar 08 13:06:11 2012 +0000
+++ b/flys-artifacts/doc/conf/themes.xml	Thu Mar 08 13:44:51 2012 +0000
@@ -860,6 +860,14 @@
         </fields>
     </theme>
 
+    <theme name="Floodmaps">
+        </fields>
+            <field name="linecolor" type="Color" display="Linienfarbe" default="0, 0, 0"/>
+            <field name="linesize"  type="int"   display="Liniendicke" default="1" hints="h"/>
+            <field name="backgroundcolor" type="Color" display="Hintergrund" default="140, 200, 130"/>
+        </fields>
+    </theme>
+
     <theme name="Qps">
         <fields>
             <field name="linecolor" type="Color" display="Linienfarbe" default="0, 0, 255"/>
@@ -998,6 +1006,7 @@
         <mapping from="floodmap.lines" to="Lines"/>
         <mapping from="floodmap.buildings" to="Buildings"/>
         <mapping from="floodmap.fixpoints" to="Fixpoints"/>
+        <mapping from="floodmap.floodmaps" to="Floodmaps"/>
         <mapping from="other.wq" to="WQPoints"/>
         <mapping from="other.wkms" to="WKms"/>
         <mapping from="other.wqkms" to="WQKms"/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSFloodmapsArtifact.java	Thu Mar 08 13:44:51 2012 +0000
@@ -0,0 +1,185 @@
+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.River;
+import de.intevation.flys.model.Floodmaps;
+
+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 WMSFloodmapsArtifact extends WMSDBArtifact {
+
+    public static final String NAME = "floodmaps";
+
+
+    private static final Logger logger =
+        Logger.getLogger(WMSFloodmapsArtifact.class);
+
+
+    @Override
+    public void setup(
+        String          identifier,
+        ArtifactFactory factory,
+        Object          context,
+        CallMeta        callMeta,
+        Document        data)
+    {
+        logger.debug("WMSFloodmapsArtifact.setup");
+
+        super.setup(identifier, factory, context, callMeta, data);
+    }
+
+
+    @Override
+    public String getName() {
+        return NAME;
+    }
+
+
+    @Override
+    public State getCurrentState(Object cc) {
+        State s = new FloodmapsState(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 FloodmapsState extends WMSDBState implements FacetTypes
+    {
+        private static final Logger logger =
+            Logger.getLogger(FloodmapsState.class);
+
+        protected int    riverId;
+        protected String floodmapName;
+
+        public FloodmapsState(WMSDBArtifact artifact) {
+            super(artifact);
+            riverId      = 0;
+            floodmapName = null;
+        }
+
+        public int getRiverId() {
+            if (riverId == 0) {
+                String ids = artifact.getDataAsString("ids");
+
+                try {
+                    String[] parts = ids.split("_");
+                    riverId = Integer.valueOf(parts[0]);
+                }
+                catch (NumberFormatException nfe) {
+                    logger.error("Cannot parse river id from '" + ids + "'");
+                }
+            }
+
+            return riverId;
+        }
+
+        public String getFloodmapName() {
+            if (floodmapName == null) {
+                String ids = artifact.getDataAsString("ids");
+
+                String parts[] = ids.split("_");
+                floodmapName   = parts[1];
+            }
+
+            return floodmapName;
+        }
+
+        @Override
+        protected String getFacetType() {
+            return FLOODMAP_FLOODMAPS;
+        }
+
+        @Override
+        protected String getTitle(CallMeta meta) {
+            return Resources.getMsg(
+                meta,
+                FLOODMAP_FLOODMAPS,
+                FLOODMAP_FLOODMAPS);
+        }
+
+        @Override
+        protected String getUrl() {
+            return FLYSUtils.getUserWMSUrl(artifact.identifier());
+        }
+
+        @Override
+        protected String getSrid() {
+            River river = RiverFactory.getRiver(getRiverId());
+            return FLYSUtils.getRiverSrid(river.getName());
+        }
+
+        @Override
+        protected Envelope getExtent() {
+            List<Floodmaps> floodmaps =
+                Floodmaps.getFloodmaps(getRiverId(), getFloodmapName());
+
+            Envelope max = null;
+
+            for (Floodmaps f: floodmaps) {
+                Envelope env = f.getGeom().getEnvelopeInternal();
+
+                if (max == null) {
+                    max = env;
+                    continue;
+                }
+
+                max.expandToInclude(env);
+            }
+
+            return max;
+        }
+
+        @Override
+        protected String getFilter() {
+            return "river_id=" + String.valueOf(getRiverId())
+                + "name=" + getFloodmapName();
+        }
+
+        @Override
+        protected String getDataString() {
+            String srid = getSrid();
+
+            if (FLYSUtils.isUsingOracle()) {
+                return "geom FROM floodmaps USING SRID " + srid;
+            }
+            else {
+                return "geom FROM floodmaps USING UNIQUE id USING SRID " + srid;
+            }
+        }
+
+        @Override
+        protected String getGeometryType() {
+            return "MULTIPOLYGON";
+        }
+    } // 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	Thu Mar 08 13:06:11 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Thu Mar 08 13:44:51 2012 +0000
@@ -74,6 +74,7 @@
     String FLOODMAP_LINES         = "floodmap.lines";
     String FLOODMAP_BUILDINGS     = "floodmap.buildings";
     String FLOODMAP_FIXPOINTS     = "floodmap.fixpoints";
+    String FLOODMAP_FLOODMAPS     = "floodmap.floodmaps";
     String FLOODMAP_EXTERNAL_WMS  = "floodmap.externalwms";
 
     String DISCHARGE_LONGITUDINAL_W = "discharge_longitudinal_section.w";
--- a/flys-artifacts/src/main/resources/messages.properties	Thu Mar 08 13:06:11 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages.properties	Thu Mar 08 13:44:51 2012 +0000
@@ -170,6 +170,7 @@
 floodmap.lines = Lines
 floodmap.buildings = Buildings
 floodmap.fixpoints = Fixpoints
+floodmap.floodmaps = Floodmaps
 
 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	Thu Mar 08 13:06:11 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_de.properties	Thu Mar 08 13:44:51 2012 +0000
@@ -170,6 +170,7 @@
 floodmap.lines = Linien
 floodmap.buildings = Bauwerke
 floodmap.fixpoints = Festpunkte
+floodmap.floodmaps = \u00dcberschwemmungsfl\u00e4che
 
 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	Thu Mar 08 13:06:11 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_de_DE.properties	Thu Mar 08 13:44:51 2012 +0000
@@ -169,6 +169,7 @@
 floodmap.lines = Linien
 floodmap.buildings = Bauwerke
 floodmap.fixpoints = Festpunkte
+floodmap.floodmaps = \u00dcberschwemmungsfl\u00e4che
 
 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	Thu Mar 08 13:06:11 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_en.properties	Thu Mar 08 13:44:51 2012 +0000
@@ -166,6 +166,7 @@
 floodmap.lines = Lines
 floodmap.buildings = Buildings
 floodmap.fixpoints = Fixpoints
+floodmap.floodmaps = Floodmaps
 
 wsplgen.job.queued = WSPLGEN job in queue.
 wsplgen.job.error = An unexpected error while starting WSPLGEN occured.

http://dive4elements.wald.intevation.org