topojson.feature of a FeatureCollection of MultiPolygons returns a "Feature" object with null as geometry property
Closed this issue · 4 comments
I have the topojson file in attachment:
topojson_issue.json.txt
which I made with the "pytopojson" library. I'm pretty confident it looks ok, library doesn't complain but I guess there isn't an online validator. Geojson-wise it's a feature collection of 20 multipolygons. I use the following snippet in javascript:
d3.json("https://75.119.131.164/data/hourly_homezones.json", function(error, topology) {
console.log(topojson.feature(topology, topology.objects.my_geojson.geometries));
};
which returns:
I don't think this is an expected response. I expect a featurecollection of multipolygons.
Any foolish mistake I'm making ? Or is this a bug ?
What happens if you do this?
topojson.feature(topology, topology.objects.my_geojson)
Uncaught TypeError: Cannot read properties of undefined (reading 'objects') at Object.<anonymous> (coverage.html:69:53) at Object.t (d3.v3.min.js:1:1565) at XMLHttpRequest.i (d3.v3.min.js:1:10120)
thrown at the console.log line
Cannot read properties of undefined (reading 'objects')
This means that topology
is undefined, which means it’s not even calling topojson.feature
, so there must be a bug elsewhere.
I can’t reproduce this.
I kept trying and trying, finally works, don't really know why it didn't before. Not a bug indeed. Thx for investigating @mbostock !