ramerDouglasPeucker

inline fun <T> List<T>.ramerDouglasPeucker(epsilon: Double, crossinline xExtractor: (T) -> Double, crossinline yExtractor: (T) -> Double, crossinline xTransformer: (Double) -> Double = { it }, crossinline yTransformer: (Double) -> Double = { it }): List<T>

Takes a list of objects representing a polyline with a xExtractor and yExtractor functions and applies the Ramer-Douglas-Peucker (RDP) algorithm returning the resulting list.

Receiver

A list of any data type that you wish to apply the Ramer-Douglas-Peucker algorithm to.

Return

A List which represents the receiver with the RDP algorithm applied

Parameters

T

The type of the data points you wish to simplify

epsilon

The epsilon in the RDP algorithm

xExtractor

A function that given an input T can extract the x value

yExtractor

A function that given an input T can extract the y value

xTransformer

Optional function that transforms the x value sent to the simplification algorithms but not what is returned by the simplification.

yTransformer

Optional function that transforms the y value sent to the simplification algorithms but not what is returned by the simplification.