[PATCH] flys/issue1485 Better titles for UESK layers

Wald Commits scm-commit at wald.intevation.org
Wed Sep 11 13:15:34 CEST 2013


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1378898130 -7200
# Node ID fc2de41ebdb87c647ce549ac323fb551a6af581f
# Parent  e562a9a42495bb6f3d8556f436cea27641e6f1d9
flys/issue1485 Better titles for UESK layers.

diff -r e562a9a42495 -r fc2de41ebdb8 artifacts/src/main/java/org/dive4elements/river/artifacts/access/RangeAccess.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/access/RangeAccess.java	Wed Sep 11 11:41:29 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/access/RangeAccess.java	Wed Sep 11 13:15:30 2013 +0200
@@ -111,6 +111,14 @@
         return locations.toNativeArray();
     }
 
+    public boolean hasFrom() {
+        return from != null || (from = getDouble("ld_from")) != null;
+    }
+
+    public boolean hasTo() {
+        return to != null || (to = getDouble("ld_to")) != null;
+    }
+
 
     /** Return ld_from data (in km). */
     public double getFrom() {
diff -r e562a9a42495 -r fc2de41ebdb8 artifacts/src/main/java/org/dive4elements/river/utils/ArtifactMapfileGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/utils/ArtifactMapfileGenerator.java	Wed Sep 11 11:41:29 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/utils/ArtifactMapfileGenerator.java	Wed Sep 11 13:15:30 2013 +0200
@@ -10,7 +10,7 @@
 
 import org.dive4elements.artifacts.CallContext;
 import org.dive4elements.river.artifacts.D4EArtifact;
-import org.dive4elements.river.artifacts.access.RiverAccess;
+import org.dive4elements.river.artifacts.access.RangeAccess;
 import org.dive4elements.river.artifacts.model.LayerInfo;
 import org.dive4elements.river.artifacts.model.map.WMSDBLayerFacet;
 import org.dive4elements.river.artifacts.model.map.WMSLayerFacet;
@@ -33,6 +33,12 @@
 
     private static Logger logger = Logger.getLogger(ArtifactMapfileGenerator.class);
 
+    public static final String FLOODMAP_UESK_KEY =
+        "floodmap.uesk";
+
+    public static final String FLOODMAP_UESK_DEF =
+        "Floodmap: {0}-km {1,number,####} - {2,number,####} - {3}";
+
     @Override
     protected String getVelocityLogfile() {
         return RiverUtils.getXPathString(RiverUtils.XPATH_FLOODMAP_VELOCITY_LOGFILE);
@@ -78,17 +84,32 @@
     {
         logger.debug("createUeskLayer");
 
+        String identifier = flys.identifier();
+
+        RangeAccess access = new RangeAccess(flys);
+
         LayerInfo layerinfo = new LayerInfo();
-        layerinfo.setName(MS_WSPLGEN_PREFIX + flys.identifier());
+        layerinfo.setName(MS_WSPLGEN_PREFIX + identifier);
         layerinfo.setType("POLYGON");
-        layerinfo.setDirectory(flys.identifier());
+        layerinfo.setDirectory(identifier);
         layerinfo.setData(WSPLGEN_RESULT_SHAPE);
-        layerinfo.setTitle(Resources.getMsg(Resources.getLocale(context.getMeta()),
-                                            "floodmap.uesk",
-                                            "Floodmap"));
+
+        String river = access.getRiver();
+
+        double from = access.hasFrom() ? access.getFrom() : 0d;
+        double to   = access.hasTo()   ? access.getTo()   : 0d;
+
+        String title = Resources.format(
+            context.getMeta(),
+            FLOODMAP_UESK_KEY,
+            FLOODMAP_UESK_DEF,
+            river,
+            from, to,
+            identifier);
+
+        layerinfo.setTitle(title);
+
         layerinfo.setStyle(style);
-        RiverAccess access = new RiverAccess(flys);
-        String river = access.getRiver();
         layerinfo.setSrid(RiverUtils.getRiverDGMSrid(river));
 
         String name = MS_LAYER_PREFIX + wms.getName();
@@ -100,7 +121,7 @@
         }
 
         try {
-            File dir = new File(getShapefileBaseDir(), flys.identifier());
+            File dir = new File(getShapefileBaseDir(), identifier);
             writeLayer(layerinfo, new File(dir, name), template);
         }
         catch (FileNotFoundException fnfe) {
@@ -230,13 +251,12 @@
     }
 
     @Override
-        protected String getMapfilePath() {
-            return RiverUtils.getXPathString(RiverUtils.XPATH_FLOODMAP_MAPFILE_PATH);
-        }
+    protected String getMapfilePath() {
+        return RiverUtils.getXPathString(RiverUtils.XPATH_FLOODMAP_MAPFILE_PATH);
+    }
 
     @Override
-        protected String getMapfileTemplate() {
-            return RiverUtils.getXPathString(RiverUtils.XPATH_FLOODMAP_MAPFILE_TEMPLATE);
-        }
-
+    protected String getMapfileTemplate() {
+        return RiverUtils.getXPathString(RiverUtils.XPATH_FLOODMAP_MAPFILE_TEMPLATE);
+    }
 }
diff -r e562a9a42495 -r fc2de41ebdb8 artifacts/src/main/resources/messages.properties
--- a/artifacts/src/main/resources/messages.properties	Wed Sep 11 11:41:29 2013 +0200
+++ b/artifacts/src/main/resources/messages.properties	Wed Sep 11 13:15:30 2013 +0200
@@ -426,7 +426,7 @@
 
 floodmap.wmsbackground = Background Map
 floodmap.riveraxis = River Axis
-floodmap.uesk = Floodmap: {0}-km {1,number,####} - {2,number,####}
+floodmap.uesk = Floodmap: {0}-km {1,number,####} - {2,number,####} - {3}
 floodmap.barriers = Digitized Objects
 floodmap.kms = Kilometrage
 floodmap.qps = Crosssection Tracks
diff -r e562a9a42495 -r fc2de41ebdb8 artifacts/src/main/resources/messages_de.properties
--- a/artifacts/src/main/resources/messages_de.properties	Wed Sep 11 11:41:29 2013 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Wed Sep 11 13:15:30 2013 +0200
@@ -426,7 +426,7 @@
 
 floodmap.wmsbackground = Hintergrundkarte
 floodmap.riveraxis = Flussachse
-floodmap.uesk = \u00dcSG: {0}-km {1,number,####} - {2,number,####}
+floodmap.uesk = \u00dcSG: {0}-km {1,number,####} - {2,number,####} - {3}
 floodmap.barriers = Digitalisierte Objekte
 floodmap.kms = Kilometrierung
 floodmap.qps = Querprofilspuren
diff -r e562a9a42495 -r fc2de41ebdb8 artifacts/src/main/resources/messages_de_DE.properties
--- a/artifacts/src/main/resources/messages_de_DE.properties	Wed Sep 11 11:41:29 2013 +0200
+++ b/artifacts/src/main/resources/messages_de_DE.properties	Wed Sep 11 13:15:30 2013 +0200
@@ -423,7 +423,7 @@
 
 floodmap.wmsbackground = Hintergrundkarte
 floodmap.riveraxis = Flussachse
-floodmap.uesk = \u00dcSG: {0}-km {1,number,####} - {2,number,####}
+floodmap.uesk = \u00dcSG: {0}-km {1,number,####} - {2,number,####} - {3}
 floodmap.barriers = Digitalisierte Objekte
 floodmap.kms = Kilometrierung
 floodmap.qps = Querprofilspuren
diff -r e562a9a42495 -r fc2de41ebdb8 artifacts/src/main/resources/messages_en.properties
--- a/artifacts/src/main/resources/messages_en.properties	Wed Sep 11 11:41:29 2013 +0200
+++ b/artifacts/src/main/resources/messages_en.properties	Wed Sep 11 13:15:30 2013 +0200
@@ -429,7 +429,7 @@
 
 floodmap.wmsbackground = Background Map
 floodmap.riveraxis = River Axis
-floodmap.uesk = Floodmap: {0}-km {1,number,####} - {2,number,####}
+floodmap.uesk = Floodmap: {0}-km {1,number,####} - {2,number,####} - {3}
 floodmap.barriers = Digitized Objects
 floodmap.kms = Kilometrage
 floodmap.qps = Crosssection Tracks


More information about the Dive4elements-commits mailing list