Nominatim API

Apps

Configuration of Nominatim API app

class integreat_cms.nominatim_api.apps.NominatimApiConfig(app_name, app_module)[source]

Bases: AppConfig

Nominatim API config inheriting the Django AppConfig

name: Final[str] = 'integreat_cms.nominatim_api'[source]

Full Python path to the application

ready() None[source]

Checking if API is available

Return type:

None

verbose_name: Final[Promise] = 'Nominatim API'[source]

Human-readable name for the application

Nominatim API Client

class integreat_cms.nominatim_api.nominatim_api_client.NominatimApiClient[source]

Bases: object

Client to interact with the Nominatim API. For documentation about the underlying library, see GeoPy.

__init__() None[source]

Initialize the Nominatim client

Raises:

ImproperlyConfigured – When the Nominatim API is disabled

Return type:

None

check_availability() None[source]

Check if Nominatim API is available

Return type:

None

get_address(latitude: int, longitude: int) Location | None[source]

Get coordinates for given address

Parameters:
  • latitude (int) – The requested latitude

  • longitude (int) – The requested longitude

Returns:

The address at these coordinates

Return type:

Location | None

get_bounding_box(administrative_division: str, name: str, aliases: dict | None = None) BoundingBox | None[source]

Get the bounding box for a given region

Parameters:
  • administrative_division (str) – The administrative division of the requested region

  • name (str) – The name of the requested region

  • aliases (dict | None) – A dictionary of region aliases

Returns:

The bounding box

Return type:

BoundingBox | None

get_city_and_district_bounding_box(name: str) BoundingBox | None[source]

Get the bounding box for a given city and district

Parameters:

name (str) – The name of the requested region

Returns:

The bounding box

Return type:

BoundingBox | None

get_city_bounding_box(name: str) BoundingBox | None[source]

Get the bounding box for a given city

Parameters:

name (str) – The name of the requested region

Returns:

The bounding box

Return type:

BoundingBox | None

get_coordinates(street: str, postalcode: str, city: str) tuple[int, int] | tuple[None, None][source]

Get coordinates for given address

Parameters:
  • street (str) – The requested street

  • postalcode (str) – The requested postal code

  • city (str) – The requested city

Returns:

The coordinates of the requested address

Return type:

tuple[int, int] | tuple[None, None]

get_district_bounding_box(administrative_division: str, name: str) BoundingBox | None[source]

Get the bounding box for a given district

Parameters:
  • administrative_division (str) – The administrative division of the requested region

  • name (str) – The name of the requested region

Returns:

The bounding box

Return type:

BoundingBox | None

get_region_bounding_box(name: str, aliases: dict[str, str] | None = None) BoundingBox | None[source]

Get the bounding box for a given region and all its aliases

Parameters:
  • name (str) – The name of the requested region

  • aliases (dict[str, str] | None) – A dictionary of region aliases

Returns:

The bounding box

Return type:

BoundingBox | None

search(query_str: Any | None = None, exactly_one: bool = True, addressdetails: bool = False, **query_dict: Any) Location | None[source]

Search for a given query, either by string or by dict. query_str and query_dict are mutually exclusive.

Raises:

RuntimeError – When the query_str and query_dict parameters are passed at the same time

Parameters:
  • query_str (Any | None) – The query string

  • exactly_one (bool) – Whether only one result should be returned

  • addressdetails (bool) – Whether address details should be returned

  • **query_dict (Any) – The query as dictionary

Returns:

The location that matches the given criteria

Return type:

Location | None

Utils

Utilities for the Nominatim API app

class integreat_cms.nominatim_api.utils.BoundingBox(latitude_min: float, latitude_max: float, longitude_min: float, longitude_max: float)[source]

Bases: object

Class for bounding boxes

Parameters:
  • latitude_min (float) –

  • latitude_max (float) –

  • longitude_min (float) –

  • longitude_max (float) –

__init__(latitude_min: float, latitude_max: float, longitude_min: float, longitude_max: float) None[source]

Initialize the bounding box

Parameters:
  • latitude_min (float) – The bottom boundary of the box

  • latitude_max (float) – The top boundary of the box

  • longitude_min (float) – The left boundary of the box

  • longitude_max (float) – The right boundary of the box

Return type:

None

property api_representation: list[list[float]][source]

The bounding box in the format:

[
    [
        longitude_min,
        latitude_min
    ],
    [
        longitude_max,
        latitude_max
    ]
]
Returns:

A nested list of the borders of the box

classmethod from_result(result: Location | None) BoundingBox | None[source]

Return a bounding box object from a Nominatim API result

Parameters:

result (Location | None) – The Nominatim API result

Returns:

A bounding box

Return type:

BoundingBox | None

classmethod merge(*bounding_boxes: BoundingBox | None) BoundingBox | None[source]

Merge the given bounding boxes

Parameters:

*bounding_boxes (BoundingBox | None) – The bounding boxes that should be merged

Returns:

A bounding box that contains all of the given boxes

Return type:

BoundingBox | None