changeset 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 03649eb8933a
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/server/CapabilitiesParser.java
diffstat 2 files changed, 61 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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 <ingo@intevation.de>
+
+	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 <CRS>
+	  element instead of <SRS> in version 1.1.0.
+
 2012-01-02  Ingo Weinzierl <ingo@intevation.de>
 
 	* 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<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 :

http://dive4elements.wald.intevation.org