weird results when calculating WP7 GPS speed

386 views Asked by At

im trying to calculate speed by myself using Windows phone GPS Emulator by Cohen.

  void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
  {
    DateTime curTime       = DateTime.Now;
    double curDistance     = e.Position.Location.GetDistanceTo(lastKnownPosition);
    TimeSpan curTimeOffset = curTime - lastRecvTime;
    double curSpeed        = curDistance / curTimeOffset.TotalSeconds; 

when LastKnownPosition represents last GeoCoordinate, same thing about the lastRecvTime. problem here im getting unstable results regarding curSpeed. sometimes the speed is 10m/s and sometimes it jump to 20m/s.

what am i doing wrong here?

1

There are 1 answers

4
Stefan On

The GPS has limited accuracy. If you get 20 fixes per second and move - say 10m/s than the difference in position is about 0.5m between two fixes, which is usually (depending on hardware, line of sight to the satellites and number of satellites available to your GPS) below the accuracy of the GPS.

Try using a fix every few seconds or keep a queue (you can use a circular array to efficiently implement the queue) of fixes and use the average speed. I would suggest a combination of both.