]> git.openstreetmap.org Git - nominatim.git/blob - nominatim/indexer/place_info.py
fd179fef7c752fc4c53ee2d071f40fb32f9000fb
[nominatim.git] / nominatim / indexer / place_info.py
1 """
2 Wrapper around place information the indexer gets from the database and hands to
3 the tokenizer.
4 """
5
6 import psycopg2.extras
7
8 class PlaceInfo:
9     """ Data class containing all information the tokenizer gets about a
10         place it should process the names for.
11     """
12
13     def __init__(self, info):
14         self._info = info
15
16
17     def analyze(self, analyzer):
18         """ Process this place with the given tokenizer and return the
19             result in psycopg2-compatible Json.
20         """
21         return psycopg2.extras.Json(analyzer.process_place(self))
22
23
24     @property
25     def name(self):
26         """ A dictionary with the names of the place or None if the place
27             has no names.
28         """
29         return self._info.get('name')
30
31
32     @property
33     def address(self):
34         """ A dictionary with the address elements of the place
35             or None if no address information is available.
36         """
37         return self._info.get('address')
38
39
40     @property
41     def country_feature(self):
42         """ Return the country code if the place is a valid country boundary.
43         """
44         return self._info.get('country_feature')