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

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Fri Apr 29 08:10:10 EDT 2011


Author: bartvde
Date: 2011-04-29 05:10:09 -0700 (Fri, 29 Apr 2011)
New Revision: 11928

Added:
   sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/WPSDescribeProcess.js
   sandbox/bartvde/wps/openlayers/tests/Format/WPSDescribeProcess.html
Modified:
   sandbox/bartvde/wps/openlayers/lib/OpenLayers.js
   sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/OWSCommon/v1_1_0.js
   sandbox/bartvde/wps/openlayers/tests/list-tests.html
Log:
add support for reading WPS DescribeProcess

Modified: sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/OWSCommon/v1_1_0.js
===================================================================
--- sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/OWSCommon/v1_1_0.js	2011-04-29 09:57:24 UTC (rev 11927)
+++ sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/OWSCommon/v1_1_0.js	2011-04-29 12:10:09 UTC (rev 11928)
@@ -40,6 +40,9 @@
             "AnyValue": function(node, parameter) {
                 parameter.anyValue = true;
             },
+            "DataType": function(node, parameter) {
+                parameter.dataType = this.getChildValue(node);
+            },
             "Range": function(node, allowedValues) {
                 allowedValues.range = {};
                 this.readChildNodes(node, allowedValues.range);

Added: sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/WPSDescribeProcess.js
===================================================================
--- sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/WPSDescribeProcess.js	                        (rev 0)
+++ sandbox/bartvde/wps/openlayers/lib/OpenLayers/Format/WPSDescribeProcess.js	2011-04-29 12:10:09 UTC (rev 11928)
@@ -0,0 +1,167 @@
+/* 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.WPSDescribeProcess
+ * Read WPS DescribeProcess responses. 
+ *
+ * Inherits from:
+ *  - <OpenLayers.Format.XML>
+ */
+OpenLayers.Format.WPSDescribeProcess = OpenLayers.Class(
+    OpenLayers.Format.XML, {
+    
+    /**
+     * Constant: VERSION
+     * {String} 1.0.0
+     */
+    VERSION: "1.0.0",
+
+    /**
+     * Property: namespaces
+     * {Object} Mapping of namespace aliases to namespace URIs.
+     */
+    namespaces: {
+        wps: "http://www.opengis.net/wps/1.0.0",
+        ows: "http://www.opengis.net/ows/1.1",
+        xsi: "http://www.w3.org/2001/XMLSchema-instance"
+    },
+
+    /**
+     * Property: schemaLocation
+     * {String} Schema location
+     */
+    schemaLocation: "http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd",
+
+    /**
+     * Property: defaultPrefix
+     */
+    defaultPrefix: "wps",
+
+    /**
+     * 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.WPSDescribeProcess
+     *
+     * Parameters:
+     * options - {Object} An optional object whose properties will be set on
+     *     this instance.
+     */
+
+    /**
+     * APIMethod: read
+     * Parse a WPS DescribeProcess and return an object with its information.
+     * 
+     * Parameters: 
+     * data - {String} or {DOMElement} data to read/parse.
+     *
+     * Returns:
+     * {Object}
+     */
+    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 info = {};
+        this.readNode(data, info);
+        return info;
+    },
+
+    /**
+     * 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": {
+            "ProcessDescriptions": function(node, obj) {
+                obj.processDescriptions = {};
+                this.readChildNodes(node, obj.processDescriptions);
+            },
+            "ProcessDescription": function(node, processDescriptions) {
+                var processVersion = this.getAttributeNS(node, this.namespaces.wps, "processVersion");
+                var processDescription = {
+                    processVersion: processVersion,
+                    statusSupported: (node.getAttribute("statusSupported") === "true"),
+                    storeSupported: (node.getAttribute("storeSupported") === "true")
+                };
+                this.readChildNodes(node, processDescription);
+                processDescriptions[processDescription.identifier] = processDescription;
+            },
+            "DataInputs": function(node, processDescription) {
+                processDescription.dataInputs = {};
+                this.readChildNodes(node, processDescription.dataInputs);
+            },
+            "ProcessOutputs": function(node, processDescription) {
+                processDescription.processOutputs = {};
+                this.readChildNodes(node, processDescription.processOutputs);
+            },
+            "Output": function(node, processOutputs) {
+                var output = {};
+                this.readChildNodes(node, output);
+                processOutputs[output.identifier] = output;
+            },
+            "ComplexOutput": function(node, output) {
+                output.complexOutput = {};
+                this.readChildNodes(node, output.complexOutput);
+            },
+            "Input": function(node, dataInputs) {
+                var input = {
+                    maxOccurs: parseInt(node.getAttribute("maxOccurs")),
+                    minOccurs: parseInt(node.getAttribute("minOccurs"))
+                };
+                this.readChildNodes(node, input);
+                dataInputs[input.identifier] = input;
+            },
+            "LiteralData": function(node, input) {
+                input.literalData = {};
+                this.readChildNodes(node, input.literalData);
+            },
+            "ComplexData": function(node, input) {
+                input.complexData = {};
+                this.readChildNodes(node,  input.complexData);
+            },
+            "Default": function(node, complexData) {
+                complexData["default"] = {formats: {}};
+                this.readChildNodes(node,  complexData["default"]);
+            },
+            "Supported": function(node, complexData) {
+                complexData["supported"] = {formats: {}};
+                this.readChildNodes(node,  complexData["supported"]);
+            },
+            "Format": function(node, obj) {
+                var format = {};
+                this.readChildNodes(node, format);
+                obj.formats[format.mimeType] = true;
+            },
+            "MimeType": function(node, format) {
+                format.mimeType = this.getChildValue(node);
+            }
+        },
+        "ows": OpenLayers.Format.OWSCommon.v1_1_0.prototype.readers["ows"]
+    },
+    
+    CLASS_NAME: "OpenLayers.Format.WPSDescribeProcess" 
+
+});

Modified: sandbox/bartvde/wps/openlayers/lib/OpenLayers.js
===================================================================
--- sandbox/bartvde/wps/openlayers/lib/OpenLayers.js	2011-04-29 09:57:24 UTC (rev 11927)
+++ sandbox/bartvde/wps/openlayers/lib/OpenLayers.js	2011-04-29 12:10:09 UTC (rev 11928)
@@ -331,6 +331,7 @@
                 "OpenLayers/Format/WMTSCapabilities/v1_0_0.js",
                 "OpenLayers/Format/WPSCapabilities.js",
                 "OpenLayers/Format/WPSCapabilities/v1_0_0.js",
+                "OpenLayers/Format/WPSDescribeProcess.js",
                 "OpenLayers/Format/XLS.js",
                 "OpenLayers/Format/XLS/v1.js",
                 "OpenLayers/Format/XLS/v1_1_0.js",

Added: sandbox/bartvde/wps/openlayers/tests/Format/WPSDescribeProcess.html
===================================================================
--- sandbox/bartvde/wps/openlayers/tests/Format/WPSDescribeProcess.html	                        (rev 0)
+++ sandbox/bartvde/wps/openlayers/tests/Format/WPSDescribeProcess.html	2011-04-29 12:10:09 UTC (rev 11928)
@@ -0,0 +1,143 @@
+<html>
+<head>
+    <script src="../OLLoader.js"></script>
+    <script type="text/javascript">
+
+    function test_read_WPSDescribeProcess(t) {
+        t.plan(15);
+
+        var parser = new OpenLayers.Format.WPSDescribeProcess();
+        var text =
+'<?xml version="1.0" encoding="UTF-8"?>' +
+'<wps:ProcessDescriptions xml:lang="en" service="WPS" version="1.0.0" xmlns:wps="http://www.opengis.net/wps/1.0.0"' +
+'    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
+'    xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd"' +
+'    xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink">' +
+'    <ProcessDescription wps:processVersion="1.0.0" statusSupported="false"' +
+'        storeSupported="false">' +
+'        <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>' +
+'        <DataInputs>' +
+'            <Input maxOccurs="1" minOccurs="1">' +
+'                <ows:Identifier>geom</ows:Identifier>' +
+'                <ows:Title>geom</ows:Title>' +
+'                <ows:Abstract>The geometry to be buffered</ows:Abstract>' +
+'                <ComplexData>' +
+'                    <Default>' +
+'                        <Format>' +
+'                            <MimeType>text/xml; subtype=gml/3.1.1</MimeType>' +
+'                        </Format>' +
+'                    </Default>' +
+'                    <Supported>' +
+'                        <Format>' +
+'                            <MimeType>text/xml; subtype=gml/3.1.1</MimeType>' +
+'                        </Format>' +
+'                        <Format>' +
+'                            <MimeType>text/xml; subtype=gml/2.1.2</MimeType>' +
+'                        </Format>' +
+'                        <Format>' +
+'                            <MimeType>application/wkt</MimeType>' +
+'                        </Format>' +
+'                        <Format>' +
+'                            <MimeType>application/gml-3.1.1</MimeType>' +
+'                        </Format>' +
+'                        <Format>' +
+'                            <MimeType>application/gml-2.1.2</MimeType>' +
+'                        </Format>' +
+'                    </Supported>' +
+'                </ComplexData>' +
+'            </Input>' +
+'            <Input maxOccurs="1" minOccurs="1">' +
+'                <ows:Identifier>distance</ows:Identifier>' +
+'                <ows:Title>distance</ows:Title>' +
+'                <ows:Abstract>The distance (same unit of measure as the geometry)</ows:Abstract>' +
+'                <LiteralData>' +
+'                    <ows:DataType>xs:double</ows:DataType>' +
+'                    <ows:AnyValue/>' +
+'                </LiteralData>' +
+'            </Input>' +
+'            <Input maxOccurs="1" minOccurs="0">' +
+'                <ows:Identifier>quadrantSegments</ows:Identifier>' +
+'                <ows:Title>quadrantSegments</ows:Title>' +
+'                <ows:Abstract>Number of quadrant segments. Use &gt; 0 for round joins, 0 for' +
+'                    flat joins, &lt; 0 for mitred joins</ows:Abstract>' +
+'                <LiteralData>' +
+'                    <ows:DataType>xs:int</ows:DataType>' +
+'                    <ows:AnyValue/>' +
+'                </LiteralData>' +
+'            </Input>' +
+'            <Input maxOccurs="1" minOccurs="0">' +
+'                <ows:Identifier>capStyle</ows:Identifier>' +
+'                <ows:Title>capStyle</ows:Title>' +
+'                <ows:Abstract>The buffer cap style, round, flat, square</ows:Abstract>' +
+'                <LiteralData>' +
+'                    <ows:AllowedValues>' +
+'                        <ows:Value>Round</ows:Value>' +
+'                        <ows:Value>Flat</ows:Value>' +
+'                        <ows:Value>Square</ows:Value>' +
+'                    </ows:AllowedValues>' +
+'                </LiteralData>' +
+'            </Input>' +
+'        </DataInputs>' +
+'        <ProcessOutputs>' +
+'            <Output>' +
+'                <ows:Identifier>result</ows:Identifier>' +
+'                <ows:Title>result</ows:Title>' +
+'                <ComplexOutput>' +
+'                    <Default>' +
+'                        <Format>' +
+'                            <MimeType>text/xml; subtype=gml/3.1.1</MimeType>' +
+'                        </Format>' +
+'                    </Default>' +
+'                    <Supported>' +
+'                        <Format>' +
+'                            <MimeType>text/xml; subtype=gml/3.1.1</MimeType>' +
+'                        </Format>' +
+'                        <Format>' +
+'                            <MimeType>text/xml; subtype=gml/2.1.2</MimeType>' +
+'                        </Format>' +
+'                        <Format>' +
+'                            <MimeType>application/wkt</MimeType>' +
+'                        </Format>' +
+'                        <Format>' +
+'                            <MimeType>application/gml-3.1.1</MimeType>' +
+'                        </Format>' +
+'                        <Format>' +
+'                            <MimeType>application/gml-2.1.2</MimeType>' +
+'                        </Format>' +
+'                    </Supported>' +
+'                </ComplexOutput>' +
+'            </Output>' +
+'        </ProcessOutputs>' +
+'    </ProcessDescription>' +
+'</wps:ProcessDescriptions>'
+
+        var res = parser.read(text);
+        var buffer = res.processDescriptions["JTS:buffer"];
+        t.eq(buffer.statusSupported, false, "statusSupported read correctly");
+        t.eq(buffer.storeSupported, false, "storeSupported read correctly");
+        t.eq(buffer.processVersion, "1.0.0", "processVersion read correctly");
+        var capStyle = buffer.dataInputs["capStyle"];
+        t.eq(capStyle.abstract, "The buffer cap style, round, flat, square", "capStyle abstract read correctly");
+        t.eq(capStyle.minOccurs, 0, "capStyle minOccurs read correctly");
+        t.eq(capStyle.maxOccurs, 1, "maxOccurs read correctly");
+        t.eq(capStyle.literalData.allowedValues["Flat"], true, "capStyle allowedValues read correctly");
+        var distance = buffer.dataInputs["distance"];
+        t.eq(distance.literalData.anyValue, true, "distance anyValue read correctly");
+        t.eq(distance.literalData.dataType, "xs:double", "distance dataType read correctly");
+        var geom = buffer.dataInputs["geom"];
+        t.eq(geom.complexData["default"].formats["text/xml; subtype=gml/3.1.1"], true, "geom complexData default read correctly");
+        t.eq(geom.complexData["supported"].formats["application/gml-2.1.2"], true, "geom complexData supported read correctly [1/2]");
+        t.eq(geom.complexData["supported"].formats["application/gml-3.1.1"], true, "geom complexData supported read correctly [2/2]");
+        var result = buffer.processOutputs["result"];
+        t.eq(result.complexOutput["default"].formats["text/xml; subtype=gml/3.1.1"], true, "processOutputs default format read correctly");
+        t.eq(result.complexOutput["supported"].formats["text/xml; subtype=gml/3.1.1"], true, "processOutputs supported format read correctly [1/2]");
+        t.eq(result.complexOutput["supported"].formats["application/wkt"], true, "processOutputs supported format read correctly [1/2]");
+    }
+
+    </script>
+</head>
+<body>
+</body>
+</html>

Modified: sandbox/bartvde/wps/openlayers/tests/list-tests.html
===================================================================
--- sandbox/bartvde/wps/openlayers/tests/list-tests.html	2011-04-29 09:57:24 UTC (rev 11927)
+++ sandbox/bartvde/wps/openlayers/tests/list-tests.html	2011-04-29 12:10:09 UTC (rev 11928)
@@ -105,6 +105,7 @@
     <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/WPSDescribeProcess.html</li>
     <li>Format/XML.html</li>
     <li>Geometry.html</li>
     <li>Geometry/Collection.html</li>



More information about the Commits mailing list