[OpenLayers-Commits] r12125 - in trunk/openlayers: lib lib/OpenLayers/Format tests tests/Format

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Jun 22 11:20:02 EDT 2011


Author: bartvde
Date: 2011-06-22 08:20:01 -0700 (Wed, 22 Jun 2011)
New Revision: 12125

Added:
   trunk/openlayers/lib/OpenLayers/Format/WCSGetCoverage.js
   trunk/openlayers/tests/Format/WCSGetCoverage.html
Modified:
   trunk/openlayers/lib/OpenLayers.js
   trunk/openlayers/lib/OpenLayers/Format/WPSExecute.js
   trunk/openlayers/tests/Format/WPSExecute.html
   trunk/openlayers/tests/list-tests.html
Log:
add Format for writing out Web Coverage Service (WCS) requests, r=ahocevar (closes #3375)

Added: trunk/openlayers/lib/OpenLayers/Format/WCSGetCoverage.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/WCSGetCoverage.js	                        (rev 0)
+++ trunk/openlayers/lib/OpenLayers/Format/WCSGetCoverage.js	2011-06-22 15:20:01 UTC (rev 12125)
@@ -0,0 +1,198 @@
+/* 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.WCSGetCoverage version 1.1.0
+ *
+ * Inherits from:
+ *  - <OpenLayers.Format.XML>
+ */
+OpenLayers.Format.WCSGetCoverage = OpenLayers.Class(OpenLayers.Format.XML, {
+    
+    /**
+     * Property: namespaces
+     * {Object} Mapping of namespace aliases to namespace URIs.
+     */
+    namespaces: {
+        ows: "http://www.opengis.net/ows/1.1",
+        wcs: "http://www.opengis.net/wcs/1.1",
+        xlink: "http://www.w3.org/1999/xlink",
+        xsi: "http://www.w3.org/2001/XMLSchema-instance"
+    },
+
+    /**
+     * Property: regExes
+     * Compiled regular expressions for manipulating strings.
+     */
+    regExes: {
+        trimSpace: (/^\s*|\s*$/g),
+        removeSpace: (/\s*/g),
+        splitSpace: (/\s+/),
+        trimComma: (/\s*,\s*/g)
+    },
+
+    /**
+     * Constant: VERSION
+     * {String} 1.1.2
+     */
+    VERSION: "1.1.2",
+
+    /**
+     * Property: schemaLocation
+     * {String} Schema location
+     */
+    schemaLocation: "http://www.opengis.net/wcs/1.1 http://schemas.opengis.net/wcs/1.1/wcsGetCoverage.xsd",
+
+    /**
+     * Constructor: OpenLayers.Format.WCSGetCoverage
+     *
+     * Parameters:
+     * options - {Object} An optional object whose properties will be set on
+     *     this instance.
+     */
+
+    /**
+     * Method: write
+     *
+     * Parameters:
+     * options - {Object} Optional object.
+     *
+     * Returns:
+     * {String} A WCS GetCoverage request XML string.
+     */
+    write: function(options) {
+        var node = this.writeNode("wcs:GetCoverage", options);
+        this.setAttributeNS(
+            node, this.namespaces.xsi,
+            "xsi:schemaLocation", this.schemaLocation
+        );
+        return OpenLayers.Format.XML.prototype.write.apply(this, [node]);
+    }, 
+
+    /**
+     * Property: writers
+     * As a compliment to the readers property, this structure contains public
+     *     writing functions grouped by namespace alias and named like the
+     *     node names they produce.
+     */
+    writers: {
+        "wcs": {
+            "GetCoverage": function(options) {
+                var node = this.createElementNSPlus("wcs:GetCoverage", {
+                    attributes: {
+                        version: options.version || this.VERSION,
+                        service: 'WCS'
+                    } 
+                }); 
+                this.writeNode("ows:Identifier", options.identifier, node);
+                this.writeNode("wcs:DomainSubset", options.domainSubset, node);
+                this.writeNode("wcs:Output", options.output, node);
+                return node; 
+            },
+            "DomainSubset": function(domainSubset) {
+                var node = this.createElementNSPlus("wcs:DomainSubset", {});
+                this.writeNode("ows:BoundingBox", domainSubset.boundingBox, node);
+                if (domainSubset.temporalSubset) {
+                    this.writeNode("wcs:TemporalSubset", domainSubset.temporalSubset, node);
+                }
+                return node;
+            },
+            "TemporalSubset": function(temporalSubset) {
+                var node = this.createElementNSPlus("wcs:TemporalSubset", {});
+                for (var i=0, len=temporalSubset.timePeriods.length; i<len; ++i) {
+                    this.writeNode("wcs:TimePeriod", temporalSubset.timePeriods[i], node);
+                }
+                return node;
+            },
+            "TimePeriod": function(timePeriod) {
+                var node = this.createElementNSPlus("wcs:TimePeriod", {});
+                this.writeNode("wcs:BeginPosition", timePeriod.begin, node);
+                this.writeNode("wcs:EndPosition", timePeriod.end, node);
+                if (timePeriod.resolution) {
+                    this.writeNode("wcs:TimeResolution", timePeriod.resolution, node);
+                }
+                return node;
+            },
+            "BeginPosition": function(begin) {
+                var node = this.createElementNSPlus("wcs:BeginPosition", {
+                    value: begin
+                });
+                return node;
+            },
+            "EndPosition": function(end) {
+                var node = this.createElementNSPlus("wcs:EndPosition", {
+                    value: end
+                });
+                return node;
+            },
+            "TimeResolution": function(resolution) {
+                var node = this.createElementNSPlus("wcs:TimeResolution", {
+                    value: resolution
+                });
+                return node;
+            },
+            "Output": function(output) {
+                var node = this.createElementNSPlus("wcs:Output", {
+                    attributes: {
+                        format: output.format,
+                        store: output.store
+                    }
+                });
+                if (output.gridCRS) {
+                    this.writeNode("wcs:GridCRS", output.gridCRS, node);
+                }
+                return node;
+            },
+            "GridCRS": function(gridCRS) {
+                var node = this.createElementNSPlus("wcs:GridCRS", {});
+                this.writeNode("wcs:GridBaseCRS", gridCRS.baseCRS, node);
+                if (gridCRS.type) {
+                    this.writeNode("wcs:GridType", gridCRS.type, node);
+                }
+                if (gridCRS.origin) {
+                    this.writeNode("wcs:GridOrigin", gridCRS.origin, node);
+                }
+                this.writeNode("wcs:GridOffsets", gridCRS.offsets, node);
+                if (gridCRS.CS) {
+                    this.writeNode("wcs:GridCS", gridCRS.CS, node);
+                }
+                return node;
+            },
+            "GridBaseCRS": function(baseCRS) {
+                return this.createElementNSPlus("wcs:GridBaseCRS", {
+                    value: baseCRS
+                });
+            },
+            "GridOrigin": function(origin) {
+                return this.createElementNSPlus("wcs:GridOrigin", {
+                    value: origin
+                });
+            },
+            "GridType": function(type) {
+                return this.createElementNSPlus("wcs:GridType", {
+                    value: type
+                });
+            },
+            "GridOffsets": function(offsets) {
+                return this.createElementNSPlus("wcs:GridOffsets", {
+                    value: offsets
+                });
+            },
+            "GridCS": function(CS) {
+                return this.createElementNSPlus("wcs:GridCS", {
+                    value: CS
+                });
+            }
+        },
+        "ows": OpenLayers.Format.OWSCommon.v1_1_0.prototype.writers.ows
+    },
+    
+    CLASS_NAME: "OpenLayers.Format.WCSGetCoverage" 
+
+});

Modified: trunk/openlayers/lib/OpenLayers/Format/WPSExecute.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/WPSExecute.js	2011-06-22 09:54:35 UTC (rev 12124)
+++ trunk/openlayers/lib/OpenLayers/Format/WPSExecute.js	2011-06-22 15:20:01 UTC (rev 12125)
@@ -5,6 +5,9 @@
 
 /**
  * @requires OpenLayers/Format/XML.js
+ * @requires OpenLayers/Format/OWSCommon/v1_1_0.js
+ * @requires OpenLayers/Format/WCSGetCoverage.js
+ * @requires OpenLayers/Format/WFST/v1_1_0.js
  */
 
 /**
@@ -25,7 +28,7 @@
         wps: "http://www.opengis.net/wps/1.0.0",
         wfs: "http://www.opengis.net/wfs",
         ogc: "http://www.opengis.net/ogc",
-        wcs: "http://www.opengis.net/wcs/1.1.1",
+        wcs: "http://www.opengis.net/wcs",
         xlink: "http://www.w3.org/1999/xlink",
         xsi: "http://www.w3.org/2001/XMLSchema-instance"
     },
@@ -222,7 +225,10 @@
             },
             "Body": function(body) {
                 var node = this.createElementNSPlus("wps:Body", {});
-                if (body.wfs) {
+                if (body.wcs) {
+                    this.writeNode("wcs:GetCoverage", body.wcs, node);
+                }
+                else if (body.wfs) {
                     // OpenLayers.Format.WFST expects these to be on the 
                     // instance and not in the options
                     this.featureType = body.wfs.featureType;
@@ -234,6 +240,7 @@
                 return node;                
             }
         },
+        "wcs": OpenLayers.Format.WCSGetCoverage.prototype.writers.wcs,
         "wfs": OpenLayers.Format.WFST.v1_1_0.prototype.writers.wfs,
         "ows": OpenLayers.Format.OWSCommon.v1_1_0.prototype.writers.ows
     },

Modified: trunk/openlayers/lib/OpenLayers.js
===================================================================
--- trunk/openlayers/lib/OpenLayers.js	2011-06-22 09:54:35 UTC (rev 12124)
+++ trunk/openlayers/lib/OpenLayers.js	2011-06-22 15:20:01 UTC (rev 12125)
@@ -316,6 +316,7 @@
                 "OpenLayers/Format/WMC/v1.js",
                 "OpenLayers/Format/WMC/v1_0_0.js",
                 "OpenLayers/Format/WMC/v1_1_0.js",
+                "OpenLayers/Format/WCSGetCoverage.js",
                 "OpenLayers/Format/WMSCapabilities.js",
                 "OpenLayers/Format/WMSCapabilities/v1.js",
                 "OpenLayers/Format/WMSCapabilities/v1_1.js",

Added: trunk/openlayers/tests/Format/WCSGetCoverage.html
===================================================================
--- trunk/openlayers/tests/Format/WCSGetCoverage.html	                        (rev 0)
+++ trunk/openlayers/tests/Format/WCSGetCoverage.html	2011-06-22 15:20:01 UTC (rev 12125)
@@ -0,0 +1,80 @@
+<html>
+<head>
+    <script src="../OLLoader.js"></script>
+    <script type="text/javascript">
+
+    function test_write_WCSGetCoverage(t) {
+        t.plan(1);
+        var expected = '<?xml version="1.0" encoding="UTF-8"?>' +
+'<GetCoverage xmlns="http://www.opengis.net/wcs/1.1" xmlns:ows="http://www.opengis.net/ows/1.1"' +
+'    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
+'    xsi:schemaLocation="http://www.opengis.net/wcs/1.1 http://schemas.opengis.net/wcs/1.1/wcsGetCoverage.xsd"' +
+'    service="WCS" version="1.1.2">' +
+'    <ows:Identifier>Cov123</ows:Identifier>' +
+'    <DomainSubset>' +
+'        <ows:BoundingBox crs="urn:ogc:def:crs:OGC:2:84">' +
+'            <ows:LowerCorner>-71 47</ows:LowerCorner>' +
+'            <ows:UpperCorner>-66 51</ows:UpperCorner>' +
+'        </ows:BoundingBox>' +
+'        <TemporalSubset>' +
+'            <TimePeriod>' +
+'                <BeginPosition>2006-08-01</BeginPosition>' +
+'                <EndPosition>2006-09-01</EndPosition>' +
+'                <TimeResolution>P1D</TimeResolution>' +
+'            </TimePeriod>' +
+'            <TimePeriod>' +
+'                <BeginPosition>2007-08-01</BeginPosition>' +
+'                <EndPosition>2007-09-01</EndPosition>' +
+'                <TimeResolution>P1D</TimeResolution>' +
+'            </TimePeriod>' +
+'        </TemporalSubset>' +
+'    </DomainSubset>' +
+'    <Output format="image/netcdf">' +
+'        <GridCRS>' +
+'            <GridBaseCRS>urn:ogc:def:crs:EPSG:6.6:32618</GridBaseCRS>' +
+'            <GridType>urn:ogc:def:method:WCS:1.1:2dGridin2dCrs</GridType>' +
+'            <GridOrigin>3000 4000</GridOrigin>' +
+'            <GridOffsets>6.0 8.0 -8.0 6.0</GridOffsets>' +
+'            <GridCS>urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS</GridCS>' +
+'        </GridCRS>' +
+'    </Output>' +
+'</GetCoverage>';
+
+        var format = new OpenLayers.Format.WCSGetCoverage();
+        var result = format.write({
+            identifier: 'Cov123',
+            domainSubset: {
+                boundingBox: {projection: 'urn:ogc:def:crs:OGC:2:84', bounds: new OpenLayers.Bounds(-71, 47, -66, 51)},
+                temporalSubset: {
+                    timePeriods: [
+                        {
+                            begin: '2006-08-01',
+                            end: '2006-09-01',
+                            resolution: 'P1D'
+                        }, {
+                            begin: '2007-08-01',
+                            end: '2007-09-01',
+                            resolution: 'P1D'
+                        }
+                    ]
+                }
+            },
+            output: {
+                format: 'image/netcdf',
+                gridCRS: {
+                    baseCRS: 'urn:ogc:def:crs:EPSG:6.6:32618',
+                    type: 'urn:ogc:def:method:WCS:1.1:2dGridin2dCrs',
+                    origin: '3000 4000',
+                    offsets: '6.0 8.0 -8.0 6.0',
+                    CS: 'urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS'
+                }
+            }
+        });
+        t.xml_eq(result, expected, "WCS GetCoverage written out correctly");
+    }
+
+    </script>
+</head>
+<body>
+</body>
+</html>

Modified: trunk/openlayers/tests/Format/WPSExecute.html
===================================================================
--- trunk/openlayers/tests/Format/WPSExecute.html	2011-06-22 09:54:35 UTC (rev 12124)
+++ trunk/openlayers/tests/Format/WPSExecute.html	2011-06-22 15:20:01 UTC (rev 12125)
@@ -3,6 +3,111 @@
     <script src="../OLLoader.js"></script>
     <script type="text/javascript">
 
+    function test_write_WPSExecute_WCS(t) {
+        t.plan(1);
+        var expected = '<?xml version="1.0" encoding="UTF-8"?>' +
+'<wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wps/1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wcs="http://www.opengis.net/wcs" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">' +
+'  <ows:Identifier>gs:GeorectifyCoverage</ows:Identifier>' +
+'  <wps:DataInputs>' +
+'    <wps:Input>' +
+'      <ows:Identifier>data</ows:Identifier>' +
+'      <wps:Reference mimeType="image/tiff" xlink:href="http://geoserver/wcs" method="POST">' +
+'        <wps:Body>' +
+'          <wcs:GetCoverage service="WCS" version="1.1.2">' +
+'            <ows:Identifier>topp:asbuilt</ows:Identifier>' +
+'            <wcs:DomainSubset>' +
+'              <ows:BoundingBox crs="http://www.opengis.net/gml/srs/epsg.xml#404000">' +
+'                <ows:LowerCorner>0 -7070</ows:LowerCorner>' +
+'                <ows:UpperCorner>10647 1</ows:UpperCorner>' +
+'              </ows:BoundingBox>' +
+'            </wcs:DomainSubset>' +
+'            <wcs:Output format="image/tiff"/>' +
+'          </wcs:GetCoverage>' +
+'        </wps:Body>' +
+'      </wps:Reference>' +
+'    </wps:Input>' +
+'    <wps:Input>' +
+'      <ows:Identifier>gcp</ows:Identifier>' +
+'      <wps:Data>' +
+'        <wps:LiteralData>[[[2721, 3263], [-122.472109, 37.73106003]], [[4163, 3285], [-122.4693417, 37.729929851]], [[5773, 4046], [-122.466702461, 37.7271906]], [[8885, 4187], [-122.462333, 37.725167]]]</wps:LiteralData>' +
+'      </wps:Data>' +
+'    </wps:Input>' +
+'    <wps:Input>' +
+'      <ows:Identifier>targetCRS</ows:Identifier>' +
+'      <wps:Data>' +
+'        <wps:LiteralData>EPSG:4326</wps:LiteralData>' +
+'      </wps:Data>' +
+'    </wps:Input>' +
+'    <wps:Input>' +
+'      <ows:Identifier>transparent</ows:Identifier>' +
+'      <wps:Data>' +
+'        <wps:LiteralData>true</wps:LiteralData>' +
+'      </wps:Data>' +
+'    </wps:Input>' +
+'  </wps:DataInputs>' +
+'  <wps:ResponseForm>' +
+'    <wps:RawDataOutput mimeType="image/tiff">' +
+'      <ows:Identifier>result</ows:Identifier>' +
+'    </wps:RawDataOutput>' +
+'  </wps:ResponseForm>' +
+'</wps:Execute>';
+
+        var format = new OpenLayers.Format.WPSExecute();
+        var result = format.write({
+            identifier: "gs:GeorectifyCoverage", 
+            dataInputs: [{
+                identifier: 'data',
+                reference: {
+                    mimeType: "image/tiff", 
+                    href: "http://geoserver/wcs", 
+                    method: "POST",
+                    body: {
+                        wcs: {
+                            identifier: 'topp:asbuilt',
+                            version: '1.1.2',
+                            domainSubset: {
+                                boundingBox: {
+                                    projection: 'http://www.opengis.net/gml/srs/epsg.xml#404000',
+                                    bounds: new OpenLayers.Bounds(0.0, -7070.0, 10647.0, 1.0)
+                                },
+                            },
+                            output: {format: 'image/tiff'}
+                        }
+                    }
+                }
+            }, {
+                identifier: 'gcp',
+                data: {
+                    literalData: {
+                        value: '[[[2721, 3263], [-122.472109, 37.73106003]], [[4163, 3285], [-122.4693417, 37.729929851]], [[5773, 4046], [-122.466702461, 37.7271906]], [[8885, 4187], [-122.462333, 37.725167]]]'
+                    }
+                }
+            }, {
+                identifier: 'targetCRS',
+                data: {
+                    literalData: {
+                        value: 'EPSG:4326'
+                    }
+                }
+            }, {
+                identifier: 'transparent',
+                data: {
+                    literalData: {
+                        value: 'true'
+                    }
+                }
+            }],
+            responseForm: {
+                rawDataOutput: {
+                    mimeType: "image/tiff",
+                    identifier: "result"
+                }
+            }
+        });
+        t.xml_eq(result, expected, "WPS Execute with embedded WCS GetCoverage written out correctly");
+
+    }
+
     function test_write_WPSExecute(t) {
         t.plan(1);
         var expected = '<?xml version="1.0" encoding="UTF-8"?>' +

Modified: trunk/openlayers/tests/list-tests.html
===================================================================
--- trunk/openlayers/tests/list-tests.html	2011-06-22 09:54:35 UTC (rev 12124)
+++ trunk/openlayers/tests/list-tests.html	2011-06-22 15:20:01 UTC (rev 12125)
@@ -111,6 +111,7 @@
     <li>Format/OWSCommon/v1_1_0.html</li>
     <li>Format/OGCExceptionReport.html</li>
     <li>Format/XLS/v1_1_0.html</li>
+    <li>Format/WCSGetCoverage.html</li>
     <li>Format/XML.html</li>
     <li>Geometry.html</li>
     <li>Geometry/Collection.html</li>



More information about the Commits mailing list