| | 119 | |
|---|
| | 120 | var bbox; |
|---|
| | 121 | if (options && options.returnBbox) { |
|---|
| | 122 | var boundedByNodes = this.getElementsByTagNameNS( |
|---|
| | 123 | data.documentElement, this.gmlns, 'boundedBy'); |
|---|
| | 124 | for (var i=0; i < boundedByNodes.length; i++) { |
|---|
| | 125 | // we are only interested in the top level boundedBy |
|---|
| | 126 | // and there is currently no way to limit getElementsByTagNameNS |
|---|
| | 127 | // to a certain level |
|---|
| | 128 | if (boundedByNodes[i].parentNode == data.documentElement) { |
|---|
| | 129 | var type = 'Box'; |
|---|
| | 130 | var parser = this.parseGeometry[type.toLowerCase()]; |
|---|
| | 131 | if (parser) { |
|---|
| | 132 | bbox = parser.apply(this, [boundedByNodes[i]]); |
|---|
| | 133 | } |
|---|
| | 134 | } |
|---|
| | 135 | } |
|---|
| | 136 | } |
|---|
| | 137 | |
|---|
| | 293 | |
|---|
| | 294 | /** |
|---|
| | 295 | * Method: parseGeometry.box |
|---|
| | 296 | * Given a GML node representing a box geometry, create an |
|---|
| | 297 | * OpenLayers rectangle geometry. |
|---|
| | 298 | * |
|---|
| | 299 | * Parameters: |
|---|
| | 300 | * node - {DOMElement} A GML node. |
|---|
| | 301 | * |
|---|
| | 302 | * Returns: |
|---|
| | 303 | * {<OpenLayers.Bounds>} A bounds representing the box. |
|---|
| | 304 | */ |
|---|
| | 305 | box: function(node) { |
|---|
| | 306 | var nodeList = this.getElementsByTagNameNS(node, this.gmlns, |
|---|
| | 307 | "coordinates"); |
|---|
| | 308 | var coordString; |
|---|
| | 309 | var coords, beginPoint, endPoint; |
|---|
| | 310 | if (nodeList.length > 0) { |
|---|
| | 311 | coordString = nodeList[0].firstChild.nodeValue; |
|---|
| | 312 | coords = coordString.split(" "); |
|---|
| | 313 | for (var i=0; i < coords.length; i++) { |
|---|
| | 314 | if (i == 0) { |
|---|
| | 315 | beginPoint = coords[i].split(","); |
|---|
| | 316 | } |
|---|
| | 317 | if (i == 1) { |
|---|
| | 318 | endPoint = coords[i].split(","); |
|---|
| | 319 | } |
|---|
| | 320 | } |
|---|
| | 321 | } |
|---|
| | 322 | return new OpenLayers.Bounds(parseInt(beginPoint[0]), |
|---|
| | 323 | parseInt(beginPoint[1]), |
|---|
| | 324 | parseInt(endPoint[0]), |
|---|
| | 325 | parseInt(endPoint[1]) ); |
|---|
| | 326 | }, |
|---|