diff options
author | vng <viktor.govako@gmail.com> | 2012-01-19 14:37:30 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:31:51 +0300 |
commit | 1fd760f9335b70215b0dfddcdf67a864b5235da1 (patch) | |
tree | 7b350e40c2bfbe478b70d14035eb34868ee434f4 /indexer/mercator.hpp | |
parent | f793671027fc0f378607ce8fe41fa9e6461509d7 (diff) |
Fix some Mercator functions.
Diffstat (limited to 'indexer/mercator.hpp')
-rw-r--r-- | indexer/mercator.hpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/indexer/mercator.hpp b/indexer/mercator.hpp index be46b6b7fa..24bfe0ddc2 100644 --- a/indexer/mercator.hpp +++ b/indexer/mercator.hpp @@ -50,25 +50,24 @@ struct MercatorBounds static double const degreeInMetres; + // TODO: inline static double ConvertMetresToY(double lat, double metresValue) { return LatToY(lat + metresValue * degreeInMetres) - LatToY(lat); } + // TODO: 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 MetresToXY(double lon, double lat, double metresValue) + static m2::RectD MetresToXY(double lon, double lat, + double lonMetresR, double latMetresR); + inline static m2::RectD MetresToXY(double lon, double lat, double metresR) { - // We use approximate number of metres per degree - double const degreeOffset = metresValue / 2.0 * degreeInMetres; - return m2::RectD(LonToX(lon - degreeOffset), - LatToY(lat - degreeOffset), - LonToX(lon + degreeOffset), - LatToY(lat + degreeOffset)); + return MetresToXY(lon, lat, metresR, metresR); } inline static m2::RectD RectByCenterXYAndSizeInMeters(double centerX, double centerY, @@ -76,12 +75,8 @@ struct MercatorBounds { ASSERT_GREATER_OR_EQUAL(sizeX, 0, ()); ASSERT_GREATER_OR_EQUAL(sizeY, 0, ()); - double const degreesLon = fabs(sizeX) / 2.0 * degreeInMetres; - double const degreesLat = fabs(sizeY) / 2.0 * degreeInMetres; - double const lon = XToLon(centerX); - double const lat = YToLat(centerY); - return m2::RectD(LonToX(lon - degreesLon), LatToY(lat - degreesLat), - LonToX(lon + degreesLon), LatToY(lat + degreesLat)); + + return MetresToXY(XToLon(centerX), YToLat(centerY), sizeX, sizeY); } static double GetCellID2PointAbsEpsilon() { return 1.0E-4; } |