Explorar el Código

Merge pull request #8 from jancoow/RouteSelect

Route select
Janco Kock hace 10 años
padre
commit
aec8eea4de

+ 1 - 1
Breda-Tour/Data/Gps.cs

@@ -44,7 +44,7 @@ namespace Breda_Tour.Data
             switch (accessStatus)
             {
                 case GeolocationAccessStatus.Allowed:
-                    geolocator = new Geolocator { DesiredAccuracyInMeters = 5, MovementThreshold = 2 };
+                    geolocator = new Geolocator{DesiredAccuracy = PositionAccuracy.High,MovementThreshold = 3};
                     // Subscribe events
                     geolocator.StatusChanged += OnStatusChanged;
                     geolocator.PositionChanged += OnPositionChanged;

+ 42 - 51
Breda-Tour/MapScreen/MapPage.xaml.cs

@@ -38,13 +38,12 @@ namespace Breda_Tour.MapScreen
     public sealed partial class MapPage : Page
     {
         private MapIcon marker;
-        private Geopoint point;
         private Gps gps;
         private Route route;
 
         public MapPage()
         {
-            GeofenceMonitor.Current.GeofenceStateChanged += OnGeofenceStateChange; 
+            GeofenceMonitor.Current.GeofenceStateChanged += OnGeofenceStateChange;
             this.NavigationCacheMode = NavigationCacheMode.Enabled;
             marker = new MapIcon();
             marker.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/Marker.png"));
@@ -56,7 +55,8 @@ namespace Breda_Tour.MapScreen
 
         protected override void OnNavigatedTo(NavigationEventArgs e)
         {
-            SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
+            SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
+                AppViewBackButtonVisibility.Collapsed;
             DefaultPivot.SetCheckedButton(DefaultPivotControl.Tab.Map);
             if (RouteExample.fromRouteExamp)
             {
@@ -66,50 +66,34 @@ namespace Breda_Tour.MapScreen
                 gps.History.Clear();
                 gps.Refresh();
                 ShowWaypoints(route);
-                //ShowRoute();
+                ShowRoute();
             }
         }
 
-        public async void ShowLocaton(Geopoint point)
+        public async void ShowLocaton(Geopoint _point)
         {
-            this.point = point;
+            Geopoint point = _point;
             await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
-           {
-               Map.Center = point;
-               if (!Map.MapElements.Contains(marker))
-               {
-                   Map.MapElements.Add(marker);
-               }
-               marker.Location = point;
-           });
+            {
+                Map.Center = point;
+                if (!Map.MapElements.Contains(marker))
+                {
+                    Map.MapElements.Add(marker);
+                }
+                marker.Location = point;
+            });
             await Map.TrySetViewAsync(point, 17);
         }
 
-        public async void ShowRoute()
+        private async void ShowRoute()
         {
             await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
             {
                 Map.Routes.Add(RouteExample.routeView);
             });
-            //await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
-            //{
-            //    List<Geopoint> geopoints = new List<Geopoint>();
-            //    foreach (Waypoint wayPoint in route.Waypoints)
-            //    {
-            //        geopoints.Add(wayPoint.Position);
-            //    }
-            //    MapRouteFinderResult finder = await MapRouteFinder.GetWalkingRouteFromWaypointsAsync(geopoints);
-            //    if (finder.Status == MapRouteFinderStatus.Success)
-            //    {
-            //        MapRouteView routeView = new MapRouteView(finder.Route);
-            //        routeView.RouteColor = Colors.Firebrick;
-            //        routeView.OutlineColor = Colors.Black;
-            //        Map.Routes.Add(routeView);
-            //    }
-            //});
         }
 
-        public async void ShowWaypoints(Route route)
+        private async void ShowWaypoints(Route route)
         {
             await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
             {
@@ -121,15 +105,10 @@ namespace Breda_Tour.MapScreen
                     MapIcon wp = new MapIcon { Location = wayp.Position, Title = (x + 1).ToString() };
                     Map.MapElements.Add(wp);
                     //Geofencing handeling
-                    string name = $"Fence {(x + 1).ToString()}";
-                    GeofenceMonitor.Current.Geofences.Add(new Geofence(name,new Geocircle(wayp.Position.Position,10), MonitoredGeofenceStates.Entered, true,TimeSpan.FromSeconds(3)));
-                    Debug.Write("Geofences count: "+ GeofenceMonitor.Current.Geofences.Count);
+                    string name = (x + 1).ToString();
+                    GeofenceMonitor.Current.Geofences.Add(new Geofence(name, new Geocircle(wayp.Position.Position, 25),
+                        MonitoredGeofenceStates.Entered, true, TimeSpan.FromSeconds(3)));
                 }
-                //foreach (var waypoint in route.WayPoints)
-                //{
-                //    MapIcon wp = new MapIcon() {Location = waypoint.Position, Title = waypoint.number.ToString()};
-                //    Map.MapElements.Add(wp);
-                //}
             });
         }
 
@@ -146,16 +125,6 @@ namespace Breda_Tour.MapScreen
                     }
                 }
             }
-            //foreach (var waypoint in route.WayPoints)
-            //{
-            //    if (Icon.Title != "")
-            //    {
-            //        if (waypoint.number == int.Parse(Icon.Title))
-            //        {
-            //            MainPage.RootFrame.Navigate(typeof(WpDetailPage), waypoint);
-            //        }
-            //    }
-            //}
         }
 
         public async void DrawWalkingPath(List<BasicGeoposition> positions)
@@ -172,7 +141,29 @@ namespace Breda_Tour.MapScreen
 
         private void OnGeofenceStateChange(GeofenceMonitor sender, object args)
         {
-            Debug.Write("Kappa circle entered!!");
+            var reports = sender.ReadReports();
+            foreach (GeofenceStateChangeReport report in reports)
+            {
+                GeofenceState state = report.NewState;
+                Geofence geofence = report.Geofence;
+
+                if (state == GeofenceState.Entered)
+                {
+                    foreach (var waypoint in route.Waypoints)
+                    {
+                        int index = waypoint.Title.IndexOf(".");
+                        string number = "";
+                        if (index > 0)
+                        {
+                            number = waypoint.Title.Substring(0, index);
+                        }
+                        if (geofence.Id == number)
+                        {
+                            new Notification("Waypoint", waypoint.Title);
+                        }
+                    }
+                }
+            }
         }
     }
 }

+ 1 - 1
Breda-Tour/RouteSelectScreen/RouteExample.xaml

@@ -9,7 +9,7 @@
     xmlns:data="using:Breda_Tour.Data"
     mc:Ignorable="d">
 
-    <Grid>
+    <Grid Background="White">
         <Grid.RowDefinitions>
             <RowDefinition Height="Auto"/>
             <RowDefinition Height="Auto"/>

+ 0 - 1
Breda-Tour/RouteSelectScreen/RouteExample.xaml.cs

@@ -102,7 +102,6 @@ namespace Breda_Tour.RouteSelectScreen
                 ProgressRing.Visibility = Visibility.Collapsed;
                 StartButton.Visibility = Visibility.Visible;
             }
-            StartButton.Visibility = Visibility.Visible;
         }
 
         private void Waypoints_OnItemClick(object sender, ItemClickEventArgs e)

+ 1 - 0
Breda-Tour/SettingsScreen/SettingsPage.xaml.cs

@@ -34,6 +34,7 @@ namespace Breda_Tours.SettingsScreen
         private void listViewItemReset_Tapped(object sender, TappedRoutedEventArgs e)
         {
             Frame.Navigate(typeof(SplashPage));
+
         }
     }
 }

+ 0 - 1
Breda-Tour/SplashScreen/SplashPage.xaml.cs

@@ -30,7 +30,6 @@ namespace Breda_Tour.SplashScreen
         public SplashPage()
         {
             this.InitializeComponent();
-            new Notification("Hallo", "Test");
         }
 
         /// <author>Jannick van Ballegooijen</author>

+ 1 - 1
Breda-Tour/project.lock.json

@@ -11523,7 +11523,7 @@
       ]
     },
     "Microsoft.ApplicationInsights.WindowsApps/1.0.0": {
-      "sha512": "NvBQnFeiFd0O1QdBz06UGApD7zn7ztVi7qO18IsM3EjiXRNgfrEBXB+azNm8XqLY8xGFAqh3HAuSd/wHZMe0XA==",
+      "sha512": "fNCAjIwvbTV+G0dT14bgM5tptsqeSaKQaCrlq7QknOq1Xdm8ZmgsDYddMgXkvykyKLjWyU6fKuOpj6fsQJy+wQ==",
       "type": "Package",
       "files": [
         "[Content_Types].xml",