Discrepancy in GPS co-ordinates between Esri LocationDisplay GPS co-ordinates and System.Device.Location.GeoCoordinateWatcher

1093
10
02-13-2024 06:36 AM
DaveMorrow
New Contributor II

 

What reason would there be a discrepancy in location between Esri maps using default Windows Location Services, getting a GPS signal (i.e. not a default wi-fi location) and Windows Location Services getting a location using Powershell?

Our application in UWP uses the below code to enable GPS location in Esri using Windows Location Services (default).

 

C# code below

 

Map.LocationDisplay.IsEnabled = true;

Map.LocationDisplay.DataSource.LocationChanged += (sender, eventArgs) => OnDeviceLocationChanged(sender, eventArgs);

private void OnDeviceLocationChanged(object sender, Location e)

{

_ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>

{

logger.Info($"Current Device Location:

Easting = { position.Easting}

Northing = { position.Northing}");

});

}

 

The log entry generated using Esri data is below.

Device Location: Easting = 631010.XXXXXXXXX Northing = 143140.XXXXXXXXX

 

Using a converter (https://gridreferencefinder.com/) to convert to Lat and Long, result is Lat

51.14 , long 1.30

 

Using System.Device.Location.GeoCoordinateWatcher using the powershell script below to capture GPS coordinates at the same time returns Lat 51.25, Long 0.514)

 

Powershell code below

 

Add-Type -AssemblyName System.Device

$GeoWatcher = New-Object System.Device.Location.GeoCoordinateWatcher

$GeoWatcher.Start()

 

while (($GeoWatcher.Status -ne 'Ready') -and ($GeoWatcher.Permission -ne 'Denied')) {

    Start-Sleep -Milliseconds 100 #Wait for discovery.

 

$GeoWatcher.Position.Location | Select Latitude,Longitude

 

See: https://learn.microsoft.com/en-us/dotnet/api/system.device.location.geocoordinatewatcher?view=netfra...

 

DaveMorrow_0-1707835596549.png

 

 

0 Kudos
10 Replies
DaveMorrow
New Contributor II

From our observations and testing we have concluded that Windows Location Service is not always able to get or provide a GPS-based location to the Esri runtime. We can use Powershell scripts to obtain GPS location but only using a slightly different API.

From comment above we understand that there is some caching involved which can be up to 1hr but we’ve seen examples where Esri has maintained a non-GPS based position for 4+hrs. Restarting the application resolves this which suggests that a GPS location was possible but not available due to a detection issue.

When GPS based location isn’t detected and wifi isn’t enabled, Windows will use IP based location hence the discrepancy we see here.

0 Kudos