From 3447ff9b60feccb91834f24500ea215f02604985 Mon Sep 17 00:00:00 2001 From: rachytski Date: Mon, 28 Mar 2011 01:08:09 +0300 Subject: [PATCH] renamed ErrorToRadius to MetresToXY for clarity. --- indexer/indexer_tests/mercator_test.cpp | 4 ++-- indexer/mercator.hpp | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/indexer/indexer_tests/mercator_test.cpp b/indexer/indexer_tests/mercator_test.cpp index 58ff31fe91..eb3fed171f 100644 --- a/indexer/indexer_tests/mercator_test.cpp +++ b/indexer/indexer_tests/mercator_test.cpp @@ -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; diff --git a/indexer/mercator.hpp b/indexer/mercator.hpp index 52659c521e..03807e6aa7 100644 --- a/indexer/mercator.hpp +++ b/indexer/mercator.hpp @@ -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; }