Skip to content

Commit 914ff8b

Browse files
committed
also remove all old-style MP tag copying
1 parent d6bdc67 commit 914ff8b

File tree

5 files changed

+62
-179
lines changed

5 files changed

+62
-179
lines changed

style.lua

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,6 @@ function filter_tags_relation_member (keyvalues, keyvaluemembers, roles, memberc
236236
linestring = 0 -- Will object be treated as linestring?
237237
polygon = 0 -- Will object be treated as polygon?
238238
roads = 0 -- Will object be added to planet_osm_roads?
239-
membersuperseded = {}
240-
for i = 1, membercount do
241-
membersuperseded[i] = 0 -- Will member be ignored when handling areas?
242-
end
243239

244240
type = keyvalues["type"]
245241

@@ -257,59 +253,18 @@ function filter_tags_relation_member (keyvalues, keyvaluemembers, roles, memberc
257253
elseif (type == "multipolygon") then
258254
-- Treat as polygon
259255
polygon = 1
260-
polytagcount = 0;
256+
filter = 1
261257
-- Count the number of polygon tags of the object
262258
for i,k in ipairs(polygon_keys) do
263259
if keyvalues[k] then
264-
polytagcount = 1
260+
filter = 0
265261
break
266262
end
267263
end
268-
-- If there are no polygon tags, add tags from all outer elements to the multipolygon itself
269-
if (polytagcount == 0) then
270-
for i = 1,membercount do
271-
if (roles[i] == "outer") then
272-
for k,v in pairs(keyvaluemembers[i]) do
273-
keyvalues[k] = v
274-
end
275-
end
276-
end
277-
278-
f, keyvalues = filter_tags_generic(keyvalues, 1)
279-
-- check again if there are still polygon tags left
280-
polytagcount = 0
281-
for i,k in ipairs(polygon_keys) do
282-
if keyvalues[k] then
283-
polytagcount = 1
284-
break
285-
end
286-
end
287-
if polytagcount == 0 then
288-
filter = 1
289-
end
290-
end
291-
-- For any member of the multipolygon, set membersuperseded to 1 (i.e. don't deal with it as area as well),
292-
-- except when the member has a key/value combination such that
293-
-- 1) the key occurs in generic_keys
294-
-- 2) the key/value combination is not also a key/value combination of the multipolygon itself
295-
for i = 1,membercount do
296-
superseded = 1
297-
for k,v in pairs(keyvaluemembers[i]) do
298-
if ((keyvalues[k] == nil) or (keyvalues[k] ~= v)) then
299-
for j,k2 in ipairs(generic_keys) do
300-
if (k == k2) then
301-
superseded = 0;
302-
break
303-
end
304-
end
305-
end
306-
end
307-
membersuperseded[i] = superseded
308-
end
309264
end
310265

311266
-- Add z_order key/value combination and determine if the object should also be added to planet_osm_roads
312267
keyvalues, roads = add_z_order(keyvalues)
313268

314-
return filter, keyvalues, membersuperseded, linestring, polygon, roads
269+
return filter, keyvalues, {}, linestring, polygon, roads
315270
end

tagtransform-c.cpp

Lines changed: 7 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -314,71 +314,16 @@ bool c_tagtransform_t::filter_rel_member_tags(
314314
} else if (is_multipolygon) {
315315
*make_polygon = 1;
316316

317-
// Check if the relation has any polygon-like tags. In that case
318-
// we have a new-style polygon.
319-
bool newstyle_mp = false;
317+
// Check if any of the tags is polygon-like
318+
int flags = 0;
319+
bool filter = false;
320320
for (const auto &tag : out_tags) {
321-
if (tag.key == "area") {
322-
newstyle_mp = true;
323-
} else {
324-
for (const auto &info : infos) {
325-
if (info.name == tag.key) {
326-
newstyle_mp = info.flags & FLAG_POLYGON;
327-
break;
328-
}
329-
}
330-
}
331-
if (newstyle_mp) {
332-
break;
333-
}
321+
check_key(infos, tag.key.c_str(), &filter, &flags, false);
334322
}
335323

336-
// Old-style MP: copy the tags from the outer way(s). Only use tags
337-
// that appear in all outer rings.
338-
if (!newstyle_mp) {
339-
taglist_t poly_tags;
340-
bool first_outerway = true;
341-
size_t i = 0;
342-
for (auto const &w : members.select<osmium::Way>()) {
343-
if (member_roles[i] && strcmp(member_roles[i], "inner") == 0)
344-
continue;
345-
346-
/* insert all tags of the first outerway to the potential list of copied tags. */
347-
if (first_outerway) {
348-
for (auto const &tag : w.tags()) {
349-
poly_tags.emplace_back(tag.key(), tag.value());
350-
}
351-
first_outerway = false;
352-
} else {
353-
/* Check if all of the tags in the list of potential tags are present on this way,
354-
otherwise remove from the list of potential tags. Tags need to be present on
355-
all outer ways to be copied over to the relation */
356-
auto it = poly_tags.begin();
357-
while (it != poly_tags.end()) {
358-
if (!w.tags().has_key(it->key.c_str()))
359-
/* This tag is not present on all member outer ways, so don't copy it over to relation */
360-
it = poly_tags.erase(it);
361-
else
362-
++it;
363-
}
364-
}
365-
++i;
366-
}
367-
// Copy the list identified outer way tags over to the relation
368-
// filtering for wanted tags on the way.
369-
bool filter;
370-
int flags = 0;
371-
for (const auto &poly_tag : poly_tags) {
372-
if (check_key(infos, poly_tag.key.c_str(), &filter, &flags,
373-
false)) {
374-
out_tags.push_dedupe(poly_tag);
375-
}
376-
}
377-
378-
if (!(flags & FLAG_POLYGON)) {
379-
out_tags.clear();
380-
return true;
381-
}
324+
if (!(flags & FLAG_POLYGON)) {
325+
out_tags.clear();
326+
return true;
382327
}
383328
}
384329

0 commit comments

Comments
 (0)