]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Mon, 12 Oct 2020 14:18:45 +0000 (16:18 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Mon, 12 Oct 2020 14:18:45 +0000 (16:18 +0200)
sql/functions/placex_triggers.sql
sql/functions/utils.sql
test/bdd/api/search/queries.feature
test/bdd/steps/queries.py

index 9ef83b82d3ed9b9db332796a43dcab09c9186917..1f664a4a5531924a68e16709b8de4f33373af5c9 100644 (file)
@@ -211,7 +211,11 @@ BEGIN
     FOR linked_placex IN
       SELECT placex.* from placex
       WHERE make_standard_name(name->'name') = bnd_name
-        AND ((bnd.rank_address > 0 and placex.rank_address = bnd.rank_address)
+        AND ((bnd.rank_address > 0
+              and bnd.rank_address = (compute_place_rank(placex.country_code,
+                                                         'N', placex.class,
+                                                         placex.type, 15::SMALLINT,
+                                                         false, placex.postcode)).address_rank)
              OR (bnd.rank_address = 0 and placex.rank_search = bnd.rank_search))
         AND placex.osm_type = 'N'
         AND placex.rank_search < 26 -- needed to select the right index
@@ -624,6 +628,21 @@ BEGIN
         NEW.rank_address := parent_address_level + 2;
       END IF;
     END IF;
+  -- If a place node is contained in a admin boundary with the same address level
+  -- and has not been linked, then make the node a subpart by increasing the
+  -- address rank (city level and above).
+  ELSEIF NEW.class = 'place' and NEW.osm_type = 'N'
+     and NEW.rank_address between 16 and 23
+  THEN
+    FOR location IN
+        SELECT rank_address FROM placex
+        WHERE osm_type = 'R' and class = 'boundary' and type = 'administrative'
+              and rank_address = NEW.rank_address
+              and geometry && NEW.centroid and _ST_Covers(geometry, NEW.centroid)
+        LIMIT 1
+    LOOP
+      NEW.rank_address = NEW.rank_address + 2;
+    END LOOP;
   ELSE
     parent_address_level := 3;
   END IF;
index 9f8d39889e1412be3db33a721595c9ba721beda9..ae841bf25d23346b9780a3a12e4ee93526877f95 100644 (file)
@@ -277,7 +277,7 @@ CREATE OR REPLACE FUNCTION near_feature_rank_distance(rank_search INTEGER)
   AS $$
 BEGIN
   IF rank_search <= 16 THEN -- city
-    RETURN 7500;
+    RETURN 15000;
   ELSIF rank_search <= 18 THEN -- town
     RETURN 4000;
   ELSIF rank_search <= 19 THEN -- village
index e5040f1e247b79ab8bb2808df568ce9dea8436b7..fea4da41dd1d78d020fdcda48d3b1a89c1b437e6 100644 (file)
@@ -19,11 +19,10 @@ Feature: Search queries
         When sending json search query "Schellingstr 86, Hamburg" with address
           | accept-language |
           | de |
-        Then address of result 0 is
+        Then address of result 0 contains
           | type          | value |
           | house_number  | 86 |
           | road          | Schellingstraße |
-          | suburb        | Eilbek |
           | postcode      | 22089 |
           | city          | Hamburg |
           | country       | Deutschland |
@@ -33,11 +32,10 @@ Feature: Search queries
         When sending json search query "Schellingstr 73, Hamburg" with address
           | accept-language |
           | de |
-        Then address of result 0 is
+        Then address of result 0 contains
           | type          | value |
           | house_number  | 73 |
           | road          | Schellingstraße |
-          | suburb        | Eilbek |
           | postcode      | 22089 |
           | city          | Hamburg |
           | country       | Deutschland |
index d3b1203b47ae7a0c0cf1897b3bc7ec34c09988a6..d6473dfa2509118e0cbccad648aa22dbc10fab4a 100644 (file)
@@ -583,8 +583,8 @@ def check_address(context, lid, neg, attrs):
         else:
             assert_in(attr, addr_parts)
 
-@then(u'address of result (?P<lid>\d+) is')
-def check_address(context, lid):
+@then(u'address of result (?P<lid>\d+) (?P<complete>is|contains)')
+def check_address(context, lid, complete):
     context.execute_steps("then more than %s results are returned" % lid)
 
     addr_parts = dict(context.response.result[int(lid)]['address'])
@@ -595,7 +595,8 @@ def check_address(context, lid):
                      "Bad address value for %s" % line['type'])
         del addr_parts[line['type']]
 
-    eq_(0, len(addr_parts), "Additional address parts found: %s" % str(addr_parts))
+    if complete == 'is':
+        eq_(0, len(addr_parts), "Additional address parts found: %s" % str(addr_parts))
 
 @then(u'result (?P<lid>\d+ )?has bounding box in (?P<coords>[\d,.-]+)')
 def step_impl(context, lid, coords):