Fix write out GeoJSON features with id equal to 0
This commit is contained in:
@@ -530,7 +530,7 @@ ol.format.GeoJSON.prototype.writeFeatureObject = function(
|
|||||||
'type': 'Feature'
|
'type': 'Feature'
|
||||||
};
|
};
|
||||||
var id = feature.getId();
|
var id = feature.getId();
|
||||||
if (id) {
|
if (id !== undefined) {
|
||||||
object['id'] = id;
|
object['id'] = id;
|
||||||
}
|
}
|
||||||
var geometry = feature.getGeometry();
|
var geometry = feature.getGeometry();
|
||||||
|
|||||||
@@ -551,6 +551,12 @@ describe('ol.format.GeoJSON', function() {
|
|||||||
expect(geojson.geometry).to.eql(null);
|
expect(geojson.geometry).to.eql(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('writes out a feature with id equal to 0 correctly', function() {
|
||||||
|
var feature = new ol.Feature();
|
||||||
|
feature.setId(0);
|
||||||
|
var geojson = format.writeFeatureObject(feature);
|
||||||
|
expect(geojson.id).to.eql(0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#writeGeometry', function() {
|
describe('#writeGeometry', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user