changeset 6988:fc2de41ebdb8

flys/issue1485 Better titles for UESK layers.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 11 Sep 2013 13:15:30 +0200
parents e562a9a42495
children 2b022ca95b3b
files artifacts/src/main/java/org/dive4elements/river/artifacts/access/RangeAccess.java artifacts/src/main/java/org/dive4elements/river/utils/ArtifactMapfileGenerator.java artifacts/src/main/resources/messages.properties artifacts/src/main/resources/messages_de.properties artifacts/src/main/resources/messages_de_DE.properties artifacts/src/main/resources/messages_en.properties
diffstat 6 files changed, 48 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- 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() {
--- 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);
+    }
 }
--- 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
--- 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
--- 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
--- 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

http://dive4elements.wald.intevation.org