X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/2bd6c761b0e573189a03e8819c6db715eb711eb1..0278ab7f41bf9bc96a87084c04bfec263c6acc40:/nominatim/data/place_info.py diff --git a/nominatim/data/place_info.py b/nominatim/data/place_info.py index ab895352..91e77a58 100644 --- a/nominatim/data/place_info.py +++ b/nominatim/data/place_info.py @@ -8,7 +8,7 @@ Wrapper around place information the indexer gets from the database and hands to the tokenizer. """ -from typing import Optional, Mapping, Any +from typing import Optional, Mapping, Any, Tuple class PlaceInfo: """ This data class contains all information the tokenizer can access @@ -55,13 +55,22 @@ class PlaceInfo: @property def rank_address(self) -> int: - """ The [rank address][1] before ant rank correction is applied. + """ The [rank address][1] before any rank correction is applied. [1]: ../customize/Ranking.md#address-rank """ return self._info.get('rank_address', 0) + @property + def centroid(self) -> Optional[Tuple[float, float]]: + """ A center point of the place in WGS84. May be None when the + geometry of the place is unknown. + """ + x, y = self._info.get('centroid_x'), self._info.get('centroid_y') + return None if x is None or y is None else (x, y) + + def is_a(self, key: str, value: str) -> bool: """ Set to True when the place's primary tag corresponds to the given key and value.