From 0ff0e2de542e1280239fd7038032179356e4f558 Mon Sep 17 00:00:00 2001 From: Kirill Zhdanovich Date: Fri, 19 Apr 2013 12:28:07 +0300 Subject: [PATCH] Checking lat and lon for validity. Rewriting tests. --- map/ge0_parser.cpp | 6 +++++- map/map_tests/ge0_parser_tests.cpp | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/map/ge0_parser.cpp b/map/ge0_parser.cpp index cbcfb3b4e2..afee35b39d 100644 --- a/map/ge0_parser.cpp +++ b/map/ge0_parser.cpp @@ -3,6 +3,7 @@ #include "../api/internal/c/api-client-internals.h" #include "../coding/url_encode.hpp" #include "../base/math.hpp" +#include "../indexer/mercator.hpp" static const int ZOOM_POSITION = 6; @@ -39,7 +40,10 @@ bool url_api::Ge0Parser::Parse(string const & url, Request & request) request.m_points.push_back(url_api::Point()); url_api::Point & newPt = request.m_points.back(); - DecodeLatLon(url.substr(7,9), newPt.m_lat, newPt.m_lon); + DecodeLatLon(url.substr(7, 9), newPt.m_lat, newPt.m_lon); + + ASSERT(MercatorBounds::ValidLon(newPt.m_lon), (newPt.m_lon)); + ASSERT(MercatorBounds::ValidLat(newPt.m_lat), (newPt.m_lat)); request.m_viewportLat = newPt.m_lat; request.m_viewportLon = newPt.m_lon; diff --git a/map/map_tests/ge0_parser_tests.cpp b/map/map_tests/ge0_parser_tests.cpp index ebee3eb5fa..ba7ce55fad 100644 --- a/map/map_tests/ge0_parser_tests.cpp +++ b/map/map_tests/ge0_parser_tests.cpp @@ -163,6 +163,9 @@ UNIT_TEST(LatLonDecoding) TestSuccess("ge0://B6qqqqqqqq/Name", 90, 0, 4.25, "Name"); TestSuccess("ge0://BVVVVVVVVV/Name", -90, 179.999999, 4.25, "Name"); TestSuccess("ge0://BP________/Name", -0.000001, -0.000001, 4.25, "Name"); + TestSuccess("ge0://Bzqqqqqqqq/Name", 45, 45, 4.25, "Name"); + TestSuccess("ge0://BaF6F6F6F6/Name", -20, 20, 4.25, "Name"); + TestSuccess("ge0://B4srhdHVVt/Name", 64.5234, 12.1234, 4.25, "Name"); TestSuccess("ge0://B_________/Name", 90, 179.999999, 4.25, "Name"); TestSuccess("ge0://Bqqqqqqqqq/Name", 90, -180, 4.25, "Name"); TestSuccess("ge0://BAAAAAAAAA/Name", -90, -180, 4.25, "Name");