From 33b9d5e435328c13e278e446f54cc9e26282b4ed Mon Sep 17 00:00:00 2001 From: Christopher Eykamp Date: Mon, 7 Jan 2013 13:34:59 +0100 Subject: [PATCH 1/9] Add initial WCS support --- lib/GeoExt/data/WCSCapabilitiesReader.js | 122 +++++++++++ .../GeoExt/data/WCSCapabilitiesReader.html | 62 ++++++ .../lib/GeoExt/data/WCSCapabilitiesReader.js | 198 ++++++++++++++++++ 3 files changed, 382 insertions(+) create mode 100644 lib/GeoExt/data/WCSCapabilitiesReader.js create mode 100644 tests/lib/GeoExt/data/WCSCapabilitiesReader.html create mode 100644 tests/lib/GeoExt/data/WCSCapabilitiesReader.js diff --git a/lib/GeoExt/data/WCSCapabilitiesReader.js b/lib/GeoExt/data/WCSCapabilitiesReader.js new file mode 100644 index 00000000..ff889a96 --- /dev/null +++ b/lib/GeoExt/data/WCSCapabilitiesReader.js @@ -0,0 +1,122 @@ +/** + * Copyright (c) 2008-2011 The Open Source Geospatial Foundation + * + * Published under the BSD license. + * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text + * of the license. + */ + +/** + * @require OpenLayers/Format/WCSCapabilities.js + * @require OpenLayers/Format/WCSCapabilities/v1_0_0.js + * @require OpenLayers/Format/WCSCapabilities/v1_1_0.js + */ + +/** api: (define) + * module = GeoExt.data + * class = WCSSCapabilitiesReader + * base_link = `Ext.data.DataReader `_ + */ +Ext.namespace("GeoExt.data"); + +/** api: constructor + * .. class:: WCSCapabilitiesReader(meta, recordType) + * + * :param meta: ``Object`` Reader configuration from which: + * ``fields`` is a list of fields to be extracted from the WCS GetCapabilities request. + * :param recordType: ``Array | Ext.data.Record`` An array of field + * configuration objects or a record object. Default is + * :class:`GeoExt.data.LayerRecord`. + * + * Data reader class to create an array of + * :class:`Ext.data.Record` objects from a WCS GetCapabilities + * response. + */ +GeoExt.data.WCSCapabilitiesReader = function(meta, recordType) { + meta = meta || {}; + if(!meta.format) { + meta.format = new OpenLayers.Format.WCSCapabilities(); + } + // Create some default items if recordType is not specified + if(!(typeof recordType === "function")) { + fields = recordType || meta.fields || [ + {name: "title", type: "string"}, + {name: "namespace", type: "string", mapping: "featureNS"}, + {name: "abstract", type: "string"} + ]; + + // Make sure we always have an identifier attribute; + // this will be needed by readRecords. + fields.push({name: "identifier", type: "string"}); // same as WFS "name" + recordType = Ext.data.Record.create(fields); + } + + GeoExt.data.WCSCapabilitiesReader.superclass.constructor.call( + this, meta, recordType + ); +}; + +Ext.extend(GeoExt.data.WCSCapabilitiesReader, Ext.data.DataReader, { + + /** private: method[read] + * :param request: ``Object`` The XHR object which contains the parsed XML + * document. + * :return: ``Object`` A data block which is used by an ``Ext.data.Store`` + * as a cache of ``Ext.data.Record`` objects. + */ + read: function(request) { + var data = request.responseXML; + if(!data || !data.documentElement) { + data = request.responseText; + } + return this.readRecords(data); + }, + + /** private: method[readRecords] + * :param data: ``DOMElement | String | Object`` A document element or XHR + * response string. As an alternative to fetching capabilities data + * from a remote source, an object representing the capabilities can + * be provided given that the structure mirrors that returned from the + * capabilities parser. + * :return: ``Object`` A data block which is used by an ``Ext.data.Store`` + * as a cache of ``Ext.data.Record`` objects. + * + * Create a data block containing Ext.data.Records from an XML document. + */ + readRecords: function(data) { + if(typeof data === "string" || data.nodeType) { + data = this.meta.format.read(data); + } + + var contents = data.contentMetadata; + var fields = this.recordType.prototype.fields; + + var coverageSummary, values, field, v; + + + + var records = []; + + for(var i=0, lenI=contents.length; i + + + + + + + + + + + + + +
+ + diff --git a/tests/lib/GeoExt/data/WCSCapabilitiesReader.js b/tests/lib/GeoExt/data/WCSCapabilitiesReader.js new file mode 100644 index 00000000..6c6b2435 --- /dev/null +++ b/tests/lib/GeoExt/data/WCSCapabilitiesReader.js @@ -0,0 +1,198 @@ +var doc = (new OpenLayers.Format.XML).read( +'' + +'' + + '' + + 'Web-Service Demo with data stored at TUDOR site' + + 'This installation serves different Web-Service types (WMS, WFS) for testing' + + '' + + 'Geospatial WebServices' + + 'Keyword One' + + 'Keyword Two!!' + + '' + + 'OGC WCS' + + '1.1.0' + + 'No fee!' + + 'Unconstrained!' + + '' + + '' + + 'CRP Henri Tudor' + + '' + + '' + + 'Roy Dumerde' + + 'R+D engineer' + + '' + + '' + + '6463320' + + '6465955' + + '' + + '' + + '66, rue de Luxembourg' + + 'Esch-sur-Alzette' + + '' + + '97202' + + 'Luxembourg' + + 'flappy@tutones.com' + + '' + + '' + + '24/7' + + 'by phone' + + '' + + 'GIS-Analyst' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + 'WCS' + + '' + + '' + + '' + + '' + + '1.1.0' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + 'WCS' + + '' + + '' + + '' + + '' + + '1.1.0' + + '' + + '' + + '' + + '' + + 'ro_dsm' + + 'ro_dsm_mini' + + 'ro_irra' + + 'ro_irra_ext' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + 'WCS' + + '' + + '' + + '' + + '' + + '1.1.0' + + '' + + '' + + '' + + '' + + 'ro_dsm' + + 'ro_dsm_mini' + + 'ro_irra' + + 'ro_irra_ext' + + '' + + '' + + '' + + '' + + 'NEAREST_NEIGHBOUR' + + 'BILINEAR' + + '' + + '' + + '' + + '' + + 'image/tiff' + + 'image/png' + + 'image/jpeg' + + 'image/gif' + + 'image/png; mode=8bit' + + '' + + '' + + '' + + '' + + 'false' + + '' + + '' + + '' + + '' + + 'urn:ogc:def:crs:epsg::4326' + + '' + + '' + + '' + + '' + + '' + + '' + + 'Rotterdam DSM' + + 'Digital Surface Model (DSM) raster data set of inner city Rotterdam' + + '' + + '4.471333734139 51.912813427383' + + '4.4808508475645 51.9248713705576' + + '' + + 'urn:ogc:def:crs:EPSG::28992' + + 'urn:ogc:def:crs:EPSG::900913' + + 'urn:ogc:def:crs:EPSG::3857' + + 'urn:ogc:def:crs:EPSG::4326' + + 'image/tiff' + + 'ro_dsm' + + '' + + '' + + 'Rotterdam sample DSM subset' + + 'This a test data set of Rotterdams DSM subset' + + '' + + '4.47489346945755 51.9159453786927' + + '4.47687824892444 51.9170706688033' + + '' + + 'urn:ogc:def:crs:EPSG::28992' + + 'urn:ogc:def:crs:EPSG::900913' + + 'urn:ogc:def:crs:EPSG::3857' + + 'urn:ogc:def:crs:EPSG::4326' + + 'image/tiff' + + 'ro_dsm_mini' + + '' + + '' + + 'Rotterdam (Ljinbaan) solar irradiation data 2010' + + 'This a result data set of a solar computation of Ljinbaan area. It shows the sum of kWh/a per sqmeter for 2010' + + '' + + '4.471333734139 51.912813427383' + + '4.4808508475645 51.9248713705576' + + '' + + 'urn:ogc:def:crs:EPSG::28992' + + 'urn:ogc:def:crs:EPSG::900913' + + 'urn:ogc:def:crs:EPSG::3857' + + 'urn:ogc:def:crs:EPSG::4326' + + 'image/tiff' + + 'ro_irra' + + '' + + '' + + 'Rotterdam (extended) solar irradiation data 2010' + + 'This a result data set of a solar computation of extended Rotterdam area. It shows the sum of kWh/a per sqmeter for 2010' + + '' + + '4.10024171314823 51.9359764992844' + + '4.21909054278063 52.001415228243' + + '' + + 'urn:ogc:def:crs:EPSG::28992' + + 'urn:ogc:def:crs:EPSG::900913' + + 'urn:ogc:def:crs:EPSG::3857' + + 'urn:ogc:def:crs:EPSG::4326' + + 'image/tiff' + + 'ro_irra_ext' + + '' + + '' + +'' ); From 5e977c1e61cfce3483fe0e86820a0cbe9a5851dd Mon Sep 17 00:00:00 2001 From: Christopher Eykamp Date: Mon, 7 Jan 2013 13:39:03 +0100 Subject: [PATCH 2/9] More early stage wcs support --- lib/GeoExt.js | 1 + lib/GeoExt/data/WFSCapabilitiesReader.js | 2 ++ tests/lib/GeoExt/data/WFSCapabilitiesReader.html | 2 +- tests/list-tests.html | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/GeoExt.js b/lib/GeoExt.js index 64ff68f2..47042b78 100644 --- a/lib/GeoExt.js +++ b/lib/GeoExt.js @@ -79,6 +79,7 @@ "GeoExt/data/WFSCapabilitiesReader.js", "GeoExt/data/WFSCapabilitiesStore.js", "GeoExt/data/WMSDescribeLayerReader.js", + "GeoExt/data/WCSCapabilitiesReader.js", "GeoExt/data/WMSDescribeLayerStore.js", "GeoExt/data/WMCReader.js", "GeoExt/data/CSWRecordsReader.js", diff --git a/lib/GeoExt/data/WFSCapabilitiesReader.js b/lib/GeoExt/data/WFSCapabilitiesReader.js index 3fc829ff..1cc0b1fd 100644 --- a/lib/GeoExt/data/WFSCapabilitiesReader.js +++ b/lib/GeoExt/data/WFSCapabilitiesReader.js @@ -95,6 +95,8 @@ Ext.extend(GeoExt.data.WFSCapabilitiesReader, Ext.data.DataReader, { var featureTypes = data.featureTypeList.featureTypes; var fields = this.recordType.prototype.fields; + debugger + var featureType, values, field, v, parts, layer; var layerOptions, protocolOptions; diff --git a/tests/lib/GeoExt/data/WFSCapabilitiesReader.html b/tests/lib/GeoExt/data/WFSCapabilitiesReader.html index def550e2..63e6809b 100644 --- a/tests/lib/GeoExt/data/WFSCapabilitiesReader.html +++ b/tests/lib/GeoExt/data/WFSCapabilitiesReader.html @@ -54,7 +54,7 @@ "[0] correct layer abstract" ); - //3 tests -- Testing the layer field (and its default protocol) + // 4 tests -- Testing the layer field (and its default protocol) var layer = record.getLayer(); t.eq(layer.CLASS_NAME, "OpenLayers.Layer.Vector", "[0] layer field is of type OpenLayers.Layer.Vector"); t.eq(layer.protocol.CLASS_NAME, "OpenLayers.Protocol.WFS.v1_0_0", "[0] protocol is of type OpenLayers.Protocol.WFS.v1_0_0"); diff --git a/tests/list-tests.html b/tests/list-tests.html index 721ab85a..aca397c4 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -14,6 +14,7 @@
  • lib/GeoExt/data/ProtocolProxy.html
  • lib/GeoExt/data/StyleReader.html
  • lib/GeoExt/data/WFSCapabilitiesReader.html
  • +
  • lib/GeoExt/data/WCSCapabilitiesReader.html
  • lib/GeoExt/data/WMSCapabilitiesReader.html
  • lib/GeoExt/data/WMSDescribeLayerReader.html
  • lib/GeoExt/data/WMCReader.html
  • From 06f0642fd5812a7105d80955b826c6d7014725e4 Mon Sep 17 00:00:00 2001 From: Christopher Eykamp Date: Mon, 7 Jan 2013 14:23:34 +0100 Subject: [PATCH 3/9] Remove debugging statement --- lib/GeoExt/data/WFSCapabilitiesReader.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/GeoExt/data/WFSCapabilitiesReader.js b/lib/GeoExt/data/WFSCapabilitiesReader.js index 1cc0b1fd..3fc829ff 100644 --- a/lib/GeoExt/data/WFSCapabilitiesReader.js +++ b/lib/GeoExt/data/WFSCapabilitiesReader.js @@ -95,8 +95,6 @@ Ext.extend(GeoExt.data.WFSCapabilitiesReader, Ext.data.DataReader, { var featureTypes = data.featureTypeList.featureTypes; var fields = this.recordType.prototype.fields; - debugger - var featureType, values, field, v, parts, layer; var layerOptions, protocolOptions; From af1b95d00f134e86b7a3a3db8fecf89c44e9b3a8 Mon Sep 17 00:00:00 2001 From: Christopher Eykamp Date: Mon, 7 Jan 2013 14:33:13 +0100 Subject: [PATCH 4/9] Add WCSCapabilitiesStore --- lib/GeoExt.js | 1 + lib/GeoExt/data/WCSCapabilitiesStore.js | 58 +++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 lib/GeoExt/data/WCSCapabilitiesStore.js diff --git a/lib/GeoExt.js b/lib/GeoExt.js index 47042b78..f883fe39 100644 --- a/lib/GeoExt.js +++ b/lib/GeoExt.js @@ -80,6 +80,7 @@ "GeoExt/data/WFSCapabilitiesStore.js", "GeoExt/data/WMSDescribeLayerReader.js", "GeoExt/data/WCSCapabilitiesReader.js", + "GeoExt/data/WCSCapabilitiesStore.js", "GeoExt/data/WMSDescribeLayerStore.js", "GeoExt/data/WMCReader.js", "GeoExt/data/CSWRecordsReader.js", diff --git a/lib/GeoExt/data/WCSCapabilitiesStore.js b/lib/GeoExt/data/WCSCapabilitiesStore.js new file mode 100644 index 00000000..4efd8b67 --- /dev/null +++ b/lib/GeoExt/data/WCSCapabilitiesStore.js @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2008-2012 The Open Source Geospatial Foundation + * + * Published under the BSD license. + * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text + * of the license. + */ + +/** + * @include GeoExt/data/WCSCapabilitiesReader.js + */ + +/** api: (define) + * module = GeoExt.data + * class = WCSCapabilitiesStore + * base_link = `Ext.data.Store `_ + */ +Ext.namespace("GeoExt.data"); + +/** api: constructor + * .. class:: WCSCapabilitiesStore + * + * Small helper class to make creating stores for remote WCS metadata + * easier. The store is pre-configured with a built-in + * ``Ext.data.HttpProxy`` and :class:`GeoExt.data.WCSCapabilitiesReader`. + * The proxy is configured to allow caching and issues requests via GET. + */ + +/** api: config[format] + * ``OpenLayers.Format`` + * A parser for transforming the XHR response into an array of objects + * representing attributes. Defaults to an ``OpenLayers.Format.WCSCapabilities`` + * parser. + */ + +/** api: config[fields] + * ``Array | Function`` + * Either an Array of field definition objects as passed to + * ``Ext.data.Record.create``, or a record constructor created using + * ``Ext.data.Record.create``. Defaults to ``["name", "type"]``. + */ + +GeoExt.data.WCSCapabilitiesStore = function(c) { + c = c || {}; + GeoExt.data.WCSCapabilitiesStore.superclass.constructor.call( + this, + Ext.apply(c, { + proxy: c.proxy || (!c.data ? + new Ext.data.HttpProxy({url: c.url, disableCaching: false, method: "GET"}) : + undefined + ), + reader: new GeoExt.data.WCSCapabilitiesReader( + c, c.fields + ) + }) + ); +}; +Ext.extend(GeoExt.data.WCSCapabilitiesStore, Ext.data.Store); From 88f0548974cb5725e6ddf0c7412275e84979c463 Mon Sep 17 00:00:00 2001 From: Christopher Eykamp Date: Tue, 8 Jan 2013 10:31:34 +0100 Subject: [PATCH 5/9] Finalize (hopefully) WCSCapabilitiesReader --- lib/GeoExt/data/WCSCapabilitiesReader.js | 11 +- .../GeoExt/data/WCSCapabilitiesReader.html | 27 +++- .../lib/GeoExt/data/WCSCapabilitiesReader.js | 127 +++++++++++++++++- 3 files changed, 152 insertions(+), 13 deletions(-) diff --git a/lib/GeoExt/data/WCSCapabilitiesReader.js b/lib/GeoExt/data/WCSCapabilitiesReader.js index ff889a96..f8701cfd 100644 --- a/lib/GeoExt/data/WCSCapabilitiesReader.js +++ b/lib/GeoExt/data/WCSCapabilitiesReader.js @@ -41,13 +41,12 @@ GeoExt.data.WCSCapabilitiesReader = function(meta, recordType) { if(!(typeof recordType === "function")) { fields = recordType || meta.fields || [ {name: "title", type: "string"}, - {name: "namespace", type: "string", mapping: "featureNS"}, {name: "abstract", type: "string"} ]; // Make sure we always have an identifier attribute; // this will be needed by readRecords. - fields.push({name: "identifier", type: "string"}); // same as WFS "name" + fields.push({name: "identifier", type: "string"}); recordType = Ext.data.Record.create(fields); } @@ -93,13 +92,13 @@ Ext.extend(GeoExt.data.WCSCapabilitiesReader, Ext.data.DataReader, { var coverageSummary, values, field, v; - - var records = []; for(var i=0, lenI=contents.length; i - +