Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java @ 4474:bd78d2b0e309
Map print settings can now be configured via settings window.
Configurable for now are page layout (A0 or A4), caption text and
comment text.
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Sun, 11 Nov 2012 14:44:12 +0100 |
parents | 6db783627137 |
children | f8ed8114f415 |
comparison
equal
deleted
inserted
replaced
4473:6db783627137 | 4474:bd78d2b0e309 |
---|---|
17 import java.io.OutputStream; | 17 import java.io.OutputStream; |
18 import java.io.UnsupportedEncodingException; | 18 import java.io.UnsupportedEncodingException; |
19 import java.net.URLEncoder; | 19 import java.net.URLEncoder; |
20 import java.util.ArrayList; | 20 import java.util.ArrayList; |
21 import java.util.Collections; | 21 import java.util.Collections; |
22 import java.util.Enumeration; | |
22 import java.util.HashMap; | 23 import java.util.HashMap; |
23 import java.util.LinkedHashMap; | 24 import java.util.LinkedHashMap; |
24 import java.util.List; | 25 import java.util.List; |
25 import java.util.Map; | 26 import java.util.Map; |
26 | 27 |
122 protected static String generateSpec( | 123 protected static String generateSpec( |
123 Document descDocument, | 124 Document descDocument, |
124 MapConfig mapConfig, | 125 MapConfig mapConfig, |
125 Double minX, Double minY, | 126 Double minX, Double minY, |
126 Double maxX, Double maxY, | 127 Double maxX, Double maxY, |
127 Map<String, Object> settings | 128 Map<String, Object> pageSpecs |
128 ) { | 129 ) { |
129 Map<String, Object> spec = new LinkedHashMap<String, Object>(); | 130 Map<String, Object> spec = new LinkedHashMap<String, Object>(); |
130 spec.put("layout", "A4 portrait"); | 131 spec.put("pageSize", "A4"); |
132 spec.put("landscape", "false"); | |
131 spec.put("title", "FLYS Druck"); | 133 spec.put("title", "FLYS Druck"); |
132 spec.put("srs", "EPSG:" + mapConfig.getSrid()); | 134 spec.put("srs", "EPSG:" + mapConfig.getSrid()); |
133 spec.put("dpi", Integer.valueOf(254)); | 135 spec.put("dpi", Integer.valueOf(254)); |
134 spec.put("units", "m"); | 136 spec.put("units", "m"); |
135 spec.put("geodaetic", "true"); | 137 spec.put("geodaetic", "true"); |
136 spec.put("outputFormat", "pdf"); | 138 spec.put("outputFormat", "pdf"); |
137 | 139 |
140 spec.putAll(pageSpecs); | |
141 | |
138 String ns = ArtifactNamespaceContext.NAMESPACE_URI; | 142 String ns = ArtifactNamespaceContext.NAMESPACE_URI; |
139 | 143 |
140 List<Layer> ls = new ArrayList<Layer>(); | 144 List<Layer> ls = new ArrayList<Layer>(); |
141 Layer l = new Layer(); | 145 Layer l = new Layer(); |
142 | 146 |
185 page.put("mapTitle", "FLYS Karte"); | 189 page.put("mapTitle", "FLYS Karte"); |
186 page.put("comment", "Eine mit FLYS gedruckte Karte."); | 190 page.put("comment", "Eine mit FLYS gedruckte Karte."); |
187 page.put("rotation", Integer.valueOf(0)); | 191 page.put("rotation", Integer.valueOf(0)); |
188 | 192 |
189 // This may overwrite default settings above | 193 // This may overwrite default settings above |
190 page.putAll(settings); | 194 page.putAll(pageSpecs); |
191 | 195 |
192 pages.add(page); | 196 pages.add(page); |
193 spec.put("pages", pages); | 197 spec.put("pages", pages); |
194 | 198 |
195 List<Object> legends = new ArrayList<Object>(layers.size()); | 199 List<Object> legends = new ArrayList<Object>(layers.size()); |
254 if (mapType == null || !mapType.equals("floodmap")) { | 258 if (mapType == null || !mapType.equals("floodmap")) { |
255 mapType = "map"; | 259 mapType = "map"; |
256 } | 260 } |
257 | 261 |
258 // Retrieve print settings from request | 262 // Retrieve print settings from request |
259 Map<String, Object> settings = new HashMap<String, Object>(); | 263 Map<String, Object> pageSpecs = new HashMap<String, Object>(); |
260 String pageTitle = req.getParameter("page-title"); | 264 Enumeration<String> paramNames = req.getParameterNames(); |
261 settings.put("mapTitle", pageTitle); | 265 while (paramNames.hasMoreElements()) { |
266 String paramName = paramNames.nextElement(); | |
267 if (paramName.startsWith("mapfish-")) { | |
268 String paramValue = req.getParameter(paramName); | |
269 pageSpecs.put(paramName.substring(8), paramValue); | |
270 } | |
271 } | |
262 | 272 |
263 String url = getURL(); | 273 String url = getURL(); |
264 | 274 |
265 Document requestOut = | 275 Document requestOut = |
266 ClientProtocolUtils.newOutCollectionDocument( | 276 ClientProtocolUtils.newOutCollectionDocument( |
323 String spec = generateSpec( | 333 String spec = generateSpec( |
324 descDocument, | 334 descDocument, |
325 mapConfig, | 335 mapConfig, |
326 minX, minY, | 336 minX, minY, |
327 maxX, maxY, | 337 maxX, maxY, |
328 settings); | 338 pageSpecs); |
329 | 339 |
330 if (log.isDebugEnabled()) { | 340 if (log.isDebugEnabled()) { |
331 log.debug("Generated spec:"); | 341 log.debug("Generated spec:"); |
332 log.debug(spec); | 342 log.debug(spec); |
333 //System.err.println(spec); | 343 //System.err.println(spec); |