translator_directory.utils

Functions

to_tuple(→ tuple[float, float])

found_route(→ bool)

out_of_tolerance(→ bool)

Checks if distances are off by +- a factor, but returns False if a

validate_geocode_result(→ RealCoordinates | None)

parse_directions_result(→ float)

same_coords(→ bool)

update_drive_distances(→ tuple[int, int, int, ...)

Handles updating Translator.driving_distance. Can be used in a cli or view.

geocode_translator_addresses(→ tuple[int, int, int, ...)

Module Contents

translator_directory.utils.to_tuple(coordinate: onegov.gis.models.coordinates.RealCoordinates) tuple[float, float][source]
translator_directory.utils.found_route(response: requests.Response) bool[source]
translator_directory.utils.out_of_tolerance(old_distance: float | None, new_distance: float | None, tolerance_factor: float, max_tolerance: float | None = None) bool[source]

Checks if distances are off by +- a factor, but returns False if a set max_tolerance is not exceeded.

translator_directory.utils.validate_geocode_result(response: requests.Response, zip_code: str | int | None, zoom: int | None = None, bbox: Collection[RealCoordinates] | None = None) RealCoordinates | None[source]
translator_directory.utils.parse_directions_result(response: requests.Response) float[source]
translator_directory.utils.same_coords(this: onegov.gis.Coordinates, other: onegov.gis.Coordinates) bool[source]
translator_directory.utils.update_drive_distances(request: onegov.translator_directory.request.TranslatorAppRequest, only_empty: bool, tolerance_factor: float = 0.1, max_tolerance: float | None = None, max_distance: float | None = None) tuple[int, int, int, list[onegov.translator_directory.models.translator.Translator], list[tuple[onegov.translator_directory.models.translator.Translator, float]]][source]

Handles updating Translator.driving_distance. Can be used in a cli or view.

translator_directory.utils.geocode_translator_addresses(request: onegov.translator_directory.request.TranslatorAppRequest, only_empty: bool, bbox: Collection[RealCoordinates] | None = None) tuple[int, int, int, int, list[onegov.translator_directory.models.translator.Translator]][source]