Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/MapInfoServiceImpl.java @ 4741:f6d0ad25f1ee
Merged
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 02 Jan 2013 15:42:22 +0100 |
parents | 5014a84c0c7d |
children |
comparison
equal
deleted
inserted
replaced
4740:fb135e1dfa35 | 4741:f6d0ad25f1ee |
---|---|
1 package de.intevation.flys.client.server; | 1 package de.intevation.flys.client.server; |
2 | 2 |
3 import com.google.gwt.core.client.GWT; | |
3 import com.google.gwt.user.server.rpc.RemoteServiceServlet; | 4 import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
4 | 5 |
5 import de.intevation.artifacts.common.utils.XMLUtils; | 6 import de.intevation.artifacts.common.utils.XMLUtils; |
6 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; | 7 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; |
7 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; | 8 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; |
41 "/mapinfo/river/bbox/@value"; | 42 "/mapinfo/river/bbox/@value"; |
42 | 43 |
43 public static final String XPATH_RIVER_WMS = | 44 public static final String XPATH_RIVER_WMS = |
44 "/mapinfo/river/river-wms/@url"; | 45 "/mapinfo/river/river-wms/@url"; |
45 | 46 |
46 public static final String XPATH_RIVER_WMS_LAYERS = | 47 public static final String XPATH_RIVER_LAYERS = |
47 "/mapinfo/river/river-wms/@layers"; | 48 "/mapinfo/river/river-wms/@layers"; |
48 | 49 |
49 public static final String XPATH_WMS_URL = | 50 public static final String XPATH_WMS_URL = |
50 "/mapinfo/river/background-wms/@url"; | 51 "/mapinfo/river/background-wms/@url"; |
51 | 52 |
62 { | 63 { |
63 logger.info("MapInfoServiceImpl.getMapInfo"); | 64 logger.info("MapInfoServiceImpl.getMapInfo"); |
64 | 65 |
65 String url = getServletContext().getInitParameter("server-url"); | 66 String url = getServletContext().getInitParameter("server-url"); |
66 | 67 |
67 Document request = getRequestDocument(river);; | 68 Document request = getRequestDocument(river, "rivermap"); |
68 | 69 |
69 HttpClient client = new HttpClientImpl(url, locale); | 70 HttpClient client = new HttpClientImpl(url, locale); |
70 | 71 |
71 try { | 72 try { |
72 logger.debug("MapInfoServiceImpl.callService"); | 73 logger.debug("MapInfoServiceImpl.callService"); |
85 | 86 |
86 throw new ServerException(ERROR_NO_MAPINFO_FOUND); | 87 throw new ServerException(ERROR_NO_MAPINFO_FOUND); |
87 } | 88 } |
88 | 89 |
89 | 90 |
90 public static Document getRequestDocument(String rivername) { | 91 public static Document getRequestDocument(String rivername, String maptypeStr) { |
91 logger.debug("MapInfoServiceImpl.getRequestDocument"); | 92 logger.debug("MapInfoServiceImpl.getRequestDocument"); |
92 | 93 |
93 Document request = XMLUtils.newDocument(); | 94 Document request = XMLUtils.newDocument(); |
94 ElementCreator cr = new ElementCreator(request, null, null); | 95 ElementCreator cr = new ElementCreator(request, null, null); |
95 | 96 |
96 Element root = cr.create("mapinfo"); | 97 Element root = cr.create("mapinfo"); |
97 Element river = cr.create("river"); | 98 Element river = cr.create("river"); |
99 Element maptype = cr.create("maptype"); | |
98 | 100 |
99 river.setTextContent(rivername); | 101 river.setTextContent(rivername); |
102 maptype.setTextContent(maptypeStr); | |
100 | 103 |
101 request.appendChild(root); | 104 request.appendChild(root); |
102 root.appendChild(river); | 105 root.appendChild(river); |
106 root.appendChild(maptype); | |
103 | 107 |
104 return request; | 108 return request; |
105 } | 109 } |
106 | 110 |
107 | 111 |
112 String sridStr = XMLUtils.xpathString(result, XPATH_SRID, null); | 116 String sridStr = XMLUtils.xpathString(result, XPATH_SRID, null); |
113 String bboxS = XMLUtils.xpathString(result, XPATH_BBOX, null); | 117 String bboxS = XMLUtils.xpathString(result, XPATH_BBOX, null); |
114 BBox bbox = BBox.getBBoxFromString(bboxS); | 118 BBox bbox = BBox.getBBoxFromString(bboxS); |
115 | 119 |
116 String riverWMS = XMLUtils.xpathString(result, XPATH_RIVER_WMS, null); | 120 String riverWMS = XMLUtils.xpathString(result, XPATH_RIVER_WMS, null); |
117 String riverLayers = XMLUtils.xpathString(result, XPATH_RIVER_WMS_LAYERS, null); | 121 String riverLayers = XMLUtils.xpathString(result, XPATH_RIVER_LAYERS, null); |
118 String wmsURL = XMLUtils.xpathString(result, XPATH_WMS_URL, null); | 122 String wmsURL = XMLUtils.xpathString(result, XPATH_WMS_URL, null); |
119 String wmsLayers = XMLUtils.xpathString(result, XPATH_WMS_LAYERS, null); | 123 String wmsLayers = XMLUtils.xpathString(result, XPATH_WMS_LAYERS, null); |
120 | 124 |
121 int srid = 4326; | 125 int srid = 4326; |
122 | 126 |
123 try { | 127 try { |
124 srid = Integer.parseInt(sridStr); | 128 srid = Integer.parseInt(sridStr); |
125 } | 129 } |
126 catch (NumberFormatException nfe) { | 130 catch (NumberFormatException nfe) { |
127 // do nothing | 131 GWT.log("Could not parse SRID String: " + sridStr); |
128 } | 132 } |
129 | 133 |
130 return new MapInfo(river, srid, bbox, riverWMS, riverLayers, wmsURL, wmsLayers); | 134 return new MapInfo( |
135 river, srid, bbox, riverWMS, riverLayers, wmsURL, wmsLayers); | |
131 } | 136 } |
132 } | 137 } |
133 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 138 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |