forked from organicmaps/organicmaps
[tests] fixed tests
This commit is contained in:
parent
f5b6ade3c9
commit
661e68c4db
3 changed files with 7 additions and 22 deletions
|
@ -2,6 +2,7 @@
|
|||
#include "../math.hpp"
|
||||
#include "../../std/limits.hpp"
|
||||
|
||||
#include <boost/math/special_functions/next.hpp>
|
||||
|
||||
UNIT_TEST(id)
|
||||
{
|
||||
|
@ -68,22 +69,14 @@ namespace
|
|||
// Returns the next representable floating point value without using conversion to integer.
|
||||
template <typename FloatT> FloatT NextFloat(FloatT const x, int dir = 1)
|
||||
{
|
||||
FloatT d = dir * numeric_limits<FloatT>::denorm_min();
|
||||
while (true)
|
||||
{
|
||||
FloatT y = x;
|
||||
y += d;
|
||||
if (x != y)
|
||||
return y;
|
||||
d *= 2;
|
||||
}
|
||||
return boost::math::float_advance(x, dir);
|
||||
}
|
||||
|
||||
template <typename FloatT> void TestMaxULPs()
|
||||
{
|
||||
for (unsigned int logMaxULPs = 0; logMaxULPs <= 8; ++logMaxULPs)
|
||||
{
|
||||
unsigned int const maxULPs = (logMaxULPs == 0 ? 0 : ((1 << logMaxULPs) - 1));
|
||||
unsigned int const maxULPs = (1 << logMaxULPs) - 1;
|
||||
for (int base = -1; base <= 1; ++base)
|
||||
{
|
||||
for (int dir = -1; dir <= 1; dir += 2)
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
|
||||
UNIT_TEST(Mercator_Grid)
|
||||
{
|
||||
double const eps = 0.0000001;
|
||||
for (int lat = -85; lat <= 85; ++lat)
|
||||
for (int lat = -86; lat <= 86; ++lat)
|
||||
{
|
||||
for (int lon = -180; lon <= 180; ++lon)
|
||||
{
|
||||
|
@ -27,13 +26,6 @@ UNIT_TEST(Mercator_Grid)
|
|||
|
||||
// x is actually lon unmodified.
|
||||
TEST_ALMOST_EQUAL(x, static_cast<double>(lon), ());
|
||||
|
||||
if (lat == 0)
|
||||
{
|
||||
// TODO: Investigate, how to make Mercator transform more precise.
|
||||
// Error is to large for TEST_ALMOST_EQUAL(y, 0.0, ());
|
||||
TEST_LESS(fabs(y), eps, (lat, y, lat1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,13 +43,13 @@ struct MercatorBounds
|
|||
|
||||
inline static double YToLat(double y)
|
||||
{
|
||||
return my::RadToDeg(2.0 * atan(exp(my::DegToRad(y))) - math::pi / 2.0);
|
||||
return my::RadToDeg(2.0 * atan(tanh(0.5 * my::DegToRad(y))));
|
||||
}
|
||||
|
||||
inline static double LatToY(double lat)
|
||||
{
|
||||
lat = my::clamp(lat, -86.0, 86.0);
|
||||
double const res = my::RadToDeg(log(tan(my::DegToRad(45.0 + lat * 0.5))));
|
||||
double const sinx = sin(my::DegToRad(my::clamp(lat, -86.0, 86.0)));
|
||||
double const res = my::RadToDeg(0.5 * log((1.0 + sinx) / (1.0 - sinx)));
|
||||
return ClampY(res);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue