From 1e1ed936d6733d6e2b56518030ed5b32ecff9555 Mon Sep 17 00:00:00 2001 From: vng Date: Mon, 30 Jul 2012 15:54:07 -0700 Subject: [PATCH] Move fixed location routine (for screenshots) to native code: Framework::OnGpsUpdate. --- iphone/Maps/Platform/LocationManager.h | 8 ------ iphone/Maps/Platform/LocationManager.mm | 17 ------------ map/framework.cpp | 35 +++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/iphone/Maps/Platform/LocationManager.h b/iphone/Maps/Platform/LocationManager.h index 70318a5cfe..f6cf047dec 100644 --- a/iphone/Maps/Platform/LocationManager.h +++ b/iphone/Maps/Platform/LocationManager.h @@ -21,14 +21,6 @@ BOOL m_reportFirstUpdate; NSMutableSet * m_observers; BOOL m_isTimerActive; - - // Fixed location coordinates for debug or other special purpose. - pair m_latlon; - bool m_fixedLatLon; - - // Fixed device direction from north (radians). - double m_dirFromNorth; - bool m_fixedDir; } - (void)start:(id )observer; diff --git a/iphone/Maps/Platform/LocationManager.mm b/iphone/Maps/Platform/LocationManager.mm index df2c9aeb63..8a8f12c354 100644 --- a/iphone/Maps/Platform/LocationManager.mm +++ b/iphone/Maps/Platform/LocationManager.mm @@ -13,10 +13,6 @@ { if ((self = [super init])) { - // Read fixed location from settings. - m_fixedLatLon = Settings::Get("FixPosition", m_latlon); - m_fixedDir = Settings::Get("FixDirection", m_dirFromNorth); - m_locationManager = [[CLLocationManager alloc] init]; m_locationManager.delegate = self; m_locationManager.purpose = NSLocalizedString(@"location_services_are_needed_desc", @"Location purpose text description"); @@ -184,13 +180,6 @@ - (bool)getLat:(double &)lat Lon:(double &)lon { - if (m_fixedLatLon) - { - lat = m_latlon.first; - lon = m_latlon.second; - return true; - } - CLLocation * l = [self lastLocation]; static NSTimeInterval const SECONDS_TO_EXPIRE = 300.0; @@ -208,12 +197,6 @@ - (bool)getNorthRad:(double &)rad { - if (m_fixedDir) - { - rad = m_dirFromNorth; - return true; - } - CLHeading * h = [self lastHeading]; if (h != nil) diff --git a/map/framework.cpp b/map/framework.cpp index 7077345744..b98dd5f001 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -73,10 +73,41 @@ void Framework::OnLocationStatusChanged(location::TLocationStatus newStatus) } } +//#define FIX_LOCATION + +#ifdef FIX_LOCATION +namespace +{ + class FixedPosition + { + pair m_latlon; + double m_dirFromNorth; + bool m_fixedLatLon, m_fixedDir; + + public: + FixedPosition() + { + m_fixedLatLon = Settings::Get("FixPosition", m_latlon); + } + + void GetLat(double & l) const { if (m_fixedLatLon) l = m_latlon.first; } + void GetLon(double & l) const { if (m_fixedLatLon) l = m_latlon.second; } + }; +} +#endif + void Framework::OnGpsUpdate(location::GpsInfo const & info) { - m2::RectD rect = MercatorBounds::MetresToXY( - info.m_longitude, info.m_latitude, info.m_horizontalAccuracy); + double lon = info.m_longitude; + double lat = info.m_latitude; + +#ifdef FIX_LOCATION + static FixedPosition fixedPos; + fixedPos.GetLon(lon); + fixedPos.GetLat(lat); +#endif + + m2::RectD rect = MercatorBounds::MetresToXY(lon, lat, info.m_horizontalAccuracy); m2::PointD const center = rect.Center(); m_locationState.UpdateGps(rect);