X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/c314a3092c5b51c7782015f6fa9ac093b46fa174..1f0796778754d8df0dfab9dd01302e26a397f064:/src/nominatim_db/data/place_info.py diff --git a/src/nominatim_db/data/place_info.py b/src/nominatim_db/data/place_info.py index 5b5ef57f..5fc6a48a 100644 --- a/src/nominatim_db/data/place_info.py +++ b/src/nominatim_db/data/place_info.py @@ -10,6 +10,7 @@ the tokenizer. """ from typing import Optional, Mapping, Any, Tuple + class PlaceInfo: """ This data class contains all information the tokenizer can access about a place. @@ -18,7 +19,6 @@ class PlaceInfo: def __init__(self, info: Mapping[str, Any]) -> None: self._info = info - @property def name(self) -> Optional[Mapping[str, str]]: """ A dictionary with the names of the place. Keys and values represent @@ -28,7 +28,6 @@ class PlaceInfo: """ return self._info.get('name') - @property def address(self) -> Optional[Mapping[str, str]]: """ A dictionary with the address elements of the place. They key @@ -43,7 +42,6 @@ class PlaceInfo: """ return self._info.get('address') - @property def country_code(self) -> Optional[str]: """ The country code of the country the place is in. Guaranteed @@ -52,7 +50,6 @@ class PlaceInfo: """ return self._info.get('country_code') - @property def rank_address(self) -> int: """ The [rank address][1] before any rank correction is applied. @@ -61,7 +58,6 @@ class PlaceInfo: """ 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 @@ -70,17 +66,15 @@ class PlaceInfo: 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. """ return self._info.get('class') == key and self._info.get('type') == value - def is_country(self) -> bool: """ Set to True when the place is a valid country boundary. """ return self.rank_address == 4 \ - and self.is_a('boundary', 'administrative') \ - and self.country_code is not None + and self.is_a('boundary', 'administrative') \ + and self.country_code is not None