Sensible axisOrientation and srsName defaults
This commit is contained in:
@@ -357,9 +357,9 @@
|
|||||||
/**
|
/**
|
||||||
* @typedef {Object} ol.parser.GMLOptions
|
* @typedef {Object} ol.parser.GMLOptions
|
||||||
* @property {string|undefined} axisOrientation The axis orientation as
|
* @property {string|undefined} axisOrientation The axis orientation as
|
||||||
* specified in Proj4. If this is not provided, 'enu' will be used for GML2,
|
* specified in Proj4. If this is not provided, the projection's axis
|
||||||
* and the projection's axis orientation for GML3, with a fallback to 'enu'
|
* orientation will be used if `projection` is not overridden (i.e. the
|
||||||
* if `projection` was not configured and is not provided by the data.
|
* projection defined in the data is used). Otherwise the default is 'enu'.
|
||||||
* @property {boolean|undefined} curve Write gml:Curve instead of
|
* @property {boolean|undefined} curve Write gml:Curve instead of
|
||||||
* gml:LineString elements. This also affects the elements in multi-part
|
* gml:LineString elements. This also affects the elements in multi-part
|
||||||
* geometries. Default is `false´. This only applies to GML version 3.
|
* geometries. Default is `false´. This only applies to GML version 3.
|
||||||
|
|||||||
+14
-15
@@ -29,7 +29,7 @@ ol.parser.ogc.GML = function(opt_options) {
|
|||||||
var options = /** @type {ol.parser.GMLOptions} */
|
var options = /** @type {ol.parser.GMLOptions} */
|
||||||
(goog.isDef(opt_options) ? opt_options : {});
|
(goog.isDef(opt_options) ? opt_options : {});
|
||||||
this.axisOrientation = goog.isDef(options.axisOrientation) ?
|
this.axisOrientation = goog.isDef(options.axisOrientation) ?
|
||||||
options.axisOrientation : 'enu';
|
options.axisOrientation : null;
|
||||||
this.extractAttributes = goog.isDef(options.extractAttributes) ?
|
this.extractAttributes = goog.isDef(options.extractAttributes) ?
|
||||||
options.extractAttributes : true;
|
options.extractAttributes : true;
|
||||||
this.surface = goog.isDef(options.surface) ?
|
this.surface = goog.isDef(options.surface) ?
|
||||||
@@ -47,14 +47,13 @@ ol.parser.ogc.GML = function(opt_options) {
|
|||||||
* @private
|
* @private
|
||||||
* @type {string|undefined}
|
* @type {string|undefined}
|
||||||
*/
|
*/
|
||||||
this.srsName_ = goog.isNull(this.srsName) ? undefined : this.srsName;
|
this.srsName_;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {string|undefined}
|
* @type {string|undefined}
|
||||||
*/
|
*/
|
||||||
this.axisOrientation_ = goog.isNull(this.srsName) ? undefined :
|
this.axisOrientation_;
|
||||||
ol.proj.get(this.srsName).getAxisOrientation();
|
|
||||||
|
|
||||||
if (goog.isDef(options.schemaLocation)) {
|
if (goog.isDef(options.schemaLocation)) {
|
||||||
this.schemaLocation = options.schemaLocation;
|
this.schemaLocation = options.schemaLocation;
|
||||||
@@ -319,25 +318,24 @@ ol.parser.ogc.GML = function(opt_options) {
|
|||||||
}
|
}
|
||||||
// TODO: Deal with GML documents that do not have the same SRS for all
|
// TODO: Deal with GML documents that do not have the same SRS for all
|
||||||
// geometries.
|
// geometries.
|
||||||
|
var srsName;
|
||||||
if (!goog.isDef(this.srsName_)) {
|
if (!goog.isDef(this.srsName_)) {
|
||||||
for (var i = node.childNodes.length - 1; i >= 0; --i) {
|
for (var i = node.childNodes.length - 1; i >= 0; --i) {
|
||||||
var child = node.childNodes[i];
|
var child = node.childNodes[i];
|
||||||
if (child.nodeType == 1) {
|
if (child.nodeType == 1) {
|
||||||
var srsName = child.getAttribute('srsName');
|
srsName = child.getAttribute('srsName');
|
||||||
if (goog.isDef(srsName)) {
|
if (goog.isDef(srsName)) {
|
||||||
this.srsName_ = srsName.replace(ol.parser.ogc.GML.regExes.epsg,
|
this.srsName_ = srsName;
|
||||||
'EPSG:');
|
|
||||||
if (!goog.isDef(this.axisOrientation_)) {
|
|
||||||
var projection = ol.proj.get(this.srsName_);
|
|
||||||
if (!goog.isNull(projection)) {
|
|
||||||
this.axisOrientation_ = projection.getAxisOrientation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!goog.isDef(this.axisOrientation_)) {
|
||||||
|
if (goog.isDef(srsName)) {
|
||||||
|
this.axisOrientation_ = ol.proj.get(srsName).getAxisOrientation();
|
||||||
|
}
|
||||||
|
}
|
||||||
this.readChildNodes(node, obj);
|
this.readChildNodes(node, obj);
|
||||||
},
|
},
|
||||||
'_attribute': function(node, obj) {
|
'_attribute': function(node, obj) {
|
||||||
@@ -516,12 +514,13 @@ ol.parser.ogc.GML.prototype.read = function(data) {
|
|||||||
if (data && data.nodeType == 9) {
|
if (data && data.nodeType == 9) {
|
||||||
data = data.documentElement;
|
data = data.documentElement;
|
||||||
}
|
}
|
||||||
|
this.srsName_ = goog.isNull(this.srsName) ? undefined : this.srsName;
|
||||||
|
this.axisOrientation_ = goog.isNull(this.axisOrientation) ?
|
||||||
|
undefined : this.axisOrientation;
|
||||||
var obj = /** @type {ol.parser.ReadFeaturesResult} */
|
var obj = /** @type {ol.parser.ReadFeaturesResult} */
|
||||||
({features: [], metadata: {}});
|
({features: [], metadata: {}});
|
||||||
this.readNode(data, obj, true);
|
this.readNode(data, obj, true);
|
||||||
obj.metadata.projection = this.srsName_;
|
obj.metadata.projection = this.srsName_;
|
||||||
this.srsName_ = goog.isNull(this.srsName) ? undefined : this.srsName;
|
|
||||||
delete this.axisOrientation_;
|
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ ol.parser.ogc.GML_v2 = function(opt_options) {
|
|||||||
for (var i = 0; i < numCoordinates; ++i) {
|
for (var i = 0; i < numCoordinates; ++i) {
|
||||||
var coord = coordinates[i];
|
var coord = coordinates[i];
|
||||||
var part = goog.array.concat(coord);
|
var part = goog.array.concat(coord);
|
||||||
if (this.axisOrientation.substr(0, 2) !== 'en') {
|
if (this.getAxisOrientation().substr(0, 2) !== 'en') {
|
||||||
part[0] = coord[1];
|
part[0] = coord[1];
|
||||||
part[1] = coord[0];
|
part[1] = coord[0];
|
||||||
}
|
}
|
||||||
@@ -101,8 +101,8 @@ ol.parser.ogc.GML_v2 = function(opt_options) {
|
|||||||
this.writeNode('coordinates', [[extent.minX, extent.minY],
|
this.writeNode('coordinates', [[extent.minX, extent.minY],
|
||||||
[extent.maxX, extent.maxY]], null, node);
|
[extent.maxX, extent.maxY]], null, node);
|
||||||
// srsName attribute is optional for gml:Box
|
// srsName attribute is optional for gml:Box
|
||||||
if (goog.isDef(this.srsName)) {
|
if (goog.isDef(this.getSrsName())) {
|
||||||
node.setAttribute('srsName', this.srsName);
|
node.setAttribute('srsName', this.getSrsName());
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
@@ -111,14 +111,6 @@ ol.parser.ogc.GML_v2 = function(opt_options) {
|
|||||||
goog.inherits(ol.parser.ogc.GML_v2, ol.parser.ogc.GML);
|
goog.inherits(ol.parser.ogc.GML_v2, ol.parser.ogc.GML);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string?} Axis orientation that was configured with this instance.
|
|
||||||
*/
|
|
||||||
ol.parser.ogc.GML_v2.prototype.getAxisOrientation = function() {
|
|
||||||
return this.axisOrientation;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} obj Object structure to write out as XML.
|
* @param {Object} obj Object structure to write out as XML.
|
||||||
* @return {string} An string representing the XML document.
|
* @return {string} An string representing the XML document.
|
||||||
@@ -129,5 +121,8 @@ ol.parser.ogc.GML_v2.prototype.write = function(obj) {
|
|||||||
this.setAttributeNS(
|
this.setAttributeNS(
|
||||||
root, 'http://www.w3.org/2001/XMLSchema-instance',
|
root, 'http://www.w3.org/2001/XMLSchema-instance',
|
||||||
'xsi:schemaLocation', this.schemaLocation);
|
'xsi:schemaLocation', this.schemaLocation);
|
||||||
|
this.srsName_ = goog.isNull(this.srsName) ? undefined : this.srsName;
|
||||||
|
this.axisOrientation_ = goog.isNull(this.axisOrientation) ?
|
||||||
|
undefined : this.axisOrientation;
|
||||||
return this.serialize(root);
|
return this.serialize(root);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
|
|||||||
} else if (type === ol.geom.GeometryType.GEOMETRYCOLLECTION) {
|
} else if (type === ol.geom.GeometryType.GEOMETRYCOLLECTION) {
|
||||||
child = this.writeNode('MultiGeometry', geometry, null, node);
|
child = this.writeNode('MultiGeometry', geometry, null, node);
|
||||||
}
|
}
|
||||||
if (goog.isDef(this.srsName)) {
|
if (goog.isDef(this.getSrsName())) {
|
||||||
this.setAttributeNS(child, null, 'srsName', this.srsName);
|
this.setAttributeNS(child, null, 'srsName', this.getSrsName());
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
};
|
};
|
||||||
@@ -238,7 +238,7 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
|
|||||||
'pos': function(point) {
|
'pos': function(point) {
|
||||||
// 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.getAxisOrientation().substr(0, 2) === 'en') {
|
||||||
pos = (point[0] + ' ' + point[1]);
|
pos = (point[0] + ' ' + point[1]);
|
||||||
} else {
|
} else {
|
||||||
pos = (point[1] + ' ' + point[0]);
|
pos = (point[1] + ' ' + point[0]);
|
||||||
@@ -274,7 +274,7 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
|
|||||||
var point;
|
var point;
|
||||||
for (var i = 0; i < len; ++i) {
|
for (var i = 0; i < len; ++i) {
|
||||||
point = points[i];
|
point = points[i];
|
||||||
if (this.axisOrientation.substr(0, 2) === 'en') {
|
if (this.getAxisOrientation().substr(0, 2) === 'en') {
|
||||||
parts[i] = point[0] + ' ' + point[1];
|
parts[i] = point[0] + ' ' + point[1];
|
||||||
} else {
|
} else {
|
||||||
parts[i] = point[1] + ' ' + point[0];
|
parts[i] = point[1] + ' ' + point[0];
|
||||||
@@ -373,15 +373,15 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
|
|||||||
this.writeNode('lowerCorner', bounds, null, node);
|
this.writeNode('lowerCorner', bounds, null, node);
|
||||||
this.writeNode('upperCorner', bounds, null, node);
|
this.writeNode('upperCorner', bounds, null, node);
|
||||||
// srsName attribute is required for gml:Envelope
|
// srsName attribute is required for gml:Envelope
|
||||||
if (this.srsName) {
|
if (this.getSrsName()) {
|
||||||
node.setAttribute('srsName', this.srsName);
|
node.setAttribute('srsName', this.getSrsName());
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
},
|
},
|
||||||
'lowerCorner': function(bounds) {
|
'lowerCorner': function(bounds) {
|
||||||
// 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.getAxisOrientation().substr(0, 2) === 'en') {
|
||||||
pos = (bounds.left + ' ' + bounds.bottom);
|
pos = (bounds.left + ' ' + bounds.bottom);
|
||||||
} else {
|
} else {
|
||||||
pos = (bounds.bottom + ' ' + bounds.left);
|
pos = (bounds.bottom + ' ' + bounds.left);
|
||||||
@@ -416,5 +416,8 @@ ol.parser.ogc.GML_v3.prototype.write = function(obj) {
|
|||||||
this.setAttributeNS(
|
this.setAttributeNS(
|
||||||
root, 'http://www.w3.org/2001/XMLSchema-instance',
|
root, 'http://www.w3.org/2001/XMLSchema-instance',
|
||||||
'xsi:schemaLocation', this.schemaLocation);
|
'xsi:schemaLocation', this.schemaLocation);
|
||||||
|
this.srsName_ = goog.isNull(this.srsName) ? undefined : this.srsName;
|
||||||
|
this.axisOrientation_ = goog.isNull(this.axisOrientation) ?
|
||||||
|
undefined : this.axisOrientation;
|
||||||
return this.serialize(root);
|
return this.serialize(root);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -243,6 +243,7 @@ describe('ol.parser.gml_v2', function() {
|
|||||||
'http://www.opengis.net/wfs http://demo.opengeo.org/' +
|
'http://www.opengis.net/wfs http://demo.opengeo.org/' +
|
||||||
'geoserver/schemas/wfs/1.0.0/WFS-basic.xsd';
|
'geoserver/schemas/wfs/1.0.0/WFS-basic.xsd';
|
||||||
var p = new ol.parser.ogc.GML_v2({
|
var p = new ol.parser.ogc.GML_v2({
|
||||||
|
axisOrientation: 'enu',
|
||||||
featureType: 'states',
|
featureType: 'states',
|
||||||
featureNS: 'http://www.openplans.org/topp',
|
featureNS: 'http://www.openplans.org/topp',
|
||||||
schemaLocation: schemaLoc});
|
schemaLocation: schemaLoc});
|
||||||
@@ -261,7 +262,8 @@ describe('ol.parser.gml_v2', function() {
|
|||||||
expect(attributes['SUB_REGION']).to.eql('E N Cen');
|
expect(attributes['SUB_REGION']).to.eql('E N Cen');
|
||||||
expect(attributes['STATE_ABBR']).to.eql('IL');
|
expect(attributes['STATE_ABBR']).to.eql('IL');
|
||||||
expect(attributes['LAND_KM']).to.eql('143986.61');
|
expect(attributes['LAND_KM']).to.eql('143986.61');
|
||||||
expect(obj.metadata.projection).to.eql('EPSG:4326');
|
expect(ol.proj.get(obj.metadata.projection) instanceof ol.proj.EPSG4326)
|
||||||
|
.to.be.ok();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ goog.provide('ol.test.parser.gml_v3');
|
|||||||
|
|
||||||
describe('ol.parser.gml_v3', function() {
|
describe('ol.parser.gml_v3', function() {
|
||||||
|
|
||||||
var parser = new ol.parser.ogc.GML_v3();
|
var parser = new ol.parser.ogc.GML_v3(
|
||||||
|
{srsName: 'foo', axisOrientation: 'enu'});
|
||||||
|
|
||||||
describe('Test GML v3 parser', function() {
|
describe('Test GML v3 parser', function() {
|
||||||
it('Envelope read correctly', function(done) {
|
it('Envelope read correctly', function(done) {
|
||||||
@@ -18,10 +19,8 @@ describe('ol.parser.gml_v3', function() {
|
|||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var obj = parser.read(xml);
|
var obj = parser.read(xml);
|
||||||
var geom = parser.createGeometry_({geometry: obj.geometry});
|
var geom = parser.createGeometry_({geometry: obj.geometry});
|
||||||
parser.srsName = 'foo';
|
|
||||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||||
[geom]).firstChild;
|
[geom]).firstChild;
|
||||||
parser.srsName = null;
|
|
||||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||||
expect(obj.geometry.type).to.eql('linearring');
|
expect(obj.geometry.type).to.eql('linearring');
|
||||||
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4], [5, 6],
|
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4], [5, 6],
|
||||||
@@ -34,10 +33,8 @@ describe('ol.parser.gml_v3', function() {
|
|||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var obj = parser.read(xml);
|
var obj = parser.read(xml);
|
||||||
var geom = parser.createGeometry_({geometry: obj.geometry});
|
var geom = parser.createGeometry_({geometry: obj.geometry});
|
||||||
parser.srsName = 'foo';
|
|
||||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||||
[geom]).firstChild;
|
[geom]).firstChild;
|
||||||
parser.srsName = null;
|
|
||||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||||
expect(obj.geometry.type).to.eql('linestring');
|
expect(obj.geometry.type).to.eql('linestring');
|
||||||
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4]]);
|
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4]]);
|
||||||
@@ -98,12 +95,10 @@ describe('ol.parser.gml_v3', function() {
|
|||||||
var url = 'spec/ol/parser/ogc/xml/gml_v3/multicurve-singular.xml';
|
var url = 'spec/ol/parser/ogc/xml/gml_v3/multicurve-singular.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var obj = parser.read(xml);
|
var obj = parser.read(xml);
|
||||||
parser.srsName = 'foo';
|
|
||||||
var geom = parser.createGeometry_({geometry: obj.geometry});
|
var geom = parser.createGeometry_({geometry: obj.geometry});
|
||||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||||
[geom]).firstChild;
|
[geom]).firstChild;
|
||||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||||
parser.srsName = null;
|
|
||||||
expect(obj.geometry.type).to.eql('multilinestring');
|
expect(obj.geometry.type).to.eql('multilinestring');
|
||||||
expect(obj.geometry.parts.length).to.eql(2);
|
expect(obj.geometry.parts.length).to.eql(2);
|
||||||
expect(obj.geometry.parts[0].type).to.eql('linestring');
|
expect(obj.geometry.parts[0].type).to.eql('linestring');
|
||||||
@@ -142,12 +137,10 @@ describe('ol.parser.gml_v3', function() {
|
|||||||
var url = 'spec/ol/parser/ogc/xml/gml_v3/multipoint-singular.xml';
|
var url = 'spec/ol/parser/ogc/xml/gml_v3/multipoint-singular.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var obj = parser.read(xml);
|
var obj = parser.read(xml);
|
||||||
parser.srsName = 'foo';
|
|
||||||
var geom = parser.createGeometry_({geometry: obj.geometry});
|
var geom = parser.createGeometry_({geometry: obj.geometry});
|
||||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||||
[geom]).firstChild;
|
[geom]).firstChild;
|
||||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||||
parser.srsName = null;
|
|
||||||
expect(obj.geometry.type).to.eql('multipoint');
|
expect(obj.geometry.type).to.eql('multipoint');
|
||||||
expect(obj.geometry.parts.length).to.eql(3);
|
expect(obj.geometry.parts.length).to.eql(3);
|
||||||
expect(obj.geometry.parts[0].type).to.eql('point');
|
expect(obj.geometry.parts[0].type).to.eql('point');
|
||||||
@@ -194,12 +187,10 @@ describe('ol.parser.gml_v3', function() {
|
|||||||
var url = 'spec/ol/parser/ogc/xml/gml_v3/multisurface-singular.xml';
|
var url = 'spec/ol/parser/ogc/xml/gml_v3/multisurface-singular.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var obj = parser.read(xml);
|
var obj = parser.read(xml);
|
||||||
parser.srsName = 'foo';
|
|
||||||
var geom = parser.createGeometry_({geometry: obj.geometry});
|
var geom = parser.createGeometry_({geometry: obj.geometry});
|
||||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||||
[geom]).firstChild;
|
[geom]).firstChild;
|
||||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||||
parser.srsName = null;
|
|
||||||
expect(obj.geometry.type).to.eql('multipolygon');
|
expect(obj.geometry.type).to.eql('multipolygon');
|
||||||
expect(obj.geometry.parts.length).to.eql(2);
|
expect(obj.geometry.parts.length).to.eql(2);
|
||||||
expect(obj.geometry.parts[0].type).to.eql('polygon');
|
expect(obj.geometry.parts[0].type).to.eql('polygon');
|
||||||
@@ -226,10 +217,8 @@ describe('ol.parser.gml_v3', function() {
|
|||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var obj = parser.read(xml);
|
var obj = parser.read(xml);
|
||||||
var geom = parser.createGeometry_({geometry: obj.geometry});
|
var geom = parser.createGeometry_({geometry: obj.geometry});
|
||||||
parser.srsName = 'foo';
|
|
||||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||||
[geom]).firstChild;
|
[geom]).firstChild;
|
||||||
parser.srsName = null;
|
|
||||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||||
expect(obj.geometry.type).to.eql('point');
|
expect(obj.geometry.type).to.eql('point');
|
||||||
expect(obj.geometry.coordinates).to.eql([1, 2]);
|
expect(obj.geometry.coordinates).to.eql([1, 2]);
|
||||||
@@ -241,10 +230,8 @@ describe('ol.parser.gml_v3', function() {
|
|||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var obj = parser.read(xml);
|
var obj = parser.read(xml);
|
||||||
var geom = parser.createGeometry_({geometry: obj.geometry});
|
var geom = parser.createGeometry_({geometry: obj.geometry});
|
||||||
parser.srsName = 'foo';
|
|
||||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||||
[geom]).firstChild;
|
[geom]).firstChild;
|
||||||
parser.srsName = null;
|
|
||||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||||
expect(obj.geometry.type).to.eql('polygon');
|
expect(obj.geometry.type).to.eql('polygon');
|
||||||
done();
|
done();
|
||||||
@@ -272,9 +259,8 @@ describe('ol.parser.gml_v3', function() {
|
|||||||
'http://www.opengis.net/gml ' +
|
'http://www.opengis.net/gml ' +
|
||||||
'http://schemas.opengis.net/gml/3.2.1/gml.xsd';
|
'http://schemas.opengis.net/gml/3.2.1/gml.xsd';
|
||||||
var p = new ol.parser.ogc.GML_v3({schemaLocation: schemaLoc});
|
var p = new ol.parser.ogc.GML_v3({schemaLocation: schemaLoc});
|
||||||
|
debugger
|
||||||
var obj = p.read(xml);
|
var obj = p.read(xml);
|
||||||
p.srsName = 'urn:x-ogc:def:crs:EPSG:4326';
|
|
||||||
p.axisOrientation = 'neu';
|
|
||||||
var output = p.write(obj);
|
var output = p.write(obj);
|
||||||
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
|
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
|
||||||
expect(p.geometryName).to.eql('the_geom');
|
expect(p.geometryName).to.eql('the_geom');
|
||||||
@@ -289,13 +275,15 @@ describe('ol.parser.gml_v3', function() {
|
|||||||
expect(attributes['SUB_REGION']).to.eql('E N Cen');
|
expect(attributes['SUB_REGION']).to.eql('E N Cen');
|
||||||
expect(attributes['STATE_ABBR']).to.eql('IL');
|
expect(attributes['STATE_ABBR']).to.eql('IL');
|
||||||
expect(attributes['LAND_KM']).to.eql('143986.61');
|
expect(attributes['LAND_KM']).to.eql('143986.61');
|
||||||
expect(obj.metadata.projection).to.eql('EPSG:4326');
|
expect(ol.proj.get(obj.metadata.projection) instanceof ol.proj.EPSG4326)
|
||||||
|
.to.be.ok();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('FeatureCollection from WFS read correctly', function(done) {
|
it('FeatureCollection from WFS read correctly', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/gml_v3/topp-states-wfs.xml';
|
var url = 'spec/ol/parser/ogc/xml/gml_v3/topp-states-wfs.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
|
parser.srsName = null;
|
||||||
var obj = parser.read(xml);
|
var obj = parser.read(xml);
|
||||||
expect(obj.features.length).to.eql(3);
|
expect(obj.features.length).to.eql(3);
|
||||||
var feature = obj.features[0];
|
var feature = obj.features[0];
|
||||||
@@ -308,7 +296,9 @@ describe('ol.parser.gml_v3', function() {
|
|||||||
expect(attributes['SUB_REGION']).to.eql('E N Cen');
|
expect(attributes['SUB_REGION']).to.eql('E N Cen');
|
||||||
expect(attributes['STATE_ABBR']).to.eql('IL');
|
expect(attributes['STATE_ABBR']).to.eql('IL');
|
||||||
expect(attributes['LAND_KM']).to.eql('143986.61');
|
expect(attributes['LAND_KM']).to.eql('143986.61');
|
||||||
expect(obj.metadata.projection).to.eql('EPSG:4326');
|
expect(ol.proj.get(obj.metadata.projection) instanceof ol.proj.EPSG4326)
|
||||||
|
.to.be.ok();
|
||||||
|
parser.srsName = "foo";
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user