Merge pull request #3118 from naturalatlas/wfs-firstelementchild-bugfix
Bugfix: "Cannot read property 'firstElementChild' of null" (WFS)
This commit is contained in:
@@ -747,8 +747,10 @@ ol.format.WFS.prototype.readProjectionFromDocument = function(doc) {
|
|||||||
ol.format.WFS.prototype.readProjectionFromNode = function(node) {
|
ol.format.WFS.prototype.readProjectionFromNode = function(node) {
|
||||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||||
goog.asserts.assert(node.localName == 'FeatureCollection');
|
goog.asserts.assert(node.localName == 'FeatureCollection');
|
||||||
node = node.firstElementChild.firstElementChild;
|
|
||||||
if (goog.isDefAndNotNull(node)) {
|
if (goog.isDefAndNotNull(node.firstElementChild) &&
|
||||||
|
goog.isDefAndNotNull(node.firstElementChild.firstElementChild)) {
|
||||||
|
node = node.firstElementChild.firstElementChild;
|
||||||
for (var n = node.firstElementChild; !goog.isNull(n);
|
for (var n = node.firstElementChild; !goog.isNull(n);
|
||||||
n = n.nextElementSibling) {
|
n = n.nextElementSibling) {
|
||||||
if (!(n.childNodes.length === 0 ||
|
if (!(n.childNodes.length === 0 ||
|
||||||
@@ -760,5 +762,6 @@ ol.format.WFS.prototype.readProjectionFromNode = function(node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version='1.0' encoding="ISO-8859-1" ?>
|
||||||
|
<wfs:FeatureCollection
|
||||||
|
xmlns:rws="http://mapserver.gis.umn.edu/mapserver"
|
||||||
|
xmlns:gml="http://www.opengis.net/gml"
|
||||||
|
xmlns:wfs="http://www.opengis.net/wfs"
|
||||||
|
xmlns:ogc="http://www.opengis.net/ogc"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://mapserver.gis.umn.edu/mapserver http://intranet.rijkswaterstaat.nl/services/geoservices/nwb_wegen?SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=feature:AAA64&OUTPUTFORMAT=text/xml; subtype=gml/3.1.1 http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" numberOfFeatures="0">
|
||||||
|
</wfs:FeatureCollection>
|
||||||
@@ -89,6 +89,21 @@ describe('ol.format.WFS', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when parsing FeatureCollection', function() {
|
||||||
|
var xml;
|
||||||
|
before(function(done) {
|
||||||
|
afterLoadText('spec/ol/format/wfs/EmptyFeatureCollection.xml',
|
||||||
|
function(_xml) {
|
||||||
|
xml = _xml;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('returns an empty array of features when none exist', function() {
|
||||||
|
var result = new ol.format.WFS().readFeatures(xml);
|
||||||
|
expect(result).to.have.length(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('when parsing FeatureCollection', function() {
|
describe('when parsing FeatureCollection', function() {
|
||||||
var response;
|
var response;
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
|
|||||||
Reference in New Issue
Block a user