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


C++ Way::id方法代码示例

本文整理汇总了C++中osmium::Way::id方法的典型用法代码示例。如果您正苦于以下问题:C++ Way::id方法的具体用法?C++ Way::id怎么用?C++ Way::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在osmium::Way的用法示例。


在下文中一共展示了Way::id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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

示例2: 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);
            }
        }

    }
}
开发者ID:openstreetmap,项目名称:osm2pgsql,代码行数:32,代码来源:output-pgsql.cpp

示例3: way

    void way(const osmium::Way& way) {
        // detect a new way
        if (current_way_id != 0 && current_way_id != way.id()) {
            write_way_extra_nodes();
            current_way_nodes.clear();
        }
        current_way_id = way.id();

        if (debug) {
            std::cerr << "softcut way " << way.id() << " v" << way.version() << "\n";
        }

        for (const auto& node_ref : way.nodes()) {
            current_way_nodes.insert(node_ref.ref());
        }

        for (const auto& extract : info->extracts) {
            for (const auto& node_ref : way.nodes()) {
                if (extract->node_tracker.get(node_ref.ref())) {
                    if (debug) {
                        std::cerr << "way has a node (" << node_ref.ref() << ") inside extract, recording in way_tracker\n";
                    }
                    extract->way_tracker.set(way.id());
                    break;
                }
            }
        }
    }
开发者ID:NDrive,项目名称:osm-history-splitter,代码行数:28,代码来源:softcut.hpp

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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;
            }
开发者ID:Project-OSRM,项目名称:osrm-backend,代码行数:57,代码来源:assembler.hpp

示例10: 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

示例11: 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

示例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;
     }
 }
开发者ID:hydrays,项目名称:osrm-backend,代码行数:8,代码来源:factory.hpp

示例13: way

    void way(const osmium::Way& way) {
        try {
            std::unique_ptr<OGRLineString> ogr_linestring = m_ogr_factory.create_linestring(way);
            OGRFeature* feature = OGRFeature::CreateFeature(m_layer_linestring->GetLayerDefn());
            feature->SetGeometry(ogr_linestring.get());
            feature->SetField("id", static_cast<double>(way.id()));
            feature->SetField("type", way.tags().get_value_by_key("type"));

            if (m_layer_linestring->CreateFeature(feature) != OGRERR_NONE) {
                std::cerr << "Failed to create feature.\n";
                exit(1);
            }

            OGRFeature::DestroyFeature(feature);
        } catch (osmium::geometry_error&) {
            std::cerr << "Ignoring illegal geometry for way " << way.id() << ".\n";
        }
    }
开发者ID:thomersch,项目名称:libosmium,代码行数:18,代码来源:testdata-multipolygon.cpp

示例14: 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

示例15: 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


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