#include #include #include #include #include #include template inline T round(T const& value, T const& factor) { return floor(0.5 + (value / factor)) * factor; } int main() { typedef boost::geometry::model::d2::point_xy point; typedef boost::geometry::model::polygon polygon; typedef boost::geometry::model::multi_polygon multi_polygon; multi_polygon mp; boost::geometry::read_wkt("MULTIPOLYGON(((0 0,1.123 9.987,8.876 2.234,0 0),(3.345 4.456,7.654 8.765,9.123 5.432,3.345 4.456)))", mp); const double factor = 0.1; std::vector points; boost::geometry::for_each_point ( mp, [&](point& p) { boost::geometry::set<0>(p, round(boost::geometry::get<0>(p), factor)); boost::geometry::set<1>(p, round(boost::geometry::get<1>(p), factor)); points.push_back(p); } ); std::cout << "Rounded: " << boost::geometry::wkt(mp) << std::endl; std::for_each(points.begin(), points.end(), [](point const& p) { std::cout << boost::geometry::wkt(p) << std::endl; } ); return 0; }