]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Wed, 7 Jun 2017 18:44:46 +0000 (20:44 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Wed, 7 Jun 2017 18:44:46 +0000 (20:44 +0200)
data/words.sql
sql/functions.sql
test/bdd/api/reverse/simple.feature
test/bdd/db/query/normalization.feature
test/bdd/db/update/linked_places.feature
test/bdd/db/update/simple.feature
test/bdd/osm2pgsql/import/broken.feature
test/bdd/steps/db_ops.py

index 46f062843c0ffde41d77fd702663376dafa543b5..f927d0003ae8d8756de654d374353938ba8ebcfc 100644 (file)
@@ -29787,8 +29787,8 @@ st      5557484
 -- prefill word table
 
 select count(make_keywords(v)) from (select distinct svals(name) as v from place) as w where v is not null;
-select count(make_keywords(v)) from (select distinct postcode as v from place) as w where v is not null;
-select count(getorcreate_housenumber_id(make_standard_name(v))) from (select distinct housenumber as v from place where housenumber is not null) as w;
+select count(make_keywords(v)) from (select distinct address->'postcode' as v from place where address ? 'postcode') as w where v is not null;
+select count(getorcreate_housenumber_id(make_standard_name(v))) from (select distinct address->'housenumber' as v from place where address ? 'housenumber') as w;
 
 -- copy the word frequencies
 update word set search_name_count = count from word_frequencies wf where wf.word_token = word.word_token;
index 2606cdcabc2dcb45ffe189ed9fcff7f1b990fe28..d3207843906db0312640f2034a01bfba6fb3a9ed 100644 (file)
@@ -2144,6 +2144,12 @@ BEGIN
           NEW.name := hstore('ref', NEW.address->'postcode');
       END IF;
 
+      IF NEW.class in ('boundary')
+         AND ST_GeometryType(NEW.geometry) not in ('ST_Polygon','ST_MultiPolygon') THEN
+          DELETE FROM placex where place_id = existingplacex.place_id;
+          RETURN NULL;
+      END IF;
+
       update placex set 
         name = NEW.name,
         address = NEW.address,
@@ -2161,6 +2167,20 @@ BEGIN
           update location_property_osmline p set indexed_status = 2 from planet_osm_ways w where p.linegeo && NEW.geometry and p.osm_id = w.id and NEW.osm_id = any(w.nodes);
       END IF;
 
+      -- linked places should get potential new naming and addresses
+      IF existingplacex.linked_place_id is not NULL THEN
+        update placex x set
+          name = p.name,
+          extratags = p.extratags,
+          indexed_status = 2
+        from place p
+        where x.place_id = existingplacex.linked_place_id
+              and x.indexed_status = 0
+              and x.osm_type = p.osm_type
+              and x.osm_id = p.osm_id
+              and x.class = p.class;
+      END IF;
+
     END IF;
 
     -- Abort the add (we modified the existing place instead)
index 2b4847364592e35d845b064854b08ab67bdcc446..3f4bd6eb30f589c4dff6e1cf371c28844d2a953c 100644 (file)
@@ -67,7 +67,6 @@ Feature: Simple Reverse Tests
       | json |
       | jsonv2 |
 
-    @wip
     Scenario Outline: Boundingbox is returned
         When sending <format> reverse coordinates 14.62,108.1
           | zoom |
index 71c69dec4acd463751b6ea3e4b7d6b3632975e11..1ef1fcbe6b223aee279caba92b6cd79855fb05d1 100644 (file)
@@ -127,7 +127,6 @@ Feature: Import and search of names
          | ID | osm_type | osm_id |
          | 0  | R        | 2 |
 
-    @wip
     Scenario: Postcode boundaries without ref
         Given the places
           | osm | class    | type        | postcode | geometry |
index 17ca8003673c0daf432d96cf18f9d0458e2a6e17..6c31bd8920b45710dbab76099738e02b3651f13c 100644 (file)
@@ -89,3 +89,47 @@ Feature: Updates of linked places
          | osm_type |
          | R |
 
+    Scenario: Update linking relation when linkee name is updated
+        Given the places
+         | osm | class    | type           | name | admin | geometry |
+         | R1  | boundary | administrative | rel  | 8     | poly-area:0.1 |
+        And the places
+         | osm | class    | type        | name+name:de | admin | geometry |
+         | N3  | place    | city           | pnt  | 30    | 0.00001 0 |
+        And the relations
+         | id | members  |
+         | 1  | N3:label |
+        When importing
+        Then placex contains
+         | object | linked_place_id | name+name:de |
+         | R1     | -               | pnt  |
+         | N3     | R1              | pnt  |
+        When updating places
+         | osm | class    | type        | name+name:de | admin | geometry |
+         | N3  | place    | city        | newname  | 30    | 0.00001 0 |
+        Then placex contains
+         | object | linked_place_id | name+name:de |
+         | N3     | R1              | newname  |
+         | R1     | -               | newname  |
+
+    Scenario: Updating linkee extratags keeps linker's extratags
+        Given the named places
+         | osm | class    | type           | extra+wikidata | admin | geometry |
+         | R1  | boundary | administrative | 34             | 8     | poly-area:0.1 |
+        And the named places
+         | osm | class    | type           | geometry |
+         | N3  | place    | city           | 0.00001 0 |
+        And the relations
+         | id | members  |
+         | 1  | N3:label |
+        When importing
+        Then placex contains
+         | object | extratags |
+         | R1     | 'wikidata' : '34', 'place' : 'city' |
+        When updating places
+         | osm | class    | type        | name    | extra+oneway | admin | geometry |
+         | N3  | place    | city        | newname | yes          | 30    | 0.00001 0 |
+        Then placex contains
+         | object | extratags |
+         | R1     | 'wikidata' : '34', 'oneway' : 'yes', 'place' : 'city' |
+
index 0833c90c9248427beca621182980751579c058cd..ecbb1244c7caab45a1e90c25758062b4e065fa95 100644 (file)
@@ -69,3 +69,19 @@ Feature: Update of simple objects
         Then placex contains
           | object | class | type |
           | N3     | place | house |
+
+    Scenario: remove boundary when changing from polygon to way
+        Given the grid
+          | 1 | 2 |
+          | 3 | 4 |
+        And the places
+          | osm | class    | type           | name | admin | geometry        |
+          | W1  | boundary | administrative | Haha | 5     | (1, 2, 4, 3, 1) |
+        When importing
+        Then placex contains
+          | object |
+          | W1 |
+        When updating places
+          | osm | class    | type           | name | admin | geometry   |
+          | W1  | boundary | administrative | Haha | 5     | 1, 2, 4, 3 |
+        Then placex has no entry for W1
index aa8d8e35163c429b5932ac73c14babb4a90eb7b5..13b9a08851f06b085a307debdae67ee7ecb83038 100644 (file)
@@ -13,7 +13,6 @@ Feature: Import of objects with broken geometries by osm2pgsql
           | object | class   | type    | geometry |
           | W1     | highway | primary | 0 0, 0 0.1, 0.1 0.2 |
 
-    @wip
     Scenario: Import of ballon areas
         When loading osm data
           """
index 48abfd130f921d7977d862d90c522b9631ac2964..fa8cd0de3a2ddc51fab81d427ad411c45978f267 100644 (file)
@@ -348,7 +348,13 @@ def check_placex_contents(context, exact):
             if exact:
                 expected_content.add((res['osm_type'], res['osm_id'], res['class']))
             for h in row.headings:
-                if h.startswith('name'):
+                if h in ('extratags', 'address'):
+                    if row[h] == '-':
+                        assert_is_none(res[h])
+                    else:
+                        vdict = eval('{' + row[h] + '}')
+                        assert_equals(vdict, res[h])
+                elif h.startswith('name'):
                     name = h[5:] if h.startswith('name+') else 'name'
                     assert_in(name, res['name'])
                     eq_(res['name'][name], row[h])