本文整理汇总了C++中osmium::Way类的典型用法代码示例。如果您正苦于以下问题:C++ Way类的具体用法?C++ Way怎么用?C++ Way使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Way类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: create_single_way
void create_single_way(const osmium::Way &way) {
osmium::geom::OGRFactory<> ogr_factory;
OGRLineString *linestring = nullptr;
try {
linestring = ogr_factory.create_linestring(way,
osmium::geom::use_nodes::unique,
osmium::geom::direction::forward).release();
} catch (osmium::geometry_error) {
insert_way_error(way);
return;
} catch (...) {
cerr << "Error at way: " << way.id() << endl;
cerr << " Unexpected error" << endl;
return;
}
try {
ds.insert_way_feature(linestring, way, 0);
} catch (osmium::geometry_error&) {
cerr << "Inserting to table failed for way: "
<< way.id() << endl;
} catch (...) {
cerr << "Inserting to table failed for way: "
<< way.id() << endl;
cerr << " Unexpected error" << endl;
}
delete linestring;
}
示例3: 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';
}
示例4: 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);
}
示例5: 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;
}
示例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: 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;
}
}
示例8: way
void way(const osmium::Way& way) {
try {
gdalcpp::Feature feature{m_layer_linestring, m_factory.create_linestring(way)};
feature.set_field("id", int32_t(way.id()));
add_feature(feature, way);
} catch (const osmium::geometry_error&) {
std::cerr << "Ignoring illegal geometry for way " << way.id() << ".\n";
}
}
示例9: way
void way(const osmium::Way& way) {
if (m_max_relation_id > 0) {
throw std::runtime_error("Found a way after a relation.");
}
if (m_max_way_id >= way.id()) {
throw std::runtime_error("Way IDs out of order.");
}
m_max_way_id = way.id();
}
示例10: way
// - walk over all way-versions
// - walk over all bboxes
// - if the way-id is recorded in the bboxes way-trackers
// - send the way to the bboxes writer
void way(const osmium::Way& way) {
if (debug) {
std::cerr << "cut_administrative way " << way.id() << " v" << way.version() << "\n";
}
for (const auto& extract : info->extracts) {
if (extract->way_tracker.get(way.id())){
extract->write(way);
}
}
}
示例11: 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;
}
}
}
示例12: way
// The way handler is called for each node in the input data.
void way(const osmium::Way& way) {
{
osmium::builder::WayBuilder builder{m_buffer};
copy_attributes(builder, way);
copy_tags(builder, way.tags());
// Copy the node list over to the new way.
builder.add_item(way.nodes());
}
m_buffer.commit();
}
示例13: way
void way(const osmium::Way& way) {
++ways;
if (!matches_user_filter(way)) return;
++uways;
for (const auto& node : way.nodes()) {
m_nodefile <<
way.id() << "\t" <<
way.version() << "\t" <<
node.ref() << std::endl;
}
}
示例14: 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) {
if (way.nodes().size() > 3 && way.ends_have_same_location()) {
// way is closed and has enough nodes, build simple multipolygon
try {
TAssembler assembler(m_assembler_config);
assembler(way, m_output_buffer);
possibly_flush_output_buffer();
} catch (osmium::invalid_location&) {
// XXX ignore
}
}
}
示例15: way
void parse_osmium_t::way(osmium::Way& way)
{
if (way.deleted()) {
m_data->way_delete(way.id());
} else {
if (m_append) {
m_data->way_modify(way);
} else {
m_data->way_add(way);
}
}
m_stats.add_way(way.id());
}