diff --git a/tests/cxx/geometry.cpp b/tests/cxx/geometry.cpp index a9948809b..4d2ec44a4 100644 --- a/tests/cxx/geometry.cpp +++ b/tests/cxx/geometry.cpp @@ -11,28 +11,39 @@ TEST_CASE("geometry") { -SECTION("json") { +SECTION("json point") { mapnik::util::file input("./tests/data/json/fixtures/point1.json"); auto json = input.data(); mapnik::new_geometry::geometry geom; std::string json_string(json.get()); REQUIRE( mapnik::json::from_geojson(json_string,geom) ); - if (geom.is()) { - auto const& point = mapnik::util::get(geom); - REQUIRE( point.x == 30 ); - REQUIRE( point.y == 10 ); - using adapter_type = mapnik::new_geometry::point_vertex_adapter; - adapter_type va(point); - std::string new_json; - using sink_type = std::back_insert_iterator; - // TODO: need to round trip, but does not compile yet - /* - static const mapnik::json::geometry_generator_grammar grammar; - sink_type sink(new_json); - REQUIRE( boost::spirit::karma::generate(sink, grammar, va) ); - */ - //REQUIRE( mapnik::util::to_geojson(new_json,va) ); - } + REQUIRE( geom.is() ); + auto const& point = mapnik::util::get(geom); + REQUIRE( point.x == 30 ); + REQUIRE( point.y == 10 ); + using adapter_type = mapnik::new_geometry::point_vertex_adapter; + adapter_type va(point); + std::string new_json; + using sink_type = std::back_insert_iterator; + // TODO: need to round trip, but does not compile yet + /* + static const mapnik::json::geometry_generator_grammar grammar; + sink_type sink(new_json); + REQUIRE( boost::spirit::karma::generate(sink, grammar, va) ); + */ + //REQUIRE( mapnik::util::to_geojson(new_json,va) ); +} + +SECTION("json point reversed") { + mapnik::util::file input("./tests/data/json/fixtures/point2.json"); + auto json = input.data(); + mapnik::new_geometry::geometry geom; + std::string json_string(json.get()); + 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 ); } } diff --git a/tests/data/json/fixtures/point2.json b/tests/data/json/fixtures/point2.json new file mode 100644 index 000000000..4c8120f3c --- /dev/null +++ b/tests/data/json/fixtures/point2.json @@ -0,0 +1 @@ +{"coordinates":[30,10],"type":"Point"} \ No newline at end of file