Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontalcrosssection/HorizontalCrossSectionMeshOutputState.java @ 730:452fad121560
Implemented code for changing the title of a wms layer (issue198).
gnv-artifacts/trunk@768 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 15 Mar 2010 11:13:21 +0000 |
parents | 8d475151b2c1 |
children | 93489a0c1328 |
comparison
equal
deleted
inserted
replaced
729:d23ad22bcfe7 | 730:452fad121560 |
---|---|
195 if ("zip".equals(outputMode)) { | 195 if ("zip".equals(outputMode)) { |
196 writeZip(uuid, callContext, outputStream); | 196 writeZip(uuid, callContext, outputStream); |
197 } | 197 } |
198 else if ("wms".equals(outputMode)) { | 198 else if ("wms".equals(outputMode)) { |
199 XMLUtils.toStream( | 199 XMLUtils.toStream( |
200 getWMS(uuid, callContext), | 200 getWMS(uuid, callContext, inputData), |
201 outputStream); | 201 outputStream); |
202 } | 202 } |
203 else { | 203 else { |
204 throw new StateException("unsupported output mode"); | 204 throw new StateException("unsupported output mode"); |
205 } | 205 } |
231 catch (IOException ioe) { | 231 catch (IOException ioe) { |
232 log.error(ioe.getLocalizedMessage(), ioe); | 232 log.error(ioe.getLocalizedMessage(), ioe); |
233 } | 233 } |
234 } | 234 } |
235 | 235 |
236 protected Document getWMS(String uuid, CallContext callContext) | 236 protected Document getWMS( |
237 String uuid, | |
238 CallContext callContext, | |
239 Collection<InputData> inputData | |
240 ) | |
237 throws StateException | 241 throws StateException |
238 { | 242 { |
239 // TODO: Do the real WMS publishing here! | |
240 Document document = XMLUtils.newDocument(); | 243 Document document = XMLUtils.newDocument(); |
241 | 244 |
242 Element pathElement = document.createElement("path"); | 245 Element pathElement = document.createElement("path"); |
243 document.appendChild(pathElement); | 246 document.appendChild(pathElement); |
244 | 247 |
245 String path = getShapeFilePath(); | 248 String path = getShapeFilePath(); |
246 | 249 |
247 if (path != null && new File(path).isDirectory()) { | 250 if (path != null && new File(path).isDirectory()) { |
251 String title = getLayerTitle(inputData); | |
252 if (title == null) { | |
253 title = uuid; | |
254 } | |
255 | |
256 callContext.putContextValue( | |
257 MetaWriter.CONTEXT_LAYER_TITLE, title); | |
258 | |
259 String paramType = findParameterType(callContext); | |
260 | |
261 if (log.isDebugEnabled()) { | |
262 log.debug("Layer title: " + title); | |
263 log.debug("Layer type: " + paramType); | |
264 } | |
265 | |
266 Document meta = MetaWriter.writeHorizontalcrosssectionMeta( | |
267 callContext, uuid, path, paramType); | |
268 if (meta != null) { | |
269 MapfileGenerator.getInstance().update(); | |
270 return meta; | |
271 } | |
272 | |
248 pathElement.setTextContent(path); | 273 pathElement.setTextContent(path); |
249 } | 274 } |
250 else { | 275 else { |
251 AttributedPoint2ds result = getResult(uuid, callContext); | 276 AttributedPoint2ds result = getResult(uuid, callContext); |
252 if (result != null | 277 if (result != null |
253 && (path = writeToShapeFile(uuid, result, callContext)) != null) { | 278 && (path = writeToShapeFile(uuid, result, callContext)) != null) { |
254 | 279 |
255 InputData inputParam = inputData.get("parameterid"); | 280 String paramType = findParameterType(callContext); |
256 Map<Integer, PaletteManager> paletteManagers = | 281 |
257 getPalettes(callContext); | 282 InputData inputTitle = this.inputData.get("title"); |
258 String paramType = null; | 283 String title = getLayerTitle(inputData); |
259 | 284 if (title == null) { |
260 if (inputParam == null || paletteManagers == null) { | 285 title = uuid; |
261 log.warn("Parameter-id not found."); | 286 } |
262 paramType = LAYER_MODEL; | 287 callContext.putContextValue( |
263 } | 288 MetaWriter.CONTEXT_LAYER_TITLE, title); |
264 else { | 289 |
265 Integer parameterId = Integer.parseInt(inputParam.getValue()); | 290 if (log.isDebugEnabled()) { |
266 PaletteManager paletteManager = paletteManagers.get(parameterId); | 291 log.debug("Parameter type: " + paramType); |
267 | 292 log.debug("Layer title: " + title); |
268 paramType = LAYER_MODEL + "_" + paletteManager.getName(); | |
269 } | 293 } |
270 | 294 |
271 Document meta = MetaWriter.writeHorizontalcrosssectionMeta( | 295 Document meta = MetaWriter.writeHorizontalcrosssectionMeta( |
272 callContext, uuid, path, paramType); | 296 callContext, uuid, path, paramType); |
273 if (meta != null) { | 297 if (meta != null) { |
278 pathElement.setTextContent(path); | 302 pathElement.setTextContent(path); |
279 } | 303 } |
280 } | 304 } |
281 | 305 |
282 return document; | 306 return document; |
307 } | |
308 | |
309 protected String findParameterType(CallContext callContext) { | |
310 InputData inputParam = inputData.get("parameterid"); | |
311 | |
312 Map<Integer, PaletteManager> paletteManagers = getPalettes(callContext); | |
313 | |
314 if (inputParam == null || paletteManagers == null) { | |
315 log.warn("Parameter-id not found."); | |
316 return LAYER_MODEL; | |
317 } | |
318 else { | |
319 Integer parameterId = Integer.parseInt(inputParam.getValue()); | |
320 PaletteManager paletteManager = paletteManagers.get(parameterId); | |
321 | |
322 return LAYER_MODEL + "_" + paletteManager.getName(); | |
323 } | |
324 } | |
325 | |
326 | |
327 protected String getLayerTitle(Collection<InputData> inputData) { | |
328 for (InputData data: inputData) { | |
329 String name = data.getName(); | |
330 if (name != null && name.equals("title")) { | |
331 return (String) data.getValue(); | |
332 } | |
333 } | |
334 | |
335 return null; | |
283 } | 336 } |
284 | 337 |
285 protected String writeToShapeFile( | 338 protected String writeToShapeFile( |
286 String uuid, | 339 String uuid, |
287 AttributedPoint2ds result, | 340 AttributedPoint2ds result, |