[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/WMSCapabilities/v1.js |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | /** |
---|
| 11 | * Class: OpenLayers.Format.WMSCapabilities.v1_1 |
---|
| 12 | * Abstract class not to be instantiated directly. |
---|
| 13 | * |
---|
| 14 | * Inherits from: |
---|
| 15 | * - <OpenLayers.Format.WMSCapabilities.v1> |
---|
| 16 | */ |
---|
| 17 | OpenLayers.Format.WMSCapabilities.v1_1 = OpenLayers.Class( |
---|
| 18 | OpenLayers.Format.WMSCapabilities.v1, { |
---|
| 19 | |
---|
| 20 | /** |
---|
| 21 | * Property: readers |
---|
| 22 | * Contains public functions, grouped by namespace prefix, that will |
---|
| 23 | * be applied when a namespaced node is found matching the function |
---|
| 24 | * name. The function will be applied in the scope of this parser |
---|
| 25 | * with two arguments: the node being read and a context object passed |
---|
| 26 | * from the parent. |
---|
| 27 | */ |
---|
| 28 | readers: { |
---|
| 29 | "wms": OpenLayers.Util.applyDefaults({ |
---|
| 30 | "WMT_MS_Capabilities": function(node, obj) { |
---|
| 31 | this.readChildNodes(node, obj); |
---|
| 32 | }, |
---|
| 33 | "Keyword": function(node, obj) { |
---|
| 34 | if (obj.keywords) { |
---|
| 35 | obj.keywords.push(this.getChildValue(node)); |
---|
| 36 | } |
---|
| 37 | }, |
---|
| 38 | "DescribeLayer": function(node, obj) { |
---|
| 39 | obj.describelayer = {formats: []}; |
---|
| 40 | this.readChildNodes(node, obj.describelayer); |
---|
| 41 | }, |
---|
| 42 | "GetLegendGraphic": function(node, obj) { |
---|
| 43 | obj.getlegendgraphic = {formats: []}; |
---|
| 44 | this.readChildNodes(node, obj.getlegendgraphic); |
---|
| 45 | }, |
---|
| 46 | "GetStyles": function(node, obj) { |
---|
| 47 | obj.getstyles = {formats: []}; |
---|
| 48 | this.readChildNodes(node, obj.getstyles); |
---|
| 49 | }, |
---|
| 50 | "PutStyles": function(node, obj) { |
---|
| 51 | obj.putstyles = {formats: []}; |
---|
| 52 | this.readChildNodes(node, obj.putstyles); |
---|
| 53 | }, |
---|
| 54 | "UserDefinedSymbolization": function(node, obj) { |
---|
| 55 | var userSymbols = { |
---|
| 56 | supportSLD: parseInt(node.getAttribute("SupportSLD")) == 1, |
---|
| 57 | userLayer: parseInt(node.getAttribute("UserLayer")) == 1, |
---|
| 58 | userStyle: parseInt(node.getAttribute("UserStyle")) == 1, |
---|
| 59 | remoteWFS: parseInt(node.getAttribute("RemoteWFS")) == 1 |
---|
| 60 | }; |
---|
| 61 | obj.userSymbols = userSymbols; |
---|
| 62 | }, |
---|
| 63 | "LatLonBoundingBox": function(node, obj) { |
---|
| 64 | obj.llbbox = [ |
---|
| 65 | parseFloat(node.getAttribute("minx")), |
---|
| 66 | parseFloat(node.getAttribute("miny")), |
---|
| 67 | parseFloat(node.getAttribute("maxx")), |
---|
| 68 | parseFloat(node.getAttribute("maxy")) |
---|
| 69 | ]; |
---|
| 70 | }, |
---|
| 71 | "BoundingBox": function(node, obj) { |
---|
| 72 | var bbox = OpenLayers.Format.WMSCapabilities.v1.prototype.readers["wms"].BoundingBox.apply(this, [node, obj]); |
---|
| 73 | bbox.srs = node.getAttribute("SRS"); |
---|
| 74 | obj.bbox[bbox.srs] = bbox; |
---|
| 75 | }, |
---|
| 76 | "ScaleHint": function(node, obj) { |
---|
| 77 | var min = node.getAttribute("min"); |
---|
| 78 | var max = node.getAttribute("max"); |
---|
| 79 | var rad2 = Math.pow(2, 0.5); |
---|
| 80 | var ipm = OpenLayers.INCHES_PER_UNIT["m"]; |
---|
| 81 | obj.maxScale = parseFloat( |
---|
| 82 | ((min / rad2) * ipm * |
---|
| 83 | OpenLayers.DOTS_PER_INCH).toPrecision(13) |
---|
| 84 | ); |
---|
| 85 | obj.minScale = parseFloat( |
---|
| 86 | ((max / rad2) * ipm * |
---|
| 87 | OpenLayers.DOTS_PER_INCH).toPrecision(13) |
---|
| 88 | ); |
---|
| 89 | }, |
---|
| 90 | "Dimension": function(node, obj) { |
---|
| 91 | var name = node.getAttribute("name").toLowerCase(); |
---|
| 92 | var dim = { |
---|
| 93 | name: name, |
---|
| 94 | units: node.getAttribute("units"), |
---|
| 95 | unitsymbol: node.getAttribute("unitSymbol") |
---|
| 96 | }; |
---|
| 97 | obj.dimensions[dim.name] = dim; |
---|
| 98 | }, |
---|
| 99 | "Extent": function(node, obj) { |
---|
| 100 | var name = node.getAttribute("name").toLowerCase(); |
---|
| 101 | if (name in obj["dimensions"]) { |
---|
| 102 | var extent = obj.dimensions[name]; |
---|
| 103 | extent.nearestVal = |
---|
| 104 | node.getAttribute("nearestValue") === "1"; |
---|
| 105 | extent.multipleVal = |
---|
| 106 | node.getAttribute("multipleValues") === "1"; |
---|
| 107 | extent.current = node.getAttribute("current") === "1"; |
---|
| 108 | extent["default"] = node.getAttribute("default") || ""; |
---|
| 109 | var values = this.getChildValue(node); |
---|
| 110 | extent.values = values.split(","); |
---|
| 111 | } |
---|
| 112 | } |
---|
| 113 | }, OpenLayers.Format.WMSCapabilities.v1.prototype.readers["wms"]) |
---|
| 114 | }, |
---|
| 115 | |
---|
| 116 | CLASS_NAME: "OpenLayers.Format.WMSCapabilities.v1_1" |
---|
| 117 | |
---|
| 118 | }); |
---|