# HG changeset patch # User Ingo Weinzierl # Date 1325520608 0 # Node ID 23ffee639f7cc657e9d2e6b4a740ed0ab5ac7e6a # Parent ea2aae01e7c42d2be5b35642960df90330c60339 #431 Added support for WMS 1.3.0 projection definitions. flys-client/trunk@3567 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r ea2aae01e7c4 -r 23ffee639f7c flys-client/ChangeLog --- a/flys-client/ChangeLog Mon Jan 02 14:42:59 2012 +0000 +++ b/flys-client/ChangeLog Mon Jan 02 16:10:08 2012 +0000 @@ -1,3 +1,11 @@ +2012-01-02 Ingo Weinzierl + + flys/issue431 (Karte: Hinzuladen externer WMS Layer nicht möglich) + + * src/main/java/de/intevation/flys/client/server/CapabilitiesParser.java: + Added support for WMS 1.3.0: the projection's are defined in a + element instead of in version 1.1.0. + 2012-01-02 Ingo Weinzierl * src/main/java/de/intevation/flys/client/server/CapabilitiesParser.java: diff -r ea2aae01e7c4 -r 23ffee639f7c flys-client/src/main/java/de/intevation/flys/client/server/CapabilitiesParser.java --- 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 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 allSRS = new ArrayList(); + + for (int i = 0, n = srsNodes.getLength(); i < n; i++) { + List srs = parseSRSItem(srsNodes.item(i).getTextContent()); + + if (srs != null && srs.size() > 0) { + allSRS.addAll(srs); + } + } + + return allSRS; + } + + + protected static List parseSRSItem(String srsStr) { if (srsStr == null || srsStr.length() == 0) { - logger.debug("No explicit SRS for this layer specified."); return null; } + List allSRS = new ArrayList(); + + if (srsStr.indexOf(" ") <= 0) { + String srs = getSRSFromString(srsStr); + if (srs != null && srs.length() > 0) { + allSRS.add(srs); + } + + return allSRS; + } + String[] splittedSrs = srsStr.split(" "); - List srs = new ArrayList(); 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 :