GML parsing with new extent structure

This commit is contained in:
Tim Schaub
2013-09-03 17:44:17 -06:00
parent 9226472380
commit 3ea6041714
4 changed files with 15 additions and 16 deletions

View File

@@ -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);

View File

@@ -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));

View File

@@ -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();
});
});

View File

@@ -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();
});
});