model.util.geometry

Attributes

cache_dir

cache_file

store

HTTP_TIMEOUT_SECONDS

Functions

get_altitude_openelevation(latlon)

Get altitude information for a given latitude and longitude from an OpenElevation server.

get_altitude_google(latlon)

Get altitude information for a given latitude and longitude from the Google Maps Elevation API.

get_altitude(latlon)

Get altitude information for a given latitude and longitude.

geometry_has_z()

Check whether the geometry types of Station, Route and AssocRouteStation have Z coordinates.

Module Contents

model.util.geometry.cache_dir
model.util.geometry.cache_file
model.util.geometry.store
model.util.geometry.HTTP_TIMEOUT_SECONDS = 10
model.util.geometry.get_altitude_openelevation(latlon)

Get altitude information for a given latitude and longitude from an OpenElevation server.

Requires the OPENELEVATION_URL environment variable to be set.

Parameters:

latlon (Tuple[float, float])

Return type:

float

model.util.geometry.get_altitude_google(latlon)

Get altitude information for a given latitude and longitude from the Google Maps Elevation API.

Requires the GOOGLE_MAPS_API_KEY environment variable to be set.

Parameters:

latlon (Tuple[float, float])

Return type:

float

model.util.geometry.get_altitude(latlon)

Get altitude information for a given latitude and longitude.

Tries OpenElevation first, then falls back to Google Maps. Results are cached on disk (rounded to 4 decimal places, ~11m resolution) via kv_cache. Set ELEVATION_DUMMY_MODE=True to return a constant dummy altitude.

Parameters:

latlon (Tuple[float, float])

Return type:

float

model.util.geometry.geometry_has_z()

Check whether the geometry types of Station, Route and AssocRouteStation have Z coordinates.

Returns:

True if they have Z coordinates, False otherwise

Return type:

bool