GML parsing with new extent structure
This commit is contained in:
@@ -2,6 +2,7 @@ goog.provide('ol.parser.ogc.GML_v2');
|
|||||||
|
|
||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
goog.require('goog.object');
|
goog.require('goog.object');
|
||||||
|
goog.require('ol.extent');
|
||||||
goog.require('ol.parser.ogc.GML');
|
goog.require('ol.parser.ogc.GML');
|
||||||
|
|
||||||
|
|
||||||
@@ -35,8 +36,7 @@ ol.parser.ogc.GML_v2 = function(opt_options) {
|
|||||||
[node, coordinates, container]);
|
[node, coordinates, container]);
|
||||||
this.readChildNodes(node, coordinates);
|
this.readChildNodes(node, coordinates);
|
||||||
container.projection = node.getAttribute('srsName');
|
container.projection = node.getAttribute('srsName');
|
||||||
container.bounds = [coordinates[0][0][0], coordinates[0][1][0],
|
container.bounds = ol.extent.clone(coordinates[0]);
|
||||||
coordinates[0][0][1], coordinates[0][1][1]];
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
goog.object.extend(this.writers['http://www.opengis.net/gml'], {
|
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) {
|
'Box': function(extent) {
|
||||||
var node = this.createElementNS('gml:Box');
|
var node = this.createElementNS('gml:Box');
|
||||||
this.writeNode('coordinates', [[extent[0], extent[1]],
|
this.writeNode('coordinates', extent, null, node);
|
||||||
[extent[2], extent[3]]], null, node);
|
|
||||||
// srsName attribute is optional for gml:Box
|
// srsName attribute is optional for gml:Box
|
||||||
if (goog.isDefAndNotNull(this.srsName)) {
|
if (goog.isDefAndNotNull(this.srsName)) {
|
||||||
node.setAttribute('srsName', this.srsName);
|
node.setAttribute('srsName', this.srsName);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ goog.provide('ol.parser.ogc.GML_v3');
|
|||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
goog.require('goog.functions');
|
goog.require('goog.functions');
|
||||||
goog.require('goog.object');
|
goog.require('goog.object');
|
||||||
|
goog.require('ol.extent');
|
||||||
goog.require('ol.geom.GeometryType');
|
goog.require('ol.geom.GeometryType');
|
||||||
goog.require('ol.parser.ogc.GML');
|
goog.require('ol.parser.ogc.GML');
|
||||||
|
|
||||||
@@ -113,7 +114,7 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
|
|||||||
if (coords.length === 2) {
|
if (coords.length === 2) {
|
||||||
obj.push([coords.reverse()]);
|
obj.push([coords.reverse()]);
|
||||||
} else if (coords.length === 3) {
|
} 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]);
|
[node, coordinates, container]);
|
||||||
this.readChildNodes(node, coordinates);
|
this.readChildNodes(node, coordinates);
|
||||||
container.projection = node.getAttribute('srsName');
|
container.projection = node.getAttribute('srsName');
|
||||||
container.bounds = [coordinates[0][0][0][0], coordinates[1][0][0][0],
|
container.bounds = ol.extent.clone(coordinates);
|
||||||
coordinates[0][0][0][1], coordinates[1][0][0][1]];
|
|
||||||
},
|
},
|
||||||
'lowerCorner': function(node, envelope) {
|
'lowerCorner': function(node, envelope) {
|
||||||
var coordinates = [];
|
var coordinates = [];
|
||||||
this.readers[this.defaultNamespaceURI]['pos'].apply(this,
|
this.readers[this.defaultNamespaceURI]['pos'].apply(this,
|
||||||
[node, coordinates]);
|
[node, coordinates]);
|
||||||
envelope.push(coordinates);
|
envelope.push(coordinates[0][0]);
|
||||||
},
|
},
|
||||||
'upperCorner': function(node, envelope) {
|
'upperCorner': function(node, envelope) {
|
||||||
var coordinates = [];
|
var coordinates = [];
|
||||||
this.readers[this.defaultNamespaceURI]['pos'].apply(this,
|
this.readers[this.defaultNamespaceURI]['pos'].apply(this,
|
||||||
[node, coordinates]);
|
[node, coordinates]);
|
||||||
envelope.push(coordinates);
|
envelope.push(coordinates[0][0]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
goog.object.extend(this.writers['http://www.opengis.net/gml'], {
|
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
|
// only 2d for simple features profile
|
||||||
var pos;
|
var pos;
|
||||||
if (this.axisOrientation.substr(0, 2) === 'en') {
|
if (this.axisOrientation.substr(0, 2) === 'en') {
|
||||||
pos = (bounds[0] + ' ' + bounds[2]);
|
pos = (bounds[0][0] + ' ' + bounds[0][1]);
|
||||||
} else {
|
} else {
|
||||||
pos = (bounds[2] + ' ' + bounds[0]);
|
pos = (bounds[0][1] + ' ' + bounds[0][0]);
|
||||||
}
|
}
|
||||||
var node = this.createElementNS('gml:lowerCorner');
|
var node = this.createElementNS('gml:lowerCorner');
|
||||||
node.appendChild(this.createTextNode(pos));
|
node.appendChild(this.createTextNode(pos));
|
||||||
@@ -403,9 +403,9 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
|
|||||||
// only 2d for simple features profile
|
// only 2d for simple features profile
|
||||||
var pos;
|
var pos;
|
||||||
if (this.axisOrientation.substr(0, 2) === 'en') {
|
if (this.axisOrientation.substr(0, 2) === 'en') {
|
||||||
pos = (bounds[1] + ' ' + bounds[3]);
|
pos = (bounds[1][0] + ' ' + bounds[1][1]);
|
||||||
} else {
|
} else {
|
||||||
pos = (bounds[3] + ' ' + bounds[1]);
|
pos = (bounds[1][1] + ' ' + bounds[1][0]);
|
||||||
}
|
}
|
||||||
var node = this.createElementNS('gml:upperCorner');
|
var node = this.createElementNS('gml:upperCorner');
|
||||||
node.appendChild(this.createTextNode(pos));
|
node.appendChild(this.createTextNode(pos));
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ describe('ol.parser.gml_v2', function() {
|
|||||||
var url = 'spec/ol/parser/ogc/xml/gml_v2/box-coord.xml';
|
var url = 'spec/ol/parser/ogc/xml/gml_v2/box-coord.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var obj = parser.read(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();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -212,7 +212,7 @@ describe('ol.parser.gml_v2', function() {
|
|||||||
var url = 'spec/ol/parser/ogc/xml/gml_v2/box-coordinates.xml';
|
var url = 'spec/ol/parser/ogc/xml/gml_v2/box-coordinates.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var obj = parser.read(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();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ describe('ol.parser.gml_v3', function() {
|
|||||||
var url = 'spec/ol/parser/ogc/xml/gml_v3/envelope.xml';
|
var url = 'spec/ol/parser/ogc/xml/gml_v3/envelope.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var obj = parser.read(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();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user