本文整理汇总了C++中osmium::Way::nodes方法的典型用法代码示例。如果您正苦于以下问题:C++ Way::nodes方法的具体用法?C++ Way::nodes怎么用?C++ Way::nodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osmium::Way
的用法示例。
在下文中一共展示了Way::nodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: way
void way(const osmium::Way& way) {
if (m_write_change_ops) {
open_close_op_tag(way.visible() ? (way.version() == 1 ? operation::op_create : operation::op_modify) : operation::op_delete);
}
write_prefix();
m_out += "<way";
write_meta(way);
if (way.tags().empty() && way.nodes().empty()) {
m_out += "/>\n";
return;
}
m_out += ">\n";
for (const auto& node_ref : way.nodes()) {
write_prefix();
oprintf(m_out, " <nd ref=\"%" PRId64 "\"/>\n", node_ref.ref());
}
write_tags(way.tags());
write_prefix();
m_out += "</way>\n";
}
示例2: way
void way(const osmium::Way& way) {
*m_out += 'w';
write_meta(way);
*m_out += " N";
if (!way.nodes().empty()) {
auto it = way.nodes().begin();
if (m_options.locations_on_ways) {
write_field_ref(*it);
for (++it; it != way.nodes().end(); ++it) {
*m_out += ',';
write_field_ref(*it);
}
} else {
write_field_int('n', it->ref());
for (++it; it != way.nodes().end(); ++it) {
*m_out += ',';
write_field_int('n', it->ref());
}
}
}
*m_out += '\n';
}
示例3: extract_segments_from_way
/**
* Extract segments from given way and add them to the list.
*
* Segments connecting two nodes with the same location (ie
* same node or different nodes with same location) are
* removed after reporting the duplicate node.
*/
uint32_t extract_segments_from_way(osmium::area::ProblemReporter* problem_reporter, const osmium::Way& way) {
if (way.nodes().empty()) {
return 0;
}
m_segments.reserve(way.nodes().size() - 1);
return extract_segments_from_way_impl(problem_reporter, way, role_type::outer);
}
示例4: parseWay
inline void parseWay(const osmium::Way& way)
{
const auto& tags = way.tags();
auto it = std::find_if(tags.begin(), tags.end(), highway_filter);
if (it == tags.end())
{
return;
}
const osmium::NodeRef& first = way.nodes().front();
const osmium::NodeRef& last = way.nodes().back();
// filter out closed ways, generally this will just cause false
// positives with round-a-abouts
if (first == last)
{
return;
}
const char* name = tags.get_value_by_key("name", "");
const char* ref = tags.get_value_by_key("ref", "");
unsigned name_id = getStringID(name);
unsigned ref_id = getStringID(ref);
// we can't use osmium ids because MultiMap expects unsigned keys
unsigned long firstID = static_cast<unsigned long>(first.ref());
unsigned long lastID = static_cast<unsigned long>(last.ref());
const unsigned wayIdx = parsed_ways->size();
endpoint_way_map->unsorted_set(firstID, wayIdx);
endpoint_way_map->unsorted_set(lastID, wayIdx);
parsed_ways->emplace_back(way.id(), firstID, lastID, name_id, ref_id);
}
示例5: way
void way(const osmium::Way& way) {
// detect a new way
if (current_way_id != 0 && current_way_id != way.positive_id()) {
write_way_extra_nodes();
current_way_nodes.clear();
}
current_way_id = way.positive_id();
if (debug) {
std::cerr << "softcut way " << way.positive_id() << " v" << way.version() << "\n";
}
for (const auto& node_ref : way.nodes()) {
current_way_nodes.insert(node_ref.positive_ref());
}
for (const auto& extract : info->extracts) {
for (const auto& node_ref : way.nodes()) {
if (extract->node_tracker.get(node_ref.positive_ref())) {
if (debug) {
std::cerr << "way has a node (" << node_ref.positive_ref() << ") inside extract, recording in way_tracker\n";
}
extract->way_tracker.set(way.positive_id());
break;
}
}
}
}
示例6: insert_way_error
/***
* Insert error node into nodes table: way contains of one
* coordinate.
*/
void insert_way_error(const osmium::Way &way) {
ErrorSum *sum = new ErrorSum();
sum->set_way_error();
ds.insert_node_feature(way.nodes().begin()->location(),
way.nodes().begin()->ref(), sum);
delete sum;
}
示例7: eway
void eway(extract_data& e, const osmium::Way& way) {
for (const auto& nr : way.nodes()) {
if (e.node_ids.get(nr.positive_ref())) {
e.way_ids.set(way.positive_id());
for (const auto& nr : way.nodes()) {
e.extra_node_ids.set(nr.ref());
}
return;
}
}
}
示例8: operator
/**
* Assemble an area from the given way.
* The resulting area is put into the out_buffer.
*
* @returns false if there was some kind of error building the
* area, true otherwise.
*/
bool operator()(const osmium::Way& way, osmium::memory::Buffer& out_buffer) {
if (!config().create_way_polygons) {
return true;
}
if (config().problem_reporter) {
config().problem_reporter->set_object(osmium::item_type::way, way.id());
config().problem_reporter->set_nodes(way.nodes().size());
}
// Ignore (but count) ways without segments.
if (way.nodes().size() < 2) {
++stats().short_ways;
return false;
}
if (!way.ends_have_same_id()) {
++stats().duplicate_nodes;
if (config().problem_reporter) {
config().problem_reporter->report_duplicate_node(way.nodes().front().ref(), way.nodes().back().ref(), way.nodes().front().location());
}
}
++stats().from_ways;
stats().invalid_locations = segment_list().extract_segments_from_way(config().problem_reporter,
stats().duplicate_nodes,
way);
if (!config().ignore_invalid_locations && stats().invalid_locations > 0) {
return false;
}
if (config().debug_level > 0) {
std::cerr << "\nAssembling way " << way.id() << " containing " << segment_list().size() << " nodes\n";
}
// Now create the Area object and add the attributes and tags
// from the way.
const bool okay = create_area(out_buffer, way);
if (okay) {
out_buffer.commit();
} else {
out_buffer.rollback();
}
if (debug()) {
std::cerr << "Done: " << stats() << "\n";
}
return okay;
}
示例9: extract_segments_from_way_impl
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;
}
示例10: way
/***
* Iterate through all nodes of waterways in pass 3 if way is coastline
* or riverbank. Otherwise iterate just through the nodes between
* firstnode and lastnode.
*/
void way(const osmium::Way& way) {
if (is_valid(way)) {
if (check_all_nodes(way)) {
for (auto node : way.nodes()) {
check_node(node);
}
} else {
if (way.nodes().size() > 2) {
for (auto node = way.nodes().begin() + 1;
node != way.nodes().end() - 1; ++node) {
check_node(*node);
}
}
}
}
}
示例11: pgsql_out_way
void output_pgsql_t::pgsql_out_way(osmium::Way const &way, taglist_t *tags,
bool polygon, bool roads)
{
if (polygon && way.is_closed()) {
auto wkb = m_builder.get_wkb_polygon(way);
if (!wkb.empty()) {
expire.from_wkb(wkb.c_str(), way.id());
if (m_enable_way_area) {
char tmp[32];
auto const area =
m_options.reproject_area
? ewkb::parser_t(wkb).get_area<reprojection>(
m_options.projection.get())
: ewkb::parser_t(wkb)
.get_area<osmium::geom::IdentityProjection>();
snprintf(tmp, sizeof(tmp), "%g", area);
tags->push_override(tag_t("way_area", tmp));
}
m_tables[t_poly]->write_row(way.id(), *tags, wkb);
}
} else {
double const split_at = m_options.projection->target_latlon() ? 1 : 100 * 1000;
for (auto const &wkb : m_builder.get_wkb_line(way.nodes(), split_at)) {
expire.from_wkb(wkb.c_str(), way.id());
m_tables[t_line]->write_row(way.id(), *tags, wkb);
if (roads) {
m_tables[t_roads]->write_row(way.id(), *tags, wkb);
}
}
}
}
示例12: create_polygon
polygon_type create_polygon(const osmium::Way& way, use_nodes un=use_nodes::unique, direction dir = direction::forward) {
try {
return create_polygon(way.nodes(), un, dir);
} catch (osmium::geometry_error& e) {
e.set_id("way", way.id());
throw;
}
}
示例13: extract_segments_from_way
/**
* 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;
}
}
示例14: way_not_in_any_relation
/**
* This is called when a way is not in any multipolygon
* relation.
*/
void way_not_in_any_relation(const osmium::Way& way) {
// you need at least 4 nodes to make up a polygon
if (way.nodes().size() <= 3) {
return;
}
try {
if (!way.nodes().front().location() || !way.nodes().back().location()) {
throw osmium::invalid_location{"invalid location"};
}
if (way.ends_have_same_location()) {
// way is closed and has enough nodes, build simple multipolygon
TAssembler assembler{m_assembler_config};
assembler(way, this->buffer());
m_stats += assembler.stats();
}
} catch (const osmium::invalid_location&) {
// XXX ignore
}
}
示例15: way_not_in_any_relation
/**
* This is called when a way is not in any multipolygon
* relation.
*
* Overwritten from the base class.
*/
void way_not_in_any_relation(const osmium::Way& way) {
// you need at least 4 nodes to make up a polygon
if (way.nodes().size() <= 3) {
return;
}
try {
if (!way.nodes().front().location() || !way.nodes().back().location()) {
throw osmium::invalid_location("invalid location");
}
if (way.ends_have_same_location()) {
// way is closed and has enough nodes, build simple multipolygon
TAssembler assembler(m_assembler_config);
assembler(way, m_output_buffer);
possibly_flush_output_buffer();
}
} catch (osmium::invalid_location&) {
// XXX ignore
}
}