[fusion-commits] r2251 - in trunk: . lib/OpenLayers

svn_fusion at osgeo.org svn_fusion at osgeo.org
Tue Oct 19 10:48:02 EDT 2010


Author: madair
Date: 2010-10-19 07:48:02 -0700 (Tue, 19 Oct 2010)
New Revision: 2251

Modified:
   trunk/fusion.cfg
   trunk/lib/OpenLayers/OpenLayers.js
Log:
adding WFSCapabilities and WFSDescribeFeatureType to the OL build

Modified: trunk/fusion.cfg
===================================================================
--- trunk/fusion.cfg	2010-10-19 14:47:00 UTC (rev 2250)
+++ trunk/fusion.cfg	2010-10-19 14:48:02 UTC (rev 2251)
@@ -44,6 +44,8 @@
 OpenLayers/Control/ScaleLine.js
 OpenLayers/Format/GML/v2.js
 OpenLayers/Format/GML/v3.js
+OpenLayers/Format/WFSCapabilities.js
+OpenLayers/Format/WFSDescribeFeatureType.js
 OpenLayers/Handler/Box.js
 OpenLayers/Handler/Click.js
 OpenLayers/Handler/Drag.js

Modified: trunk/lib/OpenLayers/OpenLayers.js
===================================================================
--- trunk/lib/OpenLayers/OpenLayers.js	2010-10-19 14:47:00 UTC (rev 2250)
+++ trunk/lib/OpenLayers/OpenLayers.js	2010-10-19 14:48:02 UTC (rev 2251)
@@ -20038,6 +20038,292 @@
     CLASS_NAME: "OpenLayers.Feature"
 });
 /* ======================================================================
+    OpenLayers/Format/WFSCapabilities.js
+   ====================================================================== */
+
+/* Copyright (c) 2006-2010 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.WFSCapabilities
+ * Read WFS Capabilities.
+ * 
+ * Inherits from:
+ *  - <OpenLayers.Format.XML>
+ */
+OpenLayers.Format.WFSCapabilities = OpenLayers.Class(OpenLayers.Format.XML, {
+    
+    /**
+     * APIProperty: defaultVersion
+     * {String} Version number to assume if none found.  Default is "1.1.0".
+     */
+    defaultVersion: "1.1.0",
+    
+    /**
+     * APIProperty: version
+     * {String} Specify a version string if one is known.
+     */
+    version: null,
+
+    /**
+     * Constructor: OpenLayers.Format.WFSCapabilities
+     * Create a new parser for WFS capabilities.
+     *
+     * 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 capabilities data from a string, and return a list of layers. 
+     * 
+     * Parameters: 
+     * data - {String} or {DOMElement} data to read/parse.
+     *
+     * Returns:
+     * {Array} List of named layers.
+     */
+    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;
+            }
+        }
+        var constr = OpenLayers.Format.WFSCapabilities[
+            "v" + version.replace(/\./g, "_")
+        ];
+        if(!constr) {
+            throw "Can't find a WFS capabilities parser for version " + version;
+        }
+        var parser = new constr(this.options);
+        var capabilities = parser.read(data);
+        capabilities.version = version;
+        return capabilities;
+    },
+    
+    CLASS_NAME: "OpenLayers.Format.WFSCapabilities" 
+
+});
+/* ======================================================================
+    OpenLayers/Format/WFSDescribeFeatureType.js
+   ====================================================================== */
+
+/* Copyright (c) 2006-2010 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.WFSDescribeFeatureType
+ * Read WFS DescribeFeatureType response
+ * 
+ * Inherits from:
+ *  - <OpenLayers.Format.XML>
+ */
+OpenLayers.Format.WFSDescribeFeatureType = OpenLayers.Class(
+    OpenLayers.Format.XML, {
+    
+    /**
+     * Property: namespaces
+     * {Object} Mapping of namespace aliases to namespace URIs.
+     */
+    namespaces: {
+        xsd: "http://www.w3.org/2001/XMLSchema"
+    },
+    
+    /**
+     * 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]);
+    },
+    
+    /**
+     * 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: {
+        "xsd": {
+            "schema": function(node, obj) {
+                var complexTypes = [];
+                var customTypes = {};
+                var schema = {
+                    complexTypes: complexTypes,
+                    customTypes: customTypes
+                };
+                
+                this.readChildNodes(node, schema);
+
+                var attributes = node.attributes;
+                var attr, name;
+                for(var i=0, len=attributes.length; i<len; ++i) {
+                    attr = attributes[i];
+                    name = attr.name;
+                    if(name.indexOf("xmlns") == 0) {
+                        this.setNamespace(name.split(":")[1] || "", attr.value);
+                    } else {
+                        obj[name] = attr.value;
+                    }
+                }
+                obj.featureTypes = complexTypes;                
+                obj.targetPrefix = this.namespaceAlias[obj.targetNamespace];
+                
+                // map complexTypes to names of customTypes
+                var complexType, customType;
+                for(var i=0, len=complexTypes.length; i<len; ++i) {
+                    complexType = complexTypes[i];
+                    customType = customTypes[complexType.typeName];
+                    if(customTypes[complexType.typeName]) {
+                        complexType.typeName = customType.name;
+                    }
+                }
+            },
+            "complexType": function(node, obj) {
+                var complexType = {
+                    // this is a temporary typeName, it will be overwritten by
+                    // the schema reader with the metadata found in the
+                    // customTypes hash
+                    "typeName": node.getAttribute("name")
+                };
+                this.readChildNodes(node, complexType);
+                obj.complexTypes.push(complexType);
+            },
+            "complexContent": function(node, obj) {
+                this.readChildNodes(node, obj);
+            },
+            "extension": function(node, obj) {
+                this.readChildNodes(node, obj);
+            },
+            "sequence": function(node, obj) {
+                var sequence = {
+                    elements: []
+                };
+                this.readChildNodes(node, sequence);
+                obj.properties = sequence.elements;
+            },
+            "element": function(node, obj) {
+                if(obj.elements) {
+                    var element = {};
+                    var attributes = node.attributes;
+                    var attr;
+                    for(var i=0, len=attributes.length; i<len; ++i) {
+                        attr = attributes[i];
+                        element[attr.name] = attr.value;
+                    }
+                    
+                    var type = element.type;
+                    if(!type) {
+                        type = {};
+                        this.readChildNodes(node, type);
+                        element.restriction = type;
+                        element.type = type.base;
+                    }
+                    var fullType = type.base || type;
+                    element.localType = fullType.split(":").pop();
+                    obj.elements.push(element);
+                }
+                
+                if(obj.complexTypes) {
+                    var type = node.getAttribute("type");
+                    var localType = type.split(":").pop();
+                    obj.customTypes[localType] = {
+                        "name": node.getAttribute("name"),
+                        "type": type
+                    };
+                }
+            },
+            "simpleType": function(node, obj) {
+                this.readChildNodes(node, obj);
+            },
+            "restriction": function(node, obj) {
+                obj.base = node.getAttribute("base");
+                this.readRestriction(node, obj);
+            }
+        }
+    },
+    
+    /**
+     * Method: readRestriction
+     * Reads restriction defined in the child nodes of a restriction element
+     * 
+     * Parameters:
+     * node {DOMElement} - the node to parse
+     * obj {Object} - the object that receives the read result
+     */
+    readRestriction: function(node, obj) {
+        var children = node.childNodes;
+        var child, nodeName, value;
+        for(var i=0, len=children.length; i<len; ++i) {
+            child = children[i];
+            if(child.nodeType == 1) {
+                nodeName = child.nodeName.split(":").pop();
+                value = child.getAttribute("value");
+                if(!obj[nodeName]) {
+                    obj[nodeName] = value;
+                } else {
+                    if(typeof obj[nodeName] == "string") {
+                        obj[nodeName] = [obj[nodeName]];
+                    }
+                    obj[nodeName].push(value);
+                }
+            }
+        }
+    },
+    
+    /**
+     * Method: read
+     *
+     * Parameters:
+     * data - {DOMElement|String} A WFS DescribeFeatureType document.
+     *
+     * Returns:
+     * {Object} An object representing the WFS DescribeFeatureType response.
+     */
+    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 schema = {};
+        this.readNode(data, schema);
+        
+        return schema;
+    },
+    
+    CLASS_NAME: "OpenLayers.Format.WFSDescribeFeatureType" 
+
+});
+/* ======================================================================
     OpenLayers/Handler/Click.js
    ====================================================================== */
 



More information about the fusion-commits mailing list