leaflet-polyline-hausdorffdistance
v0.2.0
Published
Compute distances between two Leaflet Polyline objects
Downloads
12
Maintainers
Readme
Leaflet Hausdorff Distance
This plugins enables you to compute distance between two L.PolyLine
objects using the Hausdorff distance.
Installing
Put the L.Polyline.HausdorffDistance script after the Leaflet one:
<script src="leaflet.js"></script>
<script src="L.Polyline.HausdorffDistance.min.js"></script>
Usage
This plugins adds two methods to L.Polyline
objects:
distanceTo(other: L.Polyline, resampling?: number)
: computes the distancefurthestFrom(other: L.Polyline, resampling?: number)
: returns the two furthest points
Given two L.Polyline
objects a
and b
, get the distance between a
and b
simply by calling a.distanceTo(b)
.
For better results, the methods resample the polylines down to at least one point every 10 meters. You can turn it off by passing null
as resampling
parameter.