diff --git a/src/ol/parser/ogc/gmlparser_v2.js b/src/ol/parser/ogc/gmlparser_v2.js index cdc7799745..bf548f3e38 100644 --- a/src/ol/parser/ogc/gmlparser_v2.js +++ b/src/ol/parser/ogc/gmlparser_v2.js @@ -2,6 +2,7 @@ goog.provide('ol.parser.ogc.GML_v2'); goog.require('goog.array'); goog.require('goog.object'); +goog.require('ol.extent'); goog.require('ol.parser.ogc.GML'); @@ -35,8 +36,7 @@ ol.parser.ogc.GML_v2 = function(opt_options) { [node, coordinates, container]); this.readChildNodes(node, coordinates); container.projection = node.getAttribute('srsName'); - container.bounds = [coordinates[0][0][0], coordinates[0][1][0], - coordinates[0][0][1], coordinates[0][1][1]]; + container.bounds = ol.extent.clone(coordinates[0]); } }); goog.object.extend(this.writers['http://www.opengis.net/gml'], { @@ -104,8 +104,7 @@ ol.parser.ogc.GML_v2 = function(opt_options) { }, 'Box': function(extent) { var node = this.createElementNS('gml:Box'); - this.writeNode('coordinates', [[extent[0], extent[1]], - [extent[2], extent[3]]], null, node); + this.writeNode('coordinates', extent, null, node); // srsName attribute is optional for gml:Box if (goog.isDefAndNotNull(this.srsName)) { node.setAttribute('srsName', this.srsName); diff --git a/src/ol/parser/ogc/gmlparser_v3.js b/src/ol/parser/ogc/gmlparser_v3.js index aa329335f9..b783f9be71 100644 --- a/src/ol/parser/ogc/gmlparser_v3.js +++ b/src/ol/parser/ogc/gmlparser_v3.js @@ -3,6 +3,7 @@ goog.provide('ol.parser.ogc.GML_v3'); goog.require('goog.array'); goog.require('goog.functions'); goog.require('goog.object'); +goog.require('ol.extent'); goog.require('ol.geom.GeometryType'); goog.require('ol.parser.ogc.GML'); @@ -113,7 +114,7 @@ ol.parser.ogc.GML_v3 = function(opt_options) { if (coords.length === 2) { obj.push([coords.reverse()]); } else if (coords.length === 3) { - obj.push([coords[1], coords[0], coords[2]]); + obj.push([[coords[1], coords[0], coords[2]]]); } } }, @@ -215,20 +216,19 @@ ol.parser.ogc.GML_v3 = function(opt_options) { [node, coordinates, container]); this.readChildNodes(node, coordinates); container.projection = node.getAttribute('srsName'); - container.bounds = [coordinates[0][0][0][0], coordinates[1][0][0][0], - coordinates[0][0][0][1], coordinates[1][0][0][1]]; + container.bounds = ol.extent.clone(coordinates); }, 'lowerCorner': function(node, envelope) { var coordinates = []; this.readers[this.defaultNamespaceURI]['pos'].apply(this, [node, coordinates]); - envelope.push(coordinates); + envelope.push(coordinates[0][0]); }, 'upperCorner': function(node, envelope) { var coordinates = []; this.readers[this.defaultNamespaceURI]['pos'].apply(this, [node, coordinates]); - envelope.push(coordinates); + envelope.push(coordinates[0][0]); } }); goog.object.extend(this.writers['http://www.opengis.net/gml'], { @@ -391,9 +391,9 @@ ol.parser.ogc.GML_v3 = function(opt_options) { // only 2d for simple features profile var pos; if (this.axisOrientation.substr(0, 2) === 'en') { - pos = (bounds[0] + ' ' + bounds[2]); + pos = (bounds[0][0] + ' ' + bounds[0][1]); } else { - pos = (bounds[2] + ' ' + bounds[0]); + pos = (bounds[0][1] + ' ' + bounds[0][0]); } var node = this.createElementNS('gml:lowerCorner'); node.appendChild(this.createTextNode(pos)); @@ -403,9 +403,9 @@ ol.parser.ogc.GML_v3 = function(opt_options) { // only 2d for simple features profile var pos; if (this.axisOrientation.substr(0, 2) === 'en') { - pos = (bounds[1] + ' ' + bounds[3]); + pos = (bounds[1][0] + ' ' + bounds[1][1]); } else { - pos = (bounds[3] + ' ' + bounds[1]); + pos = (bounds[1][1] + ' ' + bounds[1][0]); } var node = this.createElementNS('gml:upperCorner'); node.appendChild(this.createTextNode(pos)); diff --git a/test/spec/ol/parser/ogc/gml_v2.test.js b/test/spec/ol/parser/ogc/gml_v2.test.js index 9f564d5284..1c9c1ea1c3 100644 --- a/test/spec/ol/parser/ogc/gml_v2.test.js +++ b/test/spec/ol/parser/ogc/gml_v2.test.js @@ -204,7 +204,7 @@ describe('ol.parser.gml_v2', function() { var url = 'spec/ol/parser/ogc/xml/gml_v2/box-coord.xml'; afterLoadXml(url, function(xml) { var obj = parser.read(xml); - expect(obj.bounds).to.eql([1, 3, 2, 4]); + expect(obj.bounds).to.eql([[1, 2], [3, 4]]); done(); }); }); @@ -212,7 +212,7 @@ describe('ol.parser.gml_v2', function() { var url = 'spec/ol/parser/ogc/xml/gml_v2/box-coordinates.xml'; afterLoadXml(url, function(xml) { var obj = parser.read(xml); - expect(obj.bounds).to.eql([1, 3, 2, 4]); + expect(obj.bounds).to.eql([[1, 2], [3, 4]]); done(); }); }); diff --git a/test/spec/ol/parser/ogc/gml_v3.test.js b/test/spec/ol/parser/ogc/gml_v3.test.js index 9bd2fc869d..e6fd62b984 100644 --- a/test/spec/ol/parser/ogc/gml_v3.test.js +++ b/test/spec/ol/parser/ogc/gml_v3.test.js @@ -9,7 +9,7 @@ describe('ol.parser.gml_v3', function() { var url = 'spec/ol/parser/ogc/xml/gml_v3/envelope.xml'; afterLoadXml(url, function(xml) { var obj = parser.read(xml); - expect(obj.bounds).to.eql([1, 3, 2, 4]); + expect(obj.bounds).to.eql([[1, 2], [3, 4]]); done(); }); });