[英]GPS to calculate distance between two points on windows phone 7
我正在使用GPS计算两点之间的距离,即我使用Windows手机作为卷尺,但是当我开始我没有得到正确的值,即使我站着不动它给我数百米
这是我的代码
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";
}
}
}
到目前为止,准确性不是问题。 我运行这个应用程序并且当前位置的读数连续变化,而我已将movingthreshold设置为1意味着需要覆盖1米的距离来调用PositionChanged事件但是即使我仍然仍在阅读
这里的其他海报通常是正确的:GPS不会给你所需的准确性。 至少不是一个人!
假设你确实有一个很好的卫星定位,你可以获得厘米的精度,但这需要使用来自特殊固定站的信息或来自这样一个站的数据的实时馈送进行后处理。 这里的流行语是“实时相位差”,“实时动态”,“相位差分后处理”。
这个网站有一些细节。
所以,如果你可以访问饲料,它是可能的。 但它并不像你希望的那么容易。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.