diff --git a/include/mapnik/geometry_strategy.hpp b/include/mapnik/geometry_strategy.hpp index 0a322ddc0..cc4121e60 100644 --- a/include/mapnik/geometry_strategy.hpp +++ b/include/mapnik/geometry_strategy.hpp @@ -155,28 +155,8 @@ struct scale_strategy using p2_type = typename boost::geometry::coordinate_type::type; double x = (boost::geometry::get<0>(p1) * scale_) + offset_; double y = (boost::geometry::get<1>(p1) * scale_) + offset_; - try { - boost::geometry::set<0>(p2, boost::numeric_cast(x)); - } - catch(boost::numeric::negative_overflow&) - { - boost::geometry::set<0>(p2, std::numeric_limits::min()); - } - catch(boost::numeric::positive_overflow&) - { - boost::geometry::set<0>(p2, std::numeric_limits::max()); - } - try { - boost::geometry::set<1>(p2, boost::numeric_cast(y)); - } - catch(boost::numeric::negative_overflow&) - { - boost::geometry::set<1>(p2, std::numeric_limits::min()); - } - catch(boost::numeric::positive_overflow&) - { - boost::geometry::set<1>(p2, std::numeric_limits::max()); - } + boost::geometry::set<0>(p2, static_cast(x)); + boost::geometry::set<1>(p2, static_cast(y)); return true; } @@ -205,28 +185,8 @@ struct scale_rounding_strategy using p2_type = typename boost::geometry::coordinate_type::type; double x = (boost::geometry::get<0>(p1) * scale_) + offset_; double y = (boost::geometry::get<1>(p1) * scale_) + offset_; - try { - boost::geometry::set<0>(p2, util::rounding_cast(x)); - } - catch(boost::numeric::negative_overflow&) - { - boost::geometry::set<0>(p2, std::numeric_limits::min()); - } - catch(boost::numeric::positive_overflow&) - { - boost::geometry::set<0>(p2, std::numeric_limits::max()); - } - try { - boost::geometry::set<1>(p2, util::rounding_cast(y)); - } - catch(boost::numeric::negative_overflow&) - { - boost::geometry::set<1>(p2, std::numeric_limits::min()); - } - catch(boost::numeric::positive_overflow&) - { - boost::geometry::set<1>(p2, std::numeric_limits::max()); - } + boost::geometry::set<0>(p2, static_cast(std::round(x))); + boost::geometry::set<1>(p2, static_cast(std::round(y))); return true; } diff --git a/include/mapnik/proj_strategy.hpp b/include/mapnik/proj_strategy.hpp index 69ef18a1c..688e6d331 100644 --- a/include/mapnik/proj_strategy.hpp +++ b/include/mapnik/proj_strategy.hpp @@ -59,28 +59,8 @@ struct proj_strategy double y = boost::geometry::get<1>(p1); double z = 0.0; if (!prj_trans_.forward(x, y, z)) return false; - try { - boost::geometry::set<0>(p2, boost::numeric_cast(x)); - } - catch(boost::numeric::negative_overflow&) - { - boost::geometry::set<0>(p2, std::numeric_limits::min()); - } - catch(boost::numeric::positive_overflow&) - { - boost::geometry::set<0>(p2, std::numeric_limits::max()); - } - try { - boost::geometry::set<1>(p2, boost::numeric_cast(y)); - } - catch(boost::numeric::negative_overflow&) - { - boost::geometry::set<1>(p2, std::numeric_limits::min()); - } - catch(boost::numeric::positive_overflow&) - { - boost::geometry::set<1>(p2, std::numeric_limits::max()); - } + boost::geometry::set<0>(p2, static_cast(x)); + boost::geometry::set<1>(p2, static_cast(y)); return true; } @@ -108,28 +88,8 @@ struct proj_backward_strategy double y = boost::geometry::get<1>(p1); double z = 0.0; if (!prj_trans_.backward(x, y, z)) return false; - try { - boost::geometry::set<0>(p2, boost::numeric_cast(x)); - } - catch(boost::numeric::negative_overflow&) - { - boost::geometry::set<0>(p2, std::numeric_limits::min()); - } - catch(boost::numeric::positive_overflow&) - { - boost::geometry::set<0>(p2, std::numeric_limits::max()); - } - try { - boost::geometry::set<1>(p2, boost::numeric_cast(y)); - } - catch(boost::numeric::negative_overflow&) - { - boost::geometry::set<1>(p2, std::numeric_limits::min()); - } - catch(boost::numeric::positive_overflow&) - { - boost::geometry::set<1>(p2, std::numeric_limits::max()); - } + boost::geometry::set<0>(p2, static_cast(x)); + boost::geometry::set<1>(p2, static_cast(y)); return true; } diff --git a/include/mapnik/view_strategy.hpp b/include/mapnik/view_strategy.hpp index a984dc4d9..7bddb9b18 100644 --- a/include/mapnik/view_strategy.hpp +++ b/include/mapnik/view_strategy.hpp @@ -74,8 +74,8 @@ struct unview_strategy double x = boost::geometry::get<0>(p1); double y = boost::geometry::get<1>(p1); tr_.backward(&x,&y); - boost::geometry::set<0>(p2, boost::numeric_cast(x)); - boost::geometry::set<1>(p2, boost::numeric_cast(y)); + boost::geometry::set<0>(p2, static_cast(x)); + boost::geometry::set<1>(p2, static_cast(y)); return true; } diff --git a/test/unit/geometry/geometry_strategy_test.cpp b/test/unit/geometry/geometry_strategy_test.cpp index 124b343bf..a5fe01ffe 100644 --- a/test/unit/geometry/geometry_strategy_test.cpp +++ b/test/unit/geometry/geometry_strategy_test.cpp @@ -29,7 +29,6 @@ SECTION("proj and view strategy") { point p1(-97.553098,35.523105); point r1(-1.08596e+07, 4.2352e+06); point p3 = transform(p1, ps); - //std::cout << p3.x << " , " << p3.y << std::endl; assert_g_equal(r1, p3); } { @@ -37,7 +36,6 @@ SECTION("proj and view strategy") { point p1(-1.08596e+07, 4.2352e+06); point r1(58.6287 , 100.945); point p3 = transform(p1, vs); - //std::cout << p3.x << " , " << p3.y << std::endl; assert_g_equal(r1, p3); } @@ -48,7 +46,6 @@ SECTION("proj and view strategy") { using sg_type = strategy_group; sg_type sg(vs); point p3 = transform(p1, sg); - //std::cout << p3.x << " , " << p3.y << std::endl; assert_g_equal(r1, p3); } @@ -59,7 +56,6 @@ SECTION("proj and view strategy") { point p1(-97.553098,35.523105); point r1(58.6287 , 100.945); point p3 = transform(p1, sg); - //std::cout << p3.x << " , " << p3.y << std::endl; assert_g_equal(r1, p3); } { @@ -71,7 +67,6 @@ SECTION("proj and view strategy") { geometry p2 = transform(p1, sg); REQUIRE(p2.is >()); point p3 = mapnik::util::get >(p2); - //std::cout << p3.x << " , " << p3.y << std::endl; assert_g_equal(r1, p3); } { @@ -83,7 +78,6 @@ SECTION("proj and view strategy") { geometry p2 = transform(p1, sg); REQUIRE(p2.is >()); point p3 = mapnik::util::get >(p2); - //std::cout << p3.x << " , " << p3.y << std::endl; assert_g_equal(r1, p3); } { @@ -96,7 +90,6 @@ SECTION("proj and view strategy") { geometry p2 = transform(p1, sg); REQUIRE(p2.is >()); point p3 = mapnik::util::get >(p2); - //std::cout << p3.x << " , " << p3.y << std::endl; assert_g_equal(r1, p3); } { @@ -109,7 +102,6 @@ SECTION("proj and view strategy") { geometry p2 = transform(p1, sg); REQUIRE(p2.is >()); point p3 = mapnik::util::get >(p2); - //std::cout << p3.x << " , " << p3.y << std::endl; assert_g_equal(r1, p3); } { @@ -122,7 +114,6 @@ SECTION("proj and view strategy") { geometry p2 = transform(p1, sg); REQUIRE(p2.is >()); point p3 = mapnik::util::get >(p2); - //std::cout << p3.x << " , " << p3.y << std::endl; assert_g_equal(r1, p3); } { @@ -135,7 +126,6 @@ SECTION("proj and view strategy") { geometry p2 = transform(p1, sg); REQUIRE(p2.is >()); point p3 = mapnik::util::get >(p2); - //std::cout << p3.x << " , " << p3.y << std::endl; assert_g_equal(r1, p3); } @@ -159,10 +149,9 @@ SECTION("scaling strategies - double to double") { assert_g_equal(r, o); } { - // Not the rounding doesn't apply because not casting to ints scale_rounding_strategy ss(0.5, -2.0); point p(-90.3, 35.5); - point r(-47.15, 15.75); + point r(-47.0, 16.0); point o = transform(p, ss); assert_g_equal(r, o); } @@ -193,47 +182,6 @@ SECTION("scaling strategies - double to int64") { point o = transform(p, ss); assert_g_equal(r, o); } - { - // Test underflow and overflow - std::int64_t min = std::numeric_limits::min(); - std::int64_t max = std::numeric_limits::max(); - scale_strategy ss(1.0E100); - point p(-90.3, 35.5); - point r(min, max); - point o = transform(p, ss); - assert_g_equal(r, o); - } - { - // Test underflow and overflow - std::int64_t min = std::numeric_limits::min(); - std::int64_t max = std::numeric_limits::max(); - scale_rounding_strategy ss(1.0E100); - point p(-90.3, 35.5); - point r(min, max); - point o = transform(p, ss); - assert_g_equal(r, o); - } - { - // Test overrflow and underflow - std::int64_t min = std::numeric_limits::min(); - std::int64_t max = std::numeric_limits::max(); - scale_strategy ss(1.0E100); - point p(90.3, -35.5); - point r(max, min); - point o = transform(p, ss); - assert_g_equal(r, o); - } - { - // Test overflow and underflow - std::int64_t min = std::numeric_limits::min(); - std::int64_t max = std::numeric_limits::max(); - scale_rounding_strategy ss(1.0E100); - point p(90.3, -35.5); - point r(max, min); - point o = transform(p, ss); - assert_g_equal(r, o); - } - } // END SECTION } // END TEST CASE