comparison gwt-client/src/main/java/org/dive4elements/river/client/server/MapPrintServiceImpl.java @ 9755:0834c2591e14 3.2.x

Route MapServer through wiki container This reduces the need for local configuration changes to get a working Docker-based setup.
author Tom Gottfried <tom@intevation.de>
date Wed, 12 Oct 2022 12:53:36 +0200
parents 0a5239a1e46e
children 2a78ac6c8045
comparison
equal deleted inserted replaced
9754:cd07130ded8d 9755:0834c2591e14
22 22
23 import java.io.IOException; 23 import java.io.IOException;
24 import java.io.InputStream; 24 import java.io.InputStream;
25 import java.io.OutputStream; 25 import java.io.OutputStream;
26 import java.io.UnsupportedEncodingException; 26 import java.io.UnsupportedEncodingException;
27 import java.net.MalformedURLException;
28 import java.net.URL;
27 import java.net.URLEncoder; 29 import java.net.URLEncoder;
28 import java.util.ArrayList; 30 import java.util.ArrayList;
29 import java.util.Collections; 31 import java.util.Collections;
30 import java.util.Enumeration; 32 import java.util.Enumeration;
31 import java.util.HashMap; 33 import java.util.HashMap;
74 protected String description; 76 protected String description;
75 77
76 public Layer() { 78 public Layer() {
77 } 79 }
78 80
79 public boolean setup(Element element) { 81 public boolean setup(Element element, HttpServletRequest req) {
80 82
81 Element parent = (Element)element.getParentNode(); 83 Element parent = (Element)element.getParentNode();
82 String parentName = parent.getAttribute("name"); 84 String parentName = parent.getAttribute("name");
83 if (!(parentName.equals("map") 85 if (!(parentName.equals("map")
84 || parentName.equals("floodmap"))) { 86 || parentName.equals("floodmap"))) {
92 94
93 if (visible.equals("0") || active.equals("0")) { 95 if (visible.equals("0") || active.equals("0")) {
94 return false; 96 return false;
95 } 97 }
96 98
97 url = element.getAttributeNS(ns, "url"); 99 url = element.getAttributeNS(ns, "url");
100 try {
101 // if given URL is not absolute, complement it
102 url = new URL(new URL(req.getRequestURL().toString()),
103 url).toString();
104 } catch (MalformedURLException mue) {
105 log.error("Failed to complement layer URL: "
106 + mue.getMessage());
107 }
98 layers = element.getAttributeNS(ns, "layers"); 108 layers = element.getAttributeNS(ns, "layers");
99 description = element.getAttributeNS(ns, "description"); 109 description = element.getAttributeNS(ns, "description");
100 110
101 try { 111 try {
102 pos = Integer.parseInt(element.getAttributeNS(ns, "pos")); 112 pos = Integer.parseInt(element.getAttributeNS(ns, "pos"));
132 return d > 0 ? +1 : 0; 142 return d > 0 ? +1 : 0;
133 } 143 }
134 } // class Layer 144 } // class Layer
135 145
136 protected static String generateSpec( 146 protected static String generateSpec(
147 HttpServletRequest req,
137 Document descDocument, 148 Document descDocument,
138 MapConfig mapConfig, 149 MapConfig mapConfig,
139 Double minX, Double minY, 150 Double minX, Double minY,
140 Double maxX, Double maxY, 151 Double maxX, Double maxY,
141 Map<String, Object> pageSpecs 152 Map<String, Object> pageSpecs
160 171
161 NodeList facets = descDocument.getElementsByTagNameNS(ns, "facet"); 172 NodeList facets = descDocument.getElementsByTagNameNS(ns, "facet");
162 173
163 for (int i = 0, N = facets.getLength(); i < N; ++i) { 174 for (int i = 0, N = facets.getLength(); i < N; ++i) {
164 Element element = (Element)facets.item(i); 175 Element element = (Element)facets.item(i);
165 if (l.setup(element)) { 176 if (l.setup(element, req)) {
166 ls.add(l); 177 ls.add(l);
167 l = new Layer(); 178 l = new Layer();
168 } 179 }
169 } 180 }
170 181
376 log.debug("minY: " + minY); 387 log.debug("minY: " + minY);
377 log.debug("maxY: " + maxY); 388 log.debug("maxY: " + maxY);
378 } 389 }
379 390
380 String spec = generateSpec( 391 String spec = generateSpec(
392 req,
381 descDocument, 393 descDocument,
382 mapConfig, 394 mapConfig,
383 minX, minY, 395 minX, minY,
384 maxX, maxY, 396 maxX, maxY,
385 pageSpecs); 397 pageSpecs);

http://dive4elements.wald.intevation.org