X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/1f0796778754d8df0dfab9dd01302e26a397f064..7d418da564484c3f2fffcd4801188d6ffc4f436a:/src/nominatim_api/types.py diff --git a/src/nominatim_api/types.py b/src/nominatim_api/types.py index 5f3309d9..66a3c553 100644 --- a/src/nominatim_api/types.py +++ b/src/nominatim_api/types.py @@ -61,6 +61,17 @@ class OsmID: if self.osm_type not in ('N', 'W', 'R'): raise ValueError(f"Illegal OSM type '{self.osm_type}'. Must be one of N, W, R.") + def class_as_housenumber(self) -> Optional[int]: + """ Interpret the class property as a housenumber and return it. + + If the OSM ID points to an interpolation, then the class may be + a number pointing to the exact number requested. This function + returns the housenumber as an int, if class is set and is a number. + """ + if self.osm_class and self.osm_class.isdigit(): + return int(self.osm_class) + return None + PlaceRef = Union[PlaceID, OsmID]