我正在开发位置跟踪应用程序。一切都很好,但问题是当GPS运行时应用程序正在运行并显示错误的值时。所以我需要的是,如果GPS信号强度高或弱,文本标签应显示高和弱。当且仅当文本很高(GPS信号)时,应该运行应用程序。我已从此链接nokia community获取代码。与任何值或布尔值相比,是否可以跟踪GeoPositionAccuracy?
答案 0 :(得分:1)
尝试使用GeoCoordinate的HorizontalAccuracy和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
}
完全披露:我从未使用过这个。
答案 1 :(得分:1)
您可以使用水平和垂直精度。
Geolocator geolocator = new Geolocator();
geolocator.DesiredAccuracy = PositionAccuracy.High;
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
}