changeset 2684:14188f8daefb

Added support for WMS gauges in floodmaps and maps. flys-artifacts/trunk@4385 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 10 May 2012 11:56:40 +0000
parents f5af3adb3b95
children 5652a851f1b4
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/map.xml 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/WMSGaugeLocationArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java
diffstat 8 files changed, 207 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu May 10 11:14:17 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu May 10 11:56:40 2012 +0000
@@ -1,3 +1,23 @@
+2012-05-10  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/WMSGaugeLocationArtifact.java:
+	  New Artifact for storing geometries for gauges.
+
+	* src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java: Added
+	  a new facet type for WMSGaugeLocationArtifact 'floodmap.gaugelocation'.
+
+	* doc/conf/artifacts/winfo.xml,
+	  doc/conf/artifacts/map.xml: Added 'floodmap.gaugelocation' facet to the
+	  list of valid facets for map and floodmap output.
+
+	* doc/conf/conf.xml: Added a factory for creating
+	  WMSGaugeLocationArtifacts.
+
+	* doc/conf/themes.xml: Added a theme for 'floodmap.gaugelocation' facets.
+
+	* doc/conf/meta-data.xml: Added a datacage section for gauge locations to
+	  the floodmap and map section.
+
 2012-05-10  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java: Added
--- a/flys-artifacts/doc/conf/artifacts/map.xml	Thu May 10 11:14:17 2012 +0000
+++ b/flys-artifacts/doc/conf/artifacts/map.xml	Thu May 10 11:56:40 2012 +0000
@@ -28,8 +28,9 @@
                         <facet name="floodmap.lines"/>
                         <facet name="floodmap.buildings"/>
                         <facet name="floodmap.fixpoints"/>
+                        <facet name="floodmap.floodmaps"/>
+                        <facet name="floodmap.gauge_location"/>
                         <facet name="floodmap.externalwms"/>
-                        <facet name="floodmap.floodmaps"/>
                     </facets>
                 </outputmode>
             </outputmodes>
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml	Thu May 10 11:14:17 2012 +0000
+++ b/flys-artifacts/doc/conf/artifacts/winfo.xml	Thu May 10 11:56:40 2012 +0000
@@ -472,6 +472,7 @@
                         <facet name="floodmap.buildings"/>
                         <facet name="floodmap.fixpoints"/>
                         <facet name="floodmap.floodmaps"/>
+                        <facet name="floodmap.gauge_location"/>
                         <facet name="floodmap.externalwms"/>
                     </facets>
                 </outputmode>
--- a/flys-artifacts/doc/conf/conf.xml	Thu May 10 11:14:17 2012 +0000
+++ b/flys-artifacts/doc/conf/conf.xml	Thu May 10 11:56:40 2012 +0000
@@ -56,6 +56,9 @@
             <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="wmsgaugelocationfactory" description="Factory to create an artifact to be used in WINFO"
+                ttl="3600000"
+                artifact="de.intevation.flys.artifacts.WMSGaugeLocationArtifact">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	Thu May 10 11:14:17 2012 +0000
+++ b/flys-artifacts/doc/conf/meta-data.xml	Thu May 10 11:56:40 2012 +0000
@@ -786,6 +786,23 @@
                   </dc:elements>
                 </dc:context>
               </dc:macro>
+              <dc:macro name="flood-map-gaugelocations">
+                <dc:context>
+                  <dc:statement>
+                    SELECT count(*) as km_exists, name as name
+                    FROM gauge_location WHERE river_id = ${river_id} GROUP BY name
+                  </dc:statement>
+                   <dc:elements>
+                    <dc:if test="$km_exists>0">
+                      <gaugelocation>
+                        <dc:attribute name="factory" value="wmsgaugelocationfactory"/>
+                        <dc:attribute name="ids" value="${river_id};${name}"/>
+                        <dc:attribute name="name"  value="${name}"/>
+                      </gaugelocation>
+                    </dc:if>
+                  </dc:elements>
+                </dc:context>
+              </dc:macro>
               <dc:macro name="flood-map-uesk">
                 <uesk>
                   <calculations>
@@ -901,6 +918,9 @@
                     <dc:call-macro name="flood-map-lines"/>
                   </lines>
                   <dc:call-macro name="flood-map-uesk"/>
+                  <gaugelocations>
+                    <dc:call-macro name="flood-map-gaugelocations"/>
+                  </gaugelocations>
                   <rastermap>
                       <background>
                           <dc:attribute name="factory" value="wmsbackground"/>
--- a/flys-artifacts/doc/conf/themes.xml	Thu May 10 11:14:17 2012 +0000
+++ b/flys-artifacts/doc/conf/themes.xml	Thu May 10 11:56:40 2012 +0000
@@ -899,6 +899,14 @@
         </fields>
     </theme>
 
+    <theme name="GaugeLocation">
+        <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="symbol"    type="Symbol" display="Symbol"     default="point"/>
+        </fields>
+    </theme>
+
     <theme name="Qps">
         <fields>
             <field name="linecolor" type="Color" display="Linienfarbe" default="0, 0, 255"/>
@@ -1056,6 +1064,7 @@
         <mapping from="floodmap.buildings" to="Buildings"/>
         <mapping from="floodmap.fixpoints" to="Fixpoints"/>
         <mapping from="floodmap.floodmaps" to="Floodmaps"/>
+        <mapping from="floodmap.gauge_location" to="GaugeLocation"/>
         <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/WMSGaugeLocationArtifact.java	Thu May 10 11:56:40 2012 +0000
@@ -0,0 +1,151 @@
+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 com.vividsolutions.jts.geom.Geometry;
+
+import de.intevation.artifacts.ArtifactFactory;
+import de.intevation.artifacts.CallMeta;
+
+import de.intevation.artifactdatabase.state.Facet;
+import de.intevation.artifactdatabase.state.DefaultOutput;
+import de.intevation.artifactdatabase.state.State;
+
+import de.intevation.flys.model.River;
+import de.intevation.flys.model.GaugeLocation;
+
+import de.intevation.flys.artifacts.WMSDBArtifact.WMSDBState;
+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 WMSGaugeLocationArtifact extends WMSDBArtifact {
+
+    public static final String NAME = "wmsgaugelocation";
+
+
+    private static final Logger logger =
+        Logger.getLogger(WMSGaugeLocationArtifact.class);
+
+
+    @Override
+    public void setup(
+        String          identifier,
+        ArtifactFactory factory,
+        Object          context,
+        CallMeta        callMeta,
+        Document        data)
+    {
+        logger.debug("WMSGaugeLocationArtifact.setup");
+
+        super.setup(identifier, factory, context, callMeta, data);
+    }
+
+
+    @Override
+    public String getName() {
+        return NAME;
+    }
+
+
+    @Override
+    public State getCurrentState(Object cc) {
+        State s = new WMSGaugeLocationState(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 WMSGaugeLocationState extends WMSDBState implements FacetTypes {
+
+        private static final Logger logger =
+            Logger.getLogger(WMSGaugeLocationState.class);
+
+        protected Geometry geom;
+
+        public WMSGaugeLocationState(WMSDBArtifact artifact) {
+            super(artifact);
+        }
+
+        @Override
+        protected String getFacetType() {
+            return FLOODMAP_GAUGE_LOCATION;
+        }
+
+        @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<GaugeLocation> gauges =
+                GaugeLocation.getGaugeLocations(getRiverId(), getName());
+
+            Envelope max = null;
+
+            for (GaugeLocation gauge: gauges) {
+                Envelope env = gauge.getGeom().getEnvelopeInternal();
+
+                if (max == null) {
+                    max = env;
+                    continue;
+                }
+
+                max.expandToInclude(env);
+            }
+
+            return max;
+        }
+
+        @Override
+        protected String getFilter() {
+            return "river_id=" + String.valueOf(getRiverId()) +
+                " and name='" + getName() + "'";
+        }
+
+        @Override
+        protected String getDataString() {
+            String srid = getSrid();
+
+            if (FLYSUtils.isUsingOracle()) {
+                return "geom FROM gauge_location USING SRID " + srid;
+            }
+            else {
+                return "geom FROM gauge_location " +
+                       "USING UNIQUE id USING SRID " + srid;
+            }
+        }
+
+        @Override
+        protected String getGeometryType() {
+            return "POINT";
+        }
+    }
+}
+// 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 May 10 11:14:17 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Thu May 10 11:56:40 2012 +0000
@@ -79,6 +79,7 @@
     String FLOODMAP_BUILDINGS          = "floodmap.buildings";
     String FLOODMAP_FIXPOINTS          = "floodmap.fixpoints";
     String FLOODMAP_FLOODMAPS          = "floodmap.floodmaps";
+    String FLOODMAP_GAUGE_LOCATION     = "floodmap.gauge_location";
     String FLOODMAP_EXTERNAL_WMS       = "floodmap.externalwms";
 
     String DISCHARGE_LONGITUDINAL_W = "discharge_longitudinal_section.w";

http://dive4elements.wald.intevation.org