forked from organicmaps/organicmaps
renamed ErrorToRadius to MetresToXY for clarity.
This commit is contained in:
parent
b3c559d728
commit
3447ff9b60
2 changed files with 18 additions and 5 deletions
|
@ -66,10 +66,10 @@ UNIT_TEST(ErrorToRadius)
|
|||
double const lat = points[j];
|
||||
m2::PointD const mercPoint(MercatorBounds::LonToX(lon), MercatorBounds::LatToY(lat));
|
||||
|
||||
m2::RectD radius1 = MercatorBounds::ErrorToRadius(lon, lat, error1);
|
||||
m2::RectD radius1 = MercatorBounds::MetresToXY(lon, lat, error1);
|
||||
TEST(radius1.IsPointInside(mercPoint), ());
|
||||
|
||||
m2::RectD radius10 = MercatorBounds::ErrorToRadius(lon, lat, error10);
|
||||
m2::RectD radius10 = MercatorBounds::MetresToXY(lon, lat, error10);
|
||||
TEST(radius10.IsPointInside(mercPoint), ());
|
||||
|
||||
m2::RectD radius10Added = radius10;
|
||||
|
|
|
@ -34,12 +34,25 @@ struct MercatorBounds
|
|||
|
||||
static double const degreeInMetres;
|
||||
|
||||
inline static double ConvertMetresToY(double lat, double metresValue)
|
||||
{
|
||||
return LatToY(lat + metresValue * degreeInMetres) - LatToY(lat);
|
||||
}
|
||||
|
||||
inline static double ConvertMetresToX(double lon, double metresValue)
|
||||
{
|
||||
return LonToX(lon + metresValue * degreeInMetres) - LonToX(lon);
|
||||
}
|
||||
|
||||
/// @return mercator bound points in rect
|
||||
inline static m2::RectD ErrorToRadius(double lon, double lat, double errorInMetres)
|
||||
inline static m2::RectD MetresToXY(double lon, double lat, double metresValue)
|
||||
{
|
||||
// We use approximate number of metres per degree
|
||||
double const offset = errorInMetres / 2.0 * degreeInMetres;
|
||||
return m2::RectD(LonToX(lon - offset), LatToY(lat - offset), LonToX(lon + offset), LatToY(lat + offset));
|
||||
double const degreeOffset = metresValue / 2.0 * degreeInMetres;
|
||||
return m2::RectD(LonToX(lon - degreeOffset),
|
||||
LatToY(lat - degreeOffset),
|
||||
LonToX(lon + degreeOffset),
|
||||
LatToY(lat + degreeOffset));
|
||||
}
|
||||
|
||||
static double GetCellID2PointAbsEpsilon() { return 1.0E-4; }
|
||||
|
|
Loading…
Add table
Reference in a new issue