0

我正在开发位置跟踪应用程序。一切都很好,但问题是当 GPS 很弱时,应用程序正在运行并显示错误的值。所以我需要的是,如果 GPS 信号强度高或弱,文本标签应该显示高和弱。当且仅当文本很高(GPS 信号)时,应用程序才应该运行。我从这个链接诺基亚社区获取了代码。与任何值或布尔值相比,是否可以跟踪 GeoPositionAccuracy?

4

2 回答 2

1

您可以使用水平和垂直精度。

Geolocator geolocator = new Geolocator();
geolocator.DesiredAccuracy = PositionAccuracy.High;

注意 - DesiredAccuracy

geolocator.ReportInterval = ....; // or MovementThreshold
geolocator.PositionChanged += GeolocatorPositionChanged;

double YOUR_HORIZONTAL_ACCURACY = 20; // accuracy in metres
double YOUR_VERTICAL_ACCURACY = 20;   // accuracy in metres

private void GeolocatorPositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
    GeoCoordinate coordinate = args.Position.Coordinate.ToGeoCoordinate(); // ToGeoCoordinate method is extension from the Windows Phone Toolkit

    if ((Double.IsNaN(coordinate.HorizontalAccuracy) || coordinate.HorizontalAccuracy > YOUR_HORIZONTAL_ACCURACY) && (Double.IsNaN(coordinate.VerticalAccuracy) || coordinate.VerticalAccuracy > YOUR_VERTICAL_ACCURACY))
    {
        // weak
    }

    else
    {
        // high
    }
于 2013-10-29T09:07:11.323 回答
1

尝试使用 GeoCoordinate 的 Horizo​​ntalAccuracy 和 VerticalAccuracy 属性。

private void Watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e){
    if(Math.Sqrt(Math.Pow(e.Position.Location.HorizontalAccuracy,2) + Math.Pow(e.Position.Location.VerticalAccuracy,2)) < Tolerance_In_Meters)
        //accurate enough
    else
        //not accurate enough
}

地理坐标文档

完全披露:我从未使用过这个。

于 2013-10-28T23:34:42.093 回答