Fix possible division by zero by clamping latitude to 85.05°
Resolves #3530
This commit is contained in:
committed by
Patrick Niklaus
parent
f82740ed93
commit
1d4d3b80b5
@@ -118,8 +118,7 @@ BOOST_AUTO_TEST_CASE(compute_angle)
|
||||
BOOST_CHECK_EQUAL(angle, 180);
|
||||
|
||||
// Tiny changes below our calculation resolution
|
||||
// This should be equivalent to having two points on the same
|
||||
// spot.
|
||||
// This should be equivalent to having two points on the same spot.
|
||||
first = Coordinate{FloatLongitude{0}, FloatLatitude{0}};
|
||||
middle = Coordinate{FloatLongitude{1}, FloatLatitude{0}};
|
||||
end = Coordinate{FloatLongitude{1 + std::numeric_limits<double>::epsilon()}, FloatLatitude{0}};
|
||||
@@ -127,14 +126,12 @@ BOOST_AUTO_TEST_CASE(compute_angle)
|
||||
BOOST_CHECK_EQUAL(angle, 180);
|
||||
|
||||
// Invalid values
|
||||
/* TODO: Enable this when I figure out how to use BOOST_CHECK_THROW
|
||||
* and not have the whole test case fail...
|
||||
first = Coordinate(FloatLongitude{0}, FloatLatitude{0});
|
||||
middle = Coordinate(FloatLongitude{1}, FloatLatitude{0});
|
||||
end = Coordinate(FloatLongitude(std::numeric_limits<double>::max()), FloatLatitude{0});
|
||||
BOOST_CHECK_THROW( coordinate_calculation::computeAngle(first,middle,end),
|
||||
boost::numeric::positive_overflow);
|
||||
*/
|
||||
BOOST_CHECK_THROW(
|
||||
coordinate_calculation::computeAngle(
|
||||
Coordinate(FloatLongitude{0}, FloatLatitude{0}),
|
||||
Coordinate(FloatLongitude{1}, FloatLatitude{0}),
|
||||
Coordinate(FloatLongitude{std::numeric_limits<double>::max()}, FloatLatitude{0})),
|
||||
boost::numeric::positive_overflow);
|
||||
}
|
||||
|
||||
// Regression test for bug captured in #1347
|
||||
|
||||
@@ -73,12 +73,14 @@ BOOST_AUTO_TEST_CASE(xyz_to_mercator)
|
||||
double miny;
|
||||
double maxx;
|
||||
double maxy;
|
||||
|
||||
// http://tools.geofabrik.de/map/#13/85.0500/-175.5876&type=Geofabrik_Standard&grid=1
|
||||
web_mercator::xyzToMercator(100, 0, 13, minx, miny, maxx, maxy);
|
||||
|
||||
BOOST_CHECK_CLOSE(minx, -19548311.361764118075, 0.0001);
|
||||
BOOST_CHECK_CLOSE(miny, 19971868.8804085782, 0.0001);
|
||||
BOOST_CHECK_CLOSE(miny, 20032616.372979045, 0.0001);
|
||||
BOOST_CHECK_CLOSE(maxx, -19543419.391953866929, 0.0001);
|
||||
BOOST_CHECK_CLOSE(maxy, 19971868.880408578, 0.0001);
|
||||
BOOST_CHECK_CLOSE(maxy, 20037508.342789277, 0.0001); // Mercator 6378137*pi, WGS 85.0511
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user