simonw / datasette-leaflet-geojson

Datasette plugin that replaces any GeoJSON column values with a Leaflet map.
17 stars 7 forks source link

Option to simplify large GeoJSON before rendering #1

Closed simonw closed 3 years ago

simonw commented 6 years ago

GeoJSON can get big. It would be neat if this library could simplify giant GeoJSON shapes before attempting to render them.

Leaflet ships with a simplify() helper function: https://leafletjs.com/reference-1.3.0.html#lineutil-simplify

Also available as a separate library (with a really nice interactive demo): http://mourner.github.io/simplify-js/

Turf has a version of this that can be applied to GeoJSON documents directly: http://turfjs.org/docs/#simplify

The tricky part is picking the right tolerance value.

simonw commented 3 years ago

I'm happy with the simpler fix I implemented in #11 which reduces floating point accuracy.