2 Feature: Address computation
 
   3     Tests for filling of place_addressline
 
   5     Scenario: place nodes are added to the address when they are close enough
 
   7             | 2 |  |  |  |  |  | 1 |  | 3 |
 
   9             | osm | class | type     | geometry |
 
  10             | N1  | place | square   | 1 |
 
  11             | N2  | place | hamlet   | 2 |
 
  12             | N3  | place | hamlet   | 3 |
 
  14         Then place_addressline contains
 
  15             | object | address | fromarea |
 
  17         Then place_addressline doesn't contain
 
  21     Scenario: given two place nodes, the closer one wins for the address
 
  25             | osm | class | type     | geometry |
 
  26             | N1  | place | square   | 1 |
 
  27             | N2  | place | hamlet   | 2 |
 
  28             | N3  | place | hamlet   | 3 |
 
  30         Then place_addressline contains
 
  31             | object | address | fromarea | isaddress |
 
  32             | N1     | N3      | False    | True |
 
  33             | N1     | N2      | False    | False |
 
  35     Scenario: boundaries around the place are added to the address
 
  37             | 1 |    | 4 | | 7 | 10 |
 
  38             | 2 |    | 5 | | 8 | 11 |
 
  45             | osm | class    | type           | admin | geometry |
 
  46             | R1  | boundary | administrative | 3     | (1,2,3,12,11,10,7,8,9,6,5,4,1) |
 
  47             | R2  | boundary | administrative | 4     | (2,3,12,11,8,9,6,5,2) |
 
  48             | N1  | place    | square         | 15    | 99 |
 
  50         Then place_addressline contains
 
  51             | object | address | isaddress |
 
  55     Scenario: with boundaries of same rank the one with the closer centroid is prefered
 
  61             | osm | class    | type           | admin | geometry |
 
  62             | R1  | boundary | administrative | 8     | (1,2,4,3,1) |
 
  63             | R2  | boundary | administrative | 8     | (1,2,6,5,1) |
 
  64             | N1  | place    | square         | 15    | 9 |
 
  66         Then place_addressline contains
 
  67             | object | address | isaddress |
 
  71     Scenario: boundary areas are preferred over place nodes in the address
 
  78             | osm | class    | type    | admin | geometry |
 
  79             | N1  | place    | square  | 15    | 5 |
 
  80             | N2  | place    | city    | 15    | 6 |
 
  81             | R1  | place    | city    | 8     | (1,2,4,3,1) |
 
  83         Then place_addressline contains
 
  84             | object | address | isaddress | cached_rank_address |
 
  85             | N1     | R1      | True      | 16                  |
 
  86             | N1     | N2      | False     | 16                  |
 
  88     Scenario: place nodes outside a smaller ranked area are ignored
 
  94             | osm | class    | type    | admin | geometry |
 
  95             | N1  | place    | square  | 15    | 7 |
 
  96             | N2  | place    | city    | 15    | 9 |
 
  97             | R1  | place    | city    | 8     | (1,2,3,4,1) |
 
  99         Then place_addressline contains
 
 100             | object | address | isaddress | cached_rank_address |
 
 101             | N1     | R1      | True      | 16                  |
 
 102         And place_addressline doesn't contain
 
 107     Scenario: place nodes close enough to smaller ranked place nodes are included
 
 111             | osm | class | type     | geometry |
 
 112             | N1  | place | square   | 1 |
 
 113             | N2  | place | hamlet   | 2 |
 
 114             | N3  | place | quarter  | 3 |
 
 116         Then place_addressline contains
 
 117             | object | address | fromarea | isaddress |
 
 118             | N1     | N2      | False    | True      |
 
 119             | N1     | N3      | False    | True      |
 
 122     Scenario: place nodes too far away from a smaller ranked place nodes are marked non-address
 
 126             | osm | class | type     | geometry |
 
 127             | N1  | place | square   | 1 |
 
 128             | N2  | place | hamlet   | 2 |
 
 129             | N3  | place | quarter  | 3 |
 
 131         Then place_addressline contains
 
 132             | object | address | fromarea | isaddress |
 
 133             | N1     | N2      | False    | True      |
 
 134             | N1     | N3      | False    | False     |
 
 138     Scenario: Roads crossing boundaries should contain both states
 
 144             | osm | class   | type | geometry |
 
 145             | W1  | highway | road | 7, 8     |
 
 147             | osm | class    | type           | admin | geometry      |
 
 148             | W10 | boundary | administrative | 5     | (1, 2, 5, 4, 1) |
 
 149             | W11 | boundary | administrative | 5     | (2, 3, 6, 5, 2) |
 
 151         Then place_addressline contains
 
 152             | object | address | cached_rank_address |
 
 157     Scenario: Roads following a boundary should contain both states
 
 163             | osm | class   | type | geometry |
 
 164             | W1  | highway | road | 2, 7, 8  |
 
 166             | osm | class    | type           | admin | geometry      |
 
 167             | W10 | boundary | administrative | 5     | (1, 2, 5, 4, 1) |
 
 168             | W11 | boundary | administrative | 5     | (2, 3, 6, 5, 2) |
 
 170         Then place_addressline contains
 
 171             | object | address | cached_rank_address |
 
 175     Scenario: Roads should not contain boundaries they touch in a end point
 
 181             | osm | class   | type | geometry |
 
 182             | W1  | highway | road | 7, 8     |
 
 184             | osm | class    | type           | admin | geometry      |
 
 185             | W10 | boundary | administrative | 5     | (1, 2, 8, 5, 4, 1) |
 
 186             | W11 | boundary | administrative | 5     | (2, 3, 6, 5, 8, 2) |
 
 188         Then place_addressline contains
 
 189             | object | address | cached_rank_address |
 
 191         Then place_addressline doesn't contain
 
 195     Scenario: Roads should not contain boundaries they touch in a middle point
 
 199             | 4 |   | 9 | 5 |   | 6 |
 
 201             | osm | class   | type | geometry |
 
 202             | W1  | highway | road | 7, 8, 9     |
 
 204             | osm | class    | type           | admin | geometry      |
 
 205             | W10 | boundary | administrative | 5     | (1, 2, 8, 5, 4, 1) |
 
 206             | W11 | boundary | administrative | 5     | (2, 3, 6, 5, 8, 2) |
 
 208         Then place_addressline contains
 
 209             | object | address | cached_rank_address |
 
 211         Then place_addressline doesn't contain
 
 215     Scenario: Locality points should contain all boundaries they touch
 
 221             | osm | class | type     | geometry |
 
 222             | N1  | place | locality | 8        |
 
 224             | osm | class    | type           | admin | geometry      |
 
 225             | W10 | boundary | administrative | 5     | (1, 2, 8, 5, 4, 1) |
 
 226             | W11 | boundary | administrative | 5     | (2, 3, 6, 5, 8, 2) |
 
 228         Then place_addressline contains
 
 229             | object | address | cached_rank_address |
 
 233     Scenario: Areas should not contain boundaries they touch
 
 239             | osm | class    | type           | geometry      |
 
 240             | W1  | landuse  | industrial     | (1, 2, 5, 4, 1) |
 
 242             | osm | class    | type           | admin | geometry      |
 
 243             | W10 | boundary | administrative | 5     | (2, 3, 6, 5, 2) |
 
 245         Then place_addressline doesn't contain
 
 249     Scenario: buildings with only addr:postcodes do not appear in the address of a way
 
 250         Given the scene admin-areas
 
 252             | osm | class    | type           | admin | addr+postcode | geometry |
 
 253             | R1  | boundary | administrative | 6     | 112           | :b0      |
 
 254             | R34 | boundary | administrative | 8     | 112 DE        | :b1:E    |
 
 255             | R4  | boundary | administrative | 10    | 112 DE 34     | :b2:N    |
 
 257             | osm | class    | type           | geometry |
 
 258             | W93 | highway  | residential    | :w2N     |
 
 260             | osm | class    | type        | addr+postcode | geometry |
 
 261             | W22 | place    | postcode    | 445023        | :building:w2N |
 
 263         Then place_addressline doesn't contain
 
 267     Scenario: postcode boundaries do appear in the address of a way
 
 268         Given the scene admin-areas
 
 270             | osm | class    | type           | admin | addr+postcode | geometry |
 
 271             | R1  | boundary | administrative | 6     | 112           | :b0      |
 
 272             | R34 | boundary | administrative | 8     | 112 DE        | :b1:E    |
 
 274             | osm | class    | type        | addr+postcode | geometry |
 
 275             | R4  | boundary | postal_code | 112 DE 34     | :b2:N    |
 
 277             | osm | class    | type           | geometry |
 
 278             | W93 | highway  | residential    | :w2N     |
 
 280             | osm | class    | type        | addr+postcode | geometry |
 
 281             | W22 | place    | postcode    | 445023        | :building:w2N |
 
 283         Then place_addressline contains
 
 287     Scenario: squares do not appear in the address of a street
 
 293             | osm | class    | type           | geometry |
 
 294             | W1  | highway  | residential    | 8, 9     |
 
 295             | W2  | place    | square         | (1, 2, 3 ,4, 1) |
 
 297         Then place_addressline doesn't contain