Skip to content

Commit 0d9d778

Browse files
committed
gazetteer: recognise fallback flag on postcodes
1 parent 137650e commit 0d9d778

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

gazetteer-style.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ void gazetteer_style_t::process_tags(osmium::OSMObject const &o)
269269
bool address_point = false;
270270
bool interpolation = false;
271271
bool admin_boundary = false;
272+
bool postcode_fallback = false;
272273

273274
for (auto const &item : o.tags()) {
274275
char const *k = item.key();
@@ -346,6 +347,9 @@ void gazetteer_style_t::process_tags(osmium::OSMObject const &o)
346347

347348
if ((flag & SF_POSTCODE) && !postcode) {
348349
postcode = v;
350+
if (flag & SF_MAIN_FALLBACK) {
351+
postcode_fallback = true;
352+
}
349353
}
350354

351355
if ((flag & SF_COUNTRY) && !country && std::strlen(v) == 2) {
@@ -377,7 +381,7 @@ void gazetteer_style_t::process_tags(osmium::OSMObject const &o)
377381
}
378382
if (address_point) {
379383
m_main.emplace_back("place", "house", SF_MAIN | SF_MAIN_FALLBACK);
380-
} else if (postcode) {
384+
} else if (postcode_fallback && postcode) {
381385
m_main.emplace_back("place", "postcode", SF_MAIN | SF_MAIN_FALLBACK);
382386
}
383387
}

tests/regression-test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@
3232
( 11, 'Absence of way table', 'SELECT count(*) FROM pg_tables WHERE tablename = \'planet_osm_ways\'', 0),
3333
( 12, 'Absence of rel line', 'SELECT count(*) FROM pg_tables WHERE tablename = \'planet_osm_rels\'', 0),
3434
( 13, 'Basic polygon area', 'SELECT round(sum(cast(ST_Area(way) as numeric)),0) FROM planet_osm_polygon;', 1247245186),
35-
( 14, 'Gazetteer place count', 'SELECT count(*) FROM place', 2836),
35+
( 14, 'Gazetteer place count', 'SELECT count(*) FROM place', 2826),
3636
( 15, 'Gazetteer place node count', 'SELECT count(*) FROM place WHERE osm_type = \'N\'', 759),
37-
( 16, 'Gazetteer place way count', 'SELECT count(*) FROM place WHERE osm_type = \'W\'', 2059),
37+
( 16, 'Gazetteer place way count', 'SELECT count(*) FROM place WHERE osm_type = \'W\'', 2049),
3838
( 17, 'Gazetteer place rel count', 'SELECT count(*) FROM place WHERE osm_type = \'R\'', 18),
39-
( 18, 'Gazetteer post-diff place count', 'SELECT count(*) FROM place', 2877),
39+
( 18, 'Gazetteer post-diff place count', 'SELECT count(*) FROM place', 2867),
4040
( 19, 'Gazetteer post-diff place node count', 'SELECT count(*) FROM place WHERE osm_type = \'N\'', 764),
41-
( 20, 'Gazetteer post-diff place way count', 'SELECT count(*) FROM place WHERE osm_type = \'W\'', 2095),
41+
( 20, 'Gazetteer post-diff place way count', 'SELECT count(*) FROM place WHERE osm_type = \'W\'', 2085),
4242
( 21, 'Gazetteer post-diff place rel count', 'SELECT count(*) FROM place WHERE osm_type = \'R\'', 18),
4343
( 22, 'Gazetteer housenumber count', "SELECT count(*) FROM place WHERE address ? 'housenumber'", 199),
4444
( 23, 'Gazetteer post-diff housenumber count count', "SELECT count(*) FROM place WHERE address ? 'housenumber'", 199),
45-
( 24, 'Gazetteer address count', 'SELECT count(*) FROM place WHERE address is not null', 319),
46-
( 25, 'Gazetteer post-diff address count', 'SELECT count(*) FROM place WHERE address is not null', 319),
45+
( 24, 'Gazetteer address count', 'SELECT count(*) FROM place WHERE address is not null', 309),
46+
( 25, 'Gazetteer post-diff address count', 'SELECT count(*) FROM place WHERE address is not null', 309),
4747
( 26, 'removed', 'really', 0),
4848
( 27, 'Multipolygon basic case (Tags from relation)',
4949
'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -1 and landuse = \'residential\' and name = \'Name_rel\'', 12895),

0 commit comments

Comments
 (0)