Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2015-03-26 00:44:16 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:45:12 +0300
commit3c5de007bf83d14a564c9b71e4c70f0e41b6c22d (patch)
treefd647f580d2c7cd489d1e0044d151ffad7792a39 /iphone/Maps/Classes/LocationPredictor.mm
parentfad3189ccb9d34eea63dfea66e8a7c2c955288f0 (diff)
[android, iOS] Equal logic for the LocationPredictor components.
Diffstat (limited to 'iphone/Maps/Classes/LocationPredictor.mm')
-rw-r--r--iphone/Maps/Classes/LocationPredictor.mm29
1 files changed, 18 insertions, 11 deletions
diff --git a/iphone/Maps/Classes/LocationPredictor.mm b/iphone/Maps/Classes/LocationPredictor.mm
index 5edca9e3ac..2c2e32999e 100644
--- a/iphone/Maps/Classes/LocationPredictor.mm
+++ b/iphone/Maps/Classes/LocationPredictor.mm
@@ -5,6 +5,7 @@
#include "../../../map/location_state.hpp"
+
namespace
{
NSTimeInterval const PREDICTION_INTERVAL = 0.2; // in seconds
@@ -32,12 +33,13 @@ namespace
m_timer = nil;
m_gpsInfoIsValid = false;
m_generatePredictions = false;
- m_predictionCount = 0;
-
+
m_connectionSlot = GetFramework().GetLocationState()->AddStateModeListener([self](location::State::Mode mode)
{
- m_generatePredictions = mode == location::State::RotateAndFollow;
- m_gpsInfoIsValid = mode < location::State::NotFollow ? false : m_gpsInfoIsValid;
+ m_generatePredictions = (mode == location::State::RotateAndFollow);
+ if (mode < location::State::NotFollow)
+ m_gpsInfoIsValid = false;
+
[self resetTimer];
});
}
@@ -60,22 +62,27 @@ namespace
m_lastGpsInfo.m_source = location::EPredictor;
}
else
- {
m_gpsInfoIsValid = false;
- }
+
[self resetTimer];
}
+-(bool)isPredict
+{
+ return m_gpsInfoIsValid && m_generatePredictions;
+}
+
-(void)resetTimer
{
m_predictionCount = 0;
+
if (m_timer != nil)
{
[m_timer invalidate];
m_timer = nil;
}
- if (m_gpsInfoIsValid && m_generatePredictions)
+ if ([self isPredict])
{
m_timer = [NSTimer scheduledTimerWithTimeInterval:PREDICTION_INTERVAL
target:self
@@ -87,13 +94,13 @@ namespace
-(void)timerFired
{
- if (!(m_gpsInfoIsValid && m_generatePredictions))
+ if (![self isPredict])
return;
- if (m_lastGpsInfo.HasBearing() && m_lastGpsInfo.HasSpeed() && m_predictionCount < MAX_PREDICTION_COUNT)
+ if (m_predictionCount < MAX_PREDICTION_COUNT)
{
++m_predictionCount;
-
+
location::GpsInfo info = m_lastGpsInfo;
info.m_timestamp = my::Timer::LocalTime();
::Framework::PredictLocation(info.m_latitude, info.m_longitude, info.m_horizontalAccuracy, info.m_bearing,
@@ -103,4 +110,4 @@ namespace
}
}
-@end \ No newline at end of file
+@end