[api] Renamed functions

This commit is contained in:
Alex Zolotarev 2013-06-25 16:37:24 +03:00 committed by Alex Zolotarev
parent 668536cd74
commit 8a9eacc353
6 changed files with 25 additions and 20 deletions

View file

@ -94,4 +94,12 @@ struct MercatorBounds
static m2::PointD GetSmPoint(m2::PointD const & pt, double lonMetresR, double latMetresR);
static double GetCellID2PointAbsEpsilon() { return 1.0E-4; }
/// Converts lat lon rect to mercator one
inline static m2::RectD FromLatLonRect(m2::RectD const & latLonRect)
{
return m2::RectD(LonToX(latLonRect.minX()), LatToY(latLonRect.minY()),
LonToX(latLonRect.maxX()), LatToY(latLonRect.maxY()));
}
};

View file

@ -1453,15 +1453,12 @@ bool Framework::SetViewportByURL(string const & url, url_api::Request & request)
{
if (m_ParsedMapApi.SetUriAndParse(url))
{
m2::RectD z = GetMapApiRect();
//Can do better consider nav bar size
m2::RectD view(MercatorBounds::LonToX(z.minX()), MercatorBounds::LatToY(z.minY()),
MercatorBounds::LonToX(z.maxX()), MercatorBounds::LatToY(z.maxY()));
SetViewPortSync(view);
// Can do better consider nav bar size
SetViewPortSync(MercatorBounds::FromLatLonRect(m_ParsedMapApi.GetLatLonRect()));
// Populate request if request has only one point
// with this one point to show balloon.
// @todo: refacotor to more general model, Point and ApiPoint must not exist together.
// @todo: refactor to more general model, Point and ApiPoint must not exist together.
if (m_ParsedMapApi.GetPoints().size() == 1)
{
url_scheme::ApiPoint const apiPoint = m_ParsedMapApi.GetPoints().front();
@ -1470,7 +1467,7 @@ bool Framework::SetViewportByURL(string const & url, url_api::Request & request)
request.m_viewportLat = point.m_lat = apiPoint.m_lat;
request.m_viewportLon = point.m_lon = apiPoint.m_lon;
point.m_name = apiPoint.m_title;
point.m_id = apiPoint.m_id;
point.m_id = apiPoint.m_id;
request.m_points.push_back(point);
}

View file

@ -466,6 +466,6 @@ public:
int GetMapApiVersion() const { return m_ParsedMapApi.GetApiVersion(); }
string const & GetMapApiAppTitle() const { return m_ParsedMapApi.GetAppTitle(); }
string const & GetMapApiBackUrl() const { return m_ParsedMapApi.GetGlobalBackUrl(); }
m2::RectD GetMapApiRect() const { return m_ParsedMapApi.GetRect(); }
m2::RectD GetMapApiLatLonRect() const { return m_ParsedMapApi.GetLatLonRect(); }
bool IsValidMapApi() const { return m_ParsedMapApi.IsValid(); }
};

View file

@ -173,7 +173,7 @@ UNIT_TEST(RectTest)
{
{
ParsedMapApi api(Uri("mwm://map?ll=0,0"));
m2::RectD rect = api.GetRect();
m2::RectD rect = api.GetLatLonRect();
TEST_EQUAL(rect.maxX(), 0, ());
TEST_EQUAL(rect.maxY(), 0, ());
TEST_EQUAL(rect.minX(), 0, ());
@ -181,7 +181,7 @@ UNIT_TEST(RectTest)
}
{
ParsedMapApi api(Uri("mwm://map?ll=0,0&ll=1,1&ll=2,2&ll=3,3&ll=4,4&ll=5,5&"));
m2::RectD rect = api.GetRect();
m2::RectD rect = api.GetLatLonRect();
TEST_EQUAL(rect.maxX(), 5, ());
TEST_EQUAL(rect.maxY(), 5, ());
TEST_EQUAL(rect.minX(), 0, ());
@ -189,7 +189,7 @@ UNIT_TEST(RectTest)
}
{
ParsedMapApi api(Uri("mwm://map?ll=-90,90&ll=90,-90"));
m2::RectD rect = api.GetRect();
m2::RectD rect = api.GetLatLonRect();
TEST_EQUAL(rect.maxX(), 90, ());
TEST_EQUAL(rect.maxY(), 90, ());
TEST_EQUAL(rect.minX(), -90, ());
@ -197,7 +197,7 @@ UNIT_TEST(RectTest)
}
{
ParsedMapApi api(Uri("mwm://map?ll=180,180&ll=0,0&ll=-180,-180"));
m2::RectD rect = api.GetRect();
m2::RectD rect = api.GetLatLonRect();
TEST_EQUAL(rect.maxX(), 0, ());
TEST_EQUAL(rect.maxY(), 0, ());
TEST_EQUAL(rect.minX(), 0, ());
@ -205,7 +205,7 @@ UNIT_TEST(RectTest)
}
{
ParsedMapApi api(Uri("mwm://"));
m2::RectD rect = api.GetRect();
m2::RectD rect = api.GetLatLonRect();
TEST(!rect.IsValid(), ());
}
}
@ -276,14 +276,14 @@ UNIT_TEST(StressTestRandomTest)
UNIT_TEST(MWMApiZoomLevelTest)
{
m2::RectD const r1 = ParsedMapApi(Uri("mwm://map?ll=0,0")).GetRect();
m2::RectD const r2 = ParsedMapApi(Uri("mwm://map?z=14.5&ll=0,0")).GetRect();
m2::RectD const r1 = ParsedMapApi(Uri("mwm://map?ll=0,0")).GetLatLonRect();
m2::RectD const r2 = ParsedMapApi(Uri("mwm://map?z=14.5&ll=0,0")).GetLatLonRect();
TEST_NOT_EQUAL(r1, r2, ());
m2::RectD const r3 = ParsedMapApi(Uri("mwm://map?ll=0,0&z=14")).GetRect();
m2::RectD const r3 = ParsedMapApi(Uri("mwm://map?ll=0,0&z=14")).GetLatLonRect();
TEST_NOT_EQUAL(r2, r3, ());
TEST_NOT_EQUAL(r1, r3, ());
m2::RectD const rEqualToR3 = ParsedMapApi(Uri("mwm://map?ll=0,0&z=14.000")).GetRect();
m2::RectD const rEqualToR3 = ParsedMapApi(Uri("mwm://map?ll=0,0&z=14.000")).GetLatLonRect();
TEST_EQUAL(r3, rEqualToR3, ());
m2::RectD const rEqualToR1 = ParsedMapApi(Uri("mwm://map?ll=0,0&z=-23.43")).GetRect();
m2::RectD const rEqualToR1 = ParsedMapApi(Uri("mwm://map?ll=0,0&z=-23.43")).GetLatLonRect();
TEST_EQUAL(r1, rEqualToR1, ());
}

View file

@ -139,7 +139,7 @@ void ParsedMapApi::Reset()
m_zoomLevel = 0.0;
}
m2::RectD ParsedMapApi::GetRect() const
m2::RectD ParsedMapApi::GetLatLonRect() const
{
// Use zoom only for one point and ignore it for several points
if (m_zoomLevel >= 1.0 && m_points.size() == 1)

View file

@ -26,7 +26,7 @@ public:
string const & GetGlobalBackUrl() const { return m_globalBackUrl; }
string const & GetAppTitle() const { return m_appTitle; }
int GetApiVersion() const { return m_version; }
m2::RectD GetRect() const;
m2::RectD GetLatLonRect() const;
void Reset();
private: