Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to parse empty GeoJSON FeatureCollection to Datasource #3463

Closed
davidtheclark opened this issue Jul 11, 2016 · 5 comments
Closed

Unable to parse empty GeoJSON FeatureCollection to Datasource #3463

davidtheclark opened this issue Jul 11, 2016 · 5 comments

Comments

@davidtheclark
Copy link

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:

else throw mapnik::datasource_exception("geojson_datasource: Failed to parse GeoJSON file '" + filename_ + "'");

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.

@artemp
Copy link
Member

artemp commented Jul 12, 2016

@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 ^

@davidtheclark
Copy link
Author

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.

@artemp
Copy link
Member

artemp commented Jul 12, 2016

Ok, I see, thanks ^

@artemp
Copy link
Member

artemp commented Jul 12, 2016

@davidtheclark - ^

@artemp
Copy link
Member

artemp commented Jul 18, 2016

Closing here as it has been fixed ^

@artemp artemp closed this as completed Jul 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants