Skip to content

Commit 7a00e1d

Browse files
author
user name
committed
icl-1418 geometry id 设置不起作用 review by songym
1 parent f990e64 commit 7a00e1d

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/common/format/GeoJSON.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ export class GeoJSON extends JSONFormat {
612612
feature.bounds = Bounds.fromArray(bbox);
613613
}
614614
if (obj.id) {
615+
feature.geometry.id = obj.id;
615616
feature.fid = obj.id;
616617
}
617618
return feature;

test/common/format/GeoJSONSpec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,4 +740,21 @@ describe('GeoJSON', () => {
740740
expect(obj.geometry.points[0].x).toBe(10);
741741
expect(obj.geometry.points[0].y).toBe(10);
742742
});
743+
744+
it('geometry id same as feature id', () => {
745+
var feature = {
746+
type: 'Feature',
747+
properties: {
748+
POP: 1,
749+
CAPITAL: 'test'
750+
},
751+
id: 3,
752+
geometry: {
753+
type: 'Point',
754+
coordinates: [108, 44]
755+
}
756+
};
757+
var result = new GeoJSON().read(feature, feature.type);
758+
expect(result.geometry.id).toBe(3);
759+
});
743760
});

0 commit comments

Comments
 (0)