1 #ifndef OSMIUM_AREA_ASSEMBLER_LEGACY_HPP
2 #define OSMIUM_AREA_ASSEMBLER_LEGACY_HPP
37 #include <osmium/area/detail/basic_assembler_with_tags.hpp>
38 #include <osmium/area/detail/proto_ring.hpp>
39 #include <osmium/area/detail/segment_list.hpp>
80 std::map<std::string, std::size_t> counter;
82 for (
const auto& tag :
way->tags()) {
83 std::string kv{tag.key()};
85 kv.append(tag.value());
90 const std::size_t num_ways = ways.size();
91 for (
const auto& t_c : counter) {
93 std::cerr <<
" tag " << t_c.first <<
" is used " << t_c.second <<
" times in " << num_ways <<
" ways\n";
95 if (t_c.second == num_ways) {
96 const std::size_t len = std::strlen(t_c.first.c_str());
97 tl_builder.
add_tag(t_c.first.c_str(), t_c.first.c_str() + len + 1);
106 add(
false,
"created_by");
107 add(
false,
"source");
109 add(
false,
"test:id");
110 add(
false,
"test:section");
124 std::cerr <<
" found " << count <<
" tags on relation (without ignored ones)\n";
129 std::cerr <<
" use tags from relation\n";
132 if (config().keep_type_tag) {
135 copy_tags_without_type(builder,
relation.tags());
138 ++stats().no_tags_on_relation;
140 std::cerr <<
" use tags from outer ways\n";
142 std::set<const osmium::Way*> ways;
143 for (
const auto& ring : rings()) {
144 if (ring.is_outer()) {
148 if (ways.size() == 1) {
150 std::cerr <<
" only one outer way\n";
152 builder.
add_item((*ways.cbegin())->tags());
155 std::cerr <<
" multiple outer ways, get common tags\n";
165 builder.initialize_from_object(
way);
167 const bool area_okay = create_rings();
168 if (area_okay || config().create_empty_areas) {
172 add_rings_to_area(builder);
176 config().problem_reporter->report_way(
way);
179 return area_okay || config().create_empty_areas;
183 set_num_members(members.size());
185 builder.initialize_from_object(
relation);
187 const bool area_okay = create_rings();
188 if (area_okay || config().create_empty_areas) {
192 add_rings_to_area(builder);
197 config().problem_reporter->report_way(*
way);
201 return area_okay || config().create_empty_areas;
207 detail::BasicAssemblerWithTags(config) {
218 if (!config().create_way_polygons) {
222 if (
way.tags().has_tag(
"area",
"no")) {
226 if (config().problem_reporter) {
228 config().problem_reporter->set_nodes(
way.nodes().size());
232 if (
way.nodes().size() < 2) {
233 ++stats().short_ways;
237 if (!
way.ends_have_same_id()) {
238 ++stats().duplicate_nodes;
239 if (config().problem_reporter) {
240 config().problem_reporter->report_duplicate_node(
way.nodes().front().ref(),
way.nodes().back().ref(),
way.nodes().front().location());
245 stats().invalid_locations = segment_list().extract_segments_from_way(config().problem_reporter,
246 stats().duplicate_nodes,
248 if (!config().ignore_invalid_locations && stats().invalid_locations > 0) {
252 if (config().debug_level > 0) {
253 std::cerr <<
"\nAssembling way " <<
way.id() <<
" containing " << segment_list().size() <<
" nodes\n";
266 std::cerr <<
"Done: " << stats() <<
"\n";
280 assert(
relation.members().size() >= members.size());
282 if (config().problem_reporter) {
287 ++stats().no_way_in_mp_relation;
291 ++stats().from_relations;
292 stats().invalid_locations = segment_list().extract_segments_from_ways(config().problem_reporter,
293 stats().duplicate_nodes,
294 stats().duplicate_ways,
297 if (!config().ignore_invalid_locations && stats().invalid_locations > 0) {
300 stats().member_ways = members.size();
302 if (stats().member_ways == 1) {
303 ++stats().single_way_in_mp_relation;
306 if (config().debug_level > 0) {
307 std::cerr <<
"\nAssembling relation " <<
relation.id() <<
" containing " << members.size() <<
" way members with " << segment_list().size() <<
" nodes\n";
310 const std::size_t area_offset = out_buffer.
committed();
316 if ((config().create_new_style_polygons && stats().no_tags_on_relation == 0) ||
317 (config().create_old_style_polygons && stats().no_tags_on_relation != 0)) {
332 std::vector<const osmium::Way*> ways_that_should_be_areas;
333 if (stats().wrong_role == 0) {
335 if (!std::strcmp(member.
role(),
"inner")) {
336 if (!way.nodes().empty() && way.is_closed() && !way.tags().empty()) {
337 const auto d = std::count_if(way.tags().cbegin(), way.tags().cend(), std::cref(filter()));
339 osmium::tags::KeyFilter::iterator way_fi_begin(std::cref(filter()), way.tags().cbegin(), way.tags().cend());
340 osmium::tags::KeyFilter::iterator way_fi_end(std::cref(filter()), way.tags().cend(), way.tags().cend());
341 osmium::tags::KeyFilter::iterator area_fi_begin(std::cref(filter()), area_tags.cbegin(), area_tags.cend());
342 osmium::tags::KeyFilter::iterator area_fi_end(std::cref(filter()), area_tags.cend(), area_tags.cend());
344 if (!std::equal(way_fi_begin, way_fi_end, area_fi_begin) || d != std::distance(area_fi_begin, area_fi_end)) {
345 ways_that_should_be_areas.push_back(&way);
347 ++stats().inner_with_same_tags;
348 if (config().problem_reporter) {
349 config().problem_reporter->report_inner_with_same_tags(way);
359 std::cerr <<
"Done: " << stats() <<
"\n";
365 if (!assembler(*
way, out_buffer)) {
368 stats() += assembler.stats();
380 #endif // OSMIUM_AREA_ASSEMBLER_LEGACY_HPP