Forráskód Böngészése

Geocoding now
Changed MapForm to remove Google StaticMaps dependency
Renamed MapsPanel to LiveMaps
Fixed Missing GoogleAPIKey

frankvandenbos 2 hónapja
szülő
commit
19a59f3043

+ 1 - 0
prs.desktop/App.xaml.cs

@@ -320,6 +320,7 @@ namespace PRSDesktop
                     DatabaseSettings = allsettings[Profile];
                 }
             }
+            CoreUtils.GoogleAPIKey = DatabaseSettings.GoogleAPIKey;
             StartupUri = new Uri("MainWindow.xaml", UriKind.Relative);
         }
         

+ 47 - 3
prs.desktop/Forms/MapForm.xaml

@@ -4,12 +4,56 @@
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 		xmlns:wpf="clr-namespace:InABox.Wpf;assembly=InABox.Wpf"
-        mc:Ignorable="d"
-        Title="MapForm" WindowStyle="None" WindowStartupLocation="CenterScreen" SizeToContent="WidthAndHeight" MaxHeight="1000" MaxWidth="1000">
+		xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
+		xmlns:dynamicGrid="clr-namespace:InABox.Wpf.DynamicGrid;assembly=InABox.Wpf"
+		mc:Ignorable="d"
+        Title="MapForm" 
+        WindowStartupLocation="CenterScreen" 
+        Height="800" 
+        Width="1200">
     <Grid>
         <Label x:Name="TimeStamp" Panel.ZIndex="1000" VerticalAlignment="Top" HorizontalAlignment="Center"
                FontSize="24" />
-        <Image x:Name="staticmap" Margin="0,0,0,0" MouseUp="staticmap_MouseUp" />
+        
+        <syncfusion:SfMap 
+            x:Name="Map" 
+            BorderBrush="Gray"
+            BorderThickness="0.75" 
+            ZoomLevel="19" 
+            MinZoom="19"
+            MaxZoom="19"
+            EnableZoom="False"
+            EnablePan="False"
+            Grid.Row="0"
+            Grid.Column="0">
+            
+            <syncfusion:SfMap.Layers>
+                <dynamicGrid:GoogleImageryLayer
+                    x:Name="ImageryLayer"
+                    Center="-31.95105, 115.85939"
+                    Radius="10">
+                    
+                    <syncfusion:ImageryLayer.SubShapeFileLayers>
+                        <syncfusion:SubShapeFileLayer x:Name="subLayer">
+                            <syncfusion:SubShapeFileLayer.MapElements>
+
+                                <syncfusion:MapPolygon 
+                                    x:Name="Polygon" 
+                                    Stroke="Firebrick" 
+                                    StrokeThickness="0.75">
+                                    <syncfusion:MapPolygon.Fill>
+                                        <SolidColorBrush Color="Salmon" Opacity="0.5"/>     
+                                    </syncfusion:MapPolygon.Fill>
+                                </syncfusion:MapPolygon>
+                                
+                            </syncfusion:SubShapeFileLayer.MapElements>
+                        </syncfusion:SubShapeFileLayer>
+                    </syncfusion:ImageryLayer.SubShapeFileLayers>
+                    
+                </dynamicGrid:GoogleImageryLayer>
+            </syncfusion:SfMap.Layers>
+        </syncfusion:SfMap>
+        
         <StackPanel VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0,0,10,10" Orientation="Horizontal" >
             <Button x:Name="ZoomIn" Height="40" Width="40" Click="ZoomIn_OnClick">
                 <Image Source="../Resources/zoomin.png" />

+ 21 - 87
prs.desktop/Forms/MapForm.xaml.cs

@@ -1,17 +1,12 @@
 using System;
-using System.Collections.Generic;
 using System.Collections.ObjectModel;
-using System.Drawing;
 using System.Linq;
 using System.Windows;
-using System.Windows.Input;
-using System.Windows.Media.Imaging;
-using Google.Maps;
-using Google.Maps.StaticMaps;
+using Comal.Classes;
+using InABox.Clients;
 using InABox.Core;
 using InABox.Wpf;
-using Syncfusion.Linq;
-using Location = Google.Maps.Location;
+using Syncfusion.XlsIO.Implementation.PivotTables;
 using Point = System.Windows.Point;
 
 namespace PRSDesktop.Forms
@@ -22,105 +17,44 @@ namespace PRSDesktop.Forms
 	/// </summary>
 	public partial class MapForm : ThemableWindow
     {
-		StaticMapRequest request = new StaticMapRequest();
-		StaticMapService service = new StaticMapService();
 
 		private double _zoom = 18.0;
 		
-		public BitmapImage ToImage(byte[] array)
-		{
-			using (var ms = new System.IO.MemoryStream(array))
-			{
-				var image = new BitmapImage();
-				image.BeginInit();
-				image.CacheOption = BitmapCacheOption.OnLoad; // here
-				image.StreamSource = ms;
-				image.EndInit();
-				return image;
-			}
-		}
-
-		public MapForm(double latitude, double longitude, DateTime timestamp, string? geometry = null)
+		public MapForm(double latitude, double longitude, DateTime? timestamp = null)
 		{
 			InitializeComponent();
-
-			GoogleSigned.AssignAllServices(new GoogleSigned(CoreUtils.GoogleAPIKey));
-
-			request = new StaticMapRequest();
-			String sLoc = String.Format("{0},{1}", latitude, longitude);
-			Location location = new Location(sLoc);
-			request.Center = location;
-			request.Markers.Add(location);
-			request.Scale = 2;
-			request.Size = new MapSize(640,640); // Convert.ToInt32(ActualWidth)-20, Convert.ToInt32(ActualHeight)-20);
 			
-			request.Format = GMapsImageFormats.JPG;
-			if (!string.IsNullOrWhiteSpace(geometry))
+			var geopoint = new GeoPoint(latitude, longitude);
+			var fences = Client.Query<GeoFence>().ToArray<GeoFence>();
+			foreach (var fence in fences)
 			{
-				var perims = Serialization.Deserialize<Dictionary<string, List<PointF>>>(geometry) ?? new Dictionary<string, List<PointF>>();
-				var paths = new List<Path>();
-				foreach (var perim in perims)
+				var def = Serialization.Deserialize<GeoFenceDefinition>(fence.Geofence) ?? new GeoFenceDefinition();
+				if (def.Contains(geopoint))
 				{
-					var path = new Path()
-					{
-						Points = new Collection<Location>(perim.Value.Select(x => new Location($"{x.Y},{x.X}")).ToList()),
-						Color = MapColor.FromArgb(255, 255, 0, 0),
-						FillColor = MapColor.FromArgb(64, 255, 0, 0),
-						Weight = 1
-
-					};
-					paths.Add(path);
+					Polygon.Points = new ObservableCollection<Point>(def.Coordinates.Select(p => new Point(p.Latitude, p.Longitude)));
+					break;
 				}
-				request.Paths = paths;
 			}
 
-			service = new StaticMapService();
-
-			GetImage();
+			if (timestamp.HasValue)
+				TimeStamp.Content = $"Last Updated {timestamp:dd MMM yyy hh:mm:ss tt}";
+			else
+				TimeStamp.Visibility = Visibility.Collapsed;
+			ImageryLayer.Center = new Point(latitude,longitude);
 
-			TimeStamp.Content = String.Format("Last Updated {0:dd MMM yyy hh:mm:ss tt}", timestamp);
-
-		}
 
-		private void GetImage()
-		{
-			request.Zoom = (int)Math.Round(_zoom, 0);
-			var imageSource = new BitmapImage();
-			imageSource.BeginInit();
-			imageSource.StreamSource = service.GetStream(request);
-			imageSource.CacheOption = BitmapCacheOption.OnLoad;
-			imageSource.EndInit();
-			staticmap.Source = imageSource;
 		}
-
-		private bool settingbounds = false;
-		private List<Point> _boundaries = new List<Point>();
 		
-		private void staticmap_MouseUp(object sender, MouseButtonEventArgs e)
+		private void ZoomIn_OnClick(object sender, RoutedEventArgs e)
 		{
-			if (e.ChangedButton == MouseButton.Right)
-			{
-				settingbounds = false;
-				MessageBox.Show(string.Join("\n",_boundaries.Select(x => x.ToString())));
-			}
-			else if (e.ChangedButton == MouseButton.Left)
-			{
-				settingbounds = true;
-				_boundaries.Add(e.GetPosition(staticmap));
-			}
-			//Close();
+			Map.MaxZoom = Math.Min(20, Map.ZoomLevel + 1);
+			Map.ZoomLevel = Math.Min(20, Map.ZoomLevel + 1);
 		}
 
 		private void ZoomOut_OnClick(object sender, RoutedEventArgs e)
 		{
-			_zoom -= 1.0;
-			GetImage();
-		}
-
-		private void ZoomIn_OnClick(object sender, RoutedEventArgs e)
-		{
-			_zoom += 1.0;
-			GetImage();
+			Map.MinZoom= Math.Max(5, Map.ZoomLevel - 1);
+			Map.ZoomLevel = Math.Max(5, Map.ZoomLevel - 1);
 		}
     }
 }

+ 9 - 9
prs.desktop/MainWindow.xaml.cs

@@ -812,7 +812,7 @@ public partial class MainWindow : IPanelHostControl
         SetModuleVisibility<NotificationPanel>(DashboardMessagesButton, Security.CanView<Notification>());
         SetModuleVisibility<TaskPanel>(DashboardsTaskButton, ClientFactory.IsSupported<Kanban>() && Security.IsAllowed<CanViewTasks>());
         SetModuleVisibility<AttendancePanel>(DashboardsAttendanceButton, ClientFactory.IsSupported<TimeSheet>() && Security.IsAllowed<CanViewInOutBoard>());
-        SetModuleVisibility<MapsPanel>(DashboardsMapButton, bMaps);
+        SetModuleVisibility<LiveMapsPanel>(DashboardsMapButton, bMaps);
         SetModuleVisibility<DailyReport>(DashboardsDailyReportButton,
             ClientFactory.IsSupported<TimeSheet, Assignment>() && Security.IsAllowed<CanViewDailyReports>());
 
@@ -875,7 +875,7 @@ public partial class MainWindow : IPanelHostControl
         SetModuleVisibility<NotificationPanel>(DigitalFormsMessagesButton, Security.CanView<Notification>());
         SetModuleVisibility<TaskPanel>(DigitalFormsTaskButton, ClientFactory.IsSupported<Kanban>() && Security.IsAllowed<CanViewTasks>());
         SetModuleVisibility<AttendancePanel>(DigitalFormsAttendanceButton, ClientFactory.IsSupported<TimeSheet>() && Security.IsAllowed<CanViewInOutBoard>());
-        SetModuleVisibility<MapsPanel>(DigitalFormsMapButton, bMaps);
+        SetModuleVisibility<LiveMapsPanel>(DigitalFormsMapButton, bMaps);
         SetModuleVisibility<DailyReport>(DigitalFormsDailyReportButton,
             ClientFactory.IsSupported<TimeSheet, Assignment>() && Security.IsAllowed<CanViewDailyReports>());
 
@@ -909,7 +909,7 @@ public partial class MainWindow : IPanelHostControl
         SetModuleVisibility<NotificationPanel>(EquipmentMessagesButton, Security.CanView<Notification>());
         SetModuleVisibility<TaskPanel>(EquipmentTaskButton, ClientFactory.IsSupported<Kanban>() && Security.IsAllowed<CanViewTasks>());
         SetModuleVisibility<AttendancePanel>(EquipmentAttendanceButton, ClientFactory.IsSupported<TimeSheet>() && Security.IsAllowed<CanViewInOutBoard>());
-        SetModuleVisibility<MapsPanel>(EquipmentMapButton, bMaps);
+        SetModuleVisibility<LiveMapsPanel>(EquipmentMapButton, bMaps);
         SetModuleVisibility<DailyReport>(EquipmentDailyReportButton,
             ClientFactory.IsSupported<TimeSheet, Assignment>() && Security.IsAllowed<CanViewDailyReports>());
 
@@ -955,7 +955,7 @@ public partial class MainWindow : IPanelHostControl
         SetModuleVisibility<NotificationPanel>(AccountsMessagesButton, Security.CanView<Notification>());
         SetModuleVisibility<TaskPanel>(AccountsTaskButton, ClientFactory.IsSupported<Kanban>() && Security.IsAllowed<CanViewTasks>());
         SetModuleVisibility<AttendancePanel>(AccountsAttendanceButton, ClientFactory.IsSupported<TimeSheet>() && Security.IsAllowed<CanViewInOutBoard>());
-        SetModuleVisibility<MapsPanel>(AccountsMapButton, bMaps);
+        SetModuleVisibility<LiveMapsPanel>(AccountsMapButton, bMaps);
         SetModuleVisibility<DailyReport>(AccountsDailyReportButton,
             ClientFactory.IsSupported<TimeSheet, Assignment>() && Security.IsAllowed<CanViewDailyReports>());
 
@@ -1015,7 +1015,7 @@ public partial class MainWindow : IPanelHostControl
         SetModuleVisibility<TaskPanel>(HumanResourcesTaskButton, ClientFactory.IsSupported<Kanban>() && Security.IsAllowed<CanViewTasks>());
         SetModuleVisibility<AttendancePanel>(HumanResourcesAttendanceButton,
             ClientFactory.IsSupported<TimeSheet>() && Security.IsAllowed<CanViewInOutBoard>());
-        SetModuleVisibility<MapsPanel>(HumanResourcesMapButton, bMaps);
+        SetModuleVisibility<LiveMapsPanel>(HumanResourcesMapButton, bMaps);
         SetModuleVisibility<DailyReport>(HumanResourcesDailyReportButton,
             ClientFactory.IsSupported<TimeSheet, Assignment>() && Security.IsAllowed<CanViewDailyReports>());
 
@@ -1060,7 +1060,7 @@ public partial class MainWindow : IPanelHostControl
         SetModuleVisibility<NotificationPanel>(ProductsMessagesButton, Security.CanView<Notification>());
         SetModuleVisibility<TaskPanel>(ProductsTaskButton, Security.CanView<Kanban>());
         SetModuleVisibility<AttendancePanel>(ProductsAttendanceButton, Security.IsAllowed<CanViewInOutBoard>());
-        SetModuleVisibility<MapsPanel>(ProductsMapButton, bMaps);
+        SetModuleVisibility<LiveMapsPanel>(ProductsMapButton, bMaps);
         SetModuleVisibility<DailyReport>(ProductsDailyReportButton,
             ClientFactory.IsSupported<TimeSheet, Assignment>() && Security.IsAllowed<CanViewDailyReports>());
 
@@ -1094,7 +1094,7 @@ public partial class MainWindow : IPanelHostControl
         SetModuleVisibility<NotificationPanel>(LogisticsMessagesButton, Security.CanView<Notification>());
         SetModuleVisibility<TaskPanel>(LogisticsTaskButton, ClientFactory.IsSupported<Kanban>() && Security.IsAllowed<CanViewTasks>());
         SetModuleVisibility<AttendancePanel>(LogisticsAttendanceButton, ClientFactory.IsSupported<TimeSheet>() && Security.IsAllowed<CanViewInOutBoard>());
-        SetModuleVisibility<MapsPanel>(LogisticsMapButton, bMaps);
+        SetModuleVisibility<LiveMapsPanel>(LogisticsMapButton, bMaps);
         SetModuleVisibility<DailyReport>(LogisticsDailyReportButton,
             ClientFactory.IsSupported<TimeSheet, Assignment>() && Security.IsAllowed<CanViewDailyReports>());
 
@@ -1147,7 +1147,7 @@ public partial class MainWindow : IPanelHostControl
         SetModuleVisibility<TaskPanel>(ManufacturingTaskButton, ClientFactory.IsSupported<Kanban>() && Security.IsAllowed<CanViewTasks>());
         SetModuleVisibility<AttendancePanel>(ManufacturingAttendanceButton,
             ClientFactory.IsSupported<TimeSheet>() && Security.IsAllowed<CanViewInOutBoard>());
-        SetModuleVisibility<MapsPanel>(ManufacturingMapButton, bMaps);
+        SetModuleVisibility<LiveMapsPanel>(ManufacturingMapButton, bMaps);
         SetModuleVisibility<DailyReport>(ManufacturingDailyReportButton,
             ClientFactory.IsSupported<TimeSheet, Assignment>() && Security.IsAllowed<CanViewDailyReports>());
         
@@ -1202,7 +1202,7 @@ public partial class MainWindow : IPanelHostControl
         SetModuleVisibility<NotificationPanel>(ProjectMessagesButton, Security.CanView<Notification>());
         SetModuleVisibility<TaskPanel>(ProjectTaskButton, ClientFactory.IsSupported<Kanban>() && Security.IsAllowed<CanViewTasks>());
         SetModuleVisibility<AttendancePanel>(ProjectAttendanceButton, ClientFactory.IsSupported<TimeSheet>() && Security.IsAllowed<CanViewInOutBoard>());
-        SetModuleVisibility<MapsPanel>(ProjectsMapButton, bMaps);
+        SetModuleVisibility<LiveMapsPanel>(ProjectsMapButton, bMaps);
         SetModuleVisibility<DailyReport>(ProjectDailyReportButton,
             ClientFactory.IsSupported<TimeSheet, Assignment>() && Security.IsAllowed<CanViewDailyReports>());
 

+ 0 - 2
prs.desktop/PRSDesktop.csproj

@@ -908,8 +908,6 @@
       <PackageReference Include="Dirkster.AvalonDock.Themes.Metro" Version="4.72.1" />
       <PackageReference Include="DocumentFormat.OpenXml" Version="3.1.1" />
       <PackageReference Include="Fluent.Ribbon" Version="10.1.0" />
-      <PackageReference Include="Geocoding.Core" Version="4.0.1" />
-      <PackageReference Include="Geocoding.Google" Version="4.0.1" />
       <PackageReference Include="gmaps-api-net" Version="0.33.0" />
       <PackageReference Include="H.Formatters.Newtonsoft.Json" Version="13.0.59" />
       <PackageReference Include="Microsoft.Office.Interop.Outlook" Version="15.0.4797.1004" />

+ 10 - 7
prs.desktop/Panels/DynamicMapColumn.cs

@@ -73,14 +73,17 @@ namespace PRSDesktop
         {
             if (row is not null && HasLocation(row))
             {
-                var Address = new Address();
-                Address.Location.Latitude = row.Get<double>(Latitude);
-                Address.Location.Longitude = row.Get<double>(Longitude);
-                if (Geofence != null)
-                    Address.Geofence = row.Get<string>(Geofence);
+                var mapform = new MapForm(row.Get<double>(Latitude), row.Get<double>(Longitude));
+                mapform.ShowDialog();
                 
-                var form = new GeofenceEditor(Address, false); 
-                form.ShowDialog();
+                //var Address = new Address();
+                //Address.Location.Latitude = row.Get<double>(Latitude);
+                //Address.Location.Longitude = row.Get<double>(Longitude);
+                //if (Geofence != null)
+                //    Address.Geofence = row.Get<string>(Geofence);
+                
+                //var form = new GeofenceEditor(Address, false); 
+                //form.ShowDialog();
             }
 
             return false;

+ 52 - 52
prs.desktop/Panels/GPSTrackers/GPSTrackerLocationGrid.cs

@@ -39,57 +39,57 @@ internal class GPSTrackerLocationGrid : DynamicOneToManyGrid<GPSTracker, GPSTrac
         options.FilterRows = true;
     }
 
-    public static string ReverseGeocode(double latitude, double longitude)
-    {
-        _cache ??= Client.Query(
-                new Filter<GPSTrackerLocation>(x => x.Location.Address).IsNotEqualTo(""),
-                Columns.None<GPSTrackerLocation>().Add(
-                    x => x.Location.Address,
-                    x => x.Location.Longitude,
-                    x => x.Location.Latitude))
-            .ToList<GPSTrackerLocation>();
-        var tuple = _cache.FirstOrDefault(x => Equals(x.Location.Latitude, latitude) && Equals(x.Location.Longitude, longitude));
-        if (tuple == null)
-        {
-            var address = StoreUtils.ReverseGeocode(latitude, longitude);
-            if (!string.IsNullOrWhiteSpace(address))
-            {
-                tuple = new GPSTrackerLocation();
-                tuple.Location.Latitude = latitude;
-                tuple.Location.Longitude = longitude;
-                tuple.Location.Address = address;
-                _cache.Add(tuple);
-            }
-        }
-
-        return tuple != null ? tuple.Location.Address : "";
-    }
+    // public static string ReverseGeocode(double latitude, double longitude)
+    // {
+    //     _cache ??= Client.Query(
+    //             new Filter<GPSTrackerLocation>(x => x.Location.Address).IsNotEqualTo(""),
+    //             Columns.None<GPSTrackerLocation>().Add(
+    //                 x => x.Location.Address,
+    //                 x => x.Location.Longitude,
+    //                 x => x.Location.Latitude))
+    //         .ToList<GPSTrackerLocation>();
+    //     var tuple = _cache.FirstOrDefault(x => Equals(x.Location.Latitude, latitude) && Equals(x.Location.Longitude, longitude));
+    //     if (tuple == null)
+    //     {
+    //         var address = StoreUtils.ReverseGeocode(latitude, longitude);
+    //         if (!string.IsNullOrWhiteSpace(address))
+    //         {
+    //             tuple = new GPSTrackerLocation();
+    //             tuple.Location.Latitude = latitude;
+    //             tuple.Location.Longitude = longitude;
+    //             tuple.Location.Address = address;
+    //             _cache.Add(tuple);
+    //         }
+    //     }
+    //
+    //     return tuple != null ? tuple.Location.Address : "";
+    // }
 
-    private bool GetAddressClick(Button arg1, CoreRow[] arg2)
-    {
-        var result = false;
-        var rows = Data.Rows.Where(r =>
-            string.IsNullOrWhiteSpace(r.Get<GPSTrackerLocation, string>(c => c.Location.Address))
-            && !Equals(r.Get<GPSTrackerLocation, double>(c => c.Location.Latitude), 0.0F)
-            && !Equals(r.Get<GPSTrackerLocation, double>(c => c.Location.Longitude), 0.0F)
-        );
-        Progress.ShowModal("Updating Addresses", progress =>
-        {
-            foreach (var row in rows)
-            {
-                var item = LoadItem(row);
-                var address = ReverseGeocode(
-                    row.Get<GPSTrackerLocation, double>(x => x.Location.Latitude),
-                    row.Get<GPSTrackerLocation, double>(x => x.Location.Longitude)
-                );
-                if (!string.IsNullOrWhiteSpace(address))
-                {
-                    item.Location.Address = address;
-                    UpdateRow<GPSTrackerLocation, string>(row, x => x.Location.Address, address, false);
-                    result = true;
-                }
-            }
-        });
-        return result;
-    }
+    // private bool GetAddressClick(Button arg1, CoreRow[] arg2)
+    // {
+    //     var result = false;
+    //     var rows = Data.Rows.Where(r =>
+    //         string.IsNullOrWhiteSpace(r.Get<GPSTrackerLocation, string>(c => c.Location.Address))
+    //         && !Equals(r.Get<GPSTrackerLocation, double>(c => c.Location.Latitude), 0.0F)
+    //         && !Equals(r.Get<GPSTrackerLocation, double>(c => c.Location.Longitude), 0.0F)
+    //     );
+    //     Progress.ShowModal("Updating Addresses", progress =>
+    //     {
+    //         foreach (var row in rows)
+    //         {
+    //             var item = LoadItem(row);
+    //             var address = ReverseGeocode(
+    //                 row.Get<GPSTrackerLocation, double>(x => x.Location.Latitude),
+    //                 row.Get<GPSTrackerLocation, double>(x => x.Location.Longitude)
+    //             );
+    //             if (!string.IsNullOrWhiteSpace(address))
+    //             {
+    //                 item.Location.Address = address;
+    //                 UpdateRow<GPSTrackerLocation, string>(row, x => x.Location.Address, address, false);
+    //                 result = true;
+    //             }
+    //         }
+    //     });
+    //     return result;
+    // }
 }

+ 4 - 4
prs.desktop/Panels/Maps/MapsPanel.xaml → prs.desktop/Panels/LiveMaps/LiveMapsPanel.xaml

@@ -1,4 +1,4 @@
-<UserControl x:Class="PRSDesktop.MapsPanel"
+<UserControl x:Class="PRSDesktop.LiveMapsPanel"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -13,7 +13,7 @@
              d:DesignHeight="450" d:DesignWidth="800">
     
     <UserControl.DataContext>
-        <prsDesktop:MapsPanelViewModel x:Name="ViewModel" />
+        <prsDesktop:LiveMapsPanelViewModel x:Name="ViewModel" />
     </UserControl.DataContext>
     
     <UserControl.Resources>
@@ -21,8 +21,8 @@
         <prsDesktop:EquipmentThumbnailConverter x:Key="EquipmentThumbnailConverter" />
         <prsDesktop:EquipmentColorConverter x:Key="EquipmentColorConverter" />
         <DataTemplate x:Key="MarkerTemplate" DataType="{x:Type prsDesktop:MapMarker}">
-            <Border BorderBrush="Gray" BorderThickness="0.75" CornerRadius="5" Padding="0" Background="LightYellow" >
-                <Label Content="{Binding Label}" MinHeight="30" MinWidth="60" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
+            <Border BorderBrush="Gray" BorderThickness="0.75" CornerRadius="5" Padding="2" Background="LightYellow" Margin="120,0,0,0" >
+                <TextBlock Text="{Binding Label}" TextAlignment="Center"/>
             </Border>
         </DataTemplate>
         <!-- <DataTemplate x:Key="MapMarkerTemplate" DataType="{x:Type prsDesktop:MapMarker}"> -->

+ 2 - 11
prs.desktop/Panels/Maps/MapsPanel.xaml.cs → prs.desktop/Panels/LiveMaps/LiveMapsPanel.xaml.cs

@@ -21,13 +21,6 @@ using Location = InABox.Core.Location;
 
 namespace PRSDesktop
 {
-    // public class GPSHistory
-    // {
-    //     public DateTime Date { get; set; }
-    //     public string Description { get; set; }
-    //     public double Latitude { get; set; }
-    //     public double Longitude { get; set; }
-    // }
 
     public class EquipmentThumbnailConverter : AbstractConverter<Guid, BitmapImage?>
     {
@@ -45,8 +38,6 @@ namespace PRSDesktop
     public class EquipmentColorConverter : AbstractConverter<Equipment?, System.Windows.Media.Brush>
     {
         
-        //public static Dictionary<Guid, BitmapImage?> Cache { get; set; } = new ();
-        //public static DateTime CurrentDate { get; set; }
         public static GPSTrackerLocation[] Pings { get; set; }
         
         public override System.Windows.Media.Brush Convert(Equipment? value)
@@ -64,11 +55,11 @@ namespace PRSDesktop
     /// <summary>
     ///     Interaction logic for MapsPanel.xaml
     /// </summary>
-    public partial class MapsPanel : UserControl, IPanel<GPSTracker>
+    public partial class LiveMapsPanel : UserControl, IPanel<GPSTracker>
     {
         
         
-        public MapsPanel()
+        public LiveMapsPanel()
         {
             InitializeComponent();
         }

+ 7 - 2
prs.desktop/Panels/Maps/MapsPanelViewModel.cs → prs.desktop/Panels/LiveMaps/LiveMapsPanelViewModel.cs

@@ -23,12 +23,13 @@ namespace PRSDesktop;
 
 public class MapMarker
 {
+    public string Name { get; set; } = "Hi There";
     public string Label { get; set; } = "";
     public string Longitude { get; set; }
     public string Latitude { get; set; }
 }
 
-public class MapsPanelViewModel : DependencyObject, INotifyPropertyChanged
+public class LiveMapsPanelViewModel : DependencyObject, INotifyPropertyChanged
 {
     private EquipmentGroup[]? _groups;
     private Equipment[]? _items;
@@ -237,6 +238,10 @@ public class MapsPanelViewModel : DependencyObject, INotifyPropertyChanged
                                     
                                     var timelist = sites[geofence.Key].Label.Split('\n').Where(x=>!string.IsNullOrWhiteSpace(x)).ToList();
                                     
+                                    var first = timelist.FirstOrDefault() ?? "";
+                                    if (!string.Equals(first,geofence.Key.Name))
+                                        timelist.Insert(0,geofence.Key.Name);
+                                    
                                     if ((geofence.Key == curFence) && timelist.Any())
                                     {
                                             var lasttime = timelist.Last().Split(" - ").ToList();
@@ -355,7 +360,7 @@ public class MapsPanelViewModel : DependencyObject, INotifyPropertyChanged
 
     public LiveMapsSettings Settings { get; private set; }
 
-    public MapsPanelViewModel()
+    public LiveMapsPanelViewModel()
     {
         Settings = new UserConfiguration<LiveMapsSettings>().Load();
     }

+ 1 - 1
prs.desktop/prsdesktop.iss

@@ -8,7 +8,7 @@
 #define public Dependency_Path_NetCoreCheck "dependencies\"
 
 #define MyAppName "PRS Desktop"
-#define MyAppVersion "8.38c"
+#define MyAppVersion "8.39a"
 #define MyAppPublisher "PRS Digital"
 #define MyAppURL "https://www.prs-software.com.au"
 #define MyAppExeName "PRSDesktop.exe"

+ 1 - 1
prs.licensing/PRSLicensing.iss

@@ -8,7 +8,7 @@
 #define public Dependency_Path_NetCoreCheck "dependencies\"
 
 #define MyAppName "PRS Licensing"
-#define MyAppVersion "8.38c"
+#define MyAppVersion "8.39a"
 #define MyAppPublisher "PRS Digital"
 #define MyAppURL "https://www.prs-software.com.au"
 #define MyAppExeName "PRSLicensing.exe"

+ 0 - 2
prs.server/PRSServer.csproj

@@ -94,8 +94,6 @@
         <PackageReference Include="GenHTTP.Core" Version="8.4.1">
             <TreatAsUsed>true</TreatAsUsed>
         </PackageReference>
-        <PackageReference Include="Geocoding.Core" Version="4.0.1" />
-        <PackageReference Include="Geocoding.Google" Version="4.0.1" />
         <PackageReference Include="H.Pipes" Version="2.0.59" />
         <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
         <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />

+ 1 - 1
prs.server/PRSServer.iss

@@ -8,7 +8,7 @@
 #define public Dependency_Path_NetCoreCheck "dependencies\"
 
 #define MyAppName "PRS Server"
-#define MyAppVersion "8.38c"
+#define MyAppVersion "8.39a"
 #define MyAppPublisher "PRS Digital"
 #define MyAppURL "https://www.prs-software.com.au"
 #define MyAppExeName "PRSServer.exe"

+ 0 - 2
prs.shared/PRS.Shared.csproj

@@ -54,8 +54,6 @@
   </ItemGroup>
 
   <ItemGroup>
-    <PackageReference Include="Geocoding.Core" Version="4.0.1" />
-    <PackageReference Include="Geocoding.Google" Version="4.0.1" />
     <PackageReference Include="RestSharp" Version="111.2.0" />
     <PackageReference Include="System.Collections.Immutable" Version="9.0.0-preview.4.24266.19" />
   </ItemGroup>

+ 2 - 2
prs.stores/CustomerStore.cs

@@ -8,8 +8,8 @@ namespace Comal.Stores
         protected override void BeforeSave(Customer entity)
         {
             base.BeforeSave(entity);
-            StoreUtils.Geocode(entity.Delivery);
-            StoreUtils.Geocode(entity.Postal);
+            //StoreUtils.Geocode(entity.Delivery);
+            //StoreUtils.Geocode(entity.Postal);
             //UpdateAggregate<Customer>(entity, entity.Account, Count<Customer>(x => x.Sites));
         }
 

+ 1 - 1
prs.stores/JobStore.cs

@@ -36,7 +36,7 @@ namespace Comal.Stores
                 entity.Account.Synchronise(final ?? new Customer());
             }
 
-            StoreUtils.Geocode(entity.SiteAddress);
+            //StoreUtils.Geocode(entity.SiteAddress);
         }
 
         protected override void AfterSave(Job entity)

+ 1 - 1
prs.stores/PRSStores.csproj

@@ -9,7 +9,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="Geocoding.Google" Version="4.0.1" />
+    <PackageReference Include="Nominatim.API" Version="2.1.0" />
     <PackageReference Include="Syncfusion.Pdf.Wpf" Version="25.2.6" />
   </ItemGroup>
 

+ 1 - 68
prs.stores/StoreUtils.cs

@@ -1,79 +1,12 @@
-using System.Linq;
-using Geocoding;
-using Geocoding.Google;
-using InABox.Core;
-using Address = InABox.Core.Address;
-using Location = Geocoding.Location;
-using System;
+using InABox.Core;
 
 namespace Comal.Stores
 {
     public static class StoreUtils
     {
-        //public static string GoogleAPIKey { get; set; }
-
         public static void RegisterClasses()
         {
             CoreUtils.RegisterClasses(typeof(StoreUtils).Assembly);
         }
-
-        public static void Geocode(Address address)
-        {
-            if (!address.IsChanged())
-                return;
-
-            if (string.IsNullOrEmpty(address.Street) || string.IsNullOrEmpty(address.City) || string.IsNullOrEmpty(address.State))
-            {
-                address.Location.Latitude = 0.0F;
-                address.Location.Longitude = 0.0F;
-                address.Location.Timestamp = DateTime.MinValue;
-                return;
-            }
-
-            try
-            {
-                if (!string.IsNullOrWhiteSpace(CoreUtils.GoogleAPIKey))
-                {
-                    IGeocoder geocoder = new GoogleGeocoder(CoreUtils.GoogleAPIKey);
-                    var add = geocoder.GeocodeAsync(string.Format("{0} {1} {2} Australia", address.Street, address.City, address.State)).Result
-                        .FirstOrDefault();
-                    if (add != null)
-                    {
-                        address.Location.Latitude = add.Coordinates.Latitude;
-                        address.Location.Longitude = add.Coordinates.Longitude;
-                        address.Location.Timestamp = DateTime.Now;
-                    }
-                }
-            }
-            catch (Exception e)
-            {
-                address.Location.Latitude = 0.0F;
-                address.Location.Longitude = 0.0F;
-                address.Location.Timestamp = DateTime.MinValue;
-            }
-        }
-
-        // public static string ReverseGeocode(double latitude, double longitude)
-        // {
-        //     if (string.IsNullOrEmpty(CoreUtils.GoogleAPIKey))
-        //         return "";
-        //     IGeocoder geocoder = new GoogleGeocoder(CoreUtils.GoogleAPIKey);
-        //
-        //     Geocoding.Address? add = null;
-        //     var geocode = Task.Run(async () =>
-        //         {
-        //             try
-        //             {
-        //                 var adds = await geocoder.ReverseGeocodeAsync(new Location(latitude, longitude));
-        //                 add = adds.FirstOrDefault();
-        //             }
-        //             catch (Exception e)
-        //             {
-        //                 Logger.Send(LogType.Error, "",$"Gecode Error: {e.Message}\n{e.StackTrace}");
-        //             }
-        //         }
-        //     );
-        //     return add?.FormattedAddress ?? string.Empty;
-        // }
     }
 }