]> git.openstreetmap.org Git - nominatim.git/commitdiff
add simple tests for postcode import
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 6 Aug 2017 16:42:04 +0000 (18:42 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Sat, 19 Aug 2017 17:37:06 +0000 (19:37 +0200)
test/bdd/db/import/postcodes.feature [new file with mode: 0644]
test/bdd/steps/db_ops.py
test/scenes/data/building-on-street-corner.wkt
test/scenes/data/poly-area.wkt
test/scenes/data/way-area-with-center.wkt
utils/setup.php

diff --git a/test/bdd/db/import/postcodes.feature b/test/bdd/db/import/postcodes.feature
new file mode 100644 (file)
index 0000000..be469fe
--- /dev/null
@@ -0,0 +1,115 @@
+@DB
+Feature: Import of postcodes
+    Tests for postcode estimation
+
+    Scenario: Postcodes on the object are prefered over those on the address
+        Given the scene admin-areas
+        And the named places
+            | osm | class    | type           | admin | addr+postcode | geometry |
+            | R1  | boundary | administrative | 6     | 112           | :b0      |
+            | R34 | boundary | administrative | 8     | 112 DE        | :b1:E    |
+            | R4  | boundary | administrative | 10    | 112 DE 34     | :b2:N    |
+        And the named places
+            | osm | class    | type        | addr+postcode | geometry |
+            | W93 | highway  | residential | 112 DE 344    | :w2N     |
+            | W22 | building | yes         | 112 DE 344N   | :building:w2N |
+        When importing
+        Then placex contains
+            | object | postcode    |
+            | W22    | 112 DE 344N |
+            | W93    | 112 DE 344  |
+            | R4     | 112 DE 34   |
+            | R34    | 112 DE      |
+            | R1     | 112         |
+
+    Scenario: Postcodes from a road are inherited by an attached building
+        Given the scene admin-areas
+        And the named places
+            | osm | class    | type        | addr+postcode | geometry |
+            | W93 | highway  | residential | 86034         | :w2N     |
+        And the named places
+            | osm | class    | type  | geometry |
+            | W22 | building | yes   | :building:w2N |
+        When importing
+        Then placex contains
+            | object | postcode | parent_place_id |
+            | W22    | 86034    | W93 |
+
+    Scenario: Postcodes from the lowest admin area are inherited by ways
+        Given the scene admin-areas
+        And the named places
+            | osm | class    | type           | admin | addr+postcode | geometry |
+            | R1  | boundary | administrative | 6     | 112           | :b0      |
+            | R34 | boundary | administrative | 8     | 112 DE        | :b1:E    |
+            | R4  | boundary | administrative | 10    | 112 DE 34     | :b2:N    |
+        And the named places
+            | osm | class    | type           | geometry |
+            | W93 | highway  | residential    | :w2N     |
+        When importing
+        Then placex contains
+            | object | postcode  |
+            | W93    | 112 DE 34 |
+
+    Scenario: Postcodes from the lowest admin area with postcode are inherited by ways
+        Given the scene admin-areas
+        And the named places
+            | osm | class    | type           | admin | addr+postcode | geometry |
+            | R1  | boundary | administrative | 6     | 112           | :b0      |
+            | R34 | boundary | administrative | 8     | 112 DE        | :b1:E    |
+        And the named places
+            | osm | class    | type           | admin | geometry |
+            | R4  | boundary | administrative | 10    | :b2:N    |
+        And the named places
+            | osm | class    | type           | geometry |
+            | W93 | highway  | residential    | :w2N     |
+        When importing
+        Then placex contains
+            | object | postcode | parent_place_id |
+            | W93    | 112 DE   | R4 |
+
+    Scenario: Postcodes from the lowest admin area are inherited by buildings
+        Given the scene admin-areas
+        And the named places
+            | osm | class    | type           | admin | addr+postcode | geometry |
+            | R1  | boundary | administrative | 6     | 112           | :b0      |
+            | R34 | boundary | administrative | 8     | 112 DE        | :b1:E    |
+            | R4  | boundary | administrative | 10    | 112 DE 34     | :b2:N    |
+        And the named places
+            | osm | class    | type  | geometry |
+            | W22 | building | yes   | :building:w2N |
+        When importing
+        Then placex contains
+            | object | postcode  |
+            | W22    | 112 DE 34 |
+
+    Scenario: Roads get postcodes from nearby buildings without other info
+        Given the scene admin-areas
+        And the named places
+            | osm | class    | type           | geometry |
+            | W93 | highway  | residential    | :w2N     |
+        And the named places
+            | osm | class    | type        | addr+postcode | geometry |
+            | W22 | building | yes         | 445023        | :building:w2N |
+        When importing
+        Then placex contains
+            | object | postcode |
+            | W93    | 445023   |
+
+    @wip
+    Scenario: Postcodes from admin boundaries are preferred over estimated postcodes
+        Given the scene admin-areas
+        And the named places
+            | osm | class    | type           | admin | addr+postcode | geometry |
+            | R1  | boundary | administrative | 6     | 112           | :b0      |
+            | R34 | boundary | administrative | 8     | 112 DE        | :b1:E    |
+            | R4  | boundary | administrative | 10    | 112 DE 34     | :b2:N    |
+        And the named places
+            | osm | class    | type           | geometry |
+            | W93 | highway  | residential    | :w2N     |
+        And the named places
+            | osm | class    | type        | addr+postcode | geometry |
+            | W22 | building | yes         | 445023        | :building:w2N |
+        When importing
+        Then placex contains
+            | object | postcode  |
+            | W93    | 112 DE 34 |
index fa8cd0de3a2ddc51fab81d427ad411c45978f267..be2211fad9fb17c5ee65eba5ca3350106fd15c12 100644 (file)
@@ -287,7 +287,7 @@ def import_and_index_data_from_place_table(context):
               WHERE class='place' and type='houses' and osm_type='W'
                     and ST_GeometryType(geometry) = 'ST_LineString'""")
     context.db.commit()
-    context.nominatim.run_setup_script('index', 'index-noanalyse')
+    context.nominatim.run_setup_script('calculate-postcodes', 'index', 'index-noanalyse')
 
 @when("updating places")
 def update_place_table(context):
index 4c007e9ef7cf5e61ecccc07932e386b7f4273110..24da78f14435be5d6c495e3c339cc74f21b25ca1 100644 (file)
@@ -4,4 +4,4 @@ n-outer |  POINT(1.0039478 2.0004676)
 n-edge-WE |  POINT(1.0039599 2.0002345)
 w-WE |  LINESTRING(1.0031759 2.0002316,1.0040361 2.0002211,1.0042735 2.0002264)
 w-NS |  LINESTRING(1.0040414 2.0001051,1.0040361 2.0002211,1.0040364 2.0006377)
-w-building |  MULTIPOLYGON(((1.0040019 2.000324,1.0040016 2.0002344,1.0039599 2.0002345,1.0039037 2.0002347,1.0039043 2.0004389,1.0040023 2.0004386,1.0040019 2.000324)))
+w-building |  MULTIPOLYGON(((1.0039037 2.0002347,1.0039599 2.0002345,1.0040016 2.0002344,1.0040019 2.000324,1.0040023 2.0004386,1.0039043 2.0004389,1.0039037 2.0002347)))
index a8fb045dbb1db43740680ecbab60ddf89f8177f6..e65f2054e9fd8e7cb651fd19d93b46ed8f5786b1 100644 (file)
@@ -1,11 +1,11 @@
-0.0001 |  MULTIPOLYGON(((0.001 0,0 0,0 0.1,0.001 0.1,0.001 0)))
-0.0005 |  MULTIPOLYGON(((0.005 0,0 0,0 0.1,0.005 0.1,0.005 0)))
-0.001 |  MULTIPOLYGON(((0.01 0,0 0,0 0.1,0.01 0.1,0.01 0)))
-0.005 |  MULTIPOLYGON(((0.05 0,0 0,0 0.1,0.05 0.1,0.05 0)))
-0.01 |  MULTIPOLYGON(((0.1 0,0 0,0 0.1,0.1 0.1,0.1 0)))
-0.05 |  MULTIPOLYGON(((0.5 0,0 0,0 0.1,0.5 0.1,0.5 0)))
-0.1 |  MULTIPOLYGON(((0.1 0,0 0,0 1,0.1 1,0.1 0)))
-0.5 |  MULTIPOLYGON(((0.5 0,0 0,0 1,0.5 1,0.5 0)))
-1.0 |  MULTIPOLYGON(((1 0,0 0,0 1,1 1,1 0)))
-2.0 |  MULTIPOLYGON(((2 0,0 0,0 1,2 1,2 0)))
-5.0 |  MULTIPOLYGON(((5 0,0 0,0 1,5 1,5 0)))
+0.0001 |  MULTIPOLYGON(((0 0,0.001 0,0.001 0.1,0 0.1,0 0)))
+0.0005 |  MULTIPOLYGON(((0 0,0.005 0,0.005 0.1,0 0.1,0 0)))
+0.001 |  MULTIPOLYGON(((0 0,0.01 0,0.01 0.1,0 0.1,0 0)))
+0.005 |  MULTIPOLYGON(((0 0,0.05 0,0.05 0.1,0 0.1,0 0)))
+0.01 |  MULTIPOLYGON(((0 0,0.1 0,0.1 0.1,0 0.1,0 0)))
+0.05 |  MULTIPOLYGON(((0 0,0.5 0,0.5 0.1,0 0.1,0 0)))
+0.1 |  MULTIPOLYGON(((0 0,0.1 0,0.1 1,0 1,0 0)))
+0.5 |  MULTIPOLYGON(((0 0,0.5 0,0.5 1,0 1,0 0)))
+1.0 |  MULTIPOLYGON(((0 0,1 0,1 1,0 1,0 0)))
+2.0 |  MULTIPOLYGON(((0 0,2 0,2 1,0 1,0 0)))
+5.0 |  MULTIPOLYGON(((0 0,5 0,5 1,0 1,0 0)))
index 8a773633dcde98ce10fbfb62c5d8b8f1b6962723..ed34cd3bf6e054c1cdf41f199a5ae52de210fc43 100644 (file)
@@ -1,5 +1,5 @@
-inner-C |  POINT(0.0035625 -0.0066188)
-outer-C |  POINT(0.0041244 -0.0060007)
-inner-N |  POINT(0.0018846 -0.0023652)
 inner-S |  POINT(0.0048516 -0.0095176)
-area |  MULTIPOLYGON(((0.0077125 -0.0066566,0.0065469 -0.0099414,0.0038979 -0.0109481,0.0026794 -0.0105772,0.0022025 -0.0099944,0.0026264 -0.0091997,0.0026264 -0.0080341,0.0019376 -0.0065507,0.0010369 -0.0072924,0.0005071 -0.0060738,0.0017787 -0.00565,0.0005071 -0.0042195,0.0005601 -0.0025771,0.0013019 -0.0015175,0.0050105 -0.0021533,0.006441 -0.0025771,0.0075006 -0.0040076,0.0033681 -0.0059149,0.0051694 -0.0076633,0.0061231 -0.0064977,0.0068648 -0.0049612,0.0077125 -0.0066566)))
+inner-N |  POINT(0.0018846 -0.0023652)
+outer-C |  POINT(0.0041244 -0.0060007)
+inner-C |  POINT(0.0035625 -0.0066188)
+area |  MULTIPOLYGON(((0.0005071 -0.0060738,0.0010369 -0.0072924,0.0019376 -0.0065507,0.0026264 -0.0080341,0.0026264 -0.0091997,0.0022025 -0.0099944,0.0026794 -0.0105772,0.0038979 -0.0109481,0.0065469 -0.0099414,0.0077125 -0.0066566,0.0068648 -0.0049612,0.0061231 -0.0064977,0.0051694 -0.0076633,0.0033681 -0.0059149,0.0075006 -0.0040076,0.006441 -0.0025771,0.0050105 -0.0021533,0.0013019 -0.0015175,0.0005601 -0.0025771,0.0005071 -0.0042195,0.0017787 -0.00565,0.0005071 -0.0060738)))
index 5236a8270f02c32be7401b99d66efe38037c9dd7..67c7fd7f80b8be31139dca46684c29fdd34c7e87 100755 (executable)
@@ -541,7 +541,7 @@ if ($aCMDResult['calculate-postcodes'] || $aCMDResult['all']) {
         }
     }
     $sSQL = "SELECT count(getorcreate_postcode_id(v)) FROM ";
-    $sSQL .= "(SELECT distinct(postcode) FROM location_postcode) p";
+    $sSQL .= "(SELECT distinct(postcode) as v FROM location_postcode) p";
 
     if (!pg_query($oDB->connection, $sSQL)) {
         fail(pg_last_error($oDB->connection));