[OpenLayers-Commits] r11927 - in sandbox/bartvde/wps/openlayers: lib lib/OpenLayers/Format lib/OpenLayers/Format/OWSCommon lib/OpenLayers/Format/WPSCapabilities tests tests/Format tests/Format/WPSCapabilities

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Fri Apr 29 05:57:25 EDT 2011


Author: bartvde
Date: 2011-04-29 02:57:24 -0700 (Fri, 29 Apr 2011)
New Revision: 11927

Added:
   sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/WPSCapabilities.js
   sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/WPSCapabilities/
   sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/WPSCapabilities/v1_0_0.js
   sandbox/bartvde/wps/openlayers/tests/Format/WPSCapabilities/
   sandbox/bartvde/wps/openlayers/tests/Format/WPSCapabilities/v1_0_0.html
   sandbox/bartvde/wps/openlayers/tests/Format/WPSCapabilities/v1_0_0.js
Modified:
   sandbox/bartvde/wps/openlayers/lib/OpenLayers.js
   sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/OWSCommon/v1.js
   sandbox/bartvde/wps/openlayers/tests/list-tests.html
Log:
create parser for WPSGetCapabilities

Modified: sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/OWSCommon/v1.js
===================================================================
--- sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/OWSCommon/v1.js	2011-04-29 00:52:08 UTC (rev 11926)
+++ sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/OWSCommon/v1.js	2011-04-29 09:57:24 UTC (rev 11927)
@@ -206,6 +206,9 @@
                 delete obj.bottom;
                 delete obj.right;
                 delete obj.top;
+            },
+            "Language": function(node, obj) {
+                obj.language = this.getChildValue(node);
             }
         }
     },

Added: sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/WPSCapabilities/v1_0_0.js
===================================================================
--- sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/WPSCapabilities/v1_0_0.js	                        (rev 0)
+++ sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/WPSCapabilities/v1_0_0.js	2011-04-29 09:57:24 UTC (rev 11927)
@@ -0,0 +1,119 @@
+/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for 
+ * full list of contributors). Published under the Clear BSD license.  
+ * See http://svn.openlayers.org/trunk/openlayers/license.txt for the
+ * full text of the license. */
+
+/**
+ * @requires OpenLayers/Format/WPSCapabilities.js
+ * @requires OpenLayers/Format/OWSCommon/v1_1_0.js
+ */
+
+/**
+ * Class: OpenLayers.Format.WPSCapabilities.v1_0_0
+ * Read WPS Capabilities version 1.0.0.
+ * 
+ * Inherits from:
+ *  - <OpenLayers.Format.XML>
+ */
+OpenLayers.Format.WPSCapabilities.v1_0_0 = OpenLayers.Class(
+    OpenLayers.Format.XML, {
+
+    /**
+     * Property: namespaces
+     * {Object} Mapping of namespace aliases to namespace URIs.
+     */
+    namespaces: {
+        ows: "http://www.opengis.net/ows/1.1",
+        wps: "http://www.opengis.net/wps/1.0.0",
+        xlink: "http://www.w3.org/1999/xlink"
+    },
+
+    /**
+     * Property: regExes
+     * Compiled regular expressions for manipulating strings.
+     */
+    regExes: {
+        trimSpace: (/^\s*|\s*$/g),
+        removeSpace: (/\s*/g),
+        splitSpace: (/\s+/),
+        trimComma: (/\s*,\s*/g)
+    },
+    
+    /**
+     * Constructor: OpenLayers.Format.WPSCapabilities.v1_0_0
+     * Create a new parser for WPS capabilities version 1.0.0. 
+     *
+     * Parameters:
+     * options - {Object} An optional object whose properties will be set on
+     *     this instance.
+     */
+    initialize: function(options) {
+        OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);
+    },
+
+    /**
+     * APIMethod: read
+     * Read capabilities data from a string, and return info about the WPS.
+     * 
+     * Parameters: 
+     * data - {String} or {DOMElement} data to read/parse.
+     *
+     * Returns:
+     * {Object} Information about the WPS service.
+     */
+    read: function(data) {
+        if(typeof data == "string") {
+            data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
+        }
+        if(data && data.nodeType == 9) {
+            data = data.documentElement;
+        }
+        var capabilities = {};
+        this.readNode(data, capabilities);
+        return capabilities;
+    },
+
+    /**
+     * Property: readers
+     * Contains public functions, grouped by namespace prefix, that will
+     *     be applied when a namespaced node is found matching the function
+     *     name.  The function will be applied in the scope of this parser
+     *     with two arguments: the node being read and a context object passed
+     *     from the parent.
+     */
+    readers: {
+        "wps": {
+            "Capabilities": function(node, obj) {
+                this.readChildNodes(node, obj);
+            },
+            "ProcessOfferings": function(node, obj) {
+                obj.processOfferings = {};
+                this.readChildNodes(node, obj.processOfferings);
+            },
+            "Process": function(node, processOfferings) {
+                var processVersion = this.getAttributeNS(node, this.namespaces.wps, "processVersion");
+                var process = {processVersion: processVersion};
+                this.readChildNodes(node, process);
+                processOfferings[process.identifier] = process;
+            },
+            "Languages": function(node, obj) {
+                obj.languages = [];
+                this.readChildNodes(node, obj.languages);
+            },
+            "Default": function(node, languages) {
+                var language = {isDefault: true};
+                this.readChildNodes(node, language);
+                languages.push(language);
+            },
+            "Supported": function(node, languages) {
+                var language = {};
+                this.readChildNodes(node, language);     
+                languages.push(language);
+            }
+        },
+        "ows": OpenLayers.Format.OWSCommon.v1_1_0.prototype.readers["ows"]
+    },    
+    
+    CLASS_NAME: "OpenLayers.Format.WPSCapabilities.v1_0_0" 
+
+});

Added: sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/WPSCapabilities.js
===================================================================
--- sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/WPSCapabilities.js	                        (rev 0)
+++ sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/WPSCapabilities.js	2011-04-29 09:57:24 UTC (rev 11927)
@@ -0,0 +1,79 @@
+/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for 
+ * full list of contributors). Published under the Clear BSD license.  
+ * See http://svn.openlayers.org/trunk/openlayers/license.txt for the
+ * full text of the license. */
+
+/**
+ * @requires OpenLayers/Format/XML.js
+ */
+ 
+/**
+ * Class: OpenLayers.Format.WPSCapabilities
+ * Read WPS Capabilities.
+ * 
+ * Inherits from:
+ *  - <OpenLayers.Format.XML>
+ */
+OpenLayers.Format.WPSCapabilities = OpenLayers.Class(OpenLayers.Format.XML, {
+    
+    /**
+     * APIProperty: defaultVersion
+     * {String} Version number to assume if none found.  Default is "1.0.0".
+     */
+    defaultVersion: "1.0.0",
+    
+    /**
+     * APIProperty: version
+     * {String} Specify a version string if one is known.
+     */
+    version: null,
+
+    /**
+     * Property: parser
+     * {<OpenLayers.Format>} A cached versioned format used for reading.
+     */
+    parser: null,     
+
+    /**
+     * Constructor: OpenLayers.Format.WPSCapabilities
+     * Create a new parser for WPS Capabilities.
+     *
+     * Parameters:
+     * options - {Object} An optional object whose properties will be set on
+     *     this instance.
+     */
+
+    /**
+     * APIMethod: read
+     * Read capabilities data from a string, and return information about
+     * the service.
+     * 
+     * Parameters: 
+     * data - {String} or {DOMElement} data to read/parse.
+     *
+     * Returns:
+     * {Object} Info about the WPS
+     */
+    read: function(data) {
+        if(typeof data == "string") {
+            data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
+        }
+        var root = data.documentElement;
+        var version = this.version || root.getAttribute("version") || this.defaultVersion;
+        if(!this.parser || this.parser.version !== version) {
+            var constr = OpenLayers.Format.WPSCapabilities[
+                "v" + version.replace(/\./g, "_")
+            ];
+            if(!constr) {
+                throw "Can't find a WPS capabilities parser for version " + version;
+            }
+            var parser = new constr(this.options);
+        }
+        var capabilities = parser.read(data);
+        capabilities.version = version;
+        return capabilities; 
+    },
+    
+    CLASS_NAME: "OpenLayers.Format.WPSCapabilities" 
+
+});

Modified: sandbox/bartvde/wps/openlayers/lib/OpenLayers.js
===================================================================
--- sandbox/bartvde/wps/openlayers/lib/OpenLayers.js	2011-04-29 00:52:08 UTC (rev 11926)
+++ sandbox/bartvde/wps/openlayers/lib/OpenLayers.js	2011-04-29 09:57:24 UTC (rev 11927)
@@ -329,6 +329,8 @@
                 "OpenLayers/Format/OWSContext/v0_3_1.js",
                 "OpenLayers/Format/WMTSCapabilities.js",
                 "OpenLayers/Format/WMTSCapabilities/v1_0_0.js",
+                "OpenLayers/Format/WPSCapabilities.js",
+                "OpenLayers/Format/WPSCapabilities/v1_0_0.js",
                 "OpenLayers/Format/XLS.js",
                 "OpenLayers/Format/XLS/v1.js",
                 "OpenLayers/Format/XLS/v1_1_0.js",

Added: sandbox/bartvde/wps/openlayers/tests/Format/WPSCapabilities/v1_0_0.html
===================================================================
--- sandbox/bartvde/wps/openlayers/tests/Format/WPSCapabilities/v1_0_0.html	                        (rev 0)
+++ sandbox/bartvde/wps/openlayers/tests/Format/WPSCapabilities/v1_0_0.html	2011-04-29 09:57:24 UTC (rev 11927)
@@ -0,0 +1,30 @@
+<html>
+<head>
+    <script src="../../OLLoader.js"></script>
+    <script src="v1_0_0.js"></script>
+    <script type="text/javascript">
+
+    function test_read(t) {
+
+        t.plan(7);
+
+        var format = new OpenLayers.Format.WPSCapabilities();
+        var obj = format.read(doc);
+
+        t.eq(obj.version, "1.0.0", "Version parsed correctly");
+
+        t.eq(obj.languages.length, 2, "2 language entries parsed");
+        t.eq(obj.languages[0].isDefault, true, "First language is the default language");
+        t.eq(obj.languages[0].language, "en-US", "First language is US English");
+
+        var buffer = obj.processOfferings["JTS:buffer"];
+        t.eq(buffer.processVersion, "1.0.0", "processVersion for buffer is 1.0.0");
+        t.eq(buffer.abstract, "Buffers a geometry using a certain distance", "Buffer abstract correctly read");
+        t.eq(buffer.title, "Buffers a geometry using a certain distance", "Buffer title correctly read");
+    }
+
+    </script>
+</head>
+<body>
+</body>
+</html>

Added: sandbox/bartvde/wps/openlayers/tests/Format/WPSCapabilities/v1_0_0.js
===================================================================
--- sandbox/bartvde/wps/openlayers/tests/Format/WPSCapabilities/v1_0_0.js	                        (rev 0)
+++ sandbox/bartvde/wps/openlayers/tests/Format/WPSCapabilities/v1_0_0.js	2011-04-29 09:57:24 UTC (rev 11927)
@@ -0,0 +1,112 @@
+var doc = new OpenLayers.Format.XML().read(
+'<?xml version="1.0" encoding="UTF-8"?>' +
+'<wps:Capabilities xml:lang="en" service="WPS" version="1.0.0"' +
+'    xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd"' +
+'    xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1"' +
+'    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">' +
+'    <ows:ServiceIdentification>' +
+'        <ows:Title>Prototype GeoServer WPS</ows:Title>' +
+'        <ows:Abstract/>' +
+'        <ows:ServiceType>WPS</ows:ServiceType>' +
+'        <ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion>' +
+'    </ows:ServiceIdentification>' +
+'    <ows:ServiceProvider>' +
+'        <ows:ProviderName>The ancient geographes INC</ows:ProviderName>' +
+'        <ows:ProviderSite xlink:href="http://geoserver.org"/>' +
+'        <ows:ServiceContact/>' +
+'    </ows:ServiceProvider>' +
+'    <ows:OperationsMetadata>' +
+'        <ows:Operation name="GetCapabilities">' +
+'            <ows:DCP>' +
+'                <ows:HTTP>' +
+'                    <ows:Get xlink:href="http://localhost:8080/geoserver/wps"/>' +
+'                    <ows:Post xlink:href="http://localhost:8080/geoserver/wps"/>' +
+'                </ows:HTTP>' +
+'            </ows:DCP>' +
+'        </ows:Operation>' +
+'        <ows:Operation name="DescribeProcess">' +
+'            <ows:DCP>' +
+'                <ows:HTTP>' +
+'                    <ows:Get xlink:href="http://localhost:8080/geoserver/wps"/>' +
+'                    <ows:Post xlink:href="http://localhost:8080/geoserver/wps"/>' +
+'                </ows:HTTP>' +
+'            </ows:DCP>' +
+'        </ows:Operation>' +
+'        <ows:Operation name="Execute">' +
+'            <ows:DCP>' +
+'                <ows:HTTP>' +
+'                    <ows:Get xlink:href="http://localhost:8080/geoserver/wps"/>' +
+'                    <ows:Post xlink:href="http://localhost:8080/geoserver/wps"/>' +
+'                </ows:HTTP>' +
+'            </ows:DCP>' +
+'        </ows:Operation>' +
+'    </ows:OperationsMetadata>' +
+'    <wps:ProcessOfferings>' +
+'        <wps:Process wps:processVersion="1.0.0">' +
+'            <ows:Identifier>gt:Intersect</ows:Identifier>' +
+'            <ows:Title>Intersection</ows:Title>' +
+'            <ows:Abstract>Intersection between two literal geometry</ows:Abstract>' +
+'        </wps:Process>' +
+'        <wps:Process wps:processVersion="1.0.0">' +
+'            <ows:Identifier>JTS:length</ows:Identifier>' +
+'            <ows:Title>Returns the geometry perimeters, computed using cartesian geometry' +
+'                expressions in the same unit of measure as the geometry (will not return a valid' +
+'                perimeter for geometries expressed geographic coordinates</ows:Title>' +
+'            <ows:Abstract>Returns the geometry perimeters, computed using cartesian geometry' +
+'                expressions in the same unit of measure as the geometry (will not return a valid' +
+'                perimeter for geometries expressed geographic coordinates</ows:Abstract>' +
+'        </wps:Process>' +
+'        <wps:Process wps:processVersion="1.0.0">' +
+'            <ows:Identifier>JTS:isEmpty</ows:Identifier>' +
+'            <ows:Title>Checks if the provided geometry is empty</ows:Title>' +
+'            <ows:Abstract>Checks if the provided geometry is empty</ows:Abstract>' +
+'        </wps:Process>' +
+'        <wps:Process wps:processVersion="1.0.0">' +
+'            <ows:Identifier>JTS:contains</ows:Identifier>' +
+'            <ows:Title>Checks if a contains b</ows:Title>' +
+'            <ows:Abstract>Checks if a contains b</ows:Abstract>' +
+'        </wps:Process>' +
+'        <wps:Process wps:processVersion="1.0.0">' +
+'            <ows:Identifier>JTS:disjoint</ows:Identifier>' +
+'            <ows:Title>Returns true if the two geometries have no points in common</ows:Title>' +
+'            <ows:Abstract>Returns true if the two geometries have no points in common</ows:Abstract>' +
+'        </wps:Process>' +
+'        <wps:Process wps:processVersion="1.0.0">' +
+'            <ows:Identifier>JTS:intersects</ows:Identifier>' +
+'            <ows:Title>Returns true if the two geometries intersect, false otherwise</ows:Title>' +
+'            <ows:Abstract>Returns true if the two geometries intersect, false' +
+'                otherwise</ows:Abstract>' +
+'        </wps:Process>' +
+'        <wps:Process wps:processVersion="1.0.0">' +
+'            <ows:Identifier>JTS:isClosed</ows:Identifier>' +
+'            <ows:Title>Returns true if the line is closed</ows:Title>' +
+'            <ows:Abstract>Returns true if the line is closed</ows:Abstract>' +
+'        </wps:Process>' +
+'        <wps:Process wps:processVersion="1.0.0">' +
+'            <ows:Identifier>JTS:isValid</ows:Identifier>' +
+'            <ows:Title>Returns true if the geometry is topologically valid, false' +
+'                otherwise</ows:Title>' +
+'            <ows:Abstract>Returns true if the geometry is topologically valid, false' +
+'                otherwise</ows:Abstract>' +
+'        </wps:Process>' +
+'        <wps:Process wps:processVersion="1.0.0">' +
+'            <ows:Identifier>JTS:buffer</ows:Identifier>' +
+'            <ows:Title>Buffers a geometry using a certain distance</ows:Title>' +
+'            <ows:Abstract>Buffers a geometry using a certain distance</ows:Abstract>' +
+'        </wps:Process>' +
+'        <wps:Process wps:processVersion="1.0.0">' +
+'            <ows:Identifier>JTS:getY</ows:Identifier>' +
+'            <ows:Title>Returns the Y ordinate of the point</ows:Title>' +
+'            <ows:Abstract>Returns the Y ordinate of the point</ows:Abstract>' +
+'        </wps:Process>' +
+'    </wps:ProcessOfferings>' +
+'    <wps:Languages>' +
+'        <wps:Default>' +
+'            <ows:Language>en-US</ows:Language>' +
+'        </wps:Default>' +
+'        <wps:Supported>' +
+'            <ows:Language>en-US</ows:Language>' +
+'        </wps:Supported>' +
+'    </wps:Languages>' +
+'</wps:Capabilities>'
+);

Modified: sandbox/bartvde/wps/openlayers/tests/list-tests.html
===================================================================
--- sandbox/bartvde/wps/openlayers/tests/list-tests.html	2011-04-29 00:52:08 UTC (rev 11926)
+++ sandbox/bartvde/wps/openlayers/tests/list-tests.html	2011-04-29 09:57:24 UTC (rev 11927)
@@ -104,6 +104,7 @@
     <li>Format/SOSGetFeatureOfInterest.html</li>
     <li>Format/OWSContext/v0_3_1.html</li>
     <li>Format/XLS/v1_1_0.html</li>
+    <li>Format/WPSCapabilities/v1_0_0.html</li>
     <li>Format/XML.html</li>
     <li>Geometry.html</li>
     <li>Geometry/Collection.html</li>



More information about the Commits mailing list