GPS to calculate distance between two points on windows phone 7

感情迁移 提交于 2019-12-20 02:34:50

问题


i am using GPS to calculate distance between two points i.e. i am using windows phone as a tape measure but when i start i dont get the correct value infact even if i am standing still it gives me hundreds of meter

here is my code

      myWatcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(myWatcher_StatusChanged);
        myWatcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(myWatcher_PositionChanged);
        myWatcher.MovementThreshold = 1;   

void myWatcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
    {
        double tempf = e.Position.Location.Latitude;
        double temps = e.Position.Location.Longitude;
        if (count2 == 0)
        {
            FirstLocation = new GeoCoordinate(tempf, temps);
            count2++;
        }
        else
        {
             double distanceInMeter;
            GeoCoordinate currentLocation;
                currentLocation = new GeoCoordinate(tempf, temps);
                distanceInMeter = currentLocation.GetDistanceTo(FirstLocation);                   

                if (App.flag == 0)
                {
                    textBlock1.Text = distanceInMeter.ToString() + " m";
                    double distanceInCm = distanceInMeter * 100;
                    textBlock2.Text = distanceInCm .ToString() + " cm";
                }
                else if (App.flag == 1)
                {
                    double distanceInInch = distanceInMeter * 39.3701;
                    textBlock1.Text = distanceInInch.ToString() + " in";
                    double distanceInFoot = distanceInMeter * 3.28084;
                    textBlock2.Text = distanceInFoot.ToString() + " ft";
                }
        }

    }

回答1:


At best, a GPS is only accurate to 3 meters. The more likely error is 5 - 10 meters.

You're going to have to augment your GPS readings to get better accuracy.




回答2:


so far accuracy is not an issue. i run this app and the reading at current location changes continuously while i have set movementthreshold to 1 means 1 meter of distance needs to be covered to call PositionChanged event but reading keeps on changing even though i am still




回答3:


The other posters here are generally correct: GPS will not give you the accuracy you need. At least not alone!

Assuming you did have a good satellite fix, you could get an accuracy of centimeters, but this would require post-processing with information from special fixed stations or a live feed of data from such a station. The buzzwords here are "real-time phase differential", "real-time kinematic", "phase-differential post-processing".

This site has some details.

So, if you can get access to feed, it may be possible. But it will not be as easy as you probably hoped.



来源:https://stackoverflow.com/questions/13825963/gps-to-calculate-distance-between-two-points-on-windows-phone-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!