Пример #1
0
    Handle<Value> OSMNodeWrap::wkt(const Arguments& args) {
        HandleScope scope;

        std::string wkt { wkt_factory.create_point(wrapped(args.This())) };

        return scope.Close(String::New(wkt.c_str()));
    }
Пример #2
0
    v8::Handle<v8::Value> OSMNodeWrap::wkt(const v8::Arguments& args) {
        v8::HandleScope scope;

        try {
            std::string wkt { wkt_factory.create_point(wrapped(args.This())) };
            return scope.Close(v8::String::New(wkt.c_str()));
        } catch (std::runtime_error& e) {
            return ThrowException(v8::Exception::Error(v8::String::New(e.what())));
        }
    }
Пример #3
0
#include "catch.hpp"

#include <osmium/geom/mercator_projection.hpp>
#include <osmium/geom/wkt.hpp>

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

TEST_CASE("WKT geometry for point") {
    const osmium::geom::WKTFactory<> factory;
    const std::string wkt{factory.create_point(osmium::Location{3.2, 4.2})};
    REQUIRE(wkt == "POINT(3.2 4.2)");
}

TEST_CASE("WKT geometry for empty point") {
    const osmium::geom::WKTFactory<> factory;
    REQUIRE_THROWS_AS(factory.create_point(osmium::Location()), const osmium::invalid_location&);
}

TEST_CASE("WKT geometry for point in ekwt") {
    const osmium::geom::WKTFactory<> factory{7, osmium::geom::wkt_type::ewkt};

    const std::string wkt{factory.create_point(osmium::Location{3.2, 4.2})};
    REQUIRE(wkt == "SRID=4326;POINT(3.2 4.2)");
}

TEST_CASE("WKT geometry for point in ekwt in web mercator") {
    const osmium::geom::WKTFactory<osmium::geom::MercatorProjection> factory{2, osmium::geom::wkt_type::ewkt};

    const std::string wkt{factory.create_point(osmium::Location{3.2, 4.2})};
    REQUIRE(wkt == "SRID=3857;POINT(356222.37 467961.14)");
Пример #4
0
#include "catch.hpp"

#include <osmium/builder/builder_helper.hpp>
#include <osmium/geom/wkt.hpp>

#include "../basic/helper.hpp"

TEST_CASE("WKT_Geometry") {

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

    std::string wkt {factory.create_point(osmium::Location(3.2, 4.2))};
    REQUIRE(std::string{"POINT(3.2 4.2)"} == wkt);
}

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

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

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

    osmium::memory::Buffer buffer(10000);
    auto& wnl = osmium::builder::build_way_node_list(buffer, {
        {1, {3.2, 4.2}},
        {3, {3.5, 4.7}},
        {4, {3.5, 4.7}},
        {2, {3.6, 4.9}}