]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/indexer/place_info.py
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / nominatim / indexer / place_info.py
index fd179fef7c752fc4c53ee2d071f40fb32f9000fb..06d730e02a839c37c08a4eb73088a465d28cf76a 100644 (file)
@@ -38,7 +38,31 @@ class PlaceInfo:
 
 
     @property
-    def country_feature(self):
-        """ Return the country code if the place is a valid country boundary.
+    def country_code(self):
+        """ The country code of the country the place is in. Guaranteed
+            to be a two-letter lower-case string or None, if no country
+            could be found.
         """
-        return self._info.get('country_feature')
+        return self._info.get('country_code')
+
+
+    @property
+    def rank_address(self):
+        """ The computed rank address before rank correction.
+        """
+        return self._info.get('rank_address')
+
+
+    def is_a(self, key, value):
+        """ Check if 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):
+        """ Check if 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