locked
geocoordinate.timestamp - NOT cached ?

    Question

  • MSDN: geocoordinate.timestamp

    Registering for PositionChanged and StatusChanged on a Geolocator my device (inside a building) remains with a PositionStatus of "Initializing".

    Shortly after the page opens the PositionChanged event will return a PositionSource of "Satellite" and a values for Latitude and Longitude. These values appear to be cached as they're for another office I took the device to last week.

    The Geoposition.Coordinate.Timestamp property however doesn't appear to be cached though.

    Or perhaps it's the WindowsLocationSensor (driver) that is returning the cached values for source and position?

    The API reporting the source as Satellite when it isn't is rather frustrating.

            private void RegisterForGeolocationNotifications()
            {
                GetLocationDevicesAsync();
    
                _geolocator = new Geolocator();
                _geolocator.DesiredAccuracy = PositionAccuracy.High;
                _geolocator.DesiredAccuracyInMeters = desiredAccuracyInMeters;
                _geolocator.ReportInterval = 3000; // -- 3 seconds
                _geolocator.MovementThreshold = 5; // -- 5 metres
                _geolocator.PositionChanged += new TypedEventHandler<Geolocator, PositionChangedEventArgs>(OnGeolocationPositionChanged);
                _geolocator.StatusChanged += new TypedEventHandler<Geolocator, StatusChangedEventArgs>(OnGeolocationStatusChanged);
    
                ddlDesiredAccuracy.IsEnabled = true;
            }
    
            private void UnregisterForGeolocationNotifications()
            {            
                _geolocator.PositionChanged -= new TypedEventHandler<Geolocator, PositionChangedEventArgs>(OnGeolocationPositionChanged);
                _geolocator.StatusChanged -= new TypedEventHandler<Geolocator, StatusChangedEventArgs>(OnGeolocationStatusChanged);
                _geolocator = null;
            }
    
            async private void OnGeolocationPositionChanged(Geolocator sender, PositionChangedEventArgs e)
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {               
                    Geoposition pos = e.Position;
                    Double latitude = pos.Coordinate.Point.Position.Latitude;
                    Double longitude = pos.Coordinate.Point.Position.Longitude;
                    lblLatitude.Text = String.Format("{0:N6}", latitude);
                    lblLongitude.Text = String.Format("{0:N6}", longitude);
                    lblGeolocationAccuracy.Text = String.Format("{0} metres", pos.Coordinate.Accuracy.ToString());
                    lblGeolocationSource.Text = pos.Coordinate.PositionSource.ToString();
    
                    lblGeolocationPositionTimestamp.Text = pos.Coordinate.Timestamp.ToString("dd/MM/yyyy HH:mm:ss");
                        //DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
    
                });
            }





    • Edited by RD8388 Monday, July 21, 2014 5:06 PM
    Monday, July 21, 2014 5:03 PM

All replies

  • Hi RD8388,

    As I can see from the documentation: Values for the Latitude, Longitude, and Accuracy properties are always provided. I guess even there is no data, the cached value will be provided. And TimeStamp will always use your current system time.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by Jamles HezModerator Tuesday, July 29, 2014 3:28 AM
    • Unmarked as answer by RD8388 Tuesday, July 29, 2014 8:13 AM
    Tuesday, July 22, 2014 11:10 AM
    Moderator
  • Thanks James.

    I share your guess, but it would be great if the behavior for the timestamp property could be confirmed.

    Is the .PositionChanged event firing with a cached value not a lie?


    Tuesday, July 29, 2014 8:12 AM