]> git.openstreetmap.org Git - nominatim.git/commitdiff
don't delete names on unknown country boundaries
authorSarah Hoffmann <lonvia@denofr.de>
Sat, 18 Feb 2017 12:51:21 +0000 (13:51 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Sat, 18 Feb 2017 12:51:21 +0000 (13:51 +0100)
If a country boundary has a country_code that is unknown to
Nominatim, it would delete all names because the coalascing
with country_name would not yield any result.

sql/functions.sql
test/bdd/osm2pgsql/update/relation.feature

index 949e4cae515ceccb006fe6a74ab24fb8790d3c35..f9a89b51f26f134d90aefbcdd402cb904de57bd6 100644 (file)
@@ -1988,7 +1988,10 @@ BEGIN
 
     -- Patch in additional country names
     IF NEW.admin_level = 2 AND NEW.type = 'administrative' AND NEW.country_code is not null THEN
-      select coalesce(country_name.name || NEW.name,NEW.name) from country_name where country_name.country_code = lower(NEW.country_code) INTO NEW.name;
+        SELECT name FROM country_name WHERE country_code = lower(NEW.country_code) INTO existing;
+        IF existing.name IS NOT NULL THEN
+            NEW.name = existing.name || NEW.name;
+        END IF;
     END IF;
       
     -- Have we already done this place?
index 88889f9a3970779214bb1b6417ff4f51833bc289..0eccd3e6fc83f16ca28c878a98b95a68aa7433d6 100644 (file)
@@ -104,7 +104,6 @@ Feature: Update of relations by osm2pgsql
           """
         Then place has no entry for R1
 
-    @wip
     Scenario: Type tag is renamed to something unknown
         When loading osm data
           """
@@ -124,3 +123,37 @@ Feature: Update of relations by osm2pgsql
           """
         Then place has no entry for R1
 
+    Scenario: Country boundary names are left untouched when country_code unknown
+        When loading osm data
+          """
+          n200 Tamenity=prison x0 y0
+          n201 x0 y0.0001
+          n202 x0.0001 y0.0001
+          n203 x0.0001 y0
+          """
+        And updating osm data
+          """
+          w1 Nn200,n201,n202,n203,n200
+          r1 Ttype=boundary,boundary=administrative,name=Foo,country_code=XX,admin_level=2 Mw1@
+          """
+        Then place contains
+          | object | country_code | name           |
+          | R1     | XX           | 'name' : 'Foo' |
+
+    Scenario: Country boundary names are extended when country_code known
+        When loading osm data
+          """
+          n200 Tamenity=prison x0 y0
+          n201 x0 y0.0001
+          n202 x0.0001 y0.0001
+          n203 x0.0001 y0
+          """
+        And updating osm data
+          """
+          w1 Nn200,n201,n202,n203,n200
+          r1 Ttype=boundary,boundary=administrative,name=Foo,country_code=ch,admin_level=2 Mw1@
+          """
+        Then place contains
+            | object | country_code | name+name:de | name+name |
+            | R1     | ch           | Schweiz      | Foo       |
+