uint32_t extract_segments_from_way_impl(osmium::area::ProblemReporter* problem_reporter, uint64_t& duplicate_nodes, const osmium::Way& way, role_type role) { uint32_t invalid_locations = 0; osmium::NodeRef previous_nr; for (const osmium::NodeRef& nr : way.nodes()) { if (!nr.location().valid()) { ++invalid_locations; if (problem_reporter) { problem_reporter->report_invalid_location(way.id(), nr.ref()); } continue; } if (previous_nr.location()) { if (previous_nr.location() != nr.location()) { m_segments.emplace_back(previous_nr, nr, role, &way); } else { ++duplicate_nodes; if (problem_reporter) { problem_reporter->report_duplicate_node(previous_nr.ref(), nr.ref(), nr.location()); } } } previous_nr = nr; } return invalid_locations; }
/** * Extract segments from given way and add them to the list. * * Segments connecting two nodes with the same location (ie same * node or different node with same location) are removed. * * XXX should two nodes with same location be reported? */ void extract_segments_from_way(const osmium::Way& way, const char* role) { osmium::NodeRef last_nr; for (const osmium::NodeRef& nr : way.nodes()) { if (last_nr.location() && last_nr.location() != nr.location()) { m_segments.emplace_back(last_nr, nr, role, &way); } last_nr = nr; } }