Exemple #1
0
        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));
            }
        }
Exemple #2
0
        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 async override Task <TollGeolocationStatus> CheckStatus()
        {
            var location  = GeoWatcher.Location;
            var waypoints = GeoDataService.FindNearestEntranceTollPoints(location);

            WaypointChecker.SetTollPointsInRadius(waypoints);

            if (waypoints.Count == 0)
            {
                return(TollGeolocationStatus.NotOnTollRoad);
            }

            var insideTollPoint = WaypointChecker.DetectWeAreInsideSomeTollPoint(location);

            if (insideTollPoint != null)
            {
                double radius = insideTollPoint.Radius != 0 ? insideTollPoint.Radius / 1000 : SettingsService.WaypointSmallRadius * 1000;
                Log.LogMessage($"We are inside tollpoint {radius} radius");

                WaypointChecker.SetIgnoredChoiceTollPoint(insideTollPoint);

                if (WaypointChecker.TollPointsInRadius.Count == 1)
                {
                    GeoWatcher.StopUpdatingHighAccuracyLocation();
                }

                if (await SpeechToTextService.AskQuestion($"Are you entering {insideTollPoint.Name} tollroad?"))
                {
                    WaypointChecker.SetEntrance(insideTollPoint);

                    if (insideTollPoint.WaypointAction == WaypointAction.Bridge)
                    {
                        WaypointChecker.SetExit(insideTollPoint);

                        WaypointChecker.SetTollPointsInRadius(null);
                        await NotifyService.Notify("Bill was created");

                        WaypointChecker.ClearData();
                        return(TollGeolocationStatus.NotOnTollRoad);
                    }
                    else
                    {
                        return(TollGeolocationStatus.OnTollRoad);
                    }
                }
                else
                {
                    return(TollGeolocationStatus.NotOnTollRoad);
                }
            }
            else
            {
                return(TollGeolocationStatus.NearTollRoadEntrance);
            }
        }
Exemple #4
0
        public override Task <TollGeoStatusResult> CheckStatus(TollGeoStatusResult tollGeoStatus)
        {
            Log.LogMessage(string.Format($"TRY TO FIND TOLLPOINT EXITS FROM {SettingsService.WaypointLargeRadius * 1000} m"));

            WaypointChecker.SetIgnoredChoiceTollPoint(null);

            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.OnTollRoad,
                    IsNeedToDoubleCheck = true
                }));
            }
            return(null);
        }
Exemple #5
0
        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
            }));
        }
Exemple #6
0
        public async override Task <TollGeoStatusResult> CheckStatus(TollGeoStatusResult tollGeoStatus)
        {
            if (tollGeoStatus?.TollPointWithDistance == null)
            {
                return new TollGeoStatusResult()
                       {
                           TollGeolocationStatus = TollGeolocationStatus.NotOnTollRoad
                       }
            }
            ;

            var insideTollPoint = WaypointChecker.DetectWeAreInsideSomeTollPoint(tollGeoStatus.Location);

            if (insideTollPoint != null)
            {
                double radius = insideTollPoint.Radius != 0 ? insideTollPoint.Radius / 1000 : SettingsService.WaypointSmallRadius * 1000;

                Log.LogMessage($"We are inside tollpoint {radius} radius");

                WaypointChecker.SetIgnoredChoiceTollPoint(insideTollPoint);

#if REALEASE
                if (WaypointChecker.TollPointsInRadius.Count == 1)
                {
                    GeoWatcher.StopUpdatingHighAccuracyLocation();
                }
#endif

                if (await SpeechToTextService.AskQuestionAsync($"Are you entering {insideTollPoint.Name} tollroad?"))
                {
                    WaypointChecker.SetEntrance(insideTollPoint);

                    if (insideTollPoint.WaypointAction == WaypointAction.Bridge)
                    {
                        WaypointChecker.SetExit(insideTollPoint);
                        SaveTripProgress();
                        WaypointChecker.SetTollPointsInRadius(null);
                        await NotifyService.NotifyAsync("Bill was created");

                        WaypointChecker.ClearData();
                        return(new TollGeoStatusResult()
                        {
                            TollGeolocationStatus = Mvx.Resolve <IStoredSettingsService>().CurrentRoadStatus == TollGeolocationStatus.OnTollRoad
                                                       ? Mvx.Resolve <IStoredSettingsService>().CurrentRoadStatus
                                                       : TollGeolocationStatus.NotOnTollRoad
                        });
                    }
                    else
                    {
                        Mvx.Resolve <IStoredSettingsService>().CurrentRoadStatus = TollGeolocationStatus.OnTollRoad;
                        return(new TollGeoStatusResult()
                        {
                            TollGeolocationStatus = TollGeolocationStatus.OnTollRoad
                        });
                    }
                }
                else
                {
                    return(new TollGeoStatusResult()
                    {
                        TollGeolocationStatus = TollGeolocationStatus.NotOnTollRoad
                    });
                }
            }
            else
            {
                return(new TollGeoStatusResult()
                {
                    TollGeolocationStatus = TollGeolocationStatus.NearTollRoadEntrance
                });
            }
        }
        public override async Task <TollGeolocationStatus> CheckStatus()
        {
            var location  = GeoWatcher.Location;
            var waypoints = GeoDataService.FindNearestExitTollPoints(location);

            WaypointChecker.SetTollPointsInRadius(waypoints);

            if (waypoints.Count == 0)
            {
                return(TollGeolocationStatus.OnTollRoad);
            }

            var insideTollPoint = WaypointChecker.DetectWeAreInsideSomeTollPoint(location);

            if (insideTollPoint != null)
            {
                double radius = insideTollPoint.Radius != 0 ? insideTollPoint.Radius / 1000 : SettingsService.WaypointSmallRadius * 1000;
                Log.LogMessage($"We are inside tollpoint {radius} radius");

                WaypointChecker.SetIgnoredChoiceTollPoint(insideTollPoint);

                if (WaypointChecker.TollPointsInRadius.Count == 1)
                {
                    GeoWatcher.StopUpdatingHighAccuracyLocation();
                }

                if (await SpeechToTextService.AskQuestion($"Are you exiting from {insideTollPoint.Name} tollroad?"))
                {
                    WaypointChecker.SetExit(insideTollPoint);
                    WaypointChecker.SetTollPointsInRadius(null);
                    WaypointChecker.SetIgnoredChoiceTollPoint(null);

                    if (WaypointChecker.Exit != null)
                    {
                        await NotifyService.Notify("Bill was created");

                        var duration = WaypointChecker.TripDuration;

                        if (duration.Hours > 0)
                        {
                            await NotifyService.Notify($"Trip duration is {duration.Hours} hours {duration.Minutes} minutes {duration.Seconds} seconds");
                        }
                        else
                        {
                            await NotifyService.Notify($"Trip duration is {duration.Minutes} minutes {duration.Seconds} seconds");
                        }

                        WaypointChecker.ClearData();
                    }
                    else
                    {
                        await NotifyService.Notify("Bill was not created. You didn't enter any exit");
                    }

                    return(TollGeolocationStatus.NotOnTollRoad);
                }
                else
                {
                    return(TollGeolocationStatus.OnTollRoad);
                }
            }
            else
            {
                return(TollGeolocationStatus.NearTollRoadExit);
            }
        }
Exemple #8
0
        public override async Task <TollGeoStatusResult> CheckStatus(TollGeoStatusResult tollGeoStatus)
        {
            if (tollGeoStatus?.TollPointWithDistance == null)
            {
                return new TollGeoStatusResult()
                       {
                           TollGeolocationStatus = TollGeolocationStatus.OnTollRoad
                       }
            }
            ;

            var insideTollPoint = WaypointChecker.DetectWeAreInsideSomeTollPoint(tollGeoStatus.Location);

            if (insideTollPoint != null)
            {
                double radius = insideTollPoint.Radius != 0 ? insideTollPoint.Radius / 1000 : SettingsService.WaypointSmallRadius * 1000;

                Log.LogMessage($"We are inside tollpoint {radius} radius");

                WaypointChecker.SetIgnoredChoiceTollPoint(insideTollPoint);

#if REALEASE
                if (WaypointChecker.TollPointsInRadius.Count == 1)
                {
                    GeoWatcher.StopUpdatingHighAccuracyLocation();
                }
#endif

                if (await SpeechToTextService.AskQuestionAsync($"Are you exiting from {insideTollPoint.Name} tollroad?"))
                {
                    WaypointChecker.SetExit(insideTollPoint);
                    SaveTripProgress();
                    WaypointChecker.SetTollPointsInRadius(null);
                    WaypointChecker.SetIgnoredChoiceTollPoint(null);

                    if (WaypointChecker.Exit != null)
                    {
                        await NotifyService.NotifyAsync("Bill was created");

                        var duration = WaypointChecker.TripDuration;

                        if (duration.Hours > 0)
                        {
                            await NotifyService.NotifyAsync($"Trip duration is {duration.Hours} hours {duration.Minutes} minutes {duration.Seconds} seconds");
                        }
                        else
                        {
                            await NotifyService.NotifyAsync($"Trip duration is {duration.Minutes} minutes {duration.Seconds} seconds");
                        }

                        Mvx.Resolve <IStoredSettingsService>().CurrentRoadStatus = TollGeolocationStatus.NotOnTollRoad;
                        WaypointChecker.ClearData();
                    }
                    else
                    {
                        await NotifyService.NotifyAsync("Bill was not created. You didn't enter any exit");
                    }

                    return(new TollGeoStatusResult()
                    {
                        TollGeolocationStatus = TollGeolocationStatus.NotOnTollRoad
                    });
                }
                else
                {
                    return(new TollGeoStatusResult()
                    {
                        TollGeolocationStatus = TollGeolocationStatus.OnTollRoad
                    });
                }
            }
            else
            {
                return(new TollGeoStatusResult()
                {
                    TollGeolocationStatus = TollGeolocationStatus.NearTollRoadExit
                });
            }
        }