2013-08-26 46 views
0

我正在開發一個windows手機運動跟蹤器應用程序,它使用gps傳感器來計算跑步者跑過的距離,我正在使用geocoordinatewatcher類,將移動閾值設置爲100.但是,我發現我的即使設備保持靜止,也可以提供距離值。只有當設備改變其位置時,我的應用纔會給出距離。我在市場上的其他應用程序中發現了相同的錯誤,請告訴我我在哪裏做錯了?
我的代碼。GPS準確性問題

watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); 
        watcher.MovementThreshold = 150; 
        watcher.PositionChanged += watcher_PositionChanged; 
        watcher.Start(); 
{ 
      latitudeCurrent = e.Position.Location.Latitude; 
      longitudeCurrent = e.Position.Location.Longitude; 
      if (stepCounter == 0) 
      { 
       latitudePrevious = latitudeCurrent; 
       longitudePrevious = longitudeCurrent; 
       distanceTravelled += Math.Round(Calculate(latitudePrevious,longitudePrevious,latitudeCurrent,longitudeCurrent),2); 
       txbDistanceTravelled.Text = distanceTravelled.ToString(); 
       txbCalories.Text=string.Format("{0:f0}", distanceTravelled * 65); 
       stepCounter++; 
       var millisPerKilometer = (distanceTravelled) * (System.Environment.TickCount - _previousPositionChangeTick); 
       txbPace.Text = TimeSpan.FromMilliseconds(millisPerKilometer).ToString(@"mm\:ss"); 
       double hrs = counterTick/3600; 
       if (!double.IsNaN((distanceTravelled/hrs))) 
       { 
        txbSpeed.Text = (distanceTravelled/hrs).ToString(); 
       } 
       else 
       { 
        txbSpeed.Text = "0"; 
       } 
} 
} 
+0

您是在室外還是在室內使用WiFi測試設備?如果你在室內,很可能你沒有使用GPS,因此失去了準確性,並切換到小區或wifi位置。也許啓用了一些記錄的調試信息,並帶你到外面散步的設備,看看你會得到什麼結果。 – LewisBenge

回答

0

您正在爲Windows Phone 7或Windows Phone 8開發應用程序嗎?如果您爲以後開發,則需要使用新的Geolocator類,而不是GeoCoordinateWatcher。

此外,正如LewisBenge所說,如果您正在測試這個室內,您可以獲得WiFi位置甚至蜂窩數據。測試室外可能會更好。

0

您的GPS信號可能在您正在測試的地方較弱。在戶外地點嘗試。