# HG changeset patch # User Sascha L. Teichmann # Date 1336580025 0 # Node ID 4861ab2c28d23d3f272cf169b72d0f2d1f30f1b1 # Parent 3952429cc41b6c131c8b4ca020f4c0fae5c31089 map print: add legend flys-client/trunk@4365 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 3952429cc41b -r 4861ab2c28d2 flys-client/ChangeLog --- a/flys-client/ChangeLog Wed May 09 13:15:26 2012 +0000 +++ b/flys-client/ChangeLog Wed May 09 16:13:45 2012 +0000 @@ -1,3 +1,12 @@ +2012-05-09 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java: + Generate legen via getlegendgraphic of the layers. Does not + look too pretty right now. + + * src/main/webapp/WEB-INF/config.yaml: Added legend block. We need + to learn how the layout really work to make it look pretty. + 2012-05-09 Sascha L. Teichmann * src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java: diff -r 3952429cc41b -r 4861ab2c28d2 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 Wed May 09 13:15:26 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java Wed May 09 16:13:45 2012 +0000 @@ -15,6 +15,7 @@ import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; import de.intevation.flys.client.shared.model.MapConfig; +import de.intevation.flys.client.shared.MapUtils; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; @@ -131,20 +132,22 @@ spec.put("srs", "EPSG:" + mapConfig.getSrid()); spec.put("dpi", Integer.valueOf(254)); spec.put("units", "m"); + spec.put("geodaetic", "true"); spec.put("outputFormat", "pdf"); - - List ls = new ArrayList(); - Layer l = new Layer(); - String ns = ArtifactNamespaceContext.NAMESPACE_URI; - NodeList facets = descDocument.getElementsByTagNameNS(ns, "facet"); - for (int i = 0, N = facets.getLength(); i < N; ++i) { - Element element = (Element)facets.item(i); - if (l.setup(element)) { - ls.add(l); - l = new Layer(); + List ls = new ArrayList(); + { Layer l = new Layer(); + + NodeList facets = descDocument.getElementsByTagNameNS(ns, "facet"); + + for (int i = 0, N = facets.getLength(); i < N; ++i) { + Element element = (Element)facets.item(i); + if (l.setup(element)) { + ls.add(l); + l = new Layer(); + } } } @@ -153,8 +156,8 @@ List layers = new ArrayList(ls.size()); - for (Layer layer: ls) { - layers.add(layer.toMap()); + for (int i = ls.size()-1; i >= 0; --i) { + layers.add(ls.get(i).toMap()); } spec.put("layers", layers); @@ -162,23 +165,47 @@ List pages = new ArrayList(1); - spec.put("pages", pages); Map page = new LinkedHashMap(); List bounds = new ArrayList(4); - bounds.add(Double.valueOf(minX)); - bounds.add(Double.valueOf(minY)); - bounds.add(Double.valueOf(maxX)); - bounds.add(Double.valueOf(maxY)); + bounds.add(minX); + bounds.add(minY); + bounds.add(maxX); + bounds.add(maxY); + page.put("bbox", bounds); - page.put("bbox", bounds); + /* + bounds.add(Double.valueOf((minX+maxX)*0.5)); + bounds.add(Double.valueOf((minY+maxY)*0.5)); + + page.put("center", bounds); + page.put("scale", Integer.valueOf(50000)); + */ page.put("mapTitle", "FLYS Karte"); page.put("comment", "Eine mit FLYS gedruckte Karte."); page.put("rotation", Integer.valueOf(0)); pages.add(page); + spec.put("pages", pages); + + List legends = new ArrayList(layers.size()); + + for (Layer layer: ls) { + Map legend = new LinkedHashMap(); + List classes = new ArrayList(1); + Map clazz = new LinkedHashMap(); + String lgu = MapUtils.getLegendGraphicUrl(layer.url, layer.layers); + clazz.put("icon", lgu); + clazz.put("name", layer.description); + classes.add(clazz); + legend.put("classes", classes); + legend.put("name", layer.description); + legends.add(legend); + } + + spec.put("legends", legends); return JSON.toJSONString(spec); } @@ -277,6 +304,12 @@ throw new ServletException(nfe); } } + if (log.isDebugEnabled()) { + log.debug("minX: " + minX); + log.debug("maxX: " + maxX); + log.debug("minY: " + minY); + log.debug("maxY: " + maxY); + } String spec = generateSpec( descDocument, @@ -285,6 +318,7 @@ maxX, maxY); if (log.isDebugEnabled()) { + log.debug("Generated spec:"); log.debug(spec); //System.err.println(spec); } diff -r 3952429cc41b -r 4861ab2c28d2 flys-client/src/main/webapp/WEB-INF/config.yaml --- a/flys-client/src/main/webapp/WEB-INF/config.yaml Wed May 09 13:15:26 2012 +0000 +++ b/flys-client/src/main/webapp/WEB-INF/config.yaml Wed May 09 16:13:45 2012 +0000 @@ -175,4 +175,8 @@ fontSize: 9 align: right text: '1:${scale} ${now MM.dd.yyyy}' + - !legends + align: left + maxIconWidth: 32 + maxIconHeight: 32 footer: *commonFooter