2 Feature: Import into placex
 
   3     Tests that data in placex is completed correctly.
 
   5     Scenario: No country code tag is available
 
   7           | osm_id | class   | type     | name           | geometry
 
   8           | 1      | highway | primary  | 'name' : 'A1'  | country:us
 
  10         Then table placex contains
 
  11           | object | country_code | calculated_country_code |
 
  14     Scenario: Location overwrites country code tag
 
  15         Given the scene country
 
  17           | osm_id | class   | type     | name           | country_code | geometry
 
  18           | 1      | highway | primary  | 'name' : 'A1'  | de           | :us
 
  20         Then table placex contains
 
  21           | object | country_code | calculated_country_code |
 
  24     Scenario: Country code tag overwrites location for countries
 
  26           | osm_type | osm_id | class    | type            | admin_level | name            | country_code | geometry
 
  27           | R        | 1      | boundary | administrative  | 2           | 'name' : 'foo'  | de           | (-100 40, -101 40, -101 41, -100 41, -100 40)
 
  29         Then table placex contains
 
  30           | object | country_code | calculated_country_code |
 
  33     Scenario: Illegal country code tag for countries is ignored
 
  35           | osm_type | osm_id | class    | type            | admin_level | name            | country_code | geometry
 
  36           | R        | 1      | boundary | administrative  | 2           | 'name' : 'foo'  | xx          | (-100 40, -101 40, -101 41, -100 41, -100 40)
 
  38         Then table placex contains
 
  39           | object | country_code | calculated_country_code |
 
  42     Scenario: admin level is copied over
 
  44           | osm_id | class | type      | admin_level | name
 
  45           | 1      | place | state     | 3           | 'name' : 'foo'
 
  47         Then table placex contains
 
  48           | object | admin_level |
 
  51     Scenario: admin level is default 15
 
  53           | osm_id | class   | type      | name
 
  54           | 1      | amenity | prison    | 'name' : 'foo'
 
  56         Then table placex contains
 
  57           | object | admin_level |
 
  60     Scenario: admin level is never larger than 15
 
  62           | osm_id | class   | type      | name           | admin_level
 
  63           | 1      | amenity | prison    | 'name' : 'foo' | 16
 
  65         Then table placex contains
 
  66           | object | admin_level |
 
  70     Scenario: postcode node without postcode is dropped
 
  72           | osm_id | class   | type
 
  73           | 1      | place   | postcode
 
  75         Then table placex has no entry for N1
 
  77     Scenario: postcode boundary without postcode is dropped
 
  79           | osm_type | osm_id | class    | type        | geometry
 
  80           | R        | 1      | boundary | postal_code | poly-area:0.1
 
  82         Then table placex has no entry for R1
 
  84     Scenario: search and address ranks for GB post codes correctly assigned
 
  86          | osm_id  | class | type     | postcode | geometry
 
  87          | 1       | place | postcode | E45 2CD  | country:gb
 
  88          | 2       | place | postcode | E45 2    | country:gb
 
  89          | 3       | place | postcode | Y45      | country:gb
 
  91         Then table placex contains
 
  92          | object | postcode | calculated_country_code | rank_search | rank_address
 
  93          | N1     | E45 2CD  | gb                      | 25          | 5
 
  94          | N2     | E45 2    | gb                      | 23          | 5
 
  95          | N3     | Y45      | gb                      | 21          | 5
 
  97     Scenario: wrongly formatted GB postcodes are down-ranked
 
  99          | osm_id  | class | type     | postcode | geometry
 
 100          | 1       | place | postcode | EA452CD  | country:gb
 
 101          | 2       | place | postcode | E45 23   | country:gb
 
 102          | 3       | place | postcode | y45      | country:gb
 
 104         Then table placex contains
 
 105          | object | calculated_country_code | rank_search | rank_address
 
 110     Scenario: search and address rank for DE postcodes correctly assigned
 
 111         Given the place nodes
 
 112          | osm_id  | class | type     | postcode | geometry
 
 113          | 1       | place | postcode | 56427    | country:de
 
 114          | 2       | place | postcode | 5642     | country:de
 
 115          | 3       | place | postcode | 5642A    | country:de
 
 116          | 4       | place | postcode | 564276   | country:de
 
 118         Then table placex contains
 
 119          | object | calculated_country_code | rank_search | rank_address
 
 125     Scenario: search and address rank for other postcodes are correctly assigned
 
 126         Given the place nodes
 
 127          | osm_id  | class | type     | postcode | geometry
 
 128          | 1       | place | postcode | 1        | country:ca
 
 129          | 2       | place | postcode | X3       | country:ca
 
 130          | 3       | place | postcode | 543      | country:ca
 
 131          | 4       | place | postcode | 54dc     | country:ca
 
 132          | 5       | place | postcode | 12345    | country:ca
 
 133          | 6       | place | postcode | 55TT667  | country:ca
 
 134          | 7       | place | postcode | 123-65   | country:ca
 
 135          | 8       | place | postcode | 12 445 4 | country:ca
 
 136          | 9       | place | postcode | A1:bc10  | country:ca
 
 138         Then table placex contains
 
 139          | object | calculated_country_code | rank_search | rank_address
 
 151     Scenario: search and address ranks for places are correctly assigned
 
 152         Given the named place nodes
 
 153           | osm_id | class     | type      | 
 
 155           | 11     | place     | Continent |
 
 156           | 12     | place     | continent |
 
 158           | 14     | place     | country   |
 
 159           | 15     | place     | state     |
 
 160           | 16     | place     | region    |
 
 161           | 17     | place     | county    |
 
 162           | 18     | place     | city      |
 
 163           | 19     | place     | island    |
 
 164           | 20     | place     | town      |
 
 165           | 21     | place     | village   |
 
 166           | 22     | place     | hamlet    |
 
 167           | 23     | place     | municipality |
 
 168           | 24     | place     | district     |
 
 169           | 25     | place     | unincorporated_area |
 
 170           | 26     | place     | borough             |
 
 171           | 27     | place     | suburb              |
 
 172           | 28     | place     | croft               |
 
 173           | 29     | place     | subdivision         |
 
 174           | 30     | place     | isolated_dwelling   |
 
 175           | 31     | place     | farm                |
 
 176           | 32     | place     | locality            |
 
 177           | 33     | place     | islet               |
 
 178           | 34     | place     | mountain_pass       |
 
 179           | 35     | place     | neighbourhood       |
 
 180           | 36     | place     | house               |
 
 181           | 37     | place     | building            |
 
 182           | 38     | place     | houses              |
 
 183         And the named place nodes
 
 184           | osm_id | class     | type      | extratags
 
 185           | 100    | place     | locality  | 'locality' : 'townland'
 
 186           | 101    | place     | city      | 'capital' : 'yes'
 
 188         Then table placex contains
 
 189           | object | rank_search | rank_address |
 
 222     Scenario: search and address ranks for boundaries are correctly assigned
 
 223         Given the named place nodes
 
 224           | osm_id | class    | type
 
 225           | 1      | boundary | administrative
 
 226         And the named place ways
 
 227           | osm_id | class    | type           | geometry
 
 228           | 10     | boundary | administrative | 10 10, 11 11
 
 229         And the named place areas
 
 230           | osm_type | osm_id | class    | type           | admin_level | geometry
 
 231           | R        | 20     | boundary | administrative | 2           | (1 1, 2 2, 1 2, 1 1)
 
 232           | R        | 21     | boundary | administrative | 32          | (3 3, 4 4, 3 4, 3 3)
 
 233           | R        | 22     | boundary | nature_park    | 6           | (0 0, 1 0, 0 1, 0 0)
 
 234           | R        | 23     | boundary | natural_reserve| 10          | (0 0, 1 1, 1 0, 0 0)
 
 236         Then table placex has no entry for N1
 
 237         And table placex has no entry for W10
 
 238         And table placex contains
 
 239           | object | rank_search | rank_address
 
 245     Scenario: search and address ranks for highways correctly assigned
 
 246         Given the scene roads-with-pois
 
 248           | osm_id | class    | type 
 
 249           | 1      | highway  | bus_stop
 
 251           | osm_id | class    | type         | geometry
 
 252           | 1      | highway  | primary      | :w-south
 
 253           | 2      | highway  | secondary    | :w-south
 
 254           | 3      | highway  | tertiary     | :w-south
 
 255           | 4      | highway  | residential  | :w-north
 
 256           | 5      | highway  | unclassified | :w-north
 
 257           | 6      | highway  | something    | :w-north
 
 259         Then table placex contains
 
 260           | object | rank_search | rank_address
 
 269     Scenario: rank and inclusion of landuses
 
 270         And the named place nodes
 
 271           | osm_id | class   | type
 
 272           | 2      | landuse | residential
 
 273         And the named place ways
 
 274           | osm_id | class   | type        | geometry
 
 275           | 2      | landuse | residential | 1 1, 1 1.1
 
 276         And the named place areas
 
 277           | osm_type | osm_id | class   | type        | geometry
 
 278           | W        | 4      | landuse | residential | poly-area:0.1
 
 279           | R        | 2      | landuse | residential | poly-area:0.05
 
 280           | R        | 3      | landuse | forrest     | poly-area:0.5
 
 282         And table placex contains
 
 283           | object | rank_search | rank_address
 
 290     Scenario: rank and inclusion of naturals
 
 291        And the named place nodes
 
 292           | osm_id | class   | type
 
 294           | 4      | natural | volcano
 
 295           | 5      | natural | foobar
 
 296        And the named place ways
 
 297           | osm_id | class   | type           | geometry
 
 298           | 2      | natural | mountain_range | 12 12,11 11
 
 299           | 3      | natural | foobar         | 13 13,13.1 13
 
 300        And the named place areas
 
 301           | osm_type | osm_id | class   | type           | geometry
 
 302           | R        | 3      | natural | volcano        | poly-area:0.1
 
 303           | R        | 4      | natural | foobar         | poly-area:0.5
 
 304           | R        | 5      | natural | sea            | poly-area:5.0
 
 305           | R        | 6      | natural | sea            | poly-area:0.01
 
 307        And table placex contains
 
 308           | object | rank_search | rank_address