tripkit-android / com.skedgo.tripkit.common.util / PolyUtil / simplify

simplify

open static fun simplify(poly:MutableList<TripKitLatLng!>!, tolerance:Double):MutableList<TripKitLatLng!>!

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.

Parameters

poly - MutableList<TripKitLatLng!>!: polyline or polygon to be simplified. Polygon should be closed (i.e., first and last points should have the same latitude and longitude).

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

Return MutableList<TripKitLatLng!>!: a simplified poly produced by the Douglas-Peucker algorithm