#include #include #include #include #include #include "utils.hpp" #include #include #include #include #include // stl #include // Convenience method for test cases void simplify(std::string const& wkt_in, double tolerance, std::string const& method, std::string const& expected) { //grab the geom mapnik::geometry_container multi_input; if (!mapnik::from_wkt(wkt_in , multi_input)) { throw std::runtime_error("Failed to parse WKT"); } //setup the generalization mapnik::vertex_adapter va(multi_input.front()); mapnik::simplify_converter generalizer(va); generalizer.set_simplify_algorithm(mapnik::simplify_algorithm_from_string(method).get()); generalizer.set_simplify_tolerance(tolerance); //suck the vertices back out of it mapnik::geometry_type* output = new mapnik::geometry_type(multi_input.front().type()); mapnik::CommandType cmd; double x, y; while ((cmd = (mapnik::CommandType)generalizer.vertex(&x, &y)) != mapnik::SEG_END) { output->push_vertex(x, y, cmd); } //construct the answer mapnik::geometry_container multi_out; multi_out.push_back(output); std::string wkt_out; BOOST_TEST(mapnik::to_wkt(multi_out, wkt_out)); BOOST_TEST_EQ(wkt_out, expected); } int main(int argc, char** argv) { std::vector args; for (int i=1;i