[Dive4elements-commits] [PATCH 3 of 3] Add a new mechanism in mapfish print call to add arbitary data maps

Wald Commits scm-commit at wald.intevation.org
Tue Apr 9 19:04:37 CEST 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1365527072 -7200
# Node ID b28a6d05e969873a8958e30c32d72b192d222ded
# Parent  bbc85c8f330ac185975577d559c4a5747efdd68f
Add a new mechanism in mapfish print call to add arbitary data maps

    Data properties are identified by starting with mapfish-data
    and they are then split in info value pairs where info
    can be the description of the information and value the value
    of the information to be transported in the data map.

diff -r bbc85c8f330a -r b28a6d05e969 flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintPanel.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintPanel.java	Tue Apr 09 19:01:23 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintPanel.java	Tue Apr 09 19:04:32 2013 +0200
@@ -33,13 +33,13 @@
 public class MapPrintPanel extends Canvas {
 
     private static final String MAPFISH_MAPTITLE = "mapfish-mapTitle";
-    private static final String MAPFISH_RANGE = "mapfish-range";
-    private static final String MAPFISH_SUBTITLE = "mapfish-subtitle";
-    private static final String MAPFISH_STRETCH = "mapfish-strech";
-    private static final String MAPFISH_CREATED = "mapfish-created";
-    private static final String MAPFISH_SOURCE = "mapfish-source";
-    private static final String MAPFISH_CREATOR = "mapfish-creator";
-    private static final String MAPFISH_DATEPLACE = "mapfish-dateplace";
+    private static final String MAPFISH_RANGE = "mapfish-data-range";
+    private static final String MAPFISH_SUBTITLE = "mapfish-data-subtitle";
+    private static final String MAPFISH_STRETCH = "mapfish-data-strech";
+    private static final String MAPFISH_CREATED = "mapfish-data-created";
+    private static final String MAPFISH_SOURCE = "mapfish-data-source";
+    private static final String MAPFISH_CREATOR = "mapfish-data-creator";
+    private static final String MAPFISH_DATEPLACE = "mapfish-data-dateplace";
 
     protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
 
diff -r bbc85c8f330a -r b28a6d05e969 flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java
--- a/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java	Tue Apr 09 19:01:23 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java	Tue Apr 09 19:04:32 2013 +0200
@@ -261,14 +261,34 @@
 
         // Retrieve print settings from request
         Map<String, Object> pageSpecs = new HashMap<String, Object>();
+        Map<String, Object> data = new HashMap<String, Object>();
+        List<Object> payload = new ArrayList<Object>();
+        data.put("data", payload);
         Enumeration<String> paramNames = req.getParameterNames();
         while (paramNames.hasMoreElements()) {
             String paramName = paramNames.nextElement();
-            if (paramName.startsWith("mapfish-")) {
+            if (paramName.startsWith("mapfish-data-")) {
+                // You can add mapfish-data variables that will be mapped
+                // to a info value pairs to provide meta data for the map
+                String paramValue = req.getParameter(paramName);
+                if (paramValue != null && !paramValue.isEmpty()) {
+                    Map<String, Object> data3 = new HashMap<String, Object>();
+                    data3.put("info", paramName.substring(13));
+                    data3.put("value", paramValue);
+                    payload.add(data3);
+                }
+            } else if (paramName.startsWith("mapfish-")) {
                 String paramValue = req.getParameter(paramName);
                 pageSpecs.put(paramName.substring(8), paramValue);
             }
         }
+        if (!payload.isEmpty()) {
+            pageSpecs.put("data", data);
+            List<Object> columns = new ArrayList<Object>();
+            columns.add("info");
+            columns.add("value");
+            data.put("columns", columns);
+        }
 
         String url = getURL();
 
diff -r bbc85c8f330a -r b28a6d05e969 flys-client/src/main/webapp/WEB-INF/config.yaml
--- a/flys-client/src/main/webapp/WEB-INF/config.yaml	Tue Apr 09 19:01:23 2013 +0200
+++ b/flys-client/src/main/webapp/WEB-INF/config.yaml	Tue Apr 09 19:04:32 2013 +0200
@@ -99,9 +99,9 @@
   A4 landscape:
   #===========================================================================
     metaData:
-      title: '${title}'
+      title: '${mapTitle}'
       author: 'Flusshydrologische Software'
-      subject: 'Kartendruck A4 Quer'
+      subject: 'Kartendruck'
       keywords: 'map,print'
       creator: 'd4e-river'
 
@@ -164,7 +164,7 @@
           width: 200
           items:
             - !legends
-              maxHeight: 0
+              maxHeight: 400
               maxWidth: 0
               maxIconHeight: 0
               inline: false
@@ -183,3 +183,38 @@
             borderWidthRight: 1
             borderWidthTop: 0
             borderWidthBottom: 1
+        # The Stamp
+        - !columns
+          absoluteX: 612
+          absoluteY: 200
+          width: 200
+          config:
+            borderWidthLeft: 1
+            borderWidthRight: 1
+            borderWidthTop: 1
+            borderWidthBottom: 1
+          items:
+            - !attributes
+              source: data
+              spacingAfter: 30
+              columnDefs:
+                info:
+                  columnWeight: 2
+                  header: !text
+                    text: Info
+                    backgroundColor: #A0A0A0
+                  cell: !text
+                    text: '${info}'
+                value:
+                  columnWeight: 5
+                  header: !text
+                    text: value
+                    backgroundColor: #A0A0A0
+                  cell: !columns
+                    config:
+                      cells:
+                        - borderWidth: 1
+                    items:
+                      - !text
+                        text: '${value}'
+


More information about the Dive4elements-commits mailing list