simplify

open fun simplify(poly: List<LatLng>, tolerance: Double): List<LatLng>

Simplifies the given poly (polyline or polygon) using the Douglas-Peucker decimation algorithm. Increasing the tolerance will result in fewer points in the simplified polyline or polygon.

When the providing a polygon as input, the first and last point of the list MUST have the same latitude and longitude (i.e., the polygon must be closed). If the input polygon is not closed, the resulting polygon may not be fully simplified.

The time complexity of Douglas-Peucker is O(n^2), so take care that you do not call this algorithm too frequently in your code.

Return

a simplified poly produced by the Douglas-Peucker algorithm

Parameters

poly

polyline or polygon to be simplified. Polygon should be closed (i.e., first and last points should have the same latitude and longitude).

tolerance

in meters. Increasing the tolerance will result in fewer points in the simplified poly.