diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSHydrBoundaryPolyArtifact.java @ 5515:87dab419b924

Properly handle hydr_boundaries and hydr_boundaries_poly in datacage This also fixes hydr_boundaries_poly which refered to the wrong table
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 28 Mar 2013 17:13:53 +0100
parents a2735a4bf75e
children
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSHydrBoundaryPolyArtifact.java	Thu Mar 28 15:56:24 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSHydrBoundaryPolyArtifact.java	Thu Mar 28 17:13:53 2013 +0100
@@ -102,8 +102,31 @@
 
         @Override
         protected Envelope getExtent(boolean reproject) {
-            List<HydrBoundaryPoly> boundaries = HydrBoundaryPoly.getHydrBoundaries(
-                getRiverId(), getName());
+            String kind = getIdPart(2);
+            String sectie = getIdPart(3);
+            String sobek = getIdPart(4);
+            int kindId = -1;
+            int sectieId = -1;
+            int sobekId = -1;
+
+            if (kind != null) {
+                kindId = Integer.parseInt(kind);
+            }
+            if (sectie != null && !sectie.equals("-1")) {
+                sectieId = Integer.parseInt(sectie);
+            }
+            if (sobek != null && !sobek.equals("-1")) {
+                sobekId = Integer.parseInt(sobek);
+            }
+
+            List<HydrBoundaryPoly> boundaries;
+            if (kindId == -1 && sobekId == -1 && sectieId == -1) {
+                boundaries = HydrBoundaryPoly.getHydrBoundaries(
+                        getRiverId(), getName());
+            } else {
+                boundaries = HydrBoundaryPoly.getHydrBoundaries(
+                        getRiverId(), kindId, sectieId, sobekId);
+            }
 
             Envelope max = null;
 
@@ -125,8 +148,29 @@
 
         @Override
         protected String getFilter() {
+            // Expected id string:
+            // river_id;layer_name;kind;sectie;sobek
+            String kind = getIdPart(2);
+            String sectie = getIdPart(3);
+            String sobek = getIdPart(4);
+
+            String filter = "";
+            if (kind != null && !kind.equals("-1")) {
+                filter += " AND kind = " + kind;
+            }
+            if (sectie != null && !sectie.equals("-1")) {
+                filter += " AND sectie = " + sectie;
+            }
+            if (sobek != null && !sobek.equals("-1")) {
+                filter += " AND sobek = " + sobek;
+            }
+
+            if (filter.isEmpty()) {
+                filter = " AND name='" + getName() + "'";
+            }
+
             return "river_id=" + String.valueOf(getRiverId())
-                + " AND name='" + getName() + "'";
+                + filter;
         }
 
         @Override
@@ -134,10 +178,10 @@
             String srid = getSrid();
 
             if (FLYSUtils.isUsingOracle()) {
-                return "geom FROM hydr_boundaries USING SRID " + srid;
+                return "geom FROM hydr_boundaries_poly USING SRID " + srid;
             }
             else {
-                return "geom FROM hydr_boundaries USING UNIQUE id USING SRID " + srid;
+                return "geom FROM hydr_boundaries_poly USING UNIQUE id USING SRID " + srid;
             }
         }
 

http://dive4elements.wald.intevation.org