X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/afc429fd928be4be76a3d74179a431ce7a9a8b0d..d396505786ce3be105249c740e0d3365beb4ef10:/sql/functions.sql

diff --git a/sql/functions.sql b/sql/functions.sql
index 0a53fd64..25769785 100644
--- a/sql/functions.sql
+++ b/sql/functions.sql
@@ -769,6 +769,13 @@ BEGIN
           -- null record of right type
           select * from placex where osm_type = 'N' and osm_id = waynodes[nodeidpos]::INTEGER and type = 'house' limit 1 INTO nextnode;
           select ST_SetSRID(ST_Point(lon::float/10000000,lat::float/10000000),4326) from planet_osm_nodes where id = waynodes[nodeidpos] INTO nextnode.geometry;
+          IF nextnode.geometry IS NULL THEN
+            -- we don't have any information about this point, most likely
+            -- because an excerpt was updated and the node never imported
+            -- because the interpolation is outside the region of the excerpt.
+            -- Give up.
+            RETURN newpoints;
+          END IF;
         ELSE
           select * from placex where place_id = search_place_id INTO nextnode;
         END IF;
@@ -1629,7 +1636,7 @@ BEGIN
 -- RAISE WARNING 'ISIN: %', isin_tokens;
 
     -- Process area matches
-    location_rank_search := 100;
+    location_rank_search := 0;
     location_distance := 0;
     location_parent := NULL;
     -- RAISE WARNING '  getNearFeatures(%,''%'',%,''%'')',NEW.partition, place_centroid, search_maxrank, isin_tokens;
@@ -1637,9 +1644,9 @@ BEGIN
 
 --RAISE WARNING '  AREA: %',location;
 
-      IF location.rank_search < location_rank_search THEN
-        location_rank_search := location.rank_search;
-        location_distance := location.distance * 0.5;
+      IF location.rank_address != location_rank_search THEN
+        location_rank_search := location.rank_address;
+        location_distance := location.distance * 1.5;
       END IF;
 
       IF location.distance < location_distance OR NOT location.isguess THEN
@@ -1698,14 +1705,14 @@ BEGIN
     -- for long ways we should add search terms for the entire length
     IF st_length(NEW.geometry) > 0.05 THEN
 
-      location_rank_search := 100;
+      location_rank_search := 0;
       location_distance := 0;
 
       FOR location IN SELECT * from getNearFeatures(NEW.partition, NEW.geometry, search_maxrank, isin_tokens) LOOP
 
-        IF location.rank_search < location_rank_search THEN
-          location_rank_search := location.rank_search;
-          location_distance := location.distance * 0.5;
+        IF location.rank_address != location_rank_search THEN
+          location_rank_search := location.rank_address;
+          location_distance := location.distance * 1.5;
         END IF;
 
         IF location.distance < location_distance THEN
