1 # SPDX-License-Identifier: GPL-3.0-or-later
3 # This file is part of Nominatim. (https://nominatim.org)
5 # Copyright (C) 2023 by the Nominatim developer community.
6 # For a full list of authors see the git log.
8 Complex datatypes used by the Nominatim API.
10 from typing import Optional, Union, NamedTuple
14 @dataclasses.dataclass
16 """ Reference an object by Nominatim's internal ID.
21 @dataclasses.dataclass
23 """ Reference by the OSM ID and potentially the basic category.
27 osm_class: Optional[str] = None
29 def __post_init__(self) -> None:
30 if self.osm_type not in ('N', 'W', 'R'):
31 raise ValueError(f"Illegal OSM type '{self.osm_type}'. Must be one of N, W, R.")
34 PlaceRef = Union[PlaceID, OsmID]
37 class Point(NamedTuple):
38 """ A geographic point in WGS84 projection.
45 def lat(self) -> float:
46 """ Return the latitude of the point.
52 def lon(self) -> float:
53 """ Return the longitude of the point.
58 class GeometryFormat(enum.Flag):
59 """ Geometry output formats supported by Nominatim.
68 @dataclasses.dataclass
70 """ Collection of parameters that define the amount of details
71 returned with a search result.
73 geometry_output: GeometryFormat = GeometryFormat.NONE
74 """ Add the full geometry of the place to the result. Multiple
75 formats may be selected. Note that geometries can become quite large.
77 address_details: bool = False
78 """ Get detailed information on the places that make up the address
81 linked_places: bool = False
82 """ Get detailed information on the places that link to the result.
84 parented_places: bool = False
85 """ Get detailed information on all places that this place is a parent
86 for, i.e. all places for which it provides the address details.
87 Only POI places can have parents.
89 keywords: bool = False
90 """ Add information about the search terms used for this place.