#include "catch.hpp" #include #include #include #include TEST_CASE("geometry") { SECTION("json point") { mapnik::util::file input("./test/data/json/point1.json"); REQUIRE( input ); mapnik::geometry::geometry geom; REQUIRE( input.data() ); std::string json_string(input.data().get(), input.size()); REQUIRE( mapnik::json::from_geojson(json_string, geom) ); REQUIRE( geom.is >() ); auto const& point = mapnik::util::get >(geom); REQUIRE( point.x == 30 ); REQUIRE( point.y == 10 ); std::string new_json; REQUIRE( mapnik::util::to_geojson(new_json, geom) ); } SECTION("json point reversed") { mapnik::util::file input("./test/data/json/point2.json"); REQUIRE( input ); mapnik::geometry::geometry geom; REQUIRE( input.data() ); std::string json_string(input.data().get(), input.size()); REQUIRE( mapnik::json::from_geojson(json_string,geom) ); REQUIRE( geom.is >() ); auto const& point = mapnik::util::get >(geom); REQUIRE( point.x == 30 ); REQUIRE( point.y == 10 ); } SECTION("json point reversed + extra attributes") { mapnik::util::file input("./test/data/json/point3.json"); REQUIRE( input ); mapnik::geometry::geometry geom; REQUIRE( input.data() ); std::string json_string(input.data().get(), input.size()); REQUIRE( mapnik::json::from_geojson(json_string,geom) ); REQUIRE( geom.is >() ); auto const& point = mapnik::util::get >(geom); REQUIRE( point.x == 30 ); REQUIRE( point.y == 10 ); } }