#include #include #include #include #include #include "utils.hpp" #include #include #include #include #include #include #include // stl #include // Ramer Douglas Peucker generalization void ramer_douglas_peucker(const std::string& wkt_in, double tolerance, const std::string& 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::simplify_converter generalizer(multi_input.front()); generalizer.set_simplify_algorithm(mapnik::simplify_algorithm_from_string("douglas-peucker").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