radialDistance

inline fun <T> List<T>.radialDistance(tolerance: 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 function and applies the Radial Distance (RD) algorithm returning the resulting list. This algorithm goes through each point and prunes points that are within the radial distance represented by tolerance param reducing the total number of points.

Receiver

A List of any data type T that you wish to apply the RD algorithm to.

Return

A List which represents the receiver with the RD algorithm applied

Parameters

T

The type of the data points you wish to simplify

tolerance

The max radial distance from each "key" value that can be removed from the resulting polyline.

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.