turf icon indicating copy to clipboard operation
turf copied to clipboard

Proof of concept: Visvalingam Whyatt Simplification

Open ffflabs opened this issue 8 years ago • 6 comments

I know turf.simplify uses simplify-js under the cover, which in turn uses Douglas-Peucker simplification algorithm.

Inspired by the approach taken by Matt Bloch (author of MapShaper) I made a little proof of concept for a simplification approach using Visvalingam Whyatt algorithm (as explained in this Mike Bostock's article)

You can compare the outcome of both simplification algorithms in https://huasofoundries.github.io/simplify-vw/

I'm using the latests unpkg available package of turf.

I guess both approaches have their own pros and cons. If you guys are interested, I could put a little effort to make this POC work for Polylines and Multigeometries.

ffflabs avatar Nov 10 '17 14:11 ffflabs

👍 Very cool!

Instead of a creating an entirely new module, couldn't we just add algorithm as an optional parameter in options which would default to douglas-peucker. That way the user can easily toggle back and forth by simply changing one parameter.

image

DenisCarriere avatar Nov 10 '17 14:11 DenisCarriere

Yeah, that would be the sanest approach, since turf.simplify already does geometry decomposition to apply the simplification to the underlying rings/arcs of geometries you feed it.

ffflabs avatar Nov 10 '17 14:11 ffflabs

👍 Sounds like a good idea! Looking forward to seeing this implemented 😄

DenisCarriere avatar Nov 10 '17 15:11 DenisCarriere

I've used a VW library in the past with python with great results. And love the approach of including it via the existing module via the options (one of the great benefits of going to this module approach)

rowanwins avatar Nov 11 '17 05:11 rowanwins

I've just seen that jsts does have both Algorithms in its simplify operation. I'll check if their weight adds too much overhead to the @turf/simplify build (as in, if I bundle simplify-js vs if I bundle jsts-es/simplify.

ffflabs avatar Nov 23 '17 12:11 ffflabs

👍 Almost done refactoring jsts to ES6 (both versions of jsts & jsts-es has major issues with extend.js & inherits.js)

Follow progress here: https://github.com/DenisCarriere/turf-jsts

Ideal goal would be to merge this directly into jsts (100% refactored/linted code... 🐵)

@amenadiel I'll check if their weight adds too much overhead to the @turf/simplify build

I'm 👍 for adding these algorithms using jsts now that it's a bit more stable and will soon be able to handle proper Rollup Tree shaking, the next release will be significantly smaller in bundle size (don't know the exact %).

DenisCarriere avatar Nov 25 '17 08:11 DenisCarriere