max-mapper / simplify-geojson

apply the ramer-douglas-peucker line simplification to geojson features or feature collections in JS or on the CLI
177 stars 17 forks source link

Use Visvalingam's algorithm instead of Douglas-Peuker #1

Open gka opened 10 years ago

gka commented 10 years ago

Here is a reference implementation in JavaScript:

https://github.com/mbostock/topojson/blob/master/lib/topojson/simplify.js

And another:

https://github.com/mbloch/mapshaper/blob/master/src/mapshaper-simplify.js

Btw, mapshaper allows GeoJSON simplification via command line.

max-mapper commented 10 years ago

thanks! I saw mapshaper when I was searching for existing geojson CLI simplifiers but it has a lot of surface area and I didn't realize it did this already. It's unfortunate that both of the examples you linked two aren't themselves standalone modules though

max-mapper commented 10 years ago

now theres a single override point for plugging in other simplification algorithms: https://github.com/maxogden/simplify-geojson/blob/master/index.js#L10-L12

What I have now suits my use case fine (simplifying linestrings from GPS data loggers), so if someone else has an e.g. polygon use-case where topojson's simplification is noticeably better then I'm happy to take a PR that plugs it in, but it'd have to be a module that just does simplification and not a coarse grained dependency e.g. all of topojson

gka commented 10 years ago

Yes, I agree that the mapshaper-cli should ideally be separated from the gui stuff (cc @mbloch).