[Dive4elements-commits] [PATCH 7 of 7] merge

Wald Commits scm-commit at wald.intevation.org
Wed Jun 5 13:20:09 CEST 2013


# HG changeset patch
# User Tom Gottfried <tom.gottfried at intevation.de>
# Date 1370431105 -7200
# Node ID 743eab7acfdb3e653d7fc5bd9f6bb51d2de25e46
# Parent  1298c1c2dadf97c31818360a32a318badc36b6b0
# Parent  734ba3732bb6dade51e6a583fd7d77864b86f272
merge

diff -r 1298c1c2dadf -r 743eab7acfdb gwt-client/src/main/java/org/dive4elements/river/client/server/CapabilitiesParser.java
--- 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);
     }
 
 
diff -r 1298c1c2dadf -r 743eab7acfdb gwt-client/src/main/java/org/dive4elements/river/client/server/GGInATrustStrategy.java
--- 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
diff -r 1298c1c2dadf -r 743eab7acfdb gwt-client/src/main/java/org/dive4elements/river/client/shared/model/Capabilities.java
--- 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();
diff -r 1298c1c2dadf -r 743eab7acfdb gwt-client/src/main/java/org/dive4elements/river/client/shared/model/WMSLayer.java
--- 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;


More information about the Dive4elements-commits mailing list