当前位置: 首页>>代码示例>>C++>>正文


C++ osmium::Way类代码示例

本文整理汇总了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);
    }
开发者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


注:本文中的osmium::Way类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。