openchargemap / ocm-data

Snapshots of current Open Charge Map data [deprecated]
https://openchargemap.org
28 stars 7 forks source link

The poi.json is not a list of dictionaries #5

Open cedricraeymaeckers opened 4 years ago

cedricraeymaeckers commented 4 years ago

It seems that the poi.json file is not a list of dictionaries but the file just contains one dictionary per line in the file, this makes it difficult to process.

webprofusion-chrisc commented 4 years ago

I'm guessing you're coding in python, have you done any coding in other languages before?

Poi.json is a direct export of our MongoDB database which in turn is a direct export of our normal poi API for all results.

hughsheehy commented 4 years ago

It's not that hard to make a (python) script to make it all into a GeoJSON file.

This below is a crude example I made to turn the whole POI file into geojson. The fact that the file isn't actually valid json is a bit of a pain, but it's manageable. There's also (on my system) some fiddling with encoding. But it works.


geojson.zip

hughsheehy commented 4 years ago

It's not that hard to make a (python) script to make it all into a GeoJSON file.

This below is a crude example I made to turn the whole POI file into geojson. The fact that the file isn't actually valid json is a bit of a pain, but it's manageable. There's also (on my system) some fiddling with encoding. But it works.

geojson.zip

Just on the above, I seem to have saved (and thus uploaded) a second-last version of my own little script. There's a function missing, to do this.

still need to trim last comma and last newline from the json file. then it's an long list of json objects, with no starting or trailing [ or ].

Once that's done, it can be read as Json.

webprofusion-chrisc commented 3 years ago

Update: I've updated our geojson output implementation so that it validates in modern GeoJSON parsers. If you encounter bugs specific to GeoJSON please create an issue:

https://api.openchargemap.io/v3/poi/?output=geojson&countrycode=BE

hughsheehy commented 3 years ago

Update: I've updated our geojson output implementation so that it validates in modern GeoJSON parsers. If you encounter bugs specific to GeoJSON please create an issue:

https://api.openchargemap.io/v3/poi/?output=geojson&countrycode=BE

If I hit that API, it seems to give back only a small fraction of the charging locations in a country. Whether BE or elsewhere. Really quite a small fraction

webprofusion-chrisc commented 3 years ago

@hughsheehy remember that maxresults defaults to 100, so you should get max 100 results whichever country code you use unless you specify a high maxresults and an API key.

hughsheehy commented 3 years ago

@hughsheehy remember that maxresults defaults to 100, so you should get max 100 results whichever country code you use unless you specify a high maxresults and an API key.

Silly me. 😳