[Commits] r1079 - in sandbox/camptocamp/geobretagne: examples examples/data lib/GeoExt/data
commits at geoext.org
commits at geoext.org
Mon Jun 15 10:49:30 CEST 2009
Author: elemoine
Date: 2009-06-15 10:49:30 +0200 (Mon, 15 Jun 2009)
New Revision: 1079
Added:
sandbox/camptocamp/geobretagne/examples/csw-getrecords.html
sandbox/camptocamp/geobretagne/examples/csw-getrecords.js
sandbox/camptocamp/geobretagne/examples/data/cswrecords.xml
Removed:
sandbox/camptocamp/geobretagne/examples/csw.html
sandbox/camptocamp/geobretagne/examples/csw.js
sandbox/camptocamp/geobretagne/examples/data/cswcap.xml
Modified:
sandbox/camptocamp/geobretagne/lib/GeoExt/data/CSWRecordsReader.js
Log:
apply patch-87-r1078-A2.diff from ticket #82
Added: sandbox/camptocamp/geobretagne/examples/csw-getrecords.html
===================================================================
--- sandbox/camptocamp/geobretagne/examples/csw-getrecords.html (rev 0)
+++ sandbox/camptocamp/geobretagne/examples/csw-getrecords.html 2009-06-15 08:49:30 UTC (rev 1079)
@@ -0,0 +1,24 @@
+<html>
+ <head>
+ <title>GeoExt CSW Example</title>
+
+ <script type="text/javascript" src="http://extjs.cachefly.net/builds/ext-cdn-771.js"></script>
+ <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/resources/css/ext-all.css" />
+ <link rel="stylesheet" type="text/css" href="http://extjs.com/deploy/dev/examples/shared/examples.css" />
+ <script src="../../openlayers/lib/OpenLayers.js"></script>
+ <script type="text/javascript" src="../lib/GeoExt.js"></script>
+
+ <script type="text/javascript" src="csw-getrecords.js"></script>
+
+ </head>
+ <body>
+ <h1>CSW Example</h1>
+ <p>This example shows how to load a grid with data from a CSW
+ GetRecords request.</p>
+
+ <p>Note that the js is not minified so it is readable.
+ See <a href="csw-getrecords.js">csw-getrecords.js</a>.</p>
+
+ <div id="cswgrid"></div>
+ </body>
+</html>
Added: sandbox/camptocamp/geobretagne/examples/csw-getrecords.js
===================================================================
--- sandbox/camptocamp/geobretagne/examples/csw-getrecords.js (rev 0)
+++ sandbox/camptocamp/geobretagne/examples/csw-getrecords.js 2009-06-15 08:49:30 UTC (rev 1079)
@@ -0,0 +1,26 @@
+
+Ext.onReady(function() {
+
+ // create store
+ var store = new Ext.data.Store({
+ reader: new GeoExt.data.CSWRecordsReader({
+ fields: ['title', 'subject']
+ }),
+ url: "data/cswrecords.xml",
+ autoLoad: true
+ });
+
+ // create grid to display records from the store
+ var grid = new Ext.grid.GridPanel({
+ title: "CSW Records",
+ store: store,
+ columns: [
+ {id: 'title', header: "Title", dataIndex: "title", sortable: true},
+ {header: "Subject", dataIndex: "subject", sortable: true, width: 300}
+ ],
+ autoExpandColumn: 'title',
+ renderTo: "cswgrid",
+ height: 300,
+ width: 650
+ });
+});
Deleted: sandbox/camptocamp/geobretagne/examples/csw.html
===================================================================
--- sandbox/camptocamp/geobretagne/examples/csw.html 2009-06-15 06:31:36 UTC (rev 1078)
+++ sandbox/camptocamp/geobretagne/examples/csw.html 2009-06-15 08:49:30 UTC (rev 1079)
@@ -1,24 +0,0 @@
-<html>
- <head>
- <title>GeoExt CSW Example</title>
-
- <script type="text/javascript" src="http://extjs.cachefly.net/builds/ext-cdn-771.js"></script>
- <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/resources/css/ext-all.css" />
- <link rel="stylesheet" type="text/css" href="http://extjs.com/deploy/dev/examples/shared/examples.css" />
- <script src="../../openlayers/lib/OpenLayers.js"></script>
- <script type="text/javascript" src="../lib/GeoExt.js"></script>
-
- <script type="text/javascript" src="csw.js"></script>
-
- </head>
- <body>
- <h1>CSW Example</h1>
- <p>This example shows how to load a grid with data from a CSW
- GetRecords request.</p>
-
- <p>Note that the js is not minified so it is readable.
- See <a href="csw.js">csw.js</a>.</p>
-
- <div id="cswgrid"></div>
- </body>
-</html>
Deleted: sandbox/camptocamp/geobretagne/examples/csw.js
===================================================================
--- sandbox/camptocamp/geobretagne/examples/csw.js 2009-06-15 06:31:36 UTC (rev 1078)
+++ sandbox/camptocamp/geobretagne/examples/csw.js 2009-06-15 08:49:30 UTC (rev 1079)
@@ -1,35 +0,0 @@
-
-Ext.onReady(function() {
-
- // create a new store
- var store = new Ext.data.Store({
- reader: new GeoExt.data.CSWRecordsReader({
- fields: ['title', 'subject']
- })
- });
- // create a grid to display records from the store
- var grid = new Ext.grid.GridPanel({
- title: "CSW Records",
- store: store,
- columns: [
- {id: 'title', header: "Title", dataIndex: "title", sortable: true},
- {header: "Subject", dataIndex: "subject", sortable: true, width: 300}
- ],
- autoExpandColumn: 'title',
- renderTo: "cswgrid",
- height: 300,
- width: 650
- });
-
- var format = new OpenLayers.Format.CSWGetRecords();
-
- // Load CSW data from a static file for csw GetRecords response
- var request = OpenLayers.Request.GET({
- url: "data/cswcap.xml",
- success : function(response) {
- // load the store with records derived from response
- store.loadData(format.read(response.responseText));
- }
- });
-
-});
Deleted: sandbox/camptocamp/geobretagne/examples/data/cswcap.xml
===================================================================
--- sandbox/camptocamp/geobretagne/examples/data/cswcap.xml 2009-06-15 06:31:36 UTC (rev 1078)
+++ sandbox/camptocamp/geobretagne/examples/data/cswcap.xml 2009-06-15 08:49:30 UTC (rev 1079)
@@ -1,81 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<csw:GetRecordsResponse xmlns:csw="http://www.opengis.net/cat/csw/2.0.2">
- <csw:SearchStatus timestamp="2009-06-12T11:01:32" />
- <csw:SearchResults numberOfRecordsMatched="60" numberOfRecordsReturned="60" elementSet="full" nextRecord="0">
- <csw:Record xmlns:geonet="http://www.fao.org/geonetwork" xmlns:ows="http://www.opengis.net/ows" xmlns:dct="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/">
- <dc:title>Globally threatened species of the world</dc:title>
- <dc:subject>GEMET 2000
- biodiversity
- endangered animal species
- endangered plant species</dc:subject>
- <dc:subject>None
- Biology</dc:subject>
- <dc:subject>None
- Global</dc:subject>
- <dct:abstract>Contains information on animals and plants threatened at the global level.</dct:abstract>
- <dct:modified>20011220</dct:modified>
- <dc:creator>GeoNetwork test user</dc:creator>
- <dc:publisher>GeoNetwork test centre</dc:publisher>
- <dc:rights>None</dc:rights>
- <dc:rights>No restrictions</dc:rights>
- <ows:BoundingBox crs="">
- <ows:LowerCorner>180.0-90.0</ows:LowerCorner>
- <ows:UpperCorner>-180.090.0</ows:UpperCorner>
- </ows:BoundingBox>
- </csw:Record>
- <csw:Record xmlns:geonet="http://www.fao.org/geonetwork" xmlns:ows="http://www.opengis.net/ows" xmlns:dc="http://purl.org/dc/elements/1.1/">
- <dc:title xmlns:dct="http://purl.org/dc/terms/">Natural polar ecosystems</dc:title>
- <dc:creator xmlns:dct="http://purl.org/dc/terms/">GeoNetwork test user</dc:creator>
- <dc:subject xmlns:dct="http://purl.org/dc/terms/">Antarctic ecosystem</dc:subject>
- <dc:subject xmlns:dct="http://purl.org/dc/terms/">Arctic ecosystem</dc:subject>
- <dc:subject xmlns:dct="http://purl.org/dc/terms/">polar ecosystem</dc:subject>
- <dc:description xmlns:dct="http://purl.org/dc/terms/">A harmonised database of natural ecosystems in the Circumpolar Arctic, based on published vegetation maps.</dc:description>
- <dc:publisher xmlns:dct="http://purl.org/dc/terms/">GeoNetwork test centre</dc:publisher>
- <dc:contributor xmlns:dct="http://purl.org/dc/terms/">Unknown</dc:contributor>
- <dc:date xmlns:dct="http://purl.org/dc/terms/">2000</dc:date>
- <dc:type xmlns:dct="http://purl.org/dc/terms/">Maps and graphics</dc:type>
- <dc:format xmlns:dct="http://purl.org/dc/terms/">Web page</dc:format>
- <dc:identifier xmlns:dct="http://purl.org/dc/terms/">e2987cb0-3090-4a31-b90f-d3d024735ff7</dc:identifier>
- <dc:source xmlns:dct="http://purl.org/dc/terms/">Compiled from published vegetation maps of the 8 circumpolar countries.</dc:source>
- <dc:language xmlns:dct="http://purl.org/dc/terms/">en</dc:language>
- <dc:relation xmlns:dct="http://purl.org/dc/terms/">Unknown</dc:relation>
- <dc:coverage xmlns:dct="http://purl.org/dc/terms/">North 90, South -90, East 180, West -180. (Global)</dc:coverage>
- <dc:rights xmlns:dct="http://purl.org/dc/terms/">Access constraints: None. Usage constraints: No restrictions</dc:rights>
- <dct:modified xmlns:dct="http://purl.org/dc/terms/">2005-03-31T19:13:30</dct:modified>
- <ows:BoundingBox crs="urn:x-ogc:def:crs:EPSG:6.11:4326">
- <ows:LowerCorner>-90 -180</ows:LowerCorner>
- <ows:UpperCorner>90 180</ows:UpperCorner>
- </ows:BoundingBox>
- </csw:Record>
- <csw:Record xmlns:ows="http://www.opengis.net/ows" xmlns:geonet="http://www.fao.org/geonetwork" xmlns:dct="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/">
- <dc:identifier>8dfef0e6-969e-4327-b292-5e7047f11808</dc:identifier>
- <dc:title>Hydrological basins in Europe</dc:title>
- <dc:subject>watersheds</dc:subject>
- <dc:subject>Europe</dc:subject>
- <dct:abstract>Major hydrological basins and their sub-basins. This dataset divides the Europe in zones.</dct:abstract>
- <dc:language>en</dc:language>
- <dc:source>None.</dc:source>
- <ows:BoundingBox crs="::">
- <ows:LowerCorner>51.1 -34.6</ows:LowerCorner>
- <ows:UpperCorner>-17.3 38.2</ows:UpperCorner>
- </ows:BoundingBox>
- <dc:URI>resources.get?id=&fname=large_s.png&access=public</dc:URI>
- </csw:Record>
- <csw:Record xmlns:ows="http://www.opengis.net/ows" xmlns:geonet="http://www.fao.org/geonetwork" xmlns:dct="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/">
- <dc:identifier>bd7b3827-d6c4-4bd1-bac3-8e0e388e7a23</dc:identifier>
- <dc:title>Cours d'eau</dc:title>
- <dc:type>dataset</dc:type>
- <dc:format />
- <dct:abstract />
- <dc:language />
- <dc:source />
- <ows:BoundingBox crs="::">
- <ows:LowerCorner>180 -90</ows:LowerCorner>
- <ows:UpperCorner>-180 90</ows:UpperCorner>
- </ows:BoundingBox>
- <dc:format />
- <dc:URI>http://services.sandre.eaufrance.fr/geo/zonage?</dc:URI>
- </csw:Record>
- </csw:SearchResults>
-</csw:GetRecordsResponse>
-
Added: sandbox/camptocamp/geobretagne/examples/data/cswrecords.xml
===================================================================
--- sandbox/camptocamp/geobretagne/examples/data/cswrecords.xml (rev 0)
+++ sandbox/camptocamp/geobretagne/examples/data/cswrecords.xml 2009-06-15 08:49:30 UTC (rev 1079)
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<csw:GetRecordsResponse xmlns:csw="http://www.opengis.net/cat/csw/2.0.2">
+ <csw:SearchStatus timestamp="2009-06-12T11:01:32" />
+ <csw:SearchResults numberOfRecordsMatched="60" numberOfRecordsReturned="60" elementSet="full" nextRecord="0">
+ <csw:Record xmlns:geonet="http://www.fao.org/geonetwork" xmlns:ows="http://www.opengis.net/ows" xmlns:dct="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <dc:title>Globally threatened species of the world</dc:title>
+ <dc:subject>GEMET 2000
+ biodiversity
+ endangered animal species
+ endangered plant species</dc:subject>
+ <dc:subject>None
+ Biology</dc:subject>
+ <dc:subject>None
+ Global</dc:subject>
+ <dct:abstract>Contains information on animals and plants threatened at the global level.</dct:abstract>
+ <dct:modified>20011220</dct:modified>
+ <dc:creator>GeoNetwork test user</dc:creator>
+ <dc:publisher>GeoNetwork test centre</dc:publisher>
+ <dc:rights>None</dc:rights>
+ <dc:rights>No restrictions</dc:rights>
+ <ows:BoundingBox crs="">
+ <ows:LowerCorner>180.0-90.0</ows:LowerCorner>
+ <ows:UpperCorner>-180.090.0</ows:UpperCorner>
+ </ows:BoundingBox>
+ </csw:Record>
+ <csw:Record xmlns:geonet="http://www.fao.org/geonetwork" xmlns:ows="http://www.opengis.net/ows" xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <dc:title xmlns:dct="http://purl.org/dc/terms/">Natural polar ecosystems</dc:title>
+ <dc:creator xmlns:dct="http://purl.org/dc/terms/">GeoNetwork test user</dc:creator>
+ <dc:subject xmlns:dct="http://purl.org/dc/terms/">Antarctic ecosystem</dc:subject>
+ <dc:subject xmlns:dct="http://purl.org/dc/terms/">Arctic ecosystem</dc:subject>
+ <dc:subject xmlns:dct="http://purl.org/dc/terms/">polar ecosystem</dc:subject>
+ <dc:description xmlns:dct="http://purl.org/dc/terms/">A harmonised database of natural ecosystems in the Circumpolar Arctic, based on published vegetation maps.</dc:description>
+ <dc:publisher xmlns:dct="http://purl.org/dc/terms/">GeoNetwork test centre</dc:publisher>
+ <dc:contributor xmlns:dct="http://purl.org/dc/terms/">Unknown</dc:contributor>
+ <dc:date xmlns:dct="http://purl.org/dc/terms/">2000</dc:date>
+ <dc:type xmlns:dct="http://purl.org/dc/terms/">Maps and graphics</dc:type>
+ <dc:format xmlns:dct="http://purl.org/dc/terms/">Web page</dc:format>
+ <dc:identifier xmlns:dct="http://purl.org/dc/terms/">e2987cb0-3090-4a31-b90f-d3d024735ff7</dc:identifier>
+ <dc:source xmlns:dct="http://purl.org/dc/terms/">Compiled from published vegetation maps of the 8 circumpolar countries.</dc:source>
+ <dc:language xmlns:dct="http://purl.org/dc/terms/">en</dc:language>
+ <dc:relation xmlns:dct="http://purl.org/dc/terms/">Unknown</dc:relation>
+ <dc:coverage xmlns:dct="http://purl.org/dc/terms/">North 90, South -90, East 180, West -180. (Global)</dc:coverage>
+ <dc:rights xmlns:dct="http://purl.org/dc/terms/">Access constraints: None. Usage constraints: No restrictions</dc:rights>
+ <dct:modified xmlns:dct="http://purl.org/dc/terms/">2005-03-31T19:13:30</dct:modified>
+ <ows:BoundingBox crs="urn:x-ogc:def:crs:EPSG:6.11:4326">
+ <ows:LowerCorner>-90 -180</ows:LowerCorner>
+ <ows:UpperCorner>90 180</ows:UpperCorner>
+ </ows:BoundingBox>
+ </csw:Record>
+ <csw:Record xmlns:ows="http://www.opengis.net/ows" xmlns:geonet="http://www.fao.org/geonetwork" xmlns:dct="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <dc:identifier>8dfef0e6-969e-4327-b292-5e7047f11808</dc:identifier>
+ <dc:title>Hydrological basins in Europe</dc:title>
+ <dc:subject>watersheds</dc:subject>
+ <dc:subject>Europe</dc:subject>
+ <dct:abstract>Major hydrological basins and their sub-basins. This dataset divides the Europe in zones.</dct:abstract>
+ <dc:language>en</dc:language>
+ <dc:source>None.</dc:source>
+ <ows:BoundingBox crs="::">
+ <ows:LowerCorner>51.1 -34.6</ows:LowerCorner>
+ <ows:UpperCorner>-17.3 38.2</ows:UpperCorner>
+ </ows:BoundingBox>
+ <dc:URI>resources.get?id=&fname=large_s.png&access=public</dc:URI>
+ </csw:Record>
+ <csw:Record xmlns:ows="http://www.opengis.net/ows" xmlns:geonet="http://www.fao.org/geonetwork" xmlns:dct="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <dc:identifier>bd7b3827-d6c4-4bd1-bac3-8e0e388e7a23</dc:identifier>
+ <dc:title>Cours d'eau</dc:title>
+ <dc:type>dataset</dc:type>
+ <dc:format />
+ <dct:abstract />
+ <dc:language />
+ <dc:source />
+ <ows:BoundingBox crs="::">
+ <ows:LowerCorner>180 -90</ows:LowerCorner>
+ <ows:UpperCorner>-180 90</ows:UpperCorner>
+ </ows:BoundingBox>
+ <dc:format />
+ <dc:URI>http://services.sandre.eaufrance.fr/geo/zonage?</dc:URI>
+ </csw:Record>
+ </csw:SearchResults>
+</csw:GetRecordsResponse>
+
Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/data/CSWRecordsReader.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/data/CSWRecordsReader.js 2009-06-15 06:31:36 UTC (rev 1078)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/data/CSWRecordsReader.js 2009-06-15 08:49:30 UTC (rev 1079)
@@ -5,15 +5,12 @@
*
* pending approval */
-/**
- * @include OpenLayers/Format/CSWGetRecords.js
- */
-
/** api: (define)
* module = GeoExt.data
* class = CSWRecordsReader
- * base_link = `Ext.data.DataReader <http://extjs.com/deploy/dev/docs/?class=Ext.data.DataReader>`_
+ * base_link = `Ext.data.JsonReader <http://extjs.com/deploy/dev/docs/?class=Ext.data.JsonReader>`_
*/
+
Ext.namespace("GeoExt.data");
/** api: constructor
@@ -24,8 +21,8 @@
* configuration objects or a record object. Default is
* :class:`Ext.data.Record`.
*
- * Data reader class to create an array of
- * objects from a CSW GetRecords response.
+ * Data reader class to create an array of records from a CSW
+ * GetRecords response.
*/
GeoExt.data.CSWRecordsReader = function(meta, recordType) {
meta = meta || {};
@@ -38,8 +35,8 @@
// FIXME
// There may be information of interest in the getRecords response
- // ie. SearchResults.numberOfRecordsReturned
- // or SearchResults.numberOfRecordsMatched
+ // namely SearchResults.numberOfRecordsReturned and
+ // SearchResults.numberOfRecordsMatched
GeoExt.data.CSWRecordsReader.superclass.constructor.call(
this, meta, recordType
@@ -49,12 +46,33 @@
Ext.extend(GeoExt.data.CSWRecordsReader, Ext.data.JsonReader, {
/** private: method[read]
- * :param reponse: ``OpenLayers.Protocol.Response`` The OpenLayers protocol
- * response as returned by the protocol read method.
- * :return: ``Object`` A data block which is used by an ``Ext.data.Store``
- * as a cache of ``Ext.data.Record`` objects.
+ * :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(response) {
- return this.readRecords(response.data);
+ 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.
+ * :return: ``Object`` A data block which is used by an
+ * ``Ext.data.Store`` as a cache of ``Ext.data.Record``
+ * objects.
+ */
+ readRecords: function(data) {
+ if(typeof data === "string" || data.nodeType) {
+ data = this.meta.format.read(data);
+ }
+ return GeoExt.data.CSWRecordsReader.superclass.readRecords.call(
+ this, data
+ );
}
});
More information about the Commits
mailing list