changeset 6206:743eab7acfdb

merge
author Tom Gottfried <tom.gottfried@intevation.de>
date Wed, 05 Jun 2013 13:18:25 +0200
parents 1298c1c2dadf (current diff) 734ba3732bb6 (diff)
children a82a724356f0
files
diffstat 4 files changed, 65 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/server/CapabilitiesParser.java	Wed Jun 05 13:16:28 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/CapabilitiesParser.java	Wed Jun 05 13:18:25 2013 +0200
@@ -8,8 +8,14 @@
 
 package org.dive4elements.river.client.server;
 
+import org.dive4elements.artifacts.common.utils.XMLUtils;
+import org.dive4elements.river.client.shared.exceptions.ServerException;
+import org.dive4elements.river.client.shared.model.Capabilities;
+import org.dive4elements.river.client.shared.model.ContactInformation;
+import org.dive4elements.river.client.shared.model.WMSLayer;
+
+import java.io.IOException;
 import java.io.InputStream;
-import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
@@ -20,21 +26,15 @@
 
 import javax.xml.xpath.XPathConstants;
 
+import org.apache.log4j.Logger;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import org.apache.log4j.Logger;
-
-import org.dive4elements.artifacts.common.utils.XMLUtils;
-
-import org.dive4elements.river.client.shared.exceptions.ServerException;
-import org.dive4elements.river.client.shared.model.Capabilities;
-import org.dive4elements.river.client.shared.model.ContactInformation;
-import org.dive4elements.river.client.shared.model.WMSLayer;
-
-
+/**
+ * Parser for GetCapabilities of a WMS.
+ */
 public class CapabilitiesParser {
 
     private static final Logger logger =
@@ -96,6 +96,9 @@
     public static final String XPATH_LAYERS =
         "Capability/Layer";
 
+    public static final String XPATH_MAP_FORMAT =
+        "Capability/Request/GetMap/Format";
+
     public static final Pattern SRS_PATTERN = Pattern.compile("(EPSG:\\d+)*");
 
 
@@ -110,9 +113,14 @@
         LoggingConfigurator.init(log4jProperties);
 
         try {
-            Capabilities caps = getCapabilities(System.getProperty("test.wms"));
+            String wmsURL = System.getProperty("test.wms");
+            if (wmsURL == null || args.length > 0) {
+                wmsURL = args[0];
+            }
+            Capabilities caps = getCapabilities(wmsURL);
 
             logger.debug(caps.toString());
+            System.out.println(caps.toString());
         }
         catch (ServerException se) {
             se.printStackTrace();
@@ -206,13 +214,22 @@
 
         List<WMSLayer> layers = parseLayers(layerNodes, onlineResource);
 
+        // Parse MIME types of supported return types, e.g. image/jpeg
+        NodeList mapFormatNodes = (NodeList)
+                XMLUtils.xpath(capabilities, XPATH_MAP_FORMAT, XPathConstants.NODESET);
+        List<String> mapFormats = new ArrayList<String>();
+        for (int n = 0; n < mapFormatNodes.getLength(); n++) {
+            mapFormats.add(mapFormatNodes.item(n).getTextContent());
+        }
+
         return new Capabilities(
             title,
             onlineResource,
             ci,
             fees,
             accessConstraints,
-            layers);
+            layers,
+            mapFormats);
     }
 
 
@@ -327,6 +344,12 @@
 
         logger.debug("Found layer: " + title + "(" + name + ")");
 
+        boolean queryable = true;
+        Node queryableAttr = layerNode.getAttributes().getNamedItem("queryable");
+        if (queryableAttr != null && queryableAttr.getNodeValue().equals("0")) {
+            queryable = false;
+        }
+
         List<String> srs = parseSRS(layerNode);
 
         NodeList layersNodes = (NodeList) XMLUtils.xpath(
@@ -336,7 +359,7 @@
 
         List<WMSLayer> layers = parseLayers(layersNodes, onlineResource);
 
-        return new WMSLayer(onlineResource, title, name, srs, layers);
+        return new WMSLayer(onlineResource, title, name, srs, layers, queryable);
     }
 
 
--- a/gwt-client/src/main/java/org/dive4elements/river/client/server/GGInATrustStrategy.java	Wed Jun 05 13:16:28 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/GGInATrustStrategy.java	Wed Jun 05 13:18:25 2013 +0200
@@ -16,7 +16,7 @@
 public class GGInATrustStrategy implements TrustStrategy {
 
     /**
-     * Tempoary class to accept all certificates for GGinA Authentication
+     * Temporary class to accept all certificates for GGinA Authentication.
      */
 
     @Override
--- a/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/Capabilities.java	Wed Jun 05 13:16:28 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/Capabilities.java	Wed Jun 05 13:18:25 2013 +0200
@@ -12,7 +12,9 @@
 import java.util.ArrayList;
 import java.util.List;
 
-
+/**
+ * Capabilities of a WMS.
+ */
 public class Capabilities implements Serializable {
 
     protected String title;
@@ -23,6 +25,7 @@
     protected ContactInformation contactInformation;
 
     protected List<WMSLayer> layers;
+    protected List<String> mapFormats;
 
 
     public Capabilities() {
@@ -41,7 +44,8 @@
         ContactInformation contactInformation,
         String             fees,
         String             accessConstraints,
-        List<WMSLayer>     layers
+        List<WMSLayer>     layers,
+        List<String>       mapFormats
     ) {
         this.title              = title;
         this.onlineResource     = onlineResource;
@@ -49,6 +53,7 @@
         this.fees               = fees;
         this.accessConstraints  = accessConstraints;
         this.layers             = layers;
+        this.mapFormats         = mapFormats;
     }
 
 
@@ -82,6 +87,11 @@
     }
 
 
+    public List<String> getMapFormats() {
+        return mapFormats;
+    }
+
+
     @Override
     public String toString() {
         StringBuilder sb = new StringBuilder();
--- a/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/WMSLayer.java	Wed Jun 05 13:16:28 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/WMSLayer.java	Wed Jun 05 13:18:25 2013 +0200
@@ -22,6 +22,8 @@
     protected List<String>   srs;
     protected List<WMSLayer> layers;
 
+    protected boolean queryable = true;
+
 
     public WMSLayer() {
         layers = new ArrayList<WMSLayer>();
@@ -39,13 +41,15 @@
         String         title,
         String         name,
         List<String>   srs,
-        List<WMSLayer> layers
+        List<WMSLayer> layers,
+        boolean        queryable
     ) {
-        this.server = server;
-        this.title  = title;
-        this.name   = name;
-        this.srs    = srs;
-        this.layers = layers;
+        this.server    = server;
+        this.title     = title;
+        this.name      = name;
+        this.srs       = srs;
+        this.layers    = layers;
+        this.queryable = queryable;
     }
 
 
@@ -74,6 +78,11 @@
     }
 
 
+    public boolean isQueryable() {
+        return queryable;
+    }
+
+
     public boolean supportsSrs(String srs) {
         if (this.srs == null || this.srs.size() == 0) {
             return true;

http://dive4elements.wald.intevation.org