Device Location data when data source is WiFi

796
5
Jump to solution
11-30-2021 03:17 AM
jamc_70
New Contributor

Hi all, I wondered if anybody could help me.

We are building a UWP app (using runtime 100.12) and experimenting with the Device location functionality to plot the user's position on a map. 

This is on Windows, so using the Windows Location Service to provide the data. If there is no GPS device available, Windows will revert to WiFi to provide the approximate location.

However we've noticed that in this case the Esri device location reports a position of 0,0 most of the time, occasionally showing the approximate location, and the AdditionalSourceProperties says the source is "GNSS".

However if we use the native Windows Geolocation API, we get a correct position and a source of "Wifi".

Subscribing to the LocationChanged event, we can see the repeated 0,0 with the odd correct position thrown in:

30/11/2021 11:05:15:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:16:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:16:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:17:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:18:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:18:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:18:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:19:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:20:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:20:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:21:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:21:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:22:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:22:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:23:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:23:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:24:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:24:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:25:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:25:MapPoint[X=0.51206589, Y=51.273515, Z=0, Wkid=4326]
30/11/2021 11:05:26:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:27:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:27:MapPoint[X=0, Y=0, Z=0, Wkid=4326]
30/11/2021 11:05:28:MapPoint[X=0, Y=0, Z=0, Wkid=4326]

I just wondered if this was deliberate or if there is something we can do to get the Esri device location to consistently use the Wifi position if that is all that is available.

The other thing I wondered was how come the locationChanged event is firing twice a second when the position remains at 0,0.

Hope this makes sense and somebody can point me in the right direction.

Regards,

John

0 Kudos
1 Solution

Accepted Solutions
dotMorten_esri
Esri Notable Contributor

I've been unable to reproduce the issue, so I'm fairly certain it is device/driver specific. Here's an example of creating a datasource that uses the existing datasource and performs some simple location filtering:

 

    public class FilteredLocationDatasource : LocationDataSource
    {
        private readonly LocationDataSource internalDatasource = new SystemLocationDataSource();
        public FilteredLocationDatasource()
        {
            internalDatasource.LocationChanged += InternalDatasource_LocationChanged;
            internalDatasource.HeadingChanged += InternalDatasource_HeadingChanged;
        }

        private void InternalDatasource_HeadingChanged(object sender, double e) => base.UpdateHeading(e)

        private void InternalDatasource_LocationChanged(object sender, Location e)
        {
            if (e.Position.X != 0 && e.Position.Y != 0)
                base.UpdateLocation(e);
        }

        protected override Task OnStartAsync() => internalDatasource.StartAsync();
        protected override Task OnStopAsync() => internalDatasource.StopAsync();
    }

 

View solution in original post

0 Kudos
5 Replies
dotMorten_esri
Esri Notable Contributor

Thank you for reporting this. The underlying datasource used for location is the Geolocator, so it should be identical. I double-checked our code and if geoposition.Coordinate.PositionSource == PositionSource.WiFi it should say "WIFI", and only if PositionSource.Satellite it should say GNSS.

How are you creating the geolocator you used for comparison? I wonder if you're seeing different behavior on different ways of creating it? Here's the equivalent settings the runtime uses:

new Geolocator()
{
  DesiredAccuracy = PositionAccuracy.High,
  MovementThreshold = 0,
  ReportInterval = 1000,
};

 
The other thing I wondered was how come the locationChanged event is firing twice a second when the position remains at 0,0.

There might be other things changing, like accuracy, elevation, heading, speed etc.

0 Kudos
jamc_70
New Contributor

Thanks Morten for your reply and the information.

Yes you're right. We were setting the accuracy to default when creating the GeoLocator. If I changed this to High then the Geolocator started publishing LocationChanged events every second with source="Satellite" but 0,0 coords just like the Esri component was, and when it occasionally emits an actual location, the positionSource changed to "WiFi". 

So it seems that if you set the positionaccuracy to High the Windows geolocator emits a 0,0 coord constantly (with source=satellite) until it occasionally gets a WiFi based coordinate, whereupon it emits that instead.

So here you can see where I'm writing out both as they publish their respective events:

Geolocator:X=0,Y=0,PositionSource=Satellite
Geolocator:X=0.51206589,Y=51.273515,PositionSource=WiFi
Geolocator:X=0.51206589,Y=51.273515,PositionSource=WiFi
EsriDeviceLocation:MapPoint[X=0, Y=0, Z=0, Wkid=4326], positionSource=GNSS
EsriDeviceLocation:MapPoint[X=0, Y=0, Z=0, Wkid=4326], positionSource=GNSS
EsriDeviceLocation:MapPoint[X=0, Y=0, Z=0, Wkid=4326], positionSource=GNSS
EsriDeviceLocation:MapPoint[X=0, Y=0, Z=0, Wkid=4326], positionSource=GNSS
EsriDeviceLocation:MapPoint[X=0, Y=0, Z=0, Wkid=4326], positionSource=GNSS
EsriDeviceLocation:MapPoint[X=0, Y=0, Z=0, Wkid=4326], positionSource=GNSS
EsriDeviceLocation:MapPoint[X=0, Y=0, Z=0, Wkid=4326], positionSource=GNSS
EsriDeviceLocation:MapPoint[X=0, Y=0, Z=0, Wkid=4326], positionSource=GNSS
EsriDeviceLocation:MapPoint[X=0, Y=0, Z=0, Wkid=4326], positionSource=GNSS
EsriDeviceLocation:MapPoint[X=0, Y=0, Z=0, Wkid=4326], positionSource=GNSS
EsriDeviceLocation:MapPoint[X=0, Y=0, Z=0, Wkid=4326], positionSource=GNSS
EsriDeviceLocation:MapPoint[X=0, Y=0, Z=0, Wkid=4326], positionSource=GNSS
Geolocator:X=0.51206589,Y=51.273515,PositionSource=WiFi
EsriDeviceLocation:MapPoint[X=0.51206589, Y=51.273515, Z=0, Wkid=4326], positionSource=WIFI
EsriDeviceLocation:MapPoint[X=0, Y=0, Z=0, Wkid=4326], positionSource=GNSS
EsriDeviceLocation:MapPoint[X=0, Y=0, Z=0, Wkid=4326], positionSource=GNSS
EsriDeviceLocation:MapPoint[X=0, Y=0, Z=0, Wkid=4326], positionSource=GNSS
EsriDeviceLocation:MapPoint[X=0, Y=0, Z=0, Wkid=4326], positionSource=GNSS

The problem for us here is that we don't really want to show this on the map, as if we are using the autopan mode it zooms us to somewhere a long way away from our map (which is just the SE of England).

Is there a way to configure your device location to not show if the coords are being reported as 0,0?

Thanks again for your help.

Regards,

John

 

0 Kudos
dotMorten_esri
Esri Notable Contributor

In that case, this sounds like a location driver issue on your device. You might want to check for updated drivers or reach out to the hardware manufacturer.

0 Kudos
dotMorten_esri
Esri Notable Contributor

I've been unable to reproduce the issue, so I'm fairly certain it is device/driver specific. Here's an example of creating a datasource that uses the existing datasource and performs some simple location filtering:

 

    public class FilteredLocationDatasource : LocationDataSource
    {
        private readonly LocationDataSource internalDatasource = new SystemLocationDataSource();
        public FilteredLocationDatasource()
        {
            internalDatasource.LocationChanged += InternalDatasource_LocationChanged;
            internalDatasource.HeadingChanged += InternalDatasource_HeadingChanged;
        }

        private void InternalDatasource_HeadingChanged(object sender, double e) => base.UpdateHeading(e)

        private void InternalDatasource_LocationChanged(object sender, Location e)
        {
            if (e.Position.X != 0 && e.Position.Y != 0)
                base.UpdateLocation(e);
        }

        protected override Task OnStartAsync() => internalDatasource.StartAsync();
        protected override Task OnStopAsync() => internalDatasource.StopAsync();
    }

 

0 Kudos
jamc_70
New Contributor

OK Morten thanks for the device driver suggestion, I will look into that, and for the sample code, that is most useful.

Thanks for your time and effort helping with this, it is much appreciated.

Regards,

John

John

0 Kudos