本文整理汇总了C++中osmium::Way类的典型用法代码示例。如果您正苦于以下问题:C++ Way类的具体用法?C++ Way怎么用?C++ Way使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Way类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:TheMarex,项目名称:streetname-fixer,代码行数:35,代码来源:streetname_fixer.cpp
示例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;
}
开发者ID:Nathanael-L,项目名称:osmi-water,代码行数:28,代码来源:waterway.hpp
示例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';
}
开发者ID:Cultrarius,项目名称:libosmium,代码行数:25,代码来源:opl_output_format.hpp
示例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);
}
开发者ID:hydrays,项目名称:osrm-backend,代码行数:14,代码来源:segment_list.hpp
示例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;
}
开发者ID:alex85k,项目名称:osm2pgsql,代码行数:27,代码来源:segment_list.hpp
示例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;
}
开发者ID:Nathanael-L,项目名称:osmi-water,代码行数:11,代码来源:waterway.hpp
示例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;
}
}
开发者ID:hydrays,项目名称:osrm-backend,代码行数:8,代码来源:factory.hpp
示例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";
}
}
开发者ID:osmcode,项目名称:osm-gis-export,代码行数:9,代码来源:osm_gis_export_overview.cpp
示例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();
}
开发者ID:Pdegoffau,项目名称:libosmium,代码行数:10,代码来源:check_order.hpp
示例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);
}
}
}
开发者ID:NDrive,项目名称:osm-history-splitter,代码行数:14,代码来源:cut_administrative.hpp
示例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;
}
}
}
开发者ID:osmcode,项目名称:osmium-tool,代码行数:11,代码来源:strategy_complete_ways.cpp
示例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();
}
开发者ID:hydrays,项目名称:osrm-backend,代码行数:12,代码来源:osmium_change_tags.cpp
示例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;
}
}
开发者ID:dekstop,项目名称:osm-history-parser,代码行数:11,代码来源:way_node_history.cpp
示例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
}
}
}
开发者ID:Androidized,项目名称:osrm-backend,代码行数:18,代码来源:multipolygon_collector.hpp
示例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());
}
开发者ID:tomhughes,项目名称:osm2pgsql,代码行数:13,代码来源:parse-osmium.cpp
示例16: way
void way(osmium::Way& w) {
++utak;
osmium::WayNodeList& wnl = w.nodes();
std::vector<osmium::unsigned_object_id_type> nds;
for( osmium::NodeRef& n : wnl )
{
nds.emplace_back(n.ref());
}
way_node_map[w.id()] = nds;
nds.clear();
}
开发者ID:szabob94,项目名称:vedes4,代码行数:13,代码来源:bus-stops.cpp
示例17: way
void way(const osmium::Way& way) {
if (m_max_relation_id > std::numeric_limits<osmium::object_id_type>::min()) {
throw out_of_order_error{"Found a way after a relation.", way.id()};
}
if (m_max_way_id == way.id()) {
throw out_of_order_error{"Way ID twice in input. Maybe you are using a history or change file?", way.id()};
}
if (id_order{}(way.id(), m_max_way_id)) {
throw out_of_order_error{"Way IDs out of order.", way.id()};
}
m_max_way_id = way.id();
}
开发者ID:openstreetmap,项目名称:osm2pgsql,代码行数:13,代码来源:check_order.hpp
示例18: getNodeDistance
double getNodeDistance(osmium::Way& w)
{
const char* way = w.tags() ["highway"];
const char* maxspeed = w.tags() ["maxspeed"];
double nodeDistance;
// std::cout<<way<<std::endl;
if(!maxspeed)
{
if(!strcmp (way, "primary")
|| !strcmp (way, "secondary")
|| !strcmp (way,"tertiary")
|| !strcmp (way, "unclassified")
|| !strcmp (way ,"road")
|| !strcmp (way, "primary_link")
|| !strcmp (way, "secondary_link"))
{
maxspeed = "90";
}
if(!strcmp(way,"trunk")
|| !strcmp(way,"trunk_link"))
{
maxspeed = "110";
}
if(!strcmp(way, "motorway"))
{
maxspeed = "130";
}
if(!strcmp (way, "residential")
|| !strcmp (way, "track"))
{
maxspeed = "50";
}
if(!strcmp (way, "platform")
|| !strcmp (way, "service")
|| !strcmp (way, "path")
|| !strcmp (way, "living_street"))
{
maxspeed = "20";
}
}
else
maxspeed = "30";
nodeDistance = atoi(maxspeed) * 0.2 / 3.6;
return nodeDistance;
}
开发者ID:Benyuss,项目名称:robocar-emulator,代码行数:50,代码来源:osmreader.hpp
示例19: way
// Many pubs are mapped as a way (often tagged as building=yes too).
// Potentially a pub could be mapped as just building=pub - but this is exceedingly rare, so it is not tested here
void way(const osmium::Way& way) {
const char* amenity = way.tags().get_value_by_key("amenity");
if (amenity && !strcmp(amenity, "pub")) {
// For such buildings one may want to confirm the way is closed before doing more processing eg:
//if (!way.is_closed()) {
// return;
//}
// However for just listing names, the above check is not really necessary
const char* name = way.tags().get_value_by_key("name");
if (name) {
std::cout << name << std::endl;
}
}
}
开发者ID:rnorris,项目名称:osmium-contrib,代码行数:16,代码来源:pub_names.cpp
示例20: 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);
}
}
}
}
}
开发者ID:Nathanael-L,项目名称:osmi-water,代码行数:21,代码来源:falsepositives.hpp
注:本文中的osmium::Way类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论