问题描述
我正在使用 GPS 计算两点之间的距离,即我使用 windows phone 作为卷尺,但是当我开始时,即使我站着不动,我也没有得到正确的值,实际上它给了我数百米
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
这是我的代码
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 意味着需要覆盖 1 米的距离才能调用 PositionChanged 事件,但即使我还在,读数也会不断变化
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
这篇关于GPS计算windows phone 7上两点之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!