[76] | 1 | /* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for |
---|
| 2 | * full list of contributors). Published under the Clear BSD license. |
---|
| 3 | * See http://svn.openlayers.org/trunk/openlayers/license.txt for the |
---|
| 4 | * full text of the license. */ |
---|
| 5 | |
---|
| 6 | /** |
---|
| 7 | * @requires OpenLayers/Format/WFSCapabilities.js |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | /** |
---|
| 11 | * Class: OpenLayers.Format.WFSCapabilities.v1 |
---|
| 12 | * Abstract class not to be instantiated directly. |
---|
| 13 | * |
---|
| 14 | * Inherits from: |
---|
| 15 | * - <OpenLayers.Format.XML> |
---|
| 16 | */ |
---|
| 17 | OpenLayers.Format.WFSCapabilities.v1 = OpenLayers.Class( |
---|
| 18 | OpenLayers.Format.WFSCapabilities, { |
---|
| 19 | |
---|
| 20 | /** |
---|
| 21 | * Constructor: OpenLayers.Format.WFSCapabilities.v1_1 |
---|
| 22 | * Create an instance of one of the subclasses. |
---|
| 23 | * |
---|
| 24 | * Parameters: |
---|
| 25 | * options - {Object} An optional object whose properties will be set on |
---|
| 26 | * this instance. |
---|
| 27 | */ |
---|
| 28 | initialize: function(options) { |
---|
| 29 | OpenLayers.Format.XML.prototype.initialize.apply(this, [options]); |
---|
| 30 | this.options = options; |
---|
| 31 | }, |
---|
| 32 | |
---|
| 33 | /** |
---|
| 34 | * APIMethod: read |
---|
| 35 | * Read capabilities data from a string, and return a list of layers. |
---|
| 36 | * |
---|
| 37 | * Parameters: |
---|
| 38 | * data - {String} or {DOMElement} data to read/parse. |
---|
| 39 | * |
---|
| 40 | * Returns: |
---|
| 41 | * {Array} List of named layers. |
---|
| 42 | */ |
---|
| 43 | read: function(data) { |
---|
| 44 | if(typeof data == "string") { |
---|
| 45 | data = OpenLayers.Format.XML.prototype.read.apply(this, [data]); |
---|
| 46 | } |
---|
| 47 | var capabilities = {}; |
---|
| 48 | var root = data.documentElement; |
---|
| 49 | this.runChildNodes(capabilities, root); |
---|
| 50 | return capabilities; |
---|
| 51 | }, |
---|
| 52 | |
---|
| 53 | /** |
---|
| 54 | * Method: runChildNodes |
---|
| 55 | */ |
---|
| 56 | runChildNodes: function(obj, node) { |
---|
| 57 | var children = node.childNodes; |
---|
| 58 | var childNode, processor; |
---|
| 59 | for(var i=0; i<children.length; ++i) { |
---|
| 60 | childNode = children[i]; |
---|
| 61 | if(childNode.nodeType == 1) { |
---|
| 62 | processor = this["read_cap_" + childNode.nodeName]; |
---|
| 63 | if(processor) { |
---|
| 64 | processor.apply(this, [obj, childNode]); |
---|
| 65 | } |
---|
| 66 | } |
---|
| 67 | } |
---|
| 68 | }, |
---|
| 69 | |
---|
| 70 | /** |
---|
| 71 | * Method: read_cap_FeatureTypeList |
---|
| 72 | */ |
---|
| 73 | read_cap_FeatureTypeList: function(request, node) { |
---|
| 74 | var featureTypeList = { |
---|
| 75 | featureTypes: [] |
---|
| 76 | }; |
---|
| 77 | this.runChildNodes(featureTypeList, node); |
---|
| 78 | request.featureTypeList = featureTypeList; |
---|
| 79 | }, |
---|
| 80 | |
---|
| 81 | /** |
---|
| 82 | * Method: read_cap_FeatureType |
---|
| 83 | */ |
---|
| 84 | read_cap_FeatureType: function(featureTypeList, node, parentLayer) { |
---|
| 85 | var featureType = {}; |
---|
| 86 | this.runChildNodes(featureType, node); |
---|
| 87 | featureTypeList.featureTypes.push(featureType); |
---|
| 88 | }, |
---|
| 89 | |
---|
| 90 | /** |
---|
| 91 | * Method: read_cap_Name |
---|
| 92 | */ |
---|
| 93 | read_cap_Name: function(obj, node) { |
---|
| 94 | var name = this.getChildValue(node); |
---|
| 95 | if(name) { |
---|
| 96 | var parts = name.split(":"); |
---|
| 97 | obj.name = parts.pop(); |
---|
| 98 | if(parts.length > 0) { |
---|
| 99 | obj.featureNS = this.lookupNamespaceURI(node, parts[0]); |
---|
| 100 | } |
---|
| 101 | } |
---|
| 102 | }, |
---|
| 103 | |
---|
| 104 | /** |
---|
| 105 | * Method: read_cap_Title |
---|
| 106 | */ |
---|
| 107 | read_cap_Title: function(obj, node) { |
---|
| 108 | var title = this.getChildValue(node); |
---|
| 109 | if(title) { |
---|
| 110 | obj.title = title; |
---|
| 111 | } |
---|
| 112 | }, |
---|
| 113 | |
---|
| 114 | /** |
---|
| 115 | * Method: read_cap_Abstract |
---|
| 116 | */ |
---|
| 117 | read_cap_Abstract: function(obj, node) { |
---|
| 118 | var abst = this.getChildValue(node); |
---|
| 119 | if(abst) { |
---|
| 120 | obj["abstract"] = abst; |
---|
| 121 | } |
---|
| 122 | }, |
---|
| 123 | |
---|
| 124 | CLASS_NAME: "OpenLayers.Format.WFSCapabilities.v1" |
---|
| 125 | |
---|
| 126 | }); |
---|