GPS对Windows Phone 7的两点之间的距离计算 [英] GPS to calculate distance between two points on windows phone 7

查看:157
本文介绍了GPS对Windows Phone 7的两点之间的距离计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用GPS两点之间计算距离

即我使用Windows手机作为一个卷尺,但是当我开始我没有得到正确的值逸岸就算我站着不动它给了我几百米



下面是我的代码

  myWatcher.StatusChanged + =新的EventHandler< GeoPositionStatusChangedEventArgs>( myWatcher_StatusChanged); 
myWatcher.PositionChanged + =新的EventHandler< GeoPositionChangedEventArgs<&会有地理座标GT;>(myWatcher_PositionChanged);
myWatcher.MovementThreshold = 1;

无效myWatcher_PositionChanged(对象发件人,GeoPositionChangedEventArgs<&会有地理座标GT; E)
{
双tempf = e.Position.Location.Latitude;
双临时工= e.Position.Location.Longitude;
如果(COUNT2 == 0)
{
FirstLocation =新会有地理座标(tempf,临时工);
COUNT2 ++;
}
,否则
{
双distanceInMeter;
会有地理座标currentLocation;
currentLocation =新会有地理座标(tempf,临时工);
distanceInMeter = currentLocation.GetDistanceTo(FirstLocation);

如果(App.flag == 0)
{
textBlock1.Text = distanceInMeter.ToString()+M;
双distanceInCm = distanceInMeter * 100;
textBlock2.Text = distanceInCm的ToString()+厘米;
}
,否则如果(App.flag == 1)
{
双distanceInInch = distanceInMeter * 39.3701;
textBlock1.Text = distanceInInch.ToString()+中;
双distanceInFoot = distanceInMeter * 3.28084;
textBlock2.Text = distanceInFoot.ToString()+英尺;
}
}

}


解决方案

迄今精度不是一个问题。我连续运行这个程序,并读出在当前位置的变化,而我已设置movementthreshold为1表示需要覆盖调用PositionChanged事件,但读数不断即使我仍然


更改1米距离的

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";
                }
        }

    }

解决方案

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的两点之间的距离计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆