public override Task <TollGeoStatusResult> CheckStatus(TollGeoStatusResult tollGeoStatus) { Log.LogMessage(string.Format($"TRY TO FIND TOLLPOINT ENTRANCES FROM {SettingsService.WaypointLargeRadius * 1000} m")); if (tollGeoStatus?.TollPointWithDistance == null) { #if REALEASE GeoWatcher.StopUpdatingHighAccuracyLocation(); #endif Log.LogMessage($"No waypoint founded for location {GeoWatcher.Location}"); return(Task.FromResult(new TollGeoStatusResult() { TollGeolocationStatus = TollGeolocationStatus.NotOnTollRoad })); } else { foreach (var item in WaypointChecker.TollPointsInRadius) { Log.LogMessage($"FOUNDED WAYPOINT : {item.Name}, DISTANCE {item.Distance}"); } #if REALEASE GeoWatcher.StartUpdatingHighAccuracyLocation(); #endif return(Task.FromResult(new TollGeoStatusResult() { TollGeolocationStatus = TollGeolocationStatus.NearTollRoadEntrance, IsNeedToDoubleCheck = false })); } }
public override Task <TollGeolocationStatus> CheckStatus() { Log.LogMessage(string.Format($"TRY TO FIND TOLLPOINT ENTRANCES FROM {SettingsService.WaypointLargeRadius * 1000} m")); var location = GeoWatcher.Location; var waypoints = GeoDataService.FindNearestEntranceTollPoints(location); WaypointChecker.SetTollPointsInRadius(waypoints); WaypointChecker.SetIgnoredChoiceTollPoint(null); if (waypoints.Count == 0) { GeoWatcher.StopUpdatingHighAccuracyLocation(); Log.LogMessage($"No waypoint founded for location {GeoWatcher.Location}"); return(Task.FromResult(TollGeolocationStatus.NotOnTollRoad)); } else { foreach (var item in WaypointChecker.TollPointsInRadius) { Log.LogMessage($"FOUNDED WAYPOINT : {item.Name}, DISTANCE {item.Distance}"); } GeoWatcher.StartUpdatingHighAccuracyLocation(); return(Task.FromResult(TollGeolocationStatus.NearTollRoadEntrance)); } }
protected Task <TollGeoStatusResult> CheckNearestPoint(TollGeolocationStatus tollGeoStatus, List <TollPointWithDistance> tollPoints = null) { var location = GeoWatcher.Location; var nearestWaypoints = GeoDataService.FindNearestTollPoints(location); if (nearestWaypoints?.Count == 0) { #if REALEASE GeoWatcher.StopUpdatingHighAccuracyLocation(); #endif Log.LogMessage($"No waypoint founded for location {GeoWatcher.Location}"); SetTollStatusWithDistance(location, Mvx.Resolve <IStoredSettingsService>().CurrentRoadStatus == TollGeolocationStatus.OnTollRoad ? Mvx.Resolve <IStoredSettingsService>().CurrentRoadStatus : TollGeolocationStatus.NotOnTollRoad); shouldContinueCheckStatus = false; return(Task.FromResult(new TollGeoStatusResult() { TollPointWithDistance = null, Location = location, TollGeolocationStatus = tollGeolocationStatus, IsNeedToDoubleCheck = shouldContinueCheckStatus })); } WaypointChecker.SetTollPointsInRadius(nearestWaypoints); WaypointChecker.SetIgnoredChoiceTollPoint(null); var tollPointInRadius = WaypointChecker.TollPointsInRadius[firstElement]; foreach (var item in WaypointChecker.TollPointsInRadius) { Log.LogMessage($"FOUNDED WAYPOINT : {item.Name}, DISTANCE {item.Distance}"); } #if REALEASE GeoWatcher.StartUpdatingHighAccuracyLocation(); #endif switch (tollPointInRadius.WaypointAction) { case WaypointAction.Entrance: if (tollGeoStatus == TollGeolocationStatus.OnTollRoad) { tollGeolocationStatus = TollGeolocationStatus.OnTollRoad; shouldContinueCheckStatus = false; } else if (Mvx.Resolve <IStoredSettingsService>().CurrentRoadStatus == TollGeolocationStatus.NotOnTollRoad || Mvx.Resolve <IStoredSettingsService>().CurrentRoadStatus == TollGeolocationStatus.SearchingNearestTollPoint) { SetTollStatusWithDistance(location, TollGeolocationStatus.NearTollRoadEntrance); } break; case WaypointAction.Bridge: SetTollStatusWithDistance(location, TollGeolocationStatus.NearTollRoadEntrance); break; case WaypointAction.Exit: if (Mvx.Resolve <IStoredSettingsService>().CurrentRoadStatus == TollGeolocationStatus.OnTollRoad) { SetTollStatusWithDistance(location, TollGeolocationStatus.NearTollRoadExit); } else { tollGeolocationStatus = tollGeoStatus; shouldContinueCheckStatus = false; } break; } return(Task.FromResult(new TollGeoStatusResult() { TollPointWithDistance = tollPointInRadius, Location = location, TollGeolocationStatus = tollGeolocationStatus, IsNeedToDoubleCheck = shouldContinueCheckStatus })); }