- Heroku: http://freedraw.herokuapp.com/ — uses
ConcaveHull
by default; - npm:
npm install concavehull
- Bower:
bower install concavehull
Based on the StackOverflow question about the CSharp implementation of a paper written by Adriano Moreira and Maribel Yasmina Santos from the University of Minho.
Initially a prototype was created by nredko – and this implementation is a refactor to transform it into a fully working module.
Using ConcaveHull
is terribly simple – all you have to do is pass an array of objects that conform to the { lat: {Number}, lng: {Number} }
format – in the case of Leaflet.js this is just an array of L.LatLng
objects.
Once you have your array of latitudinal and longitudinal values, you can instantiate the object, and then invoke the getLatLngs
method:
var latLngs = new ConcaveHull(latLngs).getLatLngs();
You can manually specify the maximum length of edges in metres by passing it into the constructor as the second argument:
var edgeLength = 35,
latLngs = new ConcaveHull(latLngs, edgeLength).getLatLngs();