]> git.openstreetmap.org Git - nominatim.git/blobdiff - sql/functions.sql
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / sql / functions.sql
index 775ff168eb27bced4149be6c8152442f9e3009f1..976c73f22bdc912851a435cbeb3c8e188b2f6e64 100644 (file)
@@ -1427,6 +1427,16 @@ BEGIN
       -- Note that addr:street links can only be indexed once the street itself is indexed
       IF NEW.parent_place_id IS NULL AND NEW.osm_type = 'N' THEN
 
+        -- if there is no address information, see if we can get it from a surrounding building
+        IF NEW.street IS NULL AND NEW.addr_place IS NULL AND NEW.housenumber IS NULL THEN
+          FOR location IN select * from placex where ST_Covers(geometry, place_centroid) and rank_search > 28 and (housenumber is not null or street is not null or addr_place is not null) AND ST_GeometryType(geometry) in ('ST_Polygon','ST_MultiPolygon')
+          LOOP
+            NEW.housenumber := location.housenumber;
+            NEW.street := location.street;
+            NEW.addr_place := location.addr_place;
+          END LOOP;
+        END IF;
+
         -- Is this node part of a relation?
         FOR relation IN select * from planet_osm_rels where parts @> ARRAY[NEW.osm_id] and members @> ARRAY['n'||NEW.osm_id]
         LOOP
@@ -1534,7 +1544,7 @@ BEGIN
       END IF;
 
       IF NEW.parent_place_id IS NULL AND NEW.addr_place IS NOT NULL THEN
-        address_street_word_ids := get_name_id(make_standard_name(NEW.addr_place));
+        address_street_word_ids := get_name_ids(make_standard_name(NEW.addr_place));
         IF address_street_word_ids IS NOT NULL THEN
           FOR location IN SELECT * from getNearestNamedPlaceFeature(NEW.partition, place_centroid, address_street_word_ids) LOOP
             NEW.parent_place_id := location.place_id;