Squashed 'third_party/libosmium/' content from commit 910f8f1

git-subtree-dir: third_party/libosmium
git-subtree-split: 910f8f1e992402e0f1acd0132eaffa7539ca83d2
This commit is contained in:
Dennis Luxen
2015-01-13 16:54:25 +01:00
commit 73efcc6b0c
235 changed files with 53733 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
#ifndef TEST_GEOM_HELPER_HPP
#define TEST_GEOM_HELPER_HPP
#include <string>
#include <geos/io/WKBWriter.h>
inline std::string geos_to_wkb(const geos::geom::Geometry* geometry) {
std::stringstream ss;
geos::io::WKBWriter wkb_writer;
wkb_writer.writeHEX(*geometry, ss);
return ss.str();
}
#endif // TEST_GEOM_HELPER_HPP
@@ -0,0 +1,41 @@
#include "catch.hpp"
#include <osmium/geom/geos.hpp>
#include <osmium/geom/mercator_projection.hpp>
#include <osmium/geom/projection.hpp>
#include <osmium/geom/wkb.hpp>
#include <osmium/geom/wkt.hpp>
#include "helper.hpp"
TEST_CASE("Projection") {
SECTION("point_mercator") {
osmium::geom::WKTFactory<osmium::geom::MercatorProjection> factory(2);
std::string wkt {factory.create_point(osmium::Location(3.2, 4.2))};
REQUIRE(std::string{"POINT(356222.37 467961.14)"} == wkt);
}
SECTION("point_epsg_3857") {
osmium::geom::WKTFactory<osmium::geom::Projection> factory(osmium::geom::Projection(3857), 2);
std::string wkt {factory.create_point(osmium::Location(3.2, 4.2))};
REQUIRE(std::string{"POINT(356222.37 467961.14)"} == wkt);
}
SECTION("wkb_with_parameter") {
osmium::geom::WKBFactory<osmium::geom::Projection> wkb_factory(osmium::geom::Projection(3857), osmium::geom::wkb_type::wkb, osmium::geom::out_type::hex);
osmium::geom::GEOSFactory<osmium::geom::Projection> geos_factory(osmium::geom::Projection(3857));
std::string wkb = wkb_factory.create_point(osmium::Location(3.2, 4.2));
std::unique_ptr<geos::geom::Point> geos_point = geos_factory.create_point(osmium::Location(3.2, 4.2));
REQUIRE(geos_to_wkb(geos_point.get()) == wkb);
}
SECTION("cleanup") {
// trying to make valgrind happy, but there is still a memory leak in proj library
pj_deallocate_grids();
}
}
+236
View File
@@ -0,0 +1,236 @@
#include "catch.hpp"
#include <osmium/builder/builder_helper.hpp>
#include <osmium/geom/geojson.hpp>
#include "../basic/helper.hpp"
TEST_CASE("GeoJSON_Geometry") {
SECTION("point") {
osmium::geom::GeoJSONFactory<> factory;
std::string json {factory.create_point(osmium::Location(3.2, 4.2))};
REQUIRE(std::string{"{\"type\":\"Point\",\"coordinates\":[3.2,4.2]}"} == json);
}
SECTION("empty_point") {
osmium::geom::GeoJSONFactory<> factory;
REQUIRE_THROWS_AS(factory.create_point(osmium::Location()), osmium::invalid_location);
}
SECTION("linestring") {
osmium::geom::GeoJSONFactory<> 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}}
});
{
std::string json {factory.create_linestring(wnl)};
REQUIRE(std::string{"{\"type\":\"LineString\",\"coordinates\":[[3.2,4.2],[3.5,4.7],[3.6,4.9]]}"} == json);
}
{
std::string json {factory.create_linestring(wnl, osmium::geom::use_nodes::unique, osmium::geom::direction::backward)};
REQUIRE(std::string{"{\"type\":\"LineString\",\"coordinates\":[[3.6,4.9],[3.5,4.7],[3.2,4.2]]}"} == json);
}
{
std::string json {factory.create_linestring(wnl, osmium::geom::use_nodes::all)};
REQUIRE(std::string{"{\"type\":\"LineString\",\"coordinates\":[[3.2,4.2],[3.5,4.7],[3.5,4.7],[3.6,4.9]]}"} == json);
}
{
std::string json {factory.create_linestring(wnl, osmium::geom::use_nodes::all, osmium::geom::direction::backward)};
REQUIRE(std::string{"{\"type\":\"LineString\",\"coordinates\":[[3.6,4.9],[3.5,4.7],[3.5,4.7],[3.2,4.2]]}"} == json);
}
}
SECTION("empty_linestring") {
osmium::geom::GeoJSONFactory<> factory;
osmium::memory::Buffer buffer(10000);
auto& wnl = osmium::builder::build_way_node_list(buffer, {});
REQUIRE_THROWS_AS(factory.create_linestring(wnl), osmium::geometry_error);
REQUIRE_THROWS_AS(factory.create_linestring(wnl, osmium::geom::use_nodes::unique, osmium::geom::direction::backward), osmium::geometry_error);
REQUIRE_THROWS_AS(factory.create_linestring(wnl, osmium::geom::use_nodes::all), osmium::geometry_error);
REQUIRE_THROWS_AS(factory.create_linestring(wnl, osmium::geom::use_nodes::all, osmium::geom::direction::backward), osmium::geometry_error);
}
SECTION("linestring_with_two_same_locations") {
osmium::geom::GeoJSONFactory<> factory;
osmium::memory::Buffer buffer(10000);
auto& wnl = osmium::builder::build_way_node_list(buffer, {
{1, {3.5, 4.7}},
{2, {3.5, 4.7}}
});
REQUIRE_THROWS_AS(factory.create_linestring(wnl), osmium::geometry_error);
REQUIRE_THROWS_AS(factory.create_linestring(wnl, osmium::geom::use_nodes::unique, osmium::geom::direction::backward), osmium::geometry_error);
{
std::string json {factory.create_linestring(wnl, osmium::geom::use_nodes::all)};
REQUIRE(std::string{"{\"type\":\"LineString\",\"coordinates\":[[3.5,4.7],[3.5,4.7]]}"} == json);
}
{
std::string json {factory.create_linestring(wnl, osmium::geom::use_nodes::all, osmium::geom::direction::backward)};
REQUIRE(std::string{"{\"type\":\"LineString\",\"coordinates\":[[3.5,4.7],[3.5,4.7]]}"} == json);
}
}
SECTION("linestring_with_undefined_location") {
osmium::geom::GeoJSONFactory<> factory;
osmium::memory::Buffer buffer(10000);
auto& wnl = osmium::builder::build_way_node_list(buffer, {
{1, {3.5, 4.7}},
{2, osmium::Location()}
});
REQUIRE_THROWS_AS(factory.create_linestring(wnl), osmium::invalid_location);
}
SECTION("area_1outer_0inner") {
osmium::geom::GeoJSONFactory<> factory;
osmium::memory::Buffer buffer(10000);
osmium::Area& area = buffer_add_area(buffer,
"foo",
{},
{
{ true, {
{1, {3.2, 4.2}},
{2, {3.5, 4.7}},
{3, {3.6, 4.9}},
{1, {3.2, 4.2}}
}}
});
REQUIRE(!area.is_multipolygon());
REQUIRE(std::distance(area.cbegin(), area.cend()) == 2);
REQUIRE(std::distance(area.cbegin<osmium::OuterRing>(), area.cend<osmium::OuterRing>()) == area.num_rings().first);
{
std::string json {factory.create_multipolygon(area)};
REQUIRE(std::string{"{\"type\":\"MultiPolygon\",\"coordinates\":[[[[3.2,4.2],[3.5,4.7],[3.6,4.9],[3.2,4.2]]]]}"} == json);
}
}
SECTION("area_1outer_1inner") {
osmium::geom::GeoJSONFactory<> factory;
osmium::memory::Buffer buffer(10000);
osmium::Area& area = buffer_add_area(buffer,
"foo",
{},
{
{ true, {
{1, {0.1, 0.1}},
{2, {9.1, 0.1}},
{3, {9.1, 9.1}},
{4, {0.1, 9.1}},
{1, {0.1, 0.1}}
}},
{ false, {
{5, {1.0, 1.0}},
{6, {8.0, 1.0}},
{7, {8.0, 8.0}},
{8, {1.0, 8.0}},
{5, {1.0, 1.0}}
}}
});
REQUIRE(!area.is_multipolygon());
REQUIRE(std::distance(area.cbegin(), area.cend()) == 3);
REQUIRE(std::distance(area.cbegin<osmium::OuterRing>(), area.cend<osmium::OuterRing>()) == area.num_rings().first);
REQUIRE(std::distance(area.cbegin<osmium::InnerRing>(), area.cend<osmium::InnerRing>()) == area.num_rings().second);
{
std::string json {factory.create_multipolygon(area)};
REQUIRE(std::string{"{\"type\":\"MultiPolygon\",\"coordinates\":[[[[0.1,0.1],[9.1,0.1],[9.1,9.1],[0.1,9.1],[0.1,0.1]],[[1,1],[8,1],[8,8],[1,8],[1,1]]]]}"} == json);
}
}
SECTION("area_2outer_2inner") {
osmium::geom::GeoJSONFactory<> factory;
osmium::memory::Buffer buffer(10000);
osmium::Area& area = buffer_add_area(buffer,
"foo",
{},
{
{ true, {
{1, {0.1, 0.1}},
{2, {9.1, 0.1}},
{3, {9.1, 9.1}},
{4, {0.1, 9.1}},
{1, {0.1, 0.1}}
}},
{ false, {
{5, {1.0, 1.0}},
{6, {4.0, 1.0}},
{7, {4.0, 4.0}},
{8, {1.0, 4.0}},
{5, {1.0, 1.0}}
}},
{ false, {
{10, {5.0, 5.0}},
{11, {5.0, 7.0}},
{12, {7.0, 7.0}},
{10, {5.0, 5.0}}
}},
{ true, {
{100, {10.0, 10.0}},
{101, {11.0, 10.0}},
{102, {11.0, 11.0}},
{103, {10.0, 11.0}},
{100, {10.0, 10.0}}
}}
});
REQUIRE(area.is_multipolygon());
REQUIRE(std::distance(area.cbegin(), area.cend()) == 5);
REQUIRE(std::distance(area.cbegin<osmium::OuterRing>(), area.cend<osmium::OuterRing>()) == area.num_rings().first);
REQUIRE(std::distance(area.cbegin<osmium::InnerRing>(), area.cend<osmium::InnerRing>()) == area.num_rings().second);
int outer_ring=0;
int inner_ring=0;
for (auto it_outer = area.cbegin<osmium::OuterRing>(); it_outer != area.cend<osmium::OuterRing>(); ++it_outer) {
if (outer_ring == 0) {
REQUIRE(it_outer->front().ref() == 1);
} else if (outer_ring == 1) {
REQUIRE(it_outer->front().ref() == 100);
} else {
REQUIRE(false);
}
for (auto it_inner = area.inner_ring_cbegin(it_outer); it_inner != area.inner_ring_cend(it_outer); ++it_inner) {
if (outer_ring == 0 && inner_ring == 0) {
REQUIRE(it_inner->front().ref() == 5);
} else if (outer_ring == 0 && inner_ring == 1) {
REQUIRE(it_inner->front().ref() == 10);
} else {
REQUIRE(false);
}
++inner_ring;
}
inner_ring = 0;
++outer_ring;
}
{
std::string json {factory.create_multipolygon(area)};
REQUIRE(std::string{"{\"type\":\"MultiPolygon\",\"coordinates\":[[[[0.1,0.1],[9.1,0.1],[9.1,9.1],[0.1,9.1],[0.1,0.1]],[[1,1],[4,1],[4,4],[1,4],[1,1]],[[5,5],[5,7],[7,7],[5,5]]],[[[10,10],[11,10],[11,11],[10,11],[10,10]]]]}"} == json);
}
}
}
+198
View File
@@ -0,0 +1,198 @@
#include "catch.hpp"
#include <osmium/builder/builder_helper.hpp>
#include <osmium/geom/geos.hpp>
#include "../basic/helper.hpp"
TEST_CASE("GEOS_Geometry") {
SECTION("point") {
osmium::geom::GEOSFactory<> factory;
std::unique_ptr<geos::geom::Point> point {factory.create_point(osmium::Location(3.2, 4.2))};
REQUIRE(3.2 == point->getX());
REQUIRE(4.2 == point->getY());
REQUIRE(-1 == point->getSRID());
}
SECTION("non_default_srid") {
osmium::geom::GEOSFactory<> factory(4326);
std::unique_ptr<geos::geom::Point> point {factory.create_point(osmium::Location(3.2, 4.2))};
REQUIRE(3.2 == point->getX());
REQUIRE(4.2 == point->getY());
REQUIRE(4326 == point->getSRID());
}
SECTION("empty_point") {
osmium::geom::GEOSFactory<> factory;
REQUIRE_THROWS_AS(factory.create_point(osmium::Location()), osmium::invalid_location);
}
SECTION("linestring") {
osmium::geom::GEOSFactory<> 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}}
});
{
std::unique_ptr<geos::geom::LineString> linestring {factory.create_linestring(wnl)};
REQUIRE(3 == linestring->getNumPoints());
std::unique_ptr<geos::geom::Point> p0 = std::unique_ptr<geos::geom::Point>(linestring->getPointN(0));
REQUIRE(3.2 == p0->getX());
std::unique_ptr<geos::geom::Point> p2 = std::unique_ptr<geos::geom::Point>(linestring->getPointN(2));
REQUIRE(3.6 == p2->getX());
}
{
std::unique_ptr<geos::geom::LineString> linestring {factory.create_linestring(wnl, osmium::geom::use_nodes::unique, osmium::geom::direction::backward)};
REQUIRE(3 == linestring->getNumPoints());
std::unique_ptr<geos::geom::Point> p0 = std::unique_ptr<geos::geom::Point>(linestring->getPointN(0));
REQUIRE(3.6 == p0->getX());
std::unique_ptr<geos::geom::Point> p2 = std::unique_ptr<geos::geom::Point>(linestring->getPointN(2));
REQUIRE(3.2 == p2->getX());
}
{
std::unique_ptr<geos::geom::LineString> linestring {factory.create_linestring(wnl, osmium::geom::use_nodes::all)};
REQUIRE(4 == linestring->getNumPoints());
std::unique_ptr<geos::geom::Point> p0 = std::unique_ptr<geos::geom::Point>(linestring->getPointN(0));
REQUIRE(3.2 == p0->getX());
}
{
std::unique_ptr<geos::geom::LineString> linestring {factory.create_linestring(wnl, osmium::geom::use_nodes::all, osmium::geom::direction::backward)};
REQUIRE(4 == linestring->getNumPoints());
std::unique_ptr<geos::geom::Point> p0 = std::unique_ptr<geos::geom::Point>(linestring->getPointN(0));
REQUIRE(3.6 == p0->getX());
}
}
SECTION("area_1outer_0inner") {
osmium::geom::GEOSFactory<> factory;
osmium::memory::Buffer buffer(10000);
osmium::Area& area = buffer_add_area(buffer,
"foo",
{},
{
{ true, {
{1, {3.2, 4.2}},
{2, {3.5, 4.7}},
{3, {3.6, 4.9}},
{1, {3.2, 4.2}}
}}
});
std::unique_ptr<geos::geom::MultiPolygon> mp {factory.create_multipolygon(area)};
REQUIRE(1 == mp->getNumGeometries());
const geos::geom::Polygon* p0 = dynamic_cast<const geos::geom::Polygon*>(mp->getGeometryN(0));
REQUIRE(0 == p0->getNumInteriorRing());
const geos::geom::LineString* l0e = p0->getExteriorRing();
REQUIRE(4 == l0e->getNumPoints());
std::unique_ptr<geos::geom::Point> l0e_p0 = std::unique_ptr<geos::geom::Point>(l0e->getPointN(1));
REQUIRE(3.5 == l0e_p0->getX());
}
SECTION("area_1outer_1inner") {
osmium::geom::GEOSFactory<> factory;
osmium::memory::Buffer buffer(10000);
osmium::Area& area = buffer_add_area(buffer,
"foo",
{},
{
{ true, {
{1, {0.1, 0.1}},
{2, {9.1, 0.1}},
{3, {9.1, 9.1}},
{4, {0.1, 9.1}},
{1, {0.1, 0.1}}
}},
{ false, {
{5, {1.0, 1.0}},
{6, {8.0, 1.0}},
{7, {8.0, 8.0}},
{8, {1.0, 8.0}},
{5, {1.0, 1.0}}
}}
});
std::unique_ptr<geos::geom::MultiPolygon> mp {factory.create_multipolygon(area)};
REQUIRE(1 == mp->getNumGeometries());
const geos::geom::Polygon* p0 = dynamic_cast<const geos::geom::Polygon*>(mp->getGeometryN(0));
REQUIRE(1 == p0->getNumInteriorRing());
const geos::geom::LineString* l0e = p0->getExteriorRing();
REQUIRE(5 == l0e->getNumPoints());
const geos::geom::LineString* l0i0 = p0->getInteriorRingN(0);
REQUIRE(5 == l0i0->getNumPoints());
}
SECTION("area_2outer_2inner") {
osmium::geom::GEOSFactory<> factory;
osmium::memory::Buffer buffer(10000);
osmium::Area& area = buffer_add_area(buffer,
"foo",
{},
{
{ true, {
{1, {0.1, 0.1}},
{2, {9.1, 0.1}},
{3, {9.1, 9.1}},
{4, {0.1, 9.1}},
{1, {0.1, 0.1}}
}},
{ false, {
{5, {1.0, 1.0}},
{6, {4.0, 1.0}},
{7, {4.0, 4.0}},
{8, {1.0, 4.0}},
{5, {1.0, 1.0}}
}},
{ false, {
{10, {5.0, 5.0}},
{11, {5.0, 7.0}},
{12, {7.0, 7.0}},
{10, {5.0, 5.0}}
}},
{ true, {
{100, {10.0, 10.0}},
{101, {11.0, 10.0}},
{102, {11.0, 11.0}},
{103, {10.0, 11.0}},
{100, {10.0, 10.0}}
}}
});
std::unique_ptr<geos::geom::MultiPolygon> mp {factory.create_multipolygon(area)};
REQUIRE(2 == mp->getNumGeometries());
const geos::geom::Polygon* p0 = dynamic_cast<const geos::geom::Polygon*>(mp->getGeometryN(0));
REQUIRE(2 == p0->getNumInteriorRing());
const geos::geom::LineString* l0e = p0->getExteriorRing();
REQUIRE(5 == l0e->getNumPoints());
const geos::geom::Polygon* p1 = dynamic_cast<const geos::geom::Polygon*>(mp->getGeometryN(1));
REQUIRE(0 == p1->getNumInteriorRing());
const geos::geom::LineString* l1e = p1->getExteriorRing();
REQUIRE(5 == l1e->getNumPoints());
}
}
+156
View File
@@ -0,0 +1,156 @@
#include "catch.hpp"
#include <osmium/builder/builder_helper.hpp>
#include <osmium/geom/geos.hpp>
#include <osmium/geom/wkb.hpp>
#include "../basic/helper.hpp"
#include "helper.hpp"
TEST_CASE("WKB_Geometry_with_GEOS") {
SECTION("point") {
osmium::geom::WKBFactory<> wkb_factory(osmium::geom::wkb_type::wkb, osmium::geom::out_type::hex);
osmium::geom::GEOSFactory<> geos_factory;
std::string wkb {wkb_factory.create_point(osmium::Location(3.2, 4.2))};
std::unique_ptr<geos::geom::Point> geos_point = geos_factory.create_point(osmium::Location(3.2, 4.2));
REQUIRE(geos_to_wkb(geos_point.get()) == wkb);
}
SECTION("linestring") {
osmium::geom::WKBFactory<> wkb_factory(osmium::geom::wkb_type::wkb, osmium::geom::out_type::hex);
osmium::geom::GEOSFactory<> geos_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}}
});
{
std::string wkb = wkb_factory.create_linestring(wnl);
std::unique_ptr<geos::geom::LineString> geos = geos_factory.create_linestring(wnl);
REQUIRE(geos_to_wkb(geos.get()) == wkb);
}
{
std::string wkb = wkb_factory.create_linestring(wnl, osmium::geom::use_nodes::unique, osmium::geom::direction::backward);
std::unique_ptr<geos::geom::LineString> geos = geos_factory.create_linestring(wnl, osmium::geom::use_nodes::unique, osmium::geom::direction::backward);
REQUIRE(geos_to_wkb(geos.get()) == wkb);
}
{
std::string wkb = wkb_factory.create_linestring(wnl, osmium::geom::use_nodes::all);
std::unique_ptr<geos::geom::LineString> geos = geos_factory.create_linestring(wnl, osmium::geom::use_nodes::all);
REQUIRE(geos_to_wkb(geos.get()) == wkb);
}
{
std::string wkb = wkb_factory.create_linestring(wnl, osmium::geom::use_nodes::all, osmium::geom::direction::backward);
std::unique_ptr<geos::geom::LineString> geos = geos_factory.create_linestring(wnl, osmium::geom::use_nodes::all, osmium::geom::direction::backward);
REQUIRE(geos_to_wkb(geos.get()) == wkb);
}
}
SECTION("area_1outer_0inner") {
osmium::geom::WKBFactory<> wkb_factory(osmium::geom::wkb_type::wkb, osmium::geom::out_type::hex);
osmium::geom::GEOSFactory<> geos_factory;
osmium::memory::Buffer buffer(10000);
osmium::Area& area = buffer_add_area(buffer,
"foo",
{},
{
{ true, {
{1, {3.2, 4.2}},
{2, {3.5, 4.7}},
{3, {3.6, 4.9}},
{1, {3.2, 4.2}}
}}
});
std::string wkb = wkb_factory.create_multipolygon(area);
std::unique_ptr<geos::geom::MultiPolygon> geos = geos_factory.create_multipolygon(area);
REQUIRE(geos_to_wkb(geos.get()) == wkb);
}
SECTION("area_1outer_1inner") {
osmium::geom::WKBFactory<> wkb_factory(osmium::geom::wkb_type::wkb, osmium::geom::out_type::hex);
osmium::geom::GEOSFactory<> geos_factory;
osmium::memory::Buffer buffer(10000);
osmium::Area& area = buffer_add_area(buffer,
"foo",
{},
{
{ true, {
{1, {0.1, 0.1}},
{2, {9.1, 0.1}},
{3, {9.1, 9.1}},
{4, {0.1, 9.1}},
{1, {0.1, 0.1}}
}},
{ false, {
{5, {1.0, 1.0}},
{6, {8.0, 1.0}},
{7, {8.0, 8.0}},
{8, {1.0, 8.0}},
{5, {1.0, 1.0}}
}}
});
std::string wkb = wkb_factory.create_multipolygon(area);
std::unique_ptr<geos::geom::MultiPolygon> geos = geos_factory.create_multipolygon(area);
REQUIRE(geos_to_wkb(geos.get()) == wkb);
}
SECTION("area_2outer_2inner") {
osmium::geom::WKBFactory<> wkb_factory(osmium::geom::wkb_type::wkb, osmium::geom::out_type::hex);
osmium::geom::GEOSFactory<> geos_factory;
osmium::memory::Buffer buffer(10000);
osmium::Area& area = buffer_add_area(buffer,
"foo",
{},
{
{ true, {
{1, {0.1, 0.1}},
{2, {9.1, 0.1}},
{3, {9.1, 9.1}},
{4, {0.1, 9.1}},
{1, {0.1, 0.1}}
}},
{ false, {
{5, {1.0, 1.0}},
{6, {4.0, 1.0}},
{7, {4.0, 4.0}},
{8, {1.0, 4.0}},
{5, {1.0, 1.0}}
}},
{ false, {
{10, {5.0, 5.0}},
{11, {5.0, 7.0}},
{12, {7.0, 7.0}},
{10, {5.0, 5.0}}
}},
{ true, {
{100, {10.0, 10.0}},
{101, {11.0, 10.0}},
{102, {11.0, 11.0}},
{103, {10.0, 11.0}},
{100, {10.0, 10.0}}
}}
});
std::string wkb = wkb_factory.create_multipolygon(area);
std::unique_ptr<geos::geom::MultiPolygon> geos = geos_factory.create_multipolygon(area);
REQUIRE(geos_to_wkb(geos.get()) == wkb);
}
}
+37
View File
@@ -0,0 +1,37 @@
#include "catch.hpp"
#include <osmium/geom/mercator_projection.hpp>
TEST_CASE("Mercator") {
SECTION("mercator_projection") {
osmium::geom::MercatorProjection projection;
REQUIRE(3857 == projection.epsg());
REQUIRE("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs" == projection.proj_string());
}
SECTION("low_level_mercator_functions") {
osmium::geom::Coordinates c1(17.839, -3.249);
osmium::geom::Coordinates r1 = osmium::geom::mercator_to_lonlat(osmium::geom::lonlat_to_mercator(c1));
REQUIRE(std::abs(c1.x - r1.x) < 0.000001);
REQUIRE(std::abs(c1.y - r1.y) < 0.000001);
osmium::geom::Coordinates c2(-89.2, 15.915);
osmium::geom::Coordinates r2 = osmium::geom::mercator_to_lonlat(osmium::geom::lonlat_to_mercator(c2));
REQUIRE(std::abs(c2.x - r2.x) < 0.000001);
REQUIRE(std::abs(c2.y - r2.y) < 0.000001);
osmium::geom::Coordinates c3(180.0, 85.0);
osmium::geom::Coordinates r3 = osmium::geom::mercator_to_lonlat(osmium::geom::lonlat_to_mercator(c3));
REQUIRE(std::abs(c3.x - r3.x) < 0.000001);
REQUIRE(std::abs(c3.y - r3.y) < 0.000001);
}
SECTION("mercator_bounds") {
osmium::Location mmax(180.0, osmium::geom::MERCATOR_MAX_LAT);
osmium::geom::Coordinates c = osmium::geom::lonlat_to_mercator(mmax);
REQUIRE((c.x - c.y) < 0.001);
REQUIRE((osmium::geom::MERCATOR_MAX_LAT - osmium::geom::detail::y_to_lat(osmium::geom::detail::lon_to_x(180.0))) < 0.0000001);
}
}
+185
View File
@@ -0,0 +1,185 @@
#include "catch.hpp"
#include <osmium/builder/builder_helper.hpp>
#include <osmium/geom/ogr.hpp>
#include "../basic/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 = 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}}
});
{
std::unique_ptr<OGRLineString> linestring {factory.create_linestring(wnl)};
REQUIRE(3 == linestring->getNumPoints());
REQUIRE(3.2 == linestring->getX(0));
REQUIRE(3.6 == linestring->getX(2));
}
{
std::unique_ptr<OGRLineString> linestring {factory.create_linestring(wnl, osmium::geom::use_nodes::unique, osmium::geom::direction::backward)};
REQUIRE(3 == linestring->getNumPoints());
REQUIRE(3.6 == linestring->getX(0));
REQUIRE(3.2 == linestring->getX(2));
}
{
std::unique_ptr<OGRLineString> linestring {factory.create_linestring(wnl, osmium::geom::use_nodes::all)};
REQUIRE(4 == linestring->getNumPoints());
REQUIRE(3.2 == linestring->getX(0));
}
{
std::unique_ptr<OGRLineString> linestring {factory.create_linestring(wnl, osmium::geom::use_nodes::all, osmium::geom::direction::backward)};
REQUIRE(4 == linestring->getNumPoints());
REQUIRE(3.6 == linestring->getX(0));
}
}
SECTION("area_1outer_0inner") {
osmium::geom::OGRFactory<> factory;
osmium::memory::Buffer buffer(10000);
osmium::Area& area = buffer_add_area(buffer,
"foo",
{},
{
{ true, {
{1, {3.2, 4.2}},
{2, {3.5, 4.7}},
{3, {3.6, 4.9}},
{1, {3.2, 4.2}}
}}
});
std::unique_ptr<OGRMultiPolygon> mp {factory.create_multipolygon(area)};
REQUIRE(1 == mp->getNumGeometries());
const OGRPolygon* p0 = dynamic_cast<const OGRPolygon*>(mp->getGeometryRef(0));
REQUIRE(0 == p0->getNumInteriorRings());
const OGRLineString* l0e = p0->getExteriorRing();
REQUIRE(4 == l0e->getNumPoints());
REQUIRE(3.5 == l0e->getX(1));
}
SECTION("area_1outer_1inner") {
osmium::geom::OGRFactory<> factory;
osmium::memory::Buffer buffer(10000);
osmium::Area& area = buffer_add_area(buffer,
"foo",
{},
{
{ true, {
{1, {0.1, 0.1}},
{2, {9.1, 0.1}},
{3, {9.1, 9.1}},
{4, {0.1, 9.1}},
{1, {0.1, 0.1}}
}},
{ false, {
{5, {1.0, 1.0}},
{6, {8.0, 1.0}},
{7, {8.0, 8.0}},
{8, {1.0, 8.0}},
{5, {1.0, 1.0}}
}}
});
std::unique_ptr<OGRMultiPolygon> mp {factory.create_multipolygon(area)};
REQUIRE(1 == mp->getNumGeometries());
const OGRPolygon* p0 = dynamic_cast<const OGRPolygon*>(mp->getGeometryRef(0));
REQUIRE(1 == p0->getNumInteriorRings());
const OGRLineString* l0e = p0->getExteriorRing();
REQUIRE(5 == l0e->getNumPoints());
const OGRLineString* l0i0 = p0->getInteriorRing(0);
REQUIRE(5 == l0i0->getNumPoints());
}
SECTION("area_2outer_2inner") {
osmium::geom::OGRFactory<> factory;
osmium::memory::Buffer buffer(10000);
osmium::Area& area = buffer_add_area(buffer,
"foo",
{},
{
{ true, {
{1, {0.1, 0.1}},
{2, {9.1, 0.1}},
{3, {9.1, 9.1}},
{4, {0.1, 9.1}},
{1, {0.1, 0.1}}
}},
{ false, {
{5, {1.0, 1.0}},
{6, {4.0, 1.0}},
{7, {4.0, 4.0}},
{8, {1.0, 4.0}},
{5, {1.0, 1.0}}
}},
{ false, {
{10, {5.0, 5.0}},
{11, {5.0, 7.0}},
{12, {7.0, 7.0}},
{10, {5.0, 5.0}}
}},
{ true, {
{100, {10.0, 10.0}},
{101, {11.0, 10.0}},
{102, {11.0, 11.0}},
{103, {10.0, 11.0}},
{100, {10.0, 10.0}}
}}
});
std::unique_ptr<OGRMultiPolygon> mp {factory.create_multipolygon(area)};
REQUIRE(2 == mp->getNumGeometries());
const OGRPolygon* p0 = dynamic_cast<const OGRPolygon*>(mp->getGeometryRef(0));
REQUIRE(2 == p0->getNumInteriorRings());
const OGRLineString* l0e = p0->getExteriorRing();
REQUIRE(5 == l0e->getNumPoints());
const OGRPolygon* p1 = dynamic_cast<const OGRPolygon*>(mp->getGeometryRef(1));
REQUIRE(0 == p1->getNumInteriorRings());
const OGRLineString* l1e = p1->getExteriorRing();
REQUIRE(5 == l1e->getNumPoints());
}
}
+131
View File
@@ -0,0 +1,131 @@
#include "catch.hpp"
#include <osmium/geom/factory.hpp>
#include <osmium/geom/mercator_projection.hpp>
#include <osmium/geom/projection.hpp>
TEST_CASE("Projection") {
SECTION("identity_projection") {
osmium::geom::IdentityProjection projection;
REQUIRE(4326 == projection.epsg());
REQUIRE("+proj=longlat +datum=WGS84 +no_defs" == projection.proj_string());
}
SECTION("project_location_4326") {
osmium::geom::Projection projection(4326);
REQUIRE(4326 == projection.epsg());
REQUIRE("+init=epsg:4326" == projection.proj_string());
const osmium::Location loc(1.0, 2.0);
const osmium::geom::Coordinates c {1.0, 2.0};
REQUIRE(c == projection(loc));
}
SECTION("project_location_4326_string") {
osmium::geom::Projection projection("+init=epsg:4326");
REQUIRE(-1 == projection.epsg());
REQUIRE("+init=epsg:4326" == projection.proj_string());
const osmium::Location loc(1.0, 2.0);
const osmium::geom::Coordinates c {1.0, 2.0};
REQUIRE(c == projection(loc));
}
SECTION("unknown_projection_string") {
REQUIRE_THROWS_AS(osmium::geom::Projection projection("abc"), osmium::projection_error);
}
SECTION("unknown_epsg_code") {
REQUIRE_THROWS_AS(osmium::geom::Projection projection(9999999), osmium::projection_error);
}
SECTION("project_location_3857") {
osmium::geom::Projection projection(3857);
REQUIRE(3857 == projection.epsg());
REQUIRE("+init=epsg:3857" == projection.proj_string());
{
const osmium::Location loc(0.0, 0.0);
const osmium::geom::Coordinates c {0.0, 0.0};
REQUIRE(std::abs(projection(loc).x - c.x) < 0.1);
REQUIRE(std::abs(projection(loc).y - c.y) < 0.1);
}
{
const osmium::Location loc(180.0, 0.0);
const osmium::geom::Coordinates c {20037508.34, 0.0};
REQUIRE(std::abs(projection(loc).x - c.x) < 0.1);
REQUIRE(std::abs(projection(loc).y - c.y) < 0.1);
}
{
const osmium::Location loc(180.0, 0.0);
const osmium::geom::Coordinates c {20037508.34, 0.0};
REQUIRE(std::abs(projection(loc).x - c.x) < 0.1);
REQUIRE(std::abs(projection(loc).y - c.y) < 0.1);
}
{
const osmium::Location loc(0.0, 85.0511288);
const osmium::geom::Coordinates c {0.0, 20037508.34};
REQUIRE(std::abs(projection(loc).x - c.x) < 0.1);
REQUIRE(std::abs(projection(loc).y - c.y) < 0.1);
}
}
SECTION("project_location_mercator") {
osmium::geom::MercatorProjection projection;
{
const osmium::Location loc(0.0, 0.0);
const osmium::geom::Coordinates c {0.0, 0.0};
REQUIRE(std::abs(projection(loc).x - c.x) < 0.1);
REQUIRE(std::abs(projection(loc).y - c.y) < 0.1);
}
{
const osmium::Location loc(180.0, 0.0);
const osmium::geom::Coordinates c {20037508.34, 0.0};
REQUIRE(std::abs(projection(loc).x - c.x) < 0.1);
REQUIRE(std::abs(projection(loc).y - c.y) < 0.1);
}
{
const osmium::Location loc(180.0, 0.0);
const osmium::geom::Coordinates c {20037508.34, 0.0};
REQUIRE(std::abs(projection(loc).x - c.x) < 0.1);
REQUIRE(std::abs(projection(loc).y - c.y) < 0.1);
}
{
const osmium::Location loc(0.0, 85.0511288);
const osmium::geom::Coordinates c {0.0, 20037508.34};
REQUIRE(std::abs(projection(loc).x - c.x) < 0.1);
REQUIRE(std::abs(projection(loc).y - c.y) < 0.1);
}
}
SECTION("compare_mercators") {
osmium::geom::MercatorProjection projection_merc;
osmium::geom::Projection projection_3857(3857);
REQUIRE(3857 == projection_3857.epsg());
REQUIRE("+init=epsg:3857" == projection_3857.proj_string());
{
const osmium::Location loc(4.2, 27.3);
REQUIRE(std::abs(projection_merc(loc).x - projection_3857(loc).x) < 0.1);
REQUIRE(std::abs(projection_merc(loc).y - projection_3857(loc).y) < 0.1);
}
{
const osmium::Location loc(160.789, -42.42);
REQUIRE(std::abs(projection_merc(loc).x - projection_3857(loc).x) < 0.1);
REQUIRE(std::abs(projection_merc(loc).y - projection_3857(loc).y) < 0.1);
}
{
const osmium::Location loc(-0.001, 0.001);
REQUIRE(std::abs(projection_merc(loc).x - projection_3857(loc).x) < 0.1);
REQUIRE(std::abs(projection_merc(loc).y - projection_3857(loc).y) < 0.1);
}
{
const osmium::Location loc(-85.2, -85.2);
REQUIRE(std::abs(projection_merc(loc).x - projection_3857(loc).x) < 0.1);
REQUIRE(std::abs(projection_merc(loc).y - projection_3857(loc).y) < 0.1);
}
}
}
+133
View File
@@ -0,0 +1,133 @@
#include "catch.hpp"
#include <osmium/builder/builder_helper.hpp>
#include <osmium/geom/wkb.hpp>
#include "../basic/helper.hpp"
#if __BYTE_ORDER == __LITTLE_ENDIAN
TEST_CASE("WKB_Geometry_byte_order_dependent") {
SECTION("point") {
osmium::geom::WKBFactory<> factory(osmium::geom::wkb_type::wkb, osmium::geom::out_type::hex);
std::string wkb {factory.create_point(osmium::Location(3.2, 4.2))};
REQUIRE(std::string{"01010000009A99999999990940CDCCCCCCCCCC1040"} == wkb);
}
SECTION("point_ewkb") {
osmium::geom::WKBFactory<> factory(osmium::geom::wkb_type::ewkb, osmium::geom::out_type::hex);
std::string wkb {factory.create_point(osmium::Location(3.2, 4.2))};
REQUIRE(std::string{"0101000020E61000009A99999999990940CDCCCCCCCCCC1040"} == wkb);
}
SECTION("linestring") {
osmium::geom::WKBFactory<> factory(osmium::geom::wkb_type::wkb, osmium::geom::out_type::hex);
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}}
});
{
std::string wkb {factory.create_linestring(wnl)};
REQUIRE(std::string{"0102000000030000009A99999999990940CDCCCCCCCCCC10400000000000000C40CDCCCCCCCCCC1240CDCCCCCCCCCC0C409A99999999991340"} == wkb);
}
{
std::string wkb {factory.create_linestring(wnl, osmium::geom::use_nodes::unique, osmium::geom::direction::backward)};
REQUIRE(std::string{"010200000003000000CDCCCCCCCCCC0C409A999999999913400000000000000C40CDCCCCCCCCCC12409A99999999990940CDCCCCCCCCCC1040"} == wkb);
}
{
std::string wkb {factory.create_linestring(wnl, osmium::geom::use_nodes::all)};
REQUIRE(std::string{"0102000000040000009A99999999990940CDCCCCCCCCCC10400000000000000C40CDCCCCCCCCCC12400000000000000C40CDCCCCCCCCCC1240CDCCCCCCCCCC0C409A99999999991340"} == wkb);
}
{
std::string wkb {factory.create_linestring(wnl, osmium::geom::use_nodes::all, osmium::geom::direction::backward)};
REQUIRE(std::string{"010200000004000000CDCCCCCCCCCC0C409A999999999913400000000000000C40CDCCCCCCCCCC12400000000000000C40CDCCCCCCCCCC12409A99999999990940CDCCCCCCCCCC1040"} == wkb);
}
}
SECTION("linestring_ewkb") {
osmium::geom::WKBFactory<> factory(osmium::geom::wkb_type::ewkb, osmium::geom::out_type::hex);
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}}
});
std::string ewkb {factory.create_linestring(wnl)};
REQUIRE(std::string{"0102000020E6100000030000009A99999999990940CDCCCCCCCCCC10400000000000000C40CDCCCCCCCCCC1240CDCCCCCCCCCC0C409A99999999991340"} == ewkb);
}
SECTION("linestring_with_two_same_locations") {
osmium::geom::WKBFactory<> factory(osmium::geom::wkb_type::wkb, osmium::geom::out_type::hex);
osmium::memory::Buffer buffer(10000);
auto& wnl = osmium::builder::build_way_node_list(buffer, {
{1, {3.5, 4.7}},
{2, {3.5, 4.7}}
});
REQUIRE_THROWS_AS(factory.create_linestring(wnl), osmium::geometry_error);
REQUIRE_THROWS_AS(factory.create_linestring(wnl, osmium::geom::use_nodes::unique, osmium::geom::direction::backward), osmium::geometry_error);
{
std::string wkb {factory.create_linestring(wnl, osmium::geom::use_nodes::all)};
REQUIRE(std::string{"0102000000020000000000000000000C40CDCCCCCCCCCC12400000000000000C40CDCCCCCCCCCC1240"} == wkb);
}
{
std::string wkb {factory.create_linestring(wnl, osmium::geom::use_nodes::all, osmium::geom::direction::backward)};
REQUIRE(std::string{"0102000000020000000000000000000C40CDCCCCCCCCCC12400000000000000C40CDCCCCCCCCCC1240"} == wkb);
}
}
SECTION("linestring_with_undefined_location") {
osmium::geom::WKBFactory<> factory(osmium::geom::wkb_type::wkb, osmium::geom::out_type::hex);
osmium::memory::Buffer buffer(10000);
auto& wnl = osmium::builder::build_way_node_list(buffer, {
{1, {3.5, 4.7}},
{2, osmium::Location()}
});
REQUIRE_THROWS_AS(factory.create_linestring(wnl), osmium::invalid_location);
}
}
#endif
TEST_CASE("WKB_Geometry_byte_order_independent") {
SECTION("empty_point") {
osmium::geom::WKBFactory<> factory(osmium::geom::wkb_type::wkb, osmium::geom::out_type::hex);
REQUIRE_THROWS_AS(factory.create_point(osmium::Location()), osmium::invalid_location);
}
SECTION("empty_linestring") {
osmium::geom::WKBFactory<> factory(osmium::geom::wkb_type::wkb, osmium::geom::out_type::hex);
osmium::memory::Buffer buffer(10000);
auto& wnl = osmium::builder::build_way_node_list(buffer, {});
REQUIRE_THROWS_AS(factory.create_linestring(wnl), osmium::geometry_error);
REQUIRE_THROWS_AS(factory.create_linestring(wnl, osmium::geom::use_nodes::unique, osmium::geom::direction::backward), osmium::geometry_error);
REQUIRE_THROWS_AS(factory.create_linestring(wnl, osmium::geom::use_nodes::all), osmium::geometry_error);
REQUIRE_THROWS_AS(factory.create_linestring(wnl, osmium::geom::use_nodes::all, osmium::geom::direction::backward), osmium::geometry_error);
}
}
+198
View File
@@ -0,0 +1,198 @@
#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}}
});
{
std::string wkt {factory.create_linestring(wnl)};
REQUIRE(std::string{"LINESTRING(3.2 4.2,3.5 4.7,3.6 4.9)"} == wkt);
}
{
std::string wkt {factory.create_linestring(wnl, osmium::geom::use_nodes::unique, osmium::geom::direction::backward)};
REQUIRE(std::string{"LINESTRING(3.6 4.9,3.5 4.7,3.2 4.2)"} == wkt);
}
{
std::string wkt {factory.create_linestring(wnl, osmium::geom::use_nodes::all)};
REQUIRE(std::string{"LINESTRING(3.2 4.2,3.5 4.7,3.5 4.7,3.6 4.9)"} == wkt);
}
{
std::string wkt {factory.create_linestring(wnl, osmium::geom::use_nodes::all, osmium::geom::direction::backward)};
REQUIRE(std::string{"LINESTRING(3.6 4.9,3.5 4.7,3.5 4.7,3.2 4.2)"} == wkt);
}
}
SECTION("empty_linestring") {
osmium::geom::WKTFactory<> factory;
osmium::memory::Buffer buffer(10000);
auto& wnl = osmium::builder::build_way_node_list(buffer, {});
REQUIRE_THROWS_AS(factory.create_linestring(wnl), osmium::geometry_error);
REQUIRE_THROWS_AS(factory.create_linestring(wnl, osmium::geom::use_nodes::unique, osmium::geom::direction::backward), osmium::geometry_error);
REQUIRE_THROWS_AS(factory.create_linestring(wnl, osmium::geom::use_nodes::all), osmium::geometry_error);
REQUIRE_THROWS_AS(factory.create_linestring(wnl, osmium::geom::use_nodes::all, osmium::geom::direction::backward), osmium::geometry_error);
}
SECTION("linestring_with_two_same_locations") {
osmium::geom::WKTFactory<> factory;
osmium::memory::Buffer buffer(10000);
auto& wnl = osmium::builder::build_way_node_list(buffer, {
{1, {3.5, 4.7}},
{2, {3.5, 4.7}}
});
REQUIRE_THROWS_AS(factory.create_linestring(wnl), osmium::geometry_error);
REQUIRE_THROWS_AS(factory.create_linestring(wnl, osmium::geom::use_nodes::unique, osmium::geom::direction::backward), osmium::geometry_error);
{
std::string wkt {factory.create_linestring(wnl, osmium::geom::use_nodes::all)};
REQUIRE(std::string{"LINESTRING(3.5 4.7,3.5 4.7)"} == wkt);
}
{
std::string wkt {factory.create_linestring(wnl, osmium::geom::use_nodes::all, osmium::geom::direction::backward)};
REQUIRE(std::string{"LINESTRING(3.5 4.7,3.5 4.7)"} == wkt);
}
}
SECTION("linestring_with_undefined_location") {
osmium::geom::WKTFactory<> factory;
osmium::memory::Buffer buffer(10000);
auto& wnl = osmium::builder::build_way_node_list(buffer, {
{1, {3.5, 4.7}},
{2, osmium::Location()}
});
REQUIRE_THROWS_AS(factory.create_linestring(wnl), osmium::invalid_location);
}
SECTION("area_1outer_0inner") {
osmium::geom::WKTFactory<> factory;
osmium::memory::Buffer buffer(10000);
osmium::Area& area = buffer_add_area(buffer,
"foo",
{},
{
{ true, {
{1, {3.2, 4.2}},
{2, {3.5, 4.7}},
{3, {3.6, 4.9}},
{1, {3.2, 4.2}}
}}
});
{
std::string wkt {factory.create_multipolygon(area)};
REQUIRE(std::string{"MULTIPOLYGON(((3.2 4.2,3.5 4.7,3.6 4.9,3.2 4.2)))"} == wkt);
}
}
SECTION("area_1outer_1inner") {
osmium::geom::WKTFactory<> factory;
osmium::memory::Buffer buffer(10000);
osmium::Area& area = buffer_add_area(buffer,
"foo",
{},
{
{ true, {
{1, {0.1, 0.1}},
{2, {9.1, 0.1}},
{3, {9.1, 9.1}},
{4, {0.1, 9.1}},
{1, {0.1, 0.1}}
}},
{ false, {
{5, {1.0, 1.0}},
{6, {8.0, 1.0}},
{7, {8.0, 8.0}},
{8, {1.0, 8.0}},
{5, {1.0, 1.0}}
}}
});
{
std::string wkt {factory.create_multipolygon(area)};
REQUIRE(std::string{"MULTIPOLYGON(((0.1 0.1,9.1 0.1,9.1 9.1,0.1 9.1,0.1 0.1),(1 1,8 1,8 8,1 8,1 1)))"} == wkt);
}
}
SECTION("area_2outer_2inner") {
osmium::geom::WKTFactory<> factory;
osmium::memory::Buffer buffer(10000);
osmium::Area& area = buffer_add_area(buffer,
"foo",
{},
{
{ true, {
{1, {0.1, 0.1}},
{2, {9.1, 0.1}},
{3, {9.1, 9.1}},
{4, {0.1, 9.1}},
{1, {0.1, 0.1}}
}},
{ false, {
{5, {1.0, 1.0}},
{6, {4.0, 1.0}},
{7, {4.0, 4.0}},
{8, {1.0, 4.0}},
{5, {1.0, 1.0}}
}},
{ false, {
{10, {5.0, 5.0}},
{11, {5.0, 7.0}},
{12, {7.0, 7.0}},
{10, {5.0, 5.0}}
}},
{ true, {
{100, {10.0, 10.0}},
{101, {11.0, 10.0}},
{102, {11.0, 11.0}},
{103, {10.0, 11.0}},
{100, {10.0, 10.0}}
}}
});
{
std::string wkt {factory.create_multipolygon(area)};
REQUIRE(std::string{"MULTIPOLYGON(((0.1 0.1,9.1 0.1,9.1 9.1,0.1 9.1,0.1 0.1),(1 1,4 1,4 4,1 4,1 1),(5 5,5 7,7 7,5 5)),((10 10,11 10,11 11,10 11,10 10)))"} == wkt);
}
}
}