fietsboek.osm module

OSM related utilities for fietsboek.

exception fietsboek.osm.ApiError

Bases: Exception

Base error class for errors occuring in OSM/Overpass accesses.

exception fietsboek.osm.ApiNotOk

Bases: ApiError

Server error response (non-200 status code).

exception fietsboek.osm.ApiTimeout

Bases: ApiError

API/Tile access timeout.

class fietsboek.osm.OverpassApi(interpreter_url)

Bases: object

Helper class to access the overpass API.

This does not really provide a nice interface to use, rather, it takes care of the low-level HTTP fuzz.

basic_auth(username, password)

Sets the HTTP basic auth for this API.

Parameters:
  • username (str) – The API username.

  • password (str) – The API password.

classmethod from_config(config)

Construct an OverpassApi from the given fietsboek config.

Parameters:

config (Config) – The config object.

Return type:

OverpassApi

Returns:

The API with correct URL/auth.

run_script(script)

Posts a overpass script to the API and returns the response.

Raises an error if the response is not 200.

Raises:
  • ApiTimeout – If the response takes too long.

  • ApiNotOk – If the response code is not 200.

Parameters:

script (str) – The overpass script.

Return type:

Response

Returns:

The response.

fietsboek.osm.find_name(api, path)

Attempt to find a name for the given path.

Parameters:
  • api (OverpassApi) – The overpass API to use.

  • path (Path) – Path to find a name for.

Return type:

str | None

Returns:

Name for the path.