Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Simplify a LineString using the Ramer-Douglas-Peucker algorithm.
Input: a list of lat, lon coordinates, and an epsilon float (Try 1.0 to begin with, reducing by orders of magnitude)
Output: a simplified list of coordinates
Example:
simplify_coords([
[0.0, 0.0], [5.0, 4.0], [11.0, 5.5], [17.3, 3.2], [27.8, 0.1]],
1.0
)
Result: [[0.0, 0.0], [5.0, 4.0], [11.0, 5.5], [27.8, 0.1]]
"""
simplify_coords_vw = lib.simplify_visvalingam_ffi
simplify_coords_vw.argtypes = (_FFIArray, c_double)
simplify_coords_vw.restype = _CoordResult
simplify_coords_vw.errcheck = _void_array_to_nested_list
simplify_coords_vw.__doc__ = """
Simplify a LineString using the Visvalingam-Whyatt algorithm.
Input: a list of lat, lon coordinates, and an epsilon float
Output: a simplified list of coordinates
Example:
simplify_coords([
[5.0, 2.0], [3.0, 8.0], [6.0, 20.0], [7.0, 25.0], [10.0, 10.0]],
30.0
)
Result: [[5.0, 2.0], [7.0, 25.0], [10.0, 10.0]]
"""
simplify_coords_vwp = lib.simplify_visvalingamp_ffi