Skip to content

Commit

Permalink
do not recheck for polygon tags in MPs
Browse files Browse the repository at this point in the history
The tag type=multipolygon already indicates an area, no
matter what the other tags say.

Fixes osm2pgsql-dev#866.
  • Loading branch information
lonvia committed Oct 3, 2018
1 parent bedb470 commit bad810a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 32 deletions.
8 changes: 0 additions & 8 deletions style.lua
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,6 @@ function filter_tags_relation_member (keyvalues, keyvaluemembers, roles, memberc
elseif (type == "multipolygon") then
-- Treat as polygon
polygon = 1
filter = 1
-- Count the number of polygon tags of the object
for i,k in ipairs(polygon_keys) do
if keyvalues[k] then
filter = 0
break
end
end
end

-- Add z_order key/value combination and determine if the object should also be added to planet_osm_roads
Expand Down
24 changes: 5 additions & 19 deletions tagtransform-c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ bool c_tagtransform_t::filter_tags(osmium::OSMObject const &o, int *polygon,
if (o.type() == osmium::item_type::relation &&
strcmp("type", k) == 0) {
out_tags.emplace_back(k, v);
filter = false;
continue;
}
/* Allow named islands to appear as polygons */
Expand Down Expand Up @@ -210,7 +209,6 @@ bool c_tagtransform_t::filter_rel_member_tags(
int *roads, export_list const &exlist, taglist_t &out_tags,
bool allow_typeless)
{
auto const &infos = exlist.get(osmium::item_type::way);
//if it has a relation figure out what kind it is
const std::string *type = rel_tags.get("type");
bool is_route = false, is_boundary = false, is_multipolygon = false;
Expand Down Expand Up @@ -239,6 +237,10 @@ bool c_tagtransform_t::filter_rel_member_tags(
out_tags.push_dedupe(rel_tag);
}

if (out_tags.empty()) {
return true;
}

if (is_route) {
const std::string *netw = rel_tags.get("network");
int networknr = -1;
Expand Down Expand Up @@ -313,25 +315,9 @@ bool c_tagtransform_t::filter_rel_member_tags(
*make_boundary = 1;
} else if (is_multipolygon) {
*make_polygon = 1;

// Check if any of the tags is polygon-like
int flags = 0;
bool filter = false;
for (const auto &tag : out_tags) {
check_key(infos, tag.key.c_str(), &filter, &flags, false);
}

if (!(flags & FLAG_POLYGON)) {
out_tags.clear();
return true;
}
}

if (out_tags.empty()) {
return true;
}

add_z_order(out_tags, roads);

return 0;
return false;
}
10 changes: 5 additions & 5 deletions tests/regression-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@
( 51, 'Basic hstore point count', 'SELECT count(*) FROM planet_osm_point;', 1360 ),
( 52, 'Basic hstore line count', 'SELECT count(*) FROM planet_osm_line;', 3254 ),
( 53, 'Basic hstore road count', 'SELECT count(*) FROM planet_osm_roads;', 375 ),
( 54, 'Basic hstore polygon count', 'SELECT count(*) FROM planet_osm_polygon;', 4130 ),
( 54, 'Basic hstore polygon count', 'SELECT count(*) FROM planet_osm_polygon;', 4131 ),
( 55, 'Basic post-diff point count', 'SELECT count(*) FROM planet_osm_point;', 1475 ),
( 56, 'Basic post-diff line count', 'SELECT count(*) FROM planet_osm_line;', 3297 ),
( 57, 'Basic post-diff road count', 'SELECT count(*) FROM planet_osm_roads;', 380 ),
( 58, 'Basic post-diff polygon count', 'SELECT count(*) FROM planet_osm_polygon;', 4277 ),
( 58, 'Basic post-diff polygon count', 'SELECT count(*) FROM planet_osm_polygon;', 4278 ),
( 59, 'Extra hstore full tags point count',
'SELECT count(*) FROM planet_osm_point WHERE tags ? \'osm_user\' and tags ? \'osm_version\' and tags ? \'osm_uid\' and tags ? \'osm_changeset\'', 1360),
( 60, 'Extra hstore full tags line count',
'SELECT count(*) FROM planet_osm_line WHERE tags ? \'osm_user\' and tags ? \'osm_version\' and tags ? \'osm_uid\' and tags ? \'osm_changeset\'', 3254),
( 61, 'Extra hstore full tags polygon count',
'SELECT count(*) FROM planet_osm_polygon WHERE tags ? \'osm_user\' and tags ? \'osm_version\' and tags ? \'osm_uid\' and tags ? \'osm_changeset\'', 4130),
'SELECT count(*) FROM planet_osm_polygon WHERE tags ? \'osm_user\' and tags ? \'osm_version\' and tags ? \'osm_uid\' and tags ? \'osm_changeset\'', 4131),
( 62, 'removed', 'really', 0),
( 63, 'removed', 'really', 0),
( 64, 'Multipolygon non copying of tags from outer with polygon tags on relation',
Expand Down Expand Up @@ -152,11 +152,11 @@
( 93, 'Basic number of hstore points tags', 'SELECT sum(array_length(akeys(tags),1)) FROM planet_osm_point;', 4228),
( 94, 'Basic number of hstore roads tags', 'SELECT sum(array_length(akeys(tags),1)) FROM planet_osm_roads;', 2317),
( 95, 'Basic number of hstore lines tags', 'SELECT sum(array_length(akeys(tags),1)) FROM planet_osm_line;', 10387),
( 96, 'Basic number of hstore polygons tags', 'SELECT sum(array_length(akeys(tags),1)) FROM planet_osm_polygon;', 9536),
( 96, 'Basic number of hstore polygons tags', 'SELECT sum(array_length(akeys(tags),1)) FROM planet_osm_polygon;', 9538),
( 97, 'Diff import number of hstore points tags', 'SELECT sum(array_length(akeys(tags),1)) FROM planet_osm_point;', 4352),
( 98, 'Diff import number of hstore roads tags', 'SELECT sum(array_length(akeys(tags),1)) FROM planet_osm_roads;', 2336),
( 99, 'Diff import number of hstore lines tags', 'SELECT sum(array_length(akeys(tags),1)) FROM planet_osm_line;', 10505),
( 100, 'Diff import number of hstore polygons tags', 'SELECT sum(array_length(akeys(tags),1)) FROM planet_osm_polygon;', 9830),
( 100, 'Diff import number of hstore polygons tags', 'SELECT sum(array_length(akeys(tags),1)) FROM planet_osm_polygon;', 9832),
#**** Tests to check if inner polygon appears when outer tags change after initially identicall inner and outer way tags in a multi-polygon ****
#**** These tests are currently broken and noted in trac ticket #2853 ****
( 101, 'Multipolygon identical tags on inner and outer (presence of relation)',
Expand Down

0 comments on commit bad810a

Please sign in to comment.