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


C++ OGRFactory::create_point方法代码示例

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


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

示例1: node

    void node(const osmium::Node& node) {
        const char* label = node.tags().get_value_by_key("label");
        if (label) {
            OGRFeature* feature = OGRFeature::CreateFeature(m_layer_labels->GetLayerDefn());
            std::unique_ptr<OGRPoint> ogr_point = m_factory.create_point(node);
            feature->SetGeometry(ogr_point.get());
            feature->SetField("id", static_cast<double>(node.id()));
            feature->SetField("label", label);

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

            OGRFeature::DestroyFeature(feature);
        } else {
            OGRFeature* feature = OGRFeature::CreateFeature(m_layer_nodes->GetLayerDefn());
            std::unique_ptr<OGRPoint> ogr_point = m_factory.create_point(node);
            feature->SetGeometry(ogr_point.get());
            feature->SetField("id", static_cast<double>(node.id()));

            if (m_layer_nodes->CreateFeature(feature) != OGRERR_NONE) {
                std::cerr << "Failed to create feature.\n";
                exit(1);
            }
            OGRFeature::DestroyFeature(feature);
        }
    }
开发者ID:7890,项目名称:osrm-backend,代码行数:28,代码来源:testdata-overview.cpp

示例2: write_point

 void write_point(const char* problem_type, osmium::object_id_type id1, osmium::object_id_type id2, osmium::Location location) {
     gdalcpp::Feature feature(m_layer_perror, m_ogr_factory.create_point(location));
     feature.set_field("id1", static_cast<double>(id1));
     feature.set_field("id2", static_cast<double>(id2));
     feature.set_field("problem_type", problem_type);
     feature.add_to_layer();
 }
开发者ID:dforsi,项目名称:libosmium,代码行数:7,代码来源:problem_reporter_ogr.hpp

示例3: write_line

            void write_line(const char* problem_type, osmium::object_id_type id1, osmium::object_id_type id2, osmium::Location loc1, osmium::Location loc2) {
                std::unique_ptr<OGRPoint> ogr_point1 = m_ogr_factory.create_point(loc1);
                std::unique_ptr<OGRPoint> ogr_point2 = m_ogr_factory.create_point(loc2);
                std::unique_ptr<OGRLineString> ogr_linestring = std::unique_ptr<OGRLineString>(new OGRLineString());
                ogr_linestring->addPoint(ogr_point1.get());
                ogr_linestring->addPoint(ogr_point2.get());

                gdalcpp::Feature feature(m_layer_lerror, std::move(ogr_linestring));
                feature.set_field("id1", static_cast<double>(id1));
                feature.set_field("id2", static_cast<double>(id2));
                feature.set_field("problem_type", problem_type);
                feature.add_to_layer();
            }
开发者ID:dforsi,项目名称:libosmium,代码行数:13,代码来源:problem_reporter_ogr.hpp

示例4: write_point

            void write_point(const char* problem_type, osmium::object_id_type id1, osmium::object_id_type id2, osmium::Location location) {
                OGRFeature* feature = OGRFeature::CreateFeature(m_layer_perror->GetLayerDefn());
                std::unique_ptr<OGRPoint> ogr_point = m_ogr_factory.create_point(location);
                feature->SetGeometry(ogr_point.get());
                feature->SetField("id1", static_cast<double>(id1));
                feature->SetField("id2", static_cast<double>(id2));
                feature->SetField("problem_type", problem_type);

                if (m_layer_perror->CreateFeature(feature) != OGRERR_NONE) {
                    std::runtime_error("Failed to create feature on layer 'perrors'");
                }

                OGRFeature::DestroyFeature(feature);
            }
开发者ID:7890,项目名称:osrm-backend,代码行数:14,代码来源:problem_reporter_ogr.hpp

示例5: node

    void node(const osmium::Node& node) {
        const char* amenity = node.tags()["amenity"];
        if (amenity && !strcmp(amenity, "post_box")) {
            OGRFeature* feature = OGRFeature::CreateFeature(m_layer_point->GetLayerDefn());
            std::unique_ptr<OGRPoint> ogr_point = m_factory.create_point(node);
            feature->SetGeometry(ogr_point.get());
            feature->SetField("id", static_cast<double>(node.id()));
            feature->SetField("operator", node.tags()["operator"]);

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

            OGRFeature::DestroyFeature(feature);
        }
    }
开发者ID:ipaddr,项目名称:omim,代码行数:17,代码来源:osmium_toogr2_exp.cpp

示例6: write_line

            void write_line(const char* problem_type, osmium::object_id_type id1, osmium::object_id_type id2, osmium::Location loc1, osmium::Location loc2) {
                std::unique_ptr<OGRPoint> ogr_point1 = m_ogr_factory.create_point(loc1);
                std::unique_ptr<OGRPoint> ogr_point2 = m_ogr_factory.create_point(loc2);
                std::unique_ptr<OGRLineString> ogr_linestring = std::unique_ptr<OGRLineString>(new OGRLineString());
                ogr_linestring->addPoint(ogr_point1.get());
                ogr_linestring->addPoint(ogr_point2.get());
                OGRFeature* feature = OGRFeature::CreateFeature(m_layer_lerror->GetLayerDefn());
                feature->SetGeometry(ogr_linestring.get());
                feature->SetField("id1", static_cast<double>(id1));
                feature->SetField("id2", static_cast<double>(id2));
                feature->SetField("problem_type", problem_type);

                if (m_layer_lerror->CreateFeature(feature) != OGRERR_NONE) {
                    std::runtime_error("Failed to create feature on layer 'lerrors'");
                }

                OGRFeature::DestroyFeature(feature);
            }
开发者ID:7890,项目名称:osrm-backend,代码行数:18,代码来源:problem_reporter_ogr.hpp

示例7: REQUIRE

#include "catch.hpp"

#include <osmium/geom/ogr.hpp>

#include "area_helper.hpp"
#include "wnl_helper.hpp"

TEST_CASE("OGR_Geometry") {

SECTION("point") {
    osmium::geom::OGRFactory<> factory;

    std::unique_ptr<OGRPoint> point {factory.create_point(osmium::Location(3.2, 4.2))};
    REQUIRE(3.2 == point->getX());
    REQUIRE(4.2 == point->getY());
}

SECTION("empty_point") {
    osmium::geom::OGRFactory<> factory;

    REQUIRE_THROWS_AS(factory.create_point(osmium::Location()), osmium::invalid_location);
}

SECTION("linestring") {
    osmium::geom::OGRFactory<> factory;

    osmium::memory::Buffer buffer(10000);
    auto &wnl = create_test_wnl_okay(buffer);

    {
        std::unique_ptr<OGRLineString> linestring {factory.create_linestring(wnl)};
开发者ID:7ute,项目名称:osrm-backend,代码行数:31,代码来源:test_ogr.cpp

示例8: to_wkb

std::string to_wkb(const OGRGeometry* geometry) {
    std::string buffer;
    buffer.resize(geometry->WkbSize());

    geometry->exportToWkb(wkbNDR, reinterpret_cast<unsigned char*>(&*buffer.begin()));

    return buffer;
}

TEST_CASE("compare WKB point against GDAL/OGR") {
    osmium::geom::WKBFactory<> wkb_factory{osmium::geom::wkb_type::wkb};
    osmium::geom::OGRFactory<> ogr_factory;

    const osmium::Location loc{3.2, 4.2};
    const std::string wkb{wkb_factory.create_point(loc)};
    const std::unique_ptr<OGRPoint> geometry = ogr_factory.create_point(loc);
    REQUIRE(to_wkb(geometry.get()) == wkb);
}

TEST_CASE("compare WKB linestring against GDAL/OGR") {
    osmium::geom::WKBFactory<> wkb_factory{osmium::geom::wkb_type::wkb};
    osmium::geom::OGRFactory<> ogr_factory;
    osmium::memory::Buffer buffer{10000};

    const auto& wnl = create_test_wnl_okay(buffer);

    SECTION("linestring") {
        const std::string wkb{wkb_factory.create_linestring(wnl)};
        const std::unique_ptr<OGRLineString> geometry = ogr_factory.create_linestring(wnl);
        REQUIRE(to_wkb(geometry.get()) == wkb);
    }
开发者ID:osmcode,项目名称:libosmium,代码行数:31,代码来源:test_ogr_wkb.cpp


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