ezgpx.utils package

Submodules

ezgpx.utils.algorithms module

This module contains algorithms.

ezgpx.utils.algorithms.ramer_douglas_peucker(points: list, epsilon: float = 1.7966305682390428e-05) list[source]

Simplify a curve using the Ramer-Douglas-Peucker algorithm. Source: https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm

Args:

points (list): List of points defining the track to simplify. epsilon (float, optional): Ramer-Douglas-Peucker threshold

distance (higher value means more simplifications). Defaults to degrees(2 / EARTH_RADIUS), (i.e.: the angle corresponding to a distance of 2 metres at the surface of the earth).

Returns:

list: List of points defining the simplified track.

ezgpx.utils.distance module

This module contains utility functions for distances.

class ezgpx.utils.distance.HasLatLon(*args, **kwargs)[source]

Bases: Protocol

Protocol for objects that have latitude and longitude.

lat: LatLon
lon: LatLon
class ezgpx.utils.distance.LatLon(*args, **kwargs)[source]

Bases: Protocol

Protocol for latitude and longitude objects.

value: float
ezgpx.utils.distance.haversine_distance(point_1: HasLatLon, point_2: HasLatLon) float[source]

Compute Haversine distance (in meters) between to points. Source: https://en.wikipedia.org/wiki/Haversine_formula

Args:

point_1 (HasLatLon): First point. point_2 (HasLatLon): Second point.

Returns:

float: Haversine distance between the points.

ezgpx.utils.distance.perpendicular_distance(start_point: HasLatLon, end_point: HasLatLon, point: HasLatLon) float[source]

Compute perpendicular distance between a point and a line.

Args:

start_point (HasLatLon): A point on the line. end_point (HasLatLon): A point on the line. point (HasLatLon): A point to measure the distance from.

Returns:
float: Perpendicular distance between the point point and the

line defined by start_point and end_point.

Module contents