From: Sarah Hoffmann Date: Thu, 15 Dec 2022 14:48:04 +0000 (+0100) Subject: flex: simplify name handling X-Git-Tag: v4.3.0~121^2~12 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/d9d13a6204c58613d0bf39ed183aa8a02e6d6522 flex: simplify name handling --- diff --git a/settings/flex-base.lua b/settings/flex-base.lua index a4c1d561..9663f960 100644 --- a/settings/flex-base.lua +++ b/settings/flex-base.lua @@ -156,6 +156,28 @@ function Place:grab_name(data) return count end +function Place:grab_name_parts(data) + local fallback = nil + + if data.groups ~= nil then + for k, v in pairs(self.object.tags) do + local atype = data.groups(k, v) + + if atype ~= nil then + self.names[k] = v + if atype == 'main' then + self.has_name = true + elseif atype == 'house' then + self.has_name = true + fallback = {'place', 'house', 'always'} + end + end + end + end + + return fallback +end + function Place:grab_tag(key) return self.object:grab_tag(key) end @@ -401,8 +423,6 @@ function osm2pgsql.process_relation(object) end function process_tags(o) - local fallback - o:delete{match = PRE_DELETE} o:grab_extratags{match = PRE_EXTRAS} @@ -413,10 +433,10 @@ function process_tags(o) end} end + -- name keys + local fallback = o:grab_name_parts{groups=NAMES} + -- address keys - if o:grab_name{match=HOUSENAME_TAGS} > 0 then - fallback = {'place', 'house', 'always'} - end if o:grab_address_parts{groups=ADDRESS_TAGS} > 0 and fallback == nil then fallback = {'place', 'house', 'always'} end @@ -432,10 +452,6 @@ function process_tags(o) return end - -- name keys - o:grab_name{match = NAMES} - o:grab_name{match = REFS, include_on_name = false} - o:delete{match = POST_DELETE} o:grab_extratags{match = POST_EXTRAS} diff --git a/settings/import-extratags.lua b/settings/import-extratags.lua index 62f14edf..67a7f5e7 100644 --- a/settings/import-extratags.lua +++ b/settings/import-extratags.lua @@ -91,8 +91,7 @@ PRE_EXTRAS = tag_match{keys = {'*:prefix', '*:suffix', 'name:prefix:*', 'name:su 'addr:street:name', 'addr:street:type'} } - -NAMES = tag_match{keys = {'name', 'name:*', +NAMES = key_group{main = {'name', 'name:*', 'int_name', 'int_name:*', 'nat_name', 'nat_name:*', 'reg_name', 'reg_name:*', @@ -101,12 +100,12 @@ NAMES = tag_match{keys = {'name', 'name:*', 'alt_name', 'alt_name:*', 'alt_name_*', 'official_name', 'official_name:*', 'place_name', 'place_name:*', - 'short_name', 'short_name:*', 'brand'}} - -REFS = tag_match{keys = {'ref', 'int_ref', 'nat_ref', 'reg_ref', 'loc_ref', 'old_ref', - 'iata', 'icao', 'pcode', 'pcode:*', 'ISO3166-2'}} - -HOUSENAME_TAGS = tag_match{keys = {'addr:housename'}} + 'short_name', 'short_name:*', 'brand'}, + extra = {'ref', 'int_ref', 'nat_ref', 'reg_ref', + 'loc_ref', 'old_ref', + 'iata', 'icao', 'pcode', 'pcode:*', 'ISO3166-2'}, + house = {'addr:housename'} + } ADDRESS_TAGS = key_group{main = {'addr:housenumber', 'addr:conscriptionnumber',