Add support for reading id & properties
This commit is contained in:
@@ -253,6 +253,12 @@ ol.format.TopoJSON.readFeatureFromGeometry_ = function(object, arcs,
|
|||||||
}
|
}
|
||||||
var feature = new ol.Feature();
|
var feature = new ol.Feature();
|
||||||
feature.setGeometry(geometry);
|
feature.setGeometry(geometry);
|
||||||
|
if (goog.isDef(object.id)) {
|
||||||
|
feature.setId(object.id);
|
||||||
|
}
|
||||||
|
if (goog.isDef(object.properties)) {
|
||||||
|
feature.setValues(object.properties);
|
||||||
|
}
|
||||||
return feature;
|
return feature;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ var aruba = {
|
|||||||
objects: {
|
objects: {
|
||||||
aruba: {
|
aruba: {
|
||||||
type: 'Polygon',
|
type: 'Polygon',
|
||||||
|
properties: {
|
||||||
|
prop0: 'value0'
|
||||||
|
},
|
||||||
arcs: [[0]],
|
arcs: [[0]],
|
||||||
id: 533
|
id: 533
|
||||||
}
|
}
|
||||||
@@ -46,6 +49,11 @@ describe('ol.format.TopoJSON', function() {
|
|||||||
var geometry = feature.getGeometry();
|
var geometry = feature.getGeometry();
|
||||||
expect(geometry).to.be.a(ol.geom.Polygon);
|
expect(geometry).to.be.a(ol.geom.Polygon);
|
||||||
|
|
||||||
|
// Parses identifier
|
||||||
|
expect(feature.getId()).to.be(533);
|
||||||
|
// Parses properties
|
||||||
|
expect(feature.get('prop0')).to.be('value0');
|
||||||
|
|
||||||
expect(geometry.getExtent()).to.eql([
|
expect(geometry.getExtent()).to.eql([
|
||||||
-70.08100810081008, 12.417091709170947,
|
-70.08100810081008, 12.417091709170947,
|
||||||
-69.9009900990099, 12.608069195591469
|
-69.9009900990099, 12.608069195591469
|
||||||
|
|||||||
Reference in New Issue
Block a user