[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/WMSDescribeLayer.js |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | /** |
---|
| 11 | * Class: OpenLayers.Format.WMSDescribeLayer.v1_1 |
---|
| 12 | * Read SLD WMS DescribeLayer response for WMS 1.1.X |
---|
| 13 | * WMS 1.1.X is tightly coupled to SLD 1.0.0 |
---|
| 14 | * |
---|
| 15 | * Example DescribeLayer request: |
---|
| 16 | * http://demo.opengeo.org/geoserver/wms?request=DescribeLayer&version=1.1.1&layers=topp:states |
---|
| 17 | * |
---|
| 18 | * Inherits from: |
---|
| 19 | * - <OpenLayers.Format.WMSDescribeLayer> |
---|
| 20 | */ |
---|
| 21 | OpenLayers.Format.WMSDescribeLayer.v1_1 = OpenLayers.Class( |
---|
| 22 | OpenLayers.Format.WMSDescribeLayer, { |
---|
| 23 | |
---|
| 24 | /** |
---|
| 25 | * Constructor: OpenLayers.Format.WMSDescribeLayer |
---|
| 26 | * Create a new parser for WMS DescribeLayer responses. |
---|
| 27 | * |
---|
| 28 | * Parameters: |
---|
| 29 | * options - {Object} An optional object whose properties will be set on |
---|
| 30 | * this instance. |
---|
| 31 | */ |
---|
| 32 | initialize: function(options) { |
---|
| 33 | OpenLayers.Format.WMSDescribeLayer.prototype.initialize.apply(this, |
---|
| 34 | [options]); |
---|
| 35 | }, |
---|
| 36 | |
---|
| 37 | /** |
---|
| 38 | * APIMethod: read |
---|
| 39 | * Read DescribeLayer data from a string, and return the response. |
---|
| 40 | * The OGC defines 2 formats which are allowed for output, |
---|
| 41 | * so we need to parse these 2 types for version 1.1.X |
---|
| 42 | * |
---|
| 43 | * Parameters: |
---|
| 44 | * data - {String} or {DOMElement} data to read/parse. |
---|
| 45 | * |
---|
| 46 | * Returns: |
---|
| 47 | * {Array} Array of {<LayerDescription>} objects which have: |
---|
| 48 | * - {String} owsType: WFS/WCS |
---|
| 49 | * - {String} owsURL: the online resource |
---|
| 50 | * - {String} typeName: the name of the typename on the service |
---|
| 51 | */ |
---|
| 52 | read: function(data) { |
---|
| 53 | if(typeof data == "string") { |
---|
| 54 | data = OpenLayers.Format.XML.prototype.read.apply(this, [data]); |
---|
| 55 | } |
---|
| 56 | var root = data.documentElement; |
---|
| 57 | var children = root.childNodes; |
---|
| 58 | var describelayer = []; |
---|
| 59 | var childNode, nodeName; |
---|
| 60 | for(var i=0; i<children.length; ++i) { |
---|
| 61 | childNode = children[i]; |
---|
| 62 | nodeName = childNode.nodeName; |
---|
| 63 | if (nodeName == 'LayerDescription') { |
---|
| 64 | var layerName = childNode.getAttribute('name'); |
---|
| 65 | var owsType = ''; |
---|
| 66 | var owsURL = ''; |
---|
| 67 | var typeName = ''; |
---|
| 68 | // check for owsType and owsURL attributes |
---|
| 69 | if (childNode.getAttribute('owsType')) { |
---|
| 70 | owsType = childNode.getAttribute('owsType'); |
---|
| 71 | owsURL = childNode.getAttribute('owsURL'); |
---|
| 72 | } else { |
---|
| 73 | // look for wfs or wcs attribute |
---|
| 74 | if (childNode.getAttribute('wfs') != '') { |
---|
| 75 | owsType = 'WFS'; |
---|
| 76 | owsURL = childNode.getAttribute('wfs'); |
---|
| 77 | } else if (childNode.getAttribute('wcs') != '') { |
---|
| 78 | owsType = 'WCS'; |
---|
| 79 | owsURL = childNode.getAttribute('wcs'); |
---|
| 80 | } |
---|
| 81 | } |
---|
| 82 | // look for Query child |
---|
| 83 | var query = childNode.getElementsByTagName('Query'); |
---|
| 84 | if(query.length > 0) { |
---|
| 85 | typeName = query[0].getAttribute('typeName'); |
---|
| 86 | if (!typeName) { |
---|
| 87 | // because of Ionic bug |
---|
| 88 | typeName = query[0].getAttribute('typename'); |
---|
| 89 | } |
---|
| 90 | } |
---|
| 91 | describelayer.push({layerName: layerName, owsType: owsType, |
---|
| 92 | owsURL: owsURL, typeName: typeName}); |
---|
| 93 | } |
---|
| 94 | } |
---|
| 95 | return describelayer; |
---|
| 96 | }, |
---|
| 97 | |
---|
| 98 | CLASS_NAME: "OpenLayers.Format.WMSDescribeLayer.v1_1" |
---|
| 99 | |
---|
| 100 | }); |
---|