Call setGeometryName on the feature
This commit is contained in:
@@ -137,7 +137,7 @@ ol.format.GML.prototype.readGeometryFromNode = function(node) {
|
|||||||
*/
|
*/
|
||||||
ol.format.GML.prototype.readFeature_ = function(node, objectStack) {
|
ol.format.GML.prototype.readFeature_ = function(node, objectStack) {
|
||||||
var n;
|
var n;
|
||||||
var values = {};
|
var values = {}, geometryName;
|
||||||
for (n = node.firstElementChild; !goog.isNull(n);
|
for (n = node.firstElementChild; !goog.isNull(n);
|
||||||
n = n.nextElementSibling) {
|
n = n.nextElementSibling) {
|
||||||
// Assume attribute elements have one child node and that the child
|
// Assume attribute elements have one child node and that the child
|
||||||
@@ -147,10 +147,15 @@ ol.format.GML.prototype.readFeature_ = function(node, objectStack) {
|
|||||||
n.firstChild.nodeType === 3)) {
|
n.firstChild.nodeType === 3)) {
|
||||||
values[ol.xml.getLocalName(n)] = ol.xml.getAllTextContent(n, false);
|
values[ol.xml.getLocalName(n)] = ol.xml.getAllTextContent(n, false);
|
||||||
} else {
|
} else {
|
||||||
values[ol.xml.getLocalName(n)] = this.readGeometryFromNode(n);
|
geometryName = ol.xml.getLocalName(n);
|
||||||
|
values[geometryName] = this.readGeometryFromNode(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ol.Feature(values);
|
var feature = new ol.Feature(values);
|
||||||
|
if (goog.isDef(geometryName)) {
|
||||||
|
feature.setGeometryName(geometryName);
|
||||||
|
}
|
||||||
|
return feature;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -592,7 +592,7 @@ describe('ol.format.GML', function() {
|
|||||||
it('creates a polygon for Illinois', function() {
|
it('creates a polygon for Illinois', function() {
|
||||||
feature = features[0];
|
feature = features[0];
|
||||||
expect(feature.get('STATE_NAME')).to.equal('Illinois');
|
expect(feature.get('STATE_NAME')).to.equal('Illinois');
|
||||||
expect(feature.get('the_geom')).to.be.an(ol.geom.MultiPolygon);
|
expect(feature.getGeometry()).to.be.an(ol.geom.MultiPolygon);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user