Nominatim API
Apps
Configuration of Nominatim API app
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
- get_address(latitude: int, longitude: int) Location | None [source]
Get coordinates for given address
- get_bounding_box(administrative_division: str, name: str, aliases: dict | None = None) BoundingBox | None [source]
Get the bounding box for a given region
- Parameters:
- 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
- get_district_bounding_box(administrative_division: str, name: str) BoundingBox | None [source]
Get the bounding box for a given district
- Parameters:
- 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:
- 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
andquery_dict
are mutually exclusive.- Raises:
RuntimeError – When the
query_str
andquery_dict
parameters are passed at the same time- Parameters:
- 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
- __init__(latitude_min: float, latitude_max: float, longitude_min: float, longitude_max: float) None [source]
Initialize the bounding box
- 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