[Dive4elements-commits] [PATCH] CapabilitesParser can parse map format types now (#554)
Wald Commits
scm-commit at wald.intevation.org
Wed Jun 5 12:56:29 CEST 2013
# HG changeset patch
# User Christian Lins <christian.lins at intevation.de>
# Date 1370429784 -7200
# Node ID 809c91beee54be1ba337d22f03c6e17cfddef7e7
# Parent cefad554637363a88eac4ed7ecc90a4e0f5bf4e9
CapabilitesParser can parse map format types now (#554).
diff -r cefad5546373 -r 809c91beee54 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 11:54:24 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/CapabilitiesParser.java Wed Jun 05 12:56:24 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);
}
diff -r cefad5546373 -r 809c91beee54 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 11:54:24 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/GGInATrustStrategy.java Wed Jun 05 12:56:24 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 cefad5546373 -r 809c91beee54 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 11:54:24 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/Capabilities.java Wed Jun 05 12:56:24 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();
More information about the Dive4elements-commits
mailing list