Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/CapabilitiesParser.java @ 1488:23ffee639f7c
#431 Added support for WMS 1.3.0 projection definitions.
flys-client/trunk@3567 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 02 Jan 2012 16:10:08 +0000 |
parents | ea2aae01e7c4 |
children | 40d02fbf414d |
comparison
equal
deleted
inserted
replaced
1487:ea2aae01e7c4 | 1488:23ffee639f7c |
---|---|
11 import java.util.regex.Pattern; | 11 import java.util.regex.Pattern; |
12 | 12 |
13 import javax.xml.xpath.XPathConstants; | 13 import javax.xml.xpath.XPathConstants; |
14 | 14 |
15 import org.w3c.dom.Document; | 15 import org.w3c.dom.Document; |
16 import org.w3c.dom.Element; | |
16 import org.w3c.dom.Node; | 17 import org.w3c.dom.Node; |
17 import org.w3c.dom.NodeList; | 18 import org.w3c.dom.NodeList; |
18 | 19 |
19 import org.apache.log4j.Logger; | 20 import org.apache.log4j.Logger; |
20 | 21 |
330 return new WMSLayer(onlineResource, title, name, srs, layers); | 331 return new WMSLayer(onlineResource, title, name, srs, layers); |
331 } | 332 } |
332 | 333 |
333 | 334 |
334 protected static List<String> parseSRS(Node layerNode) { | 335 protected static List<String> parseSRS(Node layerNode) { |
335 String srsStr = (String) XMLUtils.xpath( | 336 NodeList srsNodes = ((Element) layerNode).getElementsByTagName("SRS"); |
336 layerNode, | 337 |
337 "SRS/text()", | 338 if (srsNodes.getLength() == 0) { |
338 XPathConstants.STRING); | 339 srsNodes = ((Element) layerNode).getElementsByTagName("CRS"); |
339 | 340 |
341 if (srsNodes.getLength() == 0) { | |
342 logger.debug("No explicit SRS for this layer specified."); | |
343 return null; | |
344 } | |
345 } | |
346 | |
347 List<String> allSRS = new ArrayList<String>(); | |
348 | |
349 for (int i = 0, n = srsNodes.getLength(); i < n; i++) { | |
350 List<String> srs = parseSRSItem(srsNodes.item(i).getTextContent()); | |
351 | |
352 if (srs != null && srs.size() > 0) { | |
353 allSRS.addAll(srs); | |
354 } | |
355 } | |
356 | |
357 return allSRS; | |
358 } | |
359 | |
360 | |
361 protected static List<String> parseSRSItem(String srsStr) { | |
340 if (srsStr == null || srsStr.length() == 0) { | 362 if (srsStr == null || srsStr.length() == 0) { |
341 logger.debug("No explicit SRS for this layer specified."); | |
342 return null; | 363 return null; |
343 } | 364 } |
344 | 365 |
366 List<String> allSRS = new ArrayList<String>(); | |
367 | |
368 if (srsStr.indexOf(" ") <= 0) { | |
369 String srs = getSRSFromString(srsStr); | |
370 if (srs != null && srs.length() > 0) { | |
371 allSRS.add(srs); | |
372 } | |
373 | |
374 return allSRS; | |
375 } | |
376 | |
345 String[] splittedSrs = srsStr.split(" "); | 377 String[] splittedSrs = srsStr.split(" "); |
346 List<String> srs = new ArrayList<String>(); | |
347 | 378 |
348 for (String singleSrs: splittedSrs) { | 379 for (String singleSrs: splittedSrs) { |
349 Matcher m = SRS_PATTERN.matcher(singleSrs); | 380 String srs = getSRSFromString(singleSrs); |
350 | 381 if (srs != null && srs.length() > 0) { |
351 if (m.matches()) { | 382 allSRS.add(srs); |
352 logger.debug("Found SRS '" + m.group(1) + "'"); | |
353 srs.add(m.group(1)); | |
354 } | 383 } |
355 } | 384 } |
356 | 385 |
357 return srs; | 386 return allSRS; |
387 } | |
388 | |
389 | |
390 protected static String getSRSFromString(String singleSrs) { | |
391 Matcher m = SRS_PATTERN.matcher(singleSrs); | |
392 | |
393 if (m.matches()) { | |
394 logger.debug("Found SRS '" + m.group(1) + "'"); | |
395 return m.group(1); | |
396 } | |
397 | |
398 return null; | |
358 } | 399 } |
359 } | 400 } |
360 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 401 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |