Skip to content

Commit 01f0f45

Browse files
committed
drop interpolations when no parent can be found
A housenumber without the place it refers to is of only limited use.
1 parent 7f0d969 commit 01f0f45

File tree

4 files changed

+110
-6
lines changed

4 files changed

+110
-6
lines changed

lib-sql/functions/interpolation.sql

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ BEGIN
6767
END LOOP;
6868
END IF;
6969

70-
IF parent_place_id is null THEN
71-
RETURN 0;
72-
END IF;
73-
7470
RETURN parent_place_id;
7571
END;
7672
$$
@@ -183,6 +179,13 @@ BEGIN
183179
ST_PointOnSurface(NEW.linegeo),
184180
NEW.linegeo);
185181

182+
-- Cannot find a parent street. We will not be able to display a reliable
183+
-- address, so drop entire interpolation.
184+
IF NEW.parent_place_id is NULL THEN
185+
DELETE FROM location_property_osmline where place_id = OLD.place_id;
186+
RETURN NULL;
187+
END IF;
188+
186189
NEW.token_info := token_strip_info(NEW.token_info);
187190
IF NEW.address ? '_inherited' THEN
188191
NEW.address := hstore('interpolation', NEW.address->'interpolation');

test/bdd/db/import/interpolation.feature

Lines changed: 95 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,36 @@
22
Feature: Import of address interpolations
33
Tests that interpolated addresses are added correctly
44

5+
Scenario: Simple even interpolation line with two points and no street nearby
6+
Given the grid with origin 1,1
7+
| 1 | | 9 | | 2 |
8+
Given the places
9+
| osm | class | type | housenr |
10+
| N1 | place | house | 2 |
11+
| N2 | place | house | 6 |
12+
And the places
13+
| osm | class | type | addr+interpolation | geometry |
14+
| W1 | place | houses | even | 1,2 |
15+
And the ways
16+
| id | nodes |
17+
| 1 | 1,2 |
18+
When importing
19+
Then W1 expands to no interpolation
20+
521
Scenario: Simple even interpolation line with two points
622
Given the grid with origin 1,1
723
| 1 | | 9 | | 2 |
24+
| 4 | | | | 5 |
825
Given the places
926
| osm | class | type | housenr |
1027
| N1 | place | house | 2 |
1128
| N2 | place | house | 6 |
1229
And the places
1330
| osm | class | type | addr+interpolation | geometry |
1431
| W1 | place | houses | even | 1,2 |
32+
And the named places
33+
| osm | class | type | geometry |
34+
| W10 | highway | residential | 4,5 |
1535
And the ways
1636
| id | nodes |
1737
| 1 | 1,2 |
@@ -23,13 +43,17 @@ Feature: Import of address interpolations
2343
Scenario: Backwards even two point interpolation line
2444
Given the grid with origin 1,1
2545
| 1 | 8 | 9 | 2 |
46+
| 4 | | | 5 |
2647
Given the places
2748
| osm | class | type | housenr |
2849
| N1 | place | house | 2 |
2950
| N2 | place | house | 8 |
3051
And the places
3152
| osm | class | type | addr+interpolation | geometry |
3253
| W1 | place | houses | even | 2,1 |
54+
And the named places
55+
| osm | class | type | geometry |
56+
| W10 | highway | residential | 4,5 |
3357
And the ways
3458
| id | nodes |
3559
| 1 | 2,1 |
@@ -41,13 +65,17 @@ Feature: Import of address interpolations
4165
Scenario: Simple odd two point interpolation
4266
Given the grid with origin 1,1
4367
| 1 | 8 | | | 9 | 2 |
68+
| 4 | | | | 5 | |
4469
Given the places
4570
| osm | class | type | housenr |
4671
| N1 | place | house | 1 |
4772
| N2 | place | house | 11 |
4873
And the places
4974
| osm | class | type | addr+interpolation | geometry |
5075
| W1 | place | houses | odd | 1,2 |
76+
And the named places
77+
| osm | class | type | geometry |
78+
| W10 | highway | residential | 4,5 |
5179
And the ways
5280
| id | nodes |
5381
| 1 | 1,2 |
@@ -59,13 +87,17 @@ Feature: Import of address interpolations
5987
Scenario: Simple all two point interpolation
6088
Given the grid with origin 1,1
6189
| 1 | 8 | 9 | 2 |
90+
| 4 | | | 5 |
6291
Given the places
6392
| osm | class | type | housenr |
6493
| N1 | place | house | 1 |
6594
| N2 | place | house | 4 |
6695
And the places
6796
| osm | class | type | addr+interpolation | geometry |
6897
| W1 | place | houses | all | 1,2 |
98+
And the named places
99+
| osm | class | type | geometry |
100+
| W10 | highway | residential | 4,5 |
69101
And the ways
70102
| id | nodes |
71103
| 1 | 1,2 |
@@ -77,13 +109,17 @@ Feature: Import of address interpolations
77109
Scenario: Even two point interpolation line with intermediate empty node
78110
Given the grid
79111
| 1 | 8 | | 3 | 9 | 2 |
112+
| 4 | | | | 5 | |
80113
Given the places
81114
| osm | class | type | housenr |
82115
| N1 | place | house | 2 |
83116
| N2 | place | house | 12 |
84117
And the places
85118
| osm | class | type | addr+interpolation | geometry |
86119
| W1 | place | houses | even | 1,3,2 |
120+
And the named places
121+
| osm | class | type | geometry |
122+
| W10 | highway | residential | 4,5 |
87123
And the ways
88124
| id | nodes |
89125
| 1 | 1,3,2 |
@@ -94,6 +130,7 @@ Feature: Import of address interpolations
94130

95131
Scenario: Even two point interpolation line with intermediate duplicated empty node
96132
Given the grid
133+
| 4 | | | | 5 |
97134
| 1 | 8 | 3 | 9 | 2 |
98135
Given the places
99136
| osm | class | type | housenr |
@@ -102,6 +139,9 @@ Feature: Import of address interpolations
102139
And the places
103140
| osm | class | type | addr+interpolation | geometry |
104141
| W1 | place | houses | even | 1,3,2 |
142+
And the named places
143+
| osm | class | type | geometry |
144+
| W10 | highway | residential | 4,5 |
105145
And the ways
106146
| id | nodes |
107147
| 1 | 1,3,3,2 |
@@ -112,6 +152,7 @@ Feature: Import of address interpolations
112152

113153
Scenario: Simple even three point interpolation line
114154
Given the grid
155+
| 4 | | | | | | 5 |
115156
| 1 | 8 | | 9 | 3 | 7 | 2 |
116157
Given the places
117158
| osm | class | type | housenr |
@@ -121,6 +162,9 @@ Feature: Import of address interpolations
121162
And the places
122163
| osm | class | type | addr+interpolation | geometry |
123164
| W1 | place | houses | even | 1,3,2 |
165+
And the named places
166+
| osm | class | type | geometry |
167+
| W10 | highway | residential | 4,5 |
124168
And the ways
125169
| id | nodes |
126170
| 1 | 1,3,2 |
@@ -144,6 +188,9 @@ Feature: Import of address interpolations
144188
And the places
145189
| osm | class | type | addr+interpolation | geometry |
146190
| W1 | place | houses | even | 1,3,2,4 |
191+
And the named places
192+
| osm | class | type | geometry |
193+
| W10 | highway | residential | 1,3,2,4 |
147194
And the ways
148195
| id | nodes |
149196
| 1 | 1,3,2,4 |
@@ -157,6 +204,7 @@ Feature: Import of address interpolations
157204
Scenario: Reverse simple even three point interpolation line
158205
Given the grid
159206
| 1 | 8 | | 9 | 3 | 7 | 2 |
207+
| 4 | | | | | | 5 |
160208
Given the places
161209
| osm | class | type | housenr |
162210
| N1 | place | house | 2 |
@@ -165,6 +213,9 @@ Feature: Import of address interpolations
165213
And the places
166214
| osm | class | type | addr+interpolation | geometry |
167215
| W1 | place | houses | even | 2,3,1 |
216+
And the named places
217+
| osm | class | type | geometry |
218+
| W10 | highway | residential | 4,5 |
168219
And the ways
169220
| id | nodes |
170221
| 1 | 2,3,1 |
@@ -177,6 +228,7 @@ Feature: Import of address interpolations
177228
Scenario: Even three point interpolation line with odd center point
178229
Given the grid
179230
| 1 | | 10 | | | 11 | 3 | 2 |
231+
| 4 | | | | | | | 5 |
180232
Given the places
181233
| osm | class | type | housenr |
182234
| N1 | place | house | 2 |
@@ -185,6 +237,9 @@ Feature: Import of address interpolations
185237
And the places
186238
| osm | class | type | addr+interpolation | geometry |
187239
| W1 | place | houses | even | 1,3,2 |
240+
And the named places
241+
| osm | class | type | geometry |
242+
| W10 | highway | residential | 4,5 |
188243
And the ways
189244
| id | nodes |
190245
| 1 | 1,3,2 |
@@ -206,6 +261,9 @@ Feature: Import of address interpolations
206261
And the places
207262
| osm | class | type | addr+interpolation | geometry |
208263
| W1 | place | houses | even | 1,2,3,2 |
264+
And the named places
265+
| osm | class | type | geometry |
266+
| W10 | highway | residential | 1,2,3 |
209267
And the ways
210268
| id | nodes |
211269
| 1 | 1,2,3,2 |
@@ -227,6 +285,9 @@ Feature: Import of address interpolations
227285
And the places
228286
| osm | class | type | addr+interpolation | geometry |
229287
| W1 | place | houses | even | 1,2,3,2 |
288+
And the named places
289+
| osm | class | type | geometry |
290+
| W10 | highway | residential | 1,2,3 |
230291
And the ways
231292
| id | nodes |
232293
| 1 | 1,2,3,2 |
@@ -334,6 +395,9 @@ Feature: Import of address interpolations
334395
And the places
335396
| osm | class | type | addr+interpolation | geometry |
336397
| W1 | place | houses | even | 144.9632341 -37.76163,144.9630541 -37.7628172,144.9629794 -37.7630755 |
398+
And the named places
399+
| osm | class | type | geometry |
400+
| W10 | highway | residential | 144.9632341 -37.76163,144.9629794 -37.7630755 |
337401
And the ways
338402
| id | nodes |
339403
| 1 | 1,2,3 |
@@ -346,6 +410,7 @@ Feature: Import of address interpolations
346410
Scenario: Place with missing address information
347411
Given the grid
348412
| 1 | | 2 | | | 3 |
413+
| 4 | | | | | 5 |
349414
And the places
350415
| osm | class | type | housenr |
351416
| N1 | place | house | 23 |
@@ -354,6 +419,9 @@ Feature: Import of address interpolations
354419
And the places
355420
| osm | class | type | addr+interpolation | geometry |
356421
| W1 | place | houses | odd | 1,2,3 |
422+
And the named places
423+
| osm | class | type | geometry |
424+
| W10 | highway | residential | 4,5 |
357425
And the ways
358426
| id | nodes |
359427
| 1 | 1,2,3 |
@@ -366,32 +434,43 @@ Feature: Import of address interpolations
366434
Given the places
367435
| osm | class | type | housenr | geometry |
368436
| W1 | place | houses | even | 1 1, 1 1.001 |
437+
And the named places
438+
| osm | class | type | geometry |
439+
| W10 | highway | residential | 1 1, 1 1.001 |
369440
When importing
370441
Then W1 expands to no interpolation
371442

372443
Scenario: Ways with nodes without housenumbers are ignored
373444
Given the grid
374-
| 1 | | 2 |
445+
| 1 | | 2 |
446+
| 4 | | 5 |
375447
Given the places
376448
| osm | class | type |
377449
| N1 | place | house |
378450
| N2 | place | house |
379451
Given the places
380452
| osm | class | type | housenr | geometry |
381453
| W1 | place | houses | even | 1,2 |
454+
And the named places
455+
| osm | class | type | geometry |
456+
| W10 | highway | residential | 4,5 |
382457
When importing
383458
Then W1 expands to no interpolation
384459

385460
Scenario: Two point interpolation starting at 0
386461
Given the grid with origin 1,1
387462
| 1 | 10 | | | 11 | 2 |
463+
| 4 | | | | | 5 |
388464
Given the places
389465
| osm | class | type | housenr |
390466
| N1 | place | house | 0 |
391467
| N2 | place | house | 10 |
392468
And the places
393469
| osm | class | type | addr+interpolation | geometry |
394470
| W1 | place | houses | even | 1,2 |
471+
And the places
472+
| osm | class | type | name | geometry |
473+
| W10 | highway | residential | London Road |4,5 |
395474
And the ways
396475
| id | nodes |
397476
| 1 | 1,2 |
@@ -402,7 +481,7 @@ Feature: Import of address interpolations
402481
When sending v1/reverse at 1,1
403482
Then results contain
404483
| ID | osm | type | display_name |
405-
| 0 | N1 | house | 0 |
484+
| 0 | N1 | house | 0, London Road |
406485

407486
Scenario: Parenting of interpolation with additional tags
408487
Given the grid
@@ -438,13 +517,17 @@ Feature: Import of address interpolations
438517
Scenario Outline: Bad interpolation values are ignored
439518
Given the grid with origin 1,1
440519
| 1 | | 9 | | 2 |
520+
| 4 | | | | 5 |
441521
Given the places
442522
| osm | class | type | housenr |
443523
| N1 | place | house | 2 |
444524
| N2 | place | house | 6 |
445525
And the places
446526
| osm | class | type | addr+interpolation | geometry |
447527
| W1 | place | houses | <value> | 1,2 |
528+
And the named places
529+
| osm | class | type | geometry |
530+
| W10 | highway | residential | 4,5 |
448531
And the ways
449532
| id | nodes |
450533
| 1 | 1,2 |
@@ -470,6 +553,9 @@ Feature: Import of address interpolations
470553
And the places
471554
| osm | class | type | addr+interpolation | geometry |
472555
| W1 | place | houses | even | 1,2,3,4 |
556+
And the named places
557+
| osm | class | type | geometry |
558+
| W10 | highway | residential | 1,4 |
473559
And the ways
474560
| id | nodes |
475561
| 1 | 1,2,3,4 |
@@ -484,6 +570,7 @@ Feature: Import of address interpolations
484570
Scenario: Interpolation line with duplicated points
485571
Given the grid
486572
| 7 | 10 | 8 | 11 | 9 |
573+
| 4 | | | | 5 |
487574
Given the places
488575
| osm | class | type | housenr | geometry |
489576
| N1 | place | house | 2 | 7 |
@@ -493,6 +580,9 @@ Feature: Import of address interpolations
493580
And the places
494581
| osm | class | type | addr+interpolation | geometry |
495582
| W1 | place | houses | even | 7,8,8,9 |
583+
And the named places
584+
| osm | class | type | geometry |
585+
| W10 | highway | residential | 4,5 |
496586
And the ways
497587
| id | nodes |
498588
| 1 | 1,2,3,4 |
@@ -515,6 +605,9 @@ Feature: Import of address interpolations
515605
And the places
516606
| osm | class | type | addr+interpolation | geometry |
517607
| W1 | place | houses | even | 8,9 |
608+
And the named places
609+
| osm | class | type | geometry |
610+
| W10 | highway | residential | 1,4 |
518611
And the ways
519612
| id | nodes |
520613
| 1 | 1,8,9,2,3,4 |

0 commit comments

Comments
 (0)