changeset 5481:5187911f5d45

Merged
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 27 Mar 2013 20:19:32 +0100
parents 7a68967ca72a (current diff) 5bb3610b94f7 (diff)
children a5bb0a139f19
files
diffstat 9 files changed, 129 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/doc/conf/meta-data.xml	Wed Mar 27 20:19:09 2013 +0100
+++ b/flys-artifacts/doc/conf/meta-data.xml	Wed Mar 27 20:19:32 2013 +0100
@@ -1195,6 +1195,49 @@
                 </dc:if>
               </dc:context>
             </dc:macro>
+            <dc:macro name="flood-map-riveraxis">
+              <dc:context>
+                <dc:statement>
+                  SELECT DISTINCT
+                  ax.kind_id as kind_id,
+                  ak.name as kind_name
+                  FROM river_axes ax
+                  JOIN axis_kinds ak on ax.kind_id = ak.id
+                  WHERE river_id = ${river_id}
+                  AND kind_id=1
+                </dc:statement>
+                <dc:if test="dc:has-result()">
+                  <dc:elements>
+                    <actual factory="riveraxis">
+                      <dc:attribute name="description" value="${kind_name}"/>
+                      <dc:attribute name="ids" value="${river_id};${kind_name};${kind_id}"/>
+                    </actual>
+                  </dc:elements>
+                </dc:if>
+              </dc:context>
+              <dc:context>
+                <dc:statement>
+                  SELECT DISTINCT
+                  ak.name as kind_name,
+                  ax.kind_id as kind_id,
+                  ax.name as layer_name
+                  FROM river_axes ax
+                  JOIN axis_kinds ak on ax.kind_id = ak.id
+                  WHERE river_id = ${river_id}
+                  AND kind_id &lt;&gt; 1
+                </dc:statement>
+                <dc:if test="dc:has-result()">
+                  <other>
+                    <dc:elements>
+                      <misc-axis factory="riveraxis">
+                        <dc:attribute name="description" value="${layer_name}"/>
+                        <dc:attribute name="ids" value="${river_id};${layer_name};${kind_id}"/>
+                      </misc-axis>
+                    </dc:elements>
+                  </other>
+                </dc:if>
+              </dc:context>
+            </dc:macro>
             <dc:macro name="flood-map-hydr-boundaries">
               <hydr_boundaries_lines>
                 <dc:call-macro name="flood-map-hydr-boundaries-lines"/>
@@ -1745,10 +1788,9 @@
               </qps>
               <dc:call-macro name="flood-map-fixpoints"/>
               <dc:call-macro name="flood-map-km"/>
-              <riveraxis>
-                <dc:attribute name="factory" value="riveraxis"/>
-                <dc:attribute name="ids" value="${river_id}"/>
-              </riveraxis>
+              <axis>
+                <dc:call-macro name="flood-map-riveraxis"/>
+              </axis>
             </dc:macro>
 
             <dc:macro name="flood-map-complete">
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java	Wed Mar 27 20:19:09 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java	Wed Mar 27 20:19:32 2013 +0100
@@ -11,6 +11,7 @@
 import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.RiverFactory;
 import de.intevation.flys.model.River;
+import de.intevation.flys.model.RiverAxis;
 import de.intevation.flys.utils.FLYSUtils;
 import de.intevation.flys.utils.GeometryUtils;
 
@@ -80,23 +81,6 @@
 
         public RiverAxisState(FLYSArtifact artifact) {
             super(artifact);
-            riverId = 0;
-        }
-
-        @Override
-        public int getRiverId() {
-            if (riverId == 0) {
-                String ids = artifact.getDataAsString("ids");
-
-                try {
-                    riverId = Integer.parseInt(ids);
-                }
-                catch (NumberFormatException nfe) {
-                    logger.error("Cannot parse river id from '" + ids + "'");
-                }
-            }
-
-            return riverId;
         }
 
         @Override
@@ -123,23 +107,63 @@
         @Override
         protected Envelope getExtent(boolean reproject) {
             River river = RiverFactory.getRiver(getRiverId());
+            List<RiverAxis> axes;
 
-            if (reproject) {
-                logger.debug("Query extent for RiverAxis with Srid: " + getSrid());
-                return GeometryUtils.transform(
-                    GeometryUtils.getRiverBoundary(river.getName()),
-                    getSrid());
+            String kind = getIdPart(2);
+
+            if (kind != null && kind.equals("1")) {
+                axes = RiverAxis.getRiverAxis(river.getName(),
+                        Integer.parseInt(kind));
+            } else if (kind != null) {
+                axes = RiverAxis.getRiverAxis(river.getName(),
+                        getName(), Integer.parseInt(kind));
+            } else {
+                if (reproject) {
+                    logger.debug("Query extent for RiverAxis with Srid: " + getSrid());
+                    return GeometryUtils.transform(
+                            GeometryUtils.getRiverBoundary(river.getName()),
+                            getSrid());
+                } else {
+                    return GeometryUtils.transform(
+                            GeometryUtils.getRiverBoundary(river.getName()),
+                            "31467");
+                }
             }
-            else {
-                return GeometryUtils.transform(
-                    GeometryUtils.getRiverBoundary(river.getName()),
-                    "31467");
+
+            Envelope max = null;
+
+            for (RiverAxis ax: axes) {
+                Envelope env = ax.getGeom().getEnvelopeInternal();
+
+                if (max == null) {
+                    max = env;
+                    continue;
+                }
+
+                max.expandToInclude(env);
             }
+
+            return max != null && reproject
+                ? GeometryUtils.transform(max, getSrid())
+                : max;
         }
 
         @Override
         protected String getFilter() {
-            return "river_id=" + String.valueOf(getRiverId());
+            String kind = getIdPart(2);
+            if (kind != null && kind.equals("1")) {
+                return "river_id=" + String.valueOf(getRiverId()) +
+                    " AND kind_id=" + kind;
+            } else if (kind != null) {
+                return "river_id=" + String.valueOf(getRiverId()) +
+                    " AND kind_id=" + kind +
+                    " AND name='" + getName() + "'";
+            } else if (getIdPart(1) != null) {
+                return "river_id=" + String.valueOf(getRiverId()) +
+                    " AND name='" + getName() + "'";
+            }
+            return "river_id=" + String.valueOf(getRiverId()) +
+                " AND kind_id=" + kind;
         }
 
         @Override
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java	Wed Mar 27 20:19:09 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java	Wed Mar 27 20:19:32 2013 +0100
@@ -116,7 +116,7 @@
         } else {
             layerInfo.setData("geom FROM river_axes");
         }
-        layerInfo.setFilter("river_id = " + riverID);
+        layerInfo.setFilter("river_id = " + riverID + " and kind_id = 1");
         layerInfo.setTitle(riverName + " RiverAxis");
 
         File layerFile = new File("river-" + riverName + ".map");
--- a/flys-backend/doc/schema/oracle-minfo.sql	Wed Mar 27 20:19:09 2013 +0100
+++ b/flys-backend/doc/schema/oracle-minfo.sql	Wed Mar 27 20:19:32 2013 +0100
@@ -296,8 +296,7 @@
     CONSTRAINT fk_ms_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE,
     CONSTRAINT fk_ms_range_id FOREIGN KEY (range_id) REFERENCES ranges(id) ON DELETE CASCADE,
     CONSTRAINT fk_ms_reference_gauge_id FOREIGN KEY (reference_gauge_id) REFERENCES gauges(id) ON DELETE CASCADE,
-    CONSTRAINT fk_ms_observation_timerange_id FOREIGN KEY (observation_timerange_id) REFERENCES time_intervals(id),
-    UNIQUE (river_id, station)
+    CONSTRAINT fk_ms_observation_timerange_id FOREIGN KEY (observation_timerange_id) REFERENCES time_intervals(id)
 );
 
 
--- a/flys-backend/doc/schema/postgresql-minfo.sql	Wed Mar 27 20:19:09 2013 +0100
+++ b/flys-backend/doc/schema/postgresql-minfo.sql	Wed Mar 27 20:19:32 2013 +0100
@@ -296,8 +296,7 @@
     CONSTRAINT fk_ms_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE,
     CONSTRAINT fk_ms_range_id FOREIGN KEY (range_id) REFERENCES ranges(id) ON DELETE CASCADE,
     CONSTRAINT fk_ms_reference_gauge_id FOREIGN KEY (reference_gauge_id) REFERENCES gauges(id) ON DELETE CASCADE,
-    CONSTRAINT fk_ms_observation_timerange_id FOREIGN KEY (observation_timerange_id) REFERENCES time_intervals(id),
-    UNIQUE (river_id, station)
+    CONSTRAINT fk_ms_observation_timerange_id FOREIGN KEY (observation_timerange_id) REFERENCES time_intervals(id)
 );
 
 
--- a/flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java	Wed Mar 27 20:19:09 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java	Wed Mar 27 20:19:32 2013 +0100
@@ -34,6 +34,7 @@
     private Integer    id;
     private AxisKind   kind;
     private River      river;
+    private String     name;
     private MultiLineString geom;
 
     public static final int KIND_UNKOWN = 0;
@@ -67,6 +68,15 @@
         this.river = river;
     }
 
+    @Column(name = "name")
+    public String getName() {
+        return name;
+    }
+
+
+    public void setName(String name) {
+        this.name = name;
+    }
 
     /**
      * Get kind.
@@ -106,6 +116,21 @@
         return getRiverAxis(river, KIND_CURRENT);
     }
 
+    public static List<RiverAxis> getRiverAxis(String river, String name, int kind)
+    throws HibernateException {
+        Session session = SessionHolder.HOLDER.get();
+        Query query = session.createQuery(
+            "from RiverAxis as ax where river.name =:river" +
+            " and kind.id =:kind" +
+            " and ax.name=:name");
+        query.setParameter("river", river);
+        query.setParameter("kind", kind);
+        query.setParameter("name", name);
+
+        List<RiverAxis> list = query.list();
+        return list.isEmpty() ? null : list;
+    }
+
     public static List<RiverAxis> getRiverAxis(String river, int kind)
     throws HibernateException {
         Session session = SessionHolder.HOLDER.get();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Wed Mar 27 20:19:09 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Wed Mar 27 20:19:32 2013 +0100
@@ -1170,5 +1170,7 @@
 
     String other();
 
+    String axis();
+
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Wed Mar 27 20:19:09 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Wed Mar 27 20:19:32 2013 +0100
@@ -464,6 +464,7 @@
 jetties = Jetties
 route_data = Route Data
 other = Other
+axis = Axis
 
 startcolor = Colorrange start color
 endcolor = Colorrange end color
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Wed Mar 27 20:19:09 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Wed Mar 27 20:19:32 2013 +0100
@@ -465,6 +465,7 @@
 jetties = Buhnen
 route_data = Streckendaten
 other = Sonstige
+axis = Achse
 
 startcolor = Farbverlauf Startfarbe
 endcolor = Farbverlauf Endfarbe

http://dive4elements.wald.intevation.org