simplify

inline fun <T> List<T>.simplify(tolerance: Double = 1.0, highestQuality: Boolean = false, crossinline xExtractor: (T) -> Double, crossinline yExtractor: (T) -> Double, crossinline xTransformer: (Double) -> Double = { it }, crossinline yTransformer: (Double) -> Double = { it }): List<T>

For a List returns a List of simplified points. This is a direct port of simplify-js and should function the same.

For more information on simplify-js see simplify-js

Receiver

A List representing two-dimensional points that you wish to simplify

Parameters

T

The type of the data points you wish to simplify

tolerance

Affects the amount of simplification

highestQuality

: Setting to true will exclude Radial Distance based preprocessing but may take longer.

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.


fun List<Pair<Double, Double>>.simplify(tolerance: Double = 1.0, highestQuality: Boolean = false): List<Pair<Double, Double>>

For a List of Pair returns a List representing the simplified polyline. It is strongly encouraged to use simplify on your own data types with your own xExtractor and yExtractor to avoid making unnecessary copies of large data sets.

See also