changeset 2082:007a8f5ed9f1

Implemented new module "new map". flys-artifacts/trunk@3598 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 05 Jan 2012 14:29:54 +0000
parents aa9cc91c8193
children b52012d538af
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/map.xml flys-artifacts/doc/conf/conf.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/MapArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java
diffstat 7 files changed, 203 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Jan 05 14:15:07 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu Jan 05 14:29:54 2012 +0000
@@ -1,3 +1,26 @@
+2011-12-09  Raimund Renkert <raimund.renkert@intevation.de>
+
+	Implemented new module "new map".
+
+	* src/main/java/de/intevation/flys/artifacts/MapArtifact.java:
+	  New. Artifact for the new module, extends RiverAxisArtifact and
+	  contains the MapState class.
+
+	* src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java:
+	  Added empty constructor to embedded state classes to allow instantiation
+	  of MapState that extends the RiverAxisState.
+
+	* src/main/java/de/intevation/flys/exports/MapGenerator.java:
+	  Do not generate an initialExtent element if the initial extent is
+	  empty.
+
+	* doc/conf/artifacts/map.xml:
+	  New. Describes the state for the new module.
+
+	* doc/conf/conf.xml:
+	  Added new config file.
+
 2012-01-05  Ingo Weinzierl <ingo@intevation.de>
 
 	flys/issue444 (error_no_export_found bei "W bei ungleichwertigem Abfluss")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/doc/conf/artifacts/map.xml	Thu Jan 05 14:29:54 2012 +0000
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<artifact name="map">
+    <states>
+        <state id="state.map.new" description="state.map.new" state="de.intevation.flys.artifacts.MapArtifact$MapState">
+            <data name="river" type="String" />
+            <outputmodes>
+                <outputmode name="floodmap" description="output.uesk.map.description" type="map">
+                    <facets>
+                        <facet name="floodmap.wsplgen"/>
+                        <facet name="floodmap.barriers"/>
+                        <facet name="floodmap.riveraxis"/>
+                        <facet name="floodmap.wmsbackground"/>
+                        <facet name="floodmap.kms"/>
+                        <facet name="floodmap.qps"/>
+                        <facet name="floodmap.hws"/>
+                        <facet name="floodmap.catchment"/>
+                        <facet name="floodmap.floodplain"/>
+                        <facet name="floodmap.lines"/>
+                        <facet name="floodmap.buildings"/>
+                        <facet name="floodmap.fixpoints"/>
+                        <facet name="floodmap.externalwms"/>
+                    </facets>
+                </outputmode>
+            </outputmodes>
+        </state>
+    </states>
+</artifact>
--- a/flys-artifacts/doc/conf/conf.xml	Thu Jan 05 14:15:07 2012 +0000
+++ b/flys-artifacts/doc/conf/conf.xml	Thu Jan 05 14:29:54 2012 +0000
@@ -17,6 +17,9 @@
             <artifact-factory name="riveraxis" description="Factory to create an artifact to be used in WINFO"
                 ttl="3600000"
                 artifact="de.intevation.flys.artifacts.RiverAxisArtifact">de.intevation.artifactdatabase.DefaultArtifactFactory</artifact-factory>
+            <artifact-factory name="map" description="Factory to create an artifact to be used for new map"
+                ttl="3600000"
+                artifact="de.intevation.flys.artifacts.MapArtifact">de.intevation.artifactdatabase.DefaultArtifactFactory</artifact-factory>
             <artifact-factory name="wmskmfactory" description="Factory to create an artifact that generates WMS facets for KMs."
                 ttl="3600000"
                 artifact="de.intevation.flys.artifacts.WMSKmArtifact">de.intevation.artifactdatabase.DefaultArtifactFactory</artifact-factory>
@@ -119,6 +122,7 @@
         <artifact name="waterlevel" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="${artifacts.config.dir}/artifacts/waterlevel.xml" />
         <artifact name="annotation" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="${artifacts.config.dir}/artifacts/annotation.xml" />
         <artifact name="wmsbackground" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="${artifacts.config.dir}/artifacts/wmsbackground.xml" />
+        <artifact name="map" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="${artifacts.config.dir}/artifacts/map.xml" />
     </artifacts>
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MapArtifact.java	Thu Jan 05 14:29:54 2012 +0000
@@ -0,0 +1,137 @@
+package de.intevation.flys.artifacts;
+
+import org.apache.log4j.Logger;
+
+import java.util.List;
+
+import org.w3c.dom.Document;
+
+import de.intevation.artifacts.ArtifactFactory;
+import de.intevation.artifacts.CallMeta;
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.artifactdatabase.state.DefaultOutput;
+import de.intevation.artifactdatabase.state.Facet;
+import de.intevation.artifactdatabase.state.State;
+
+import de.intevation.flys.artifacts.model.WMSDBLayerFacet;
+
+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;
+import de.intevation.flys.utils.GeometryUtils;
+
+
+public class MapArtifact extends RiverAxisArtifact {
+
+    private static final Logger logger =
+        Logger.getLogger(MapArtifact.class);
+
+    @Override
+    public void setup(
+        String          identifier,
+        ArtifactFactory factory,
+        Object          context,
+        CallMeta        callmeta,
+        Document        data)
+    {
+        logger.debug("MapArtifact.setup");
+        this.identifier = identifier;
+    }
+
+    @Override
+    public State getCurrentState(Object cc) {
+        logger.debug("MapArtifact.getCurrentState");
+
+        State state = new MapState(this);
+        List<Facet> fs = facets.get(getCurrentStateId());
+
+        DefaultOutput o = new DefaultOutput(
+            "floodmap",
+            "floodmap",
+            "image/png",
+            fs,
+            "map");
+
+        state.getOutputs().add(o);
+
+        return state;
+    }
+
+
+    @Override
+    public String getCurrentStateId() {
+        return "state.map.new";
+    }
+
+
+    public static class MapState extends RiverAxisState {
+
+        public MapState() {
+        }
+
+        public MapState(MapArtifact artifact) {
+            super(artifact);
+            this.id = "state.map.new";
+        }
+
+        @Override
+        public Object computeInit(
+            FLYSArtifact artifact,
+            String       hash,
+            Object       context,
+            CallMeta     meta,
+            List<Facet>  facets)
+        {
+            return null;
+        }
+
+        @Override
+        public Object computeFeed(
+            FLYSArtifact artifact,
+            String       hash,
+            CallContext  context,
+            List<Facet>  facets,
+            Object       old)
+        {
+            logger.debug("MapState.computeFeed");
+
+            String type = getFacetType();
+
+            WMSDBLayerFacet facet = new WMSDBLayerFacet(
+                0,
+                type,
+                getTitle(context.getMeta()),
+                ComputeType.FEED,
+                getID(), hash,
+                getUrl());
+
+            String name = type + "-" + artifact.identifier();
+
+            facet.addLayer(name);
+            facet.setExtent(getExtent());
+            facet.setSrid(getSrid());
+            facet.setData(getDataString());
+            facet.setFilter(getFilter());
+            facet.setGeometryType(getGeometryType());
+            facet.setConnection(getConnection());
+            facet.setConnectionType(getConnectionType());
+            facet.setLabelItem(getLabelItem());
+
+            facets.add(facet);
+
+            return null;
+        }
+
+        @Override
+        public int getRiverId() {
+            River r = FLYSUtils.getRiver(artifact);
+            int riverId = r.getId();
+
+            return riverId;
+        }
+    }
+}
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java	Thu Jan 05 14:15:07 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java	Thu Jan 05 14:29:54 2012 +0000
@@ -81,6 +81,8 @@
         protected Geometry geom;
         protected int      riverId;
 
+        public RiverAxisState(){}
+
         public RiverAxisState(WMSDBArtifact artifact) {
             super(artifact);
             riverId = 0;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java	Thu Jan 05 14:15:07 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java	Thu Jan 05 14:29:54 2012 +0000
@@ -105,6 +105,8 @@
 
         protected WMSDBArtifact artifact;
 
+        public WMSDBState() {}
+
         public WMSDBState(WMSDBArtifact artifact) {
             this.artifact = artifact;
         }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java	Thu Jan 05 14:15:07 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java	Thu Jan 05 14:29:54 2012 +0000
@@ -270,11 +270,14 @@
         Element maxExtent = c.create("maxExtent");
         maxExtent.setTextContent(mE);
 
-        String iE = GeometryUtils.jtsBoundsToOLBounds(this.initialExtent);
-        logger.debug("BUILD INITIAL EXTENT OF: " + this.initialExtent);
-        logger.debug("BUILD INITIAL EXTENT: " + iE);
-        Element initExtent = c.create("initialExtent");
-        initExtent.setTextContent(iE);
+        if(this.initialExtent != null) {
+            String iE = GeometryUtils.jtsBoundsToOLBounds(this.initialExtent);
+            logger.debug("BUILD INITIAL EXTENT OF: " + this.initialExtent);
+            logger.debug("BUILD INITIAL EXTENT: " + iE);
+            Element initExtent = c.create("initialExtent");
+            initExtent.setTextContent(iE);
+            parent.appendChild(initExtent);
+        }
 
         Element srid = c.create("srid");
         srid.setTextContent(this.srid);
@@ -283,7 +286,6 @@
         // TODO resolutation
 
         parent.appendChild(maxExtent);
-        parent.appendChild(initExtent);
         parent.appendChild(srid);
     }
 

http://dive4elements.wald.intevation.org