forked from organicmaps/organicmaps
Move fixed location routine (for screenshots) to native code: Framework::OnGpsUpdate.
This commit is contained in:
parent
23e47fb3f3
commit
1e1ed936d6
3 changed files with 33 additions and 27 deletions
|
@ -21,14 +21,6 @@
|
|||
BOOL m_reportFirstUpdate;
|
||||
NSMutableSet * m_observers;
|
||||
BOOL m_isTimerActive;
|
||||
|
||||
// Fixed location coordinates for debug or other special purpose.
|
||||
pair<double, double> m_latlon;
|
||||
bool m_fixedLatLon;
|
||||
|
||||
// Fixed device direction from north (radians).
|
||||
double m_dirFromNorth;
|
||||
bool m_fixedDir;
|
||||
}
|
||||
|
||||
- (void)start:(id <LocationObserver>)observer;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -73,10 +73,41 @@ void Framework::OnLocationStatusChanged(location::TLocationStatus newStatus)
|
|||
}
|
||||
}
|
||||
|
||||
//#define FIX_LOCATION
|
||||
|
||||
#ifdef FIX_LOCATION
|
||||
namespace
|
||||
{
|
||||
class FixedPosition
|
||||
{
|
||||
pair<double, double> 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);
|
||||
|
|
Loading…
Add table
Reference in a new issue