fietsboek.geo module

This module implements GPS related functionality.

fietsboek.geo.CLIMB_MERGE_THRESHOLD = 50

Window for when climbs are merged (in m).

fietsboek.geo.CLIMB_MIN_ASCENSION = 0.03

Minimum relative ascension for a segment to be considered a climb.

fietsboek.geo.CLIMB_MIN_LENGTH = 500

Minimum length (in m) for an ascent to be considered a climb.

fietsboek.geo.EARTH_RADIUS = 6378137.0

Radius of the earth, in meters.

fietsboek.geo.MOVING_THRESHOLD = 1.1

Speed which is considered to be the moving threshold, in m/s.

class fietsboek.geo.MovementData(duration=0.0, moving_duration=0.0, stopped_duration=0.0, length=0.0, average_speed=0.0, maximum_speed=0.0, uphill=0.0, downhill=0.0, elevation_gain=0.0, min_elevation=0.0, max_elevation=0.0)

Bases: object

Movement statistics for a path.

average_speed: float = 0.0

Average speed, in m/s.

downhill: float = 0.0

Downhill elevation, in meters.

duration: float = 0.0

Duration of the path, in seconds.

elevation_gain: float = 0.0

Elevation gain, in meters.

length: float = 0.0

Length of the path, in meters.

max_elevation: float = 0.0

Maximum elevation, in meters.

maximum_speed: float = 0.0

Maximum speed, in m/s.

min_elevation: float = 0.0

Minimum elevation, in meters.

moving_duration: float = 0.0

Duration spent moving, in seconds.

stopped_duration: float = 0.0

Duration spent stopped, in seconds.

uphill: float = 0.0

Uphill elevation, in meters.

class fietsboek.geo.Path(points)

Bases: object

A GPS path, that is a series of GPS points.

bounds()

Returns the bounds of this path.

Return type:

tuple[tuple[float, float], tuple[float, float]]

Returns:

Bounds in the form (min_lat, min_lon), (max_lat, max_lon).

climbs()

Returns an iterator over all climbs of this path.

Return type:

Iterator[tuple[int, int]]

Returns:

An iterator over the climbs, represented by the starting index and ending index of points included in the climb.

interpolate(where)

Returns a point in the middle of the path.

If where is 0, the beginning of the path is returned. If where is 1, the end is returned.

Unlike accessing self.points, this function can return points between two points in the path.

Parameters:

where (float) – Float between 0 and 1 indicating the position of the wanted point.

Return type:

Point

Returns:

The interpolated point.

movement_data()

Returns the movement data.

Return type:

MovementData

similarity(reference)

Returns a similarity measure between this track and the given other track.

The higher the returned number is, the more dissimilar the given tracks are.

Note that currently, this measure is not symmetric, as other is cut to match self in length (on a best-effort basis). Therefore, longer.similarity(shorter) and shorter.similarity(longer) will not be the same.

Parameters:

reference (Path) – The other track.

Return type:

float

Returns:

The similarity measure.

class fietsboek.geo.Point(longitude, latitude, elevation, time_offset)

Bases: object

A GPS point, represented as longitude/latitude/elevation.

distance(other)

Returns the distance between this point and the given other point in meters.

Return type:

float

elevation: float
flat_distance(other)

Returns the distance between this point and the other point in meters.

This does not take elevation into account, and only looks at the 2d distance.

Return type:

float

latitude: float
latlon()

Returns the latitude and longitude of this point as a tuple.

Return type:

tuple[float, float]

longitude: float
time_offset: float
class fietsboek.geo.Waypoint(longitude, latitude, elevation, name, description)

Bases: object

A waypoint, a special landmark marked in the track.

description: str | None
elevation: float | None
latitude: float
longitude: float
name: str | None
fietsboek.geo.gpx_xml(title, description, date, points, waypoints)

Returns an XML representation of the given path.

Parameters:
  • title (str | None) – The title of the resulting track.

  • description (str | None) – The description of the resulting track.

  • points (list[Point]) – The points that make up this track.

  • waypoints (list[Waypoint]) – The waypoints that should be included.

Return type:

bytes

Returns:

The XML representation (a GPX file).