1 # SPDX-License-Identifier: GPL-2.0-only
3 # This file is part of Nominatim. (https://nominatim.org)
5 # Copyright (C) 2022 by the Nominatim developer community.
6 # For a full list of authors see the git log.
8 Wrapper around place information the indexer gets from the database and hands to
13 """ Data class containing all information the tokenizer gets about a
14 place it should process the names for.
17 def __init__(self, info):
23 """ A dictionary with the names of the place or None if the place
26 return self._info.get('name')
31 """ A dictionary with the address elements of the place
32 or None if no address information is available.
34 return self._info.get('address')
38 def country_code(self):
39 """ The country code of the country the place is in. Guaranteed
40 to be a two-letter lower-case string or None, if no country
43 return self._info.get('country_code')
47 def rank_address(self):
48 """ The computed rank address before rank correction.
50 return self._info.get('rank_address')
53 def is_a(self, key, value):
54 """ Check if the place's primary tag corresponds to the given
57 return self._info.get('class') == key and self._info.get('type') == value
61 """ Check if the place is a valid country boundary.
63 return self.rank_address == 4 \
64 and self.is_a('boundary', 'administrative') \
65 and self.country_code is not None