Fix srsDimension read on GML3 for Geoserver

Contrary to Mapserver, Geoserver sets the srsDimension attribute on
the child of the geometry node, not on the points list.
This fix searches that node as well.

A small unit test was also added.
This commit is contained in:
Joao Gouveia
2017-08-15 09:10:17 +02:00
parent 4a0f97ac6a
commit f928209256
4 changed files with 110 additions and 3 deletions
+6 -3
View File
@@ -345,7 +345,7 @@ ol.format.GML3.prototype.readFlatPosList_ = function(node, objectStack) {
var s = ol.xml.getAllTextContent(node, false).replace(/^\s*|\s*$/g, '');
var context = objectStack[0];
var containerSrs = context['srsName'];
var containerDimension = node.parentNode.getAttribute('srsDimension');
var contextDimension = context['srsDimension'];
var axisOrientation = 'enu';
if (containerSrs) {
var proj = ol.proj.get(containerSrs);
@@ -360,8 +360,11 @@ ol.format.GML3.prototype.readFlatPosList_ = function(node, objectStack) {
} else if (node.getAttribute('dimension')) {
dim = ol.format.XSD.readNonNegativeIntegerString(
node.getAttribute('dimension'));
} else if (containerDimension) {
dim = ol.format.XSD.readNonNegativeIntegerString(containerDimension);
} else if (node.parentNode.getAttribute('srsDimension')) {
dim = ol.format.XSD.readNonNegativeIntegerString(
node.parentNode.getAttribute('srsDimension'));
} else if (contextDimension) {
dim = ol.format.XSD.readNonNegativeIntegerString(contextDimension);
}
var x, y, z;
var flatCoordinates = [];
+1
View File
@@ -198,6 +198,7 @@ ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
ol.format.GMLBase.prototype.readGeometryElement = function(node, objectStack) {
var context = /** @type {Object} */ (objectStack[0]);
context['srsName'] = node.firstElementChild.getAttribute('srsName');
context['srsDimension'] = node.firstElementChild.getAttribute('srsDimension');
/** @type {ol.geom.Geometry} */
var geometry = ol.xml.pushParseAndPop(null,
this.GEOMETRY_PARSERS_, node, objectStack, this);