public void CollectLocationData() { LocationFix loc = LocationFix.CollectData(); if (loc != null) { lock (_gpsLocationFixesLock) { _gpsLocationFixes.Add(loc); } } }
public static LocationFix CollectData() { if (GameClient.Geoposition.Coordinate == null) { return(null); //Nothing to collect } LocationFix loc = new LocationFix(); //Collect provider switch (GameClient.Geoposition.Coordinate.PositionSource) { case Windows.Devices.Geolocation.PositionSource.WiFi: case Windows.Devices.Geolocation.PositionSource.Cellular: loc.Provider = "network"; break; case Windows.Devices.Geolocation.PositionSource.Satellite: loc.Provider = "gps"; break; default: loc.Provider = "fused"; break; } //1 = no fix, 2 = acquiring/inaccurate, 3 = fix acquired loc.ProviderStatus = 3; //Collect coordinates loc.Latitude = (float)GameClient.Geoposition.Coordinate.Point.Position.Latitude; loc.Longitude = (float)GameClient.Geoposition.Coordinate.Point.Position.Longitude; loc.Altitude = (float)GameClient.Geoposition.Coordinate.Point.Position.Altitude; // TODO: why 3? need more infos. loc.Floor = 3; // TODO: why 1? need more infos. loc.LocationType = 1; //some requests contains absolute utc time and some relative to app start (bug?) loc.Timestamp = (ulong)GameClient.Geoposition.Coordinate.Timestamp.ToUnixTimeMilliseconds(); loc.HorizontalAccuracy = (float?)GameClient.Geoposition.Coordinate?.Accuracy ?? (float)_random.NextGaussian(0.0, 0.5); loc.VerticalAccuracy = (float?)GameClient.Geoposition.Coordinate?.AltitudeAccuracy ?? (float)_random.NextGaussian(0.0, 0.5); return(loc); }