[OpenLayers-Commits] r7357 - in sandbox/topp/geoext/lib: . OpenLayers/Format OpenLayers/Format/WFSDescribeFeatureType
commits at openlayers.org
commits at openlayers.org
Fri Jun 13 15:14:39 EDT 2008
Author: tcoulter
Date: 2008-06-13 15:14:39 -0400 (Fri, 13 Jun 2008)
New Revision: 7357
Added:
sandbox/topp/geoext/lib/OpenLayers/Format/WFSDescribeFeatureType.js
sandbox/topp/geoext/lib/OpenLayers/Format/WFSDescribeFeatureType/
sandbox/topp/geoext/lib/OpenLayers/Format/WFSDescribeFeatureType/v1_0.js
Modified:
sandbox/topp/geoext/lib/OpenLayers.js
Log:
Added WFSDescribeFeatureType format from this patch: http://trac.openlayers.org/attachment/ticket/1202/ticket1202.patch
Notice that Trac only shows one file, but the patch actually contains two. You may need to download the original format to see both.
Added: sandbox/topp/geoext/lib/OpenLayers/Format/WFSDescribeFeatureType/v1_0.js
===================================================================
--- sandbox/topp/geoext/lib/OpenLayers/Format/WFSDescribeFeatureType/v1_0.js (rev 0)
+++ sandbox/topp/geoext/lib/OpenLayers/Format/WFSDescribeFeatureType/v1_0.js 2008-06-13 19:14:39 UTC (rev 7357)
@@ -0,0 +1,65 @@
+/**
+ * @requires OpenLayers/Format/WFSDescribeFeatureType.js
+ *
+ * Class: OpenLayers.Format.WFSDescribeFeatureType_1_0
+ * Read WFS DescribeFeatureType response for WFS 1.0
+ *
+ * Inherits from:
+ * - <OpenLayers.Format.WFSDescribeFeatureType>
+ */
+OpenLayers.Format.WFSDescribeFeatureType.v1_0 = OpenLayers.Class(
+ OpenLayers.Format.XML, {
+
+ /**
+ * Constant: VERSION
+ * {String} 1.0
+ */
+ VERSION: "1.0",
+
+ /**
+ * Constructor: OpenLayers.Format.WFSDescribeFeatureType
+ * Create a new parser for WFS DescribeFeatureType responses.
+ *
+ * Parameters:
+ * options - {Object} An optional object whose properties will be set on
+ * this instance.
+ */
+ initialize: function(options) {
+ OpenLayers.Format.WFSDescribeFeatureType.prototype.initialize.apply(this,
+ [options]);
+ },
+
+ /**
+ * APIMethod: read
+ * Read WFS DescribeFeatureType data from a string, return the response.
+ *
+ * Parameters:
+ * data - {String} or {DOMElement} data to read/parse.
+ *
+ * Returns:
+ * {Array} Array of objects which have:
+ * - {String} name: attribute names
+ * - {String} type: attributes types, like xsd:string
+ */
+ read: function(data) {
+ if(typeof data == "string") {
+ data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
+ }
+ var describefeaturetype = [];
+ var root = data.documentElement;
+ var sequence = root.getElementsByTagName('sequence');
+ if (sequence.length > 0) {
+ var elements = sequence[0].getElementsByTagName('element');
+ for(var i=0; i<elements.length; ++i) {
+ var element = elements[i];
+ var name = element.getAttribute('name');
+ var type = element.getAttribute('type');
+ describefeaturetype.push({name: name, type: type});
+ }
+ }
+ return describefeaturetype;
+ },
+
+ CLASS_NAME: "OpenLayers.Format.WFSDescribeFeatureType_1_0"
+
+});
Added: sandbox/topp/geoext/lib/OpenLayers/Format/WFSDescribeFeatureType.js
===================================================================
--- sandbox/topp/geoext/lib/OpenLayers/Format/WFSDescribeFeatureType.js (rev 0)
+++ sandbox/topp/geoext/lib/OpenLayers/Format/WFSDescribeFeatureType.js 2008-06-13 19:14:39 UTC (rev 7357)
@@ -0,0 +1,84 @@
+/**
+ * @requires OpenLayers/Format/XML.js
+ *
+ * Class: OpenLayers.Format.WFSDescribeFeatureType
+ * Read WFS DescribeFeatureType response
+ * DescribeFeatureType is meant to describe a feature type
+ * and give back its attributes and attribute types
+ * The output is an XML Schema
+ * WFS 1.0.0 uses XML Schema version 0.1, so this version
+ * comes back in the response
+ *
+ * Inherits from:
+ * - <OpenLayers.Format.XML>
+ */
+OpenLayers.Format.WFSDescribeFeatureType = OpenLayers.Class(OpenLayers.Format.XML, {
+
+ /**
+ * APIProperty: defaultVersion
+ * {String} Version number to assume if none found. Default is "1.0.0".
+ */
+ defaultVersion: "1.0",
+
+ /**
+ * APIProperty: version
+ * {String} Specify a version string if one is known.
+ */
+ version: null,
+
+ /**
+ * Constructor: OpenLayers.Format.WFSDescribeFeatureType
+ * Create a new parser for WFS DescribeFeatureType responses.
+ *
+ * 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]);
+ this.options = options;
+ },
+
+ /**
+ * APIMethod: read
+ * Read DescribeFeatureType data from a string, and return the response.
+ *
+ * Parameters:
+ * data - {String} or {DOMElement} data to read/parse.
+ *
+ * Returns:
+ * {Array} Array of objects which have:
+ * - {String} name: name of the attribute
+ * - {String} type: type of the attribute, xsd:string etc.
+ */
+ read: function(data) {
+ if(typeof data == "string") {
+ data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
+ }
+ var root = data.documentElement;
+ var version = this.version;
+ if(!version) {
+ version = root.getAttribute("version");
+
+ if(!version) {
+ version = this.defaultVersion;
+ }
+ }
+ if(!this.parser || this.parser.VERSION != version) {
+ var format = OpenLayers.Format.WFSDescribeFeatureType[
+ "v" + version.replace(/\./g, "_")
+ ];
+ if(!format) {
+ throw "Can't find a WFSDescribeFeatureType parser for version " +
+ version;
+ }
+ this.parser = new format(this.options);
+ }
+ var describeFeatureType = this.parser.read(data);
+ return describeFeatureType;
+
+ },
+
+ CLASS_NAME: "OpenLayers.Format.WFSDescribeFeatureType"
+
+});
Modified: sandbox/topp/geoext/lib/OpenLayers.js
===================================================================
--- sandbox/topp/geoext/lib/OpenLayers.js 2008-06-13 01:07:34 UTC (rev 7356)
+++ sandbox/topp/geoext/lib/OpenLayers.js 2008-06-13 19:14:39 UTC (rev 7357)
@@ -209,6 +209,8 @@
"OpenLayers/Format/GeoJSON.js",
"OpenLayers/Format/WMSCapabilities.js",
"OpenLayers/Format/WMSCapabilities/v1_1_1.js",
+ "OpenLayers/Format/WFSDescribeFeatureType.js",
+ "OpenLayers/Format/WFSDescribeFeatureType/v1_0.js",
"OpenLayers/Layer/WFS.js",
"OpenLayers/Control/MouseToolbar.js",
"OpenLayers/Control/NavToolbar.js",
More information about the Commits
mailing list