Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/CapabilitiesParser.java Mon Jan 02 14:42:59 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/CapabilitiesParser.java Mon Jan 02 16:10:08 2012 +0000 @@ -13,6 +13,7 @@ import javax.xml.xpath.XPathConstants; import org.w3c.dom.Document; +import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -332,29 +333,69 @@ protected static List<String> parseSRS(Node layerNode) { - String srsStr = (String) XMLUtils.xpath( - layerNode, - "SRS/text()", - XPathConstants.STRING); + NodeList srsNodes = ((Element) layerNode).getElementsByTagName("SRS"); + if (srsNodes.getLength() == 0) { + srsNodes = ((Element) layerNode).getElementsByTagName("CRS"); + + if (srsNodes.getLength() == 0) { + logger.debug("No explicit SRS for this layer specified."); + return null; + } + } + + List<String> allSRS = new ArrayList<String>(); + + for (int i = 0, n = srsNodes.getLength(); i < n; i++) { + List<String> srs = parseSRSItem(srsNodes.item(i).getTextContent()); + + if (srs != null && srs.size() > 0) { + allSRS.addAll(srs); + } + } + + return allSRS; + } + + + protected static List<String> parseSRSItem(String srsStr) { if (srsStr == null || srsStr.length() == 0) { - logger.debug("No explicit SRS for this layer specified."); return null; } + List<String> allSRS = new ArrayList<String>(); + + if (srsStr.indexOf(" ") <= 0) { + String srs = getSRSFromString(srsStr); + if (srs != null && srs.length() > 0) { + allSRS.add(srs); + } + + return allSRS; + } + String[] splittedSrs = srsStr.split(" "); - List<String> srs = new ArrayList<String>(); for (String singleSrs: splittedSrs) { - Matcher m = SRS_PATTERN.matcher(singleSrs); - - if (m.matches()) { - logger.debug("Found SRS '" + m.group(1) + "'"); - srs.add(m.group(1)); + String srs = getSRSFromString(singleSrs); + if (srs != null && srs.length() > 0) { + allSRS.add(srs); } } - return srs; + return allSRS; + } + + + protected static String getSRSFromString(String singleSrs) { + Matcher m = SRS_PATTERN.matcher(singleSrs); + + if (m.matches()) { + logger.debug("Found SRS '" + m.group(1) + "'"); + return m.group(1); + } + + return null; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :