restore to_wkt on geometry<std::int64_t>

This commit is contained in:
Dane Springmeyer 2016-11-14 15:23:29 -08:00
parent 657dd7d73a
commit 4449f81e03
3 changed files with 24 additions and 4 deletions

View file

@ -32,6 +32,8 @@ namespace mapnik { namespace util {
bool to_wkt(std::string & wkt, mapnik::geometry::geometry<double> const& geom);
bool to_wkt(std::string & wkt, mapnik::geometry::geometry<std::int64_t> const& geom);
}}

View file

@ -36,13 +36,12 @@ bool to_wkt(std::string & wkt, mapnik::geometry::geometry<double> const& geom)
return boost::spirit::karma::generate(sink, generator, geom);
}
/*
inline bool to_wkt(std::string & wkt, mapnik::geometry::geometry<std::int64_t> const& geom)
bool to_wkt(std::string & wkt, mapnik::geometry::geometry<std::int64_t> const& geom)
{
using sink_type = std::back_insert_iterator<std::string>;
static const mapnik::wkt::wkt_generator_grammar<sink_type, mapnik::geometry::geometry<std::int64_t>> generator;
sink_type sink(wkt);
return boost::spirit::karma::generate(sink, generator, geom);
}
*/
}}

View file

@ -100,7 +100,7 @@ TEST_CASE("Well-known-geometries")
REQUIRE(mapnik::util::parse_hex(columns[2], twkb));
mapnik::geometry::geometry<double> geom_0 = mapnik::geometry_utils::from_wkb(wkb.data(), wkb.size(), mapnik::wkbAuto);
mapnik::geometry::geometry<double> geom_1 = mapnik::geometry_utils::from_twkb(twkb.data(), twkb.size());
// compare WKTs
// compare WKTs as doubles
std::string wkt0, wkt1;
REQUIRE(mapnik::util::to_wkt(wkt0, geom_0));
REQUIRE(mapnik::util::to_wkt(wkt1, geom_1));
@ -112,6 +112,25 @@ TEST_CASE("Well-known-geometries")
REQUIRE(spatially_equal(geom_0, geom_1));
#endif
}
// compare WKTS as ints
// note: mapnik::util::to_wkt<std::int64_t> used in mapnik-vt
std::string wkt2, wkt3;
mapnik::geometry::line_string<std::int64_t> geom_2;
geom_2.emplace_back(0,0);
geom_2.emplace_back(1,1);
geom_2.emplace_back(2,2);
mapnik::geometry::line_string<std::int64_t> geom_3;
geom_3.emplace_back(0,0);
geom_3.emplace_back(1,1);
geom_3.emplace_back(2,2);
REQUIRE(mapnik::util::to_wkt(wkt0, geom_2));
REQUIRE(mapnik::util::to_wkt(wkt1, geom_3));
if (!mapnik::geometry::is_empty(geom_2) && !mapnik::geometry::is_empty(geom_3))
{
REQUIRE(wkt2 == wkt3);
// compare spatially (NOTE: GeometryCollection comparison also enforces strict order)
}
}
}
}