forked from edward/owl-map
Improve OSM name handling
This commit is contained in:
parent
906bdb7256
commit
e62dd4d1d6
|
@ -421,8 +421,8 @@ def find_osm_candidates(item, bounds):
|
|||
for osm, dist in get_nearby(bounds, item):
|
||||
tags = osm.tags
|
||||
tags.pop("way_area", None)
|
||||
name = osm.name or tags.get("addr:housename") or tags.get("inscription")
|
||||
if not name and "addr:housenumber" in tags and "addr:street" in tags:
|
||||
name = osm.display_name()
|
||||
if not name and osm.has_street_address:
|
||||
name = address_from_tags(tags)
|
||||
|
||||
if isinstance(osm, model.Polygon) and "building" in osm.tags:
|
||||
|
|
|
@ -232,6 +232,20 @@ class MapMixin:
|
|||
def as_EWKT(cls):
|
||||
return column_property(func.ST_AsEWKT(cls.way), deferred=True)
|
||||
|
||||
@hybrid_property
|
||||
def has_street_address(self):
|
||||
return ("addr:housenumber" in self.tags
|
||||
and "addr:street" in self.tags)
|
||||
|
||||
def display_name(self):
|
||||
for key in 'bridge:name', 'tunnel:name', 'lock_name':
|
||||
if key in self.tags:
|
||||
return self.tags[key]
|
||||
|
||||
return (self.name
|
||||
or self.tags.get("addr:housename")
|
||||
or self.tags.get("inscription"))
|
||||
|
||||
def geojson(self):
|
||||
return json.loads(self.geojson_str)
|
||||
|
||||
|
|
Loading…
Reference in a new issue