@@ -408,7 +408,7 @@ ol.format.GeoJSON.prototype.readFeatureFromObject = function(
|
||||
feature.setGeometryName(this.geometryName_);
|
||||
}
|
||||
feature.setGeometry(geometry);
|
||||
if (geoJSONFeature.id) {
|
||||
if (geoJSONFeature.id !== undefined) {
|
||||
feature.setId(geoJSONFeature.id);
|
||||
}
|
||||
if (geoJSONFeature.properties) {
|
||||
|
||||
@@ -27,6 +27,15 @@ describe('ol.format.GeoJSON', function() {
|
||||
}
|
||||
};
|
||||
|
||||
var zeroIdGeoJSON = {
|
||||
'type': 'Feature',
|
||||
'id': 0,
|
||||
'geometry': null,
|
||||
'properties': {
|
||||
'prop0': 'value0'
|
||||
}
|
||||
};
|
||||
|
||||
var lineStringGeoJSON = {
|
||||
'type': 'Feature',
|
||||
'geometry': {
|
||||
@@ -166,6 +175,12 @@ describe('ol.format.GeoJSON', function() {
|
||||
expect(feature.get('prop0')).to.be('value0');
|
||||
});
|
||||
|
||||
it('can read a feature with id equal to 0', function() {
|
||||
var feature = format.readFeature(zeroIdGeoJSON);
|
||||
expect(feature).to.be.an(ol.Feature);
|
||||
expect(feature.getId()).to.be(0);
|
||||
});
|
||||
|
||||
it('can read a feature collection', function() {
|
||||
var features = format.readFeatures(featureCollectionGeoJSON);
|
||||
expect(features).to.have.length(3);
|
||||
|
||||
Reference in New Issue
Block a user