Unable to parse empty GeoJSON FeatureCollection to Datasource
davidtheclark opened this issue · comments
I'm trying to create a Datasource from a GeoJSON file with no features, and Mapnik is saying that it can't parse that valid GeoJSON.
Looks like the error that throws originates here:
And through node-mapnik it comes out to me like this: Error: geojson_datasource: Failed to parse GeoJSON file ...
The file I've been trying just looks like this:
{
"type": "FeatureCollection",
"features": []
}
cc @mapsam and @jakepruitt, who chatted with me about this.
@davidtheclark - can you share how exactly you're creating a Datasource (parameters), pls ?
Python
>>> ds=mapnik.GeoJSON(file="empty.json")
>>> fs = ds.featureset()
>>> type(fs)
<class 'NoneType'>
mapnik-index
mapnik-index empty.json
max tree depth:8
split ratio:0.55
processing 'empty.json' as GeoJSON
mapnik-index (GeoJSON) : could not extract bounding boxes from : 'empty.json'
Error: failed to process empty.json
both seems reasonable ^
Ah, it seems to be tied to whether I use cache_features
or not.
var mapnik = require('mapnik');
var path = require('path');
mapnik.register_default_input_plugins();
// This throws the error "Error: geojson_datasource: Failed to parse GeoJSON file ..."
var x = new mapnik.Datasource({
type: 'geojson',
cache_features: true, // Without this line, though, no error is thrown
file: path.join(__dirname, './test/fixtures/src/no-features.geojson'),
});
I'm using node-mapnik
but filed the issue here because of the origin of the error.
Ok, I see, thanks ^
@davidtheclark - ^
Closing here as it has been fixed ^