如何确定CLLocationManager返回的位置信息是否有效?

时间:2022-01-28 16:54:53

How can I determine if location information returned by CLLocationManager is valid?

如何确定CLLocationManager返回的位置信息是否有效?

3 个解决方案

#1


Two things to look for, the timestamp and the hdop (Horizontal Degree of Precision). The first one will tell you when the reading was taken, the second will tell you the level of error in the reading. For example a hdop of 1000 will tell you that the measurement is accurate to within 1000 metres. Obviously the lower the hdop the better.

要查找的两件事,时间戳和hdop(水平精度)。第一个会告诉你何时读数,第二个会告诉你读数的错误程度。例如,1000的hdop将告诉您测量精确到1000米以内。显然,hdop越低越好。

They are both in the Core Location update you get.

它们都在您获得的核心位置更新中。

#2


You can't be absolutely certain. You'll get the phone's best idea about where it is, and you can believe it or not, but you can't easily verify that location.

你不能绝对肯定。你会得到手机最好的概念,你可以信不信由你,但你不能轻易验证这个位置。

One thing that may help some is to check the timestamp the locations you get. Core Location will cache data, and the first result you get may be a very old reading. If the phone has moved at all it may be inaccurate. On the other hand it might still be correct, and you really can't be sure until new results come in. Nevertheless it's often useful to throw away any data from Core Location where the timestamp is from before your app started up-- it might be good data but there's a decent chance that it's not. Later readings will be new and are as trustworthy as the phone can make them.

可能对某些人有帮助的一件事是检查你获得的位置的时间戳。核心位置将缓存数据,您获得的第一个结果可能是一个非常古老的读数。如果手机完全移动,则可能不准确。另一方面,它可能仍然是正确的,并且在新结果出现之前你真的无法确定。但是,从应用程序启动之前的时间戳开始的Core Location中丢弃任何数据通常很有用 - 它可能是一个很好的数据,但它有一个不错的机会。后来的读物将是新的,并且与手机可以制造的一样值得信赖。

#3


Also, if the horizontal accuracy is negative, then the latitude and longitude are invalid.

此外,如果水平精度为负,则纬度和经度无效。

#1


Two things to look for, the timestamp and the hdop (Horizontal Degree of Precision). The first one will tell you when the reading was taken, the second will tell you the level of error in the reading. For example a hdop of 1000 will tell you that the measurement is accurate to within 1000 metres. Obviously the lower the hdop the better.

要查找的两件事,时间戳和hdop(水平精度)。第一个会告诉你何时读数,第二个会告诉你读数的错误程度。例如,1000的hdop将告诉您测量精确到1000米以内。显然,hdop越低越好。

They are both in the Core Location update you get.

它们都在您获得的核心位置更新中。

#2


You can't be absolutely certain. You'll get the phone's best idea about where it is, and you can believe it or not, but you can't easily verify that location.

你不能绝对肯定。你会得到手机最好的概念,你可以信不信由你,但你不能轻易验证这个位置。

One thing that may help some is to check the timestamp the locations you get. Core Location will cache data, and the first result you get may be a very old reading. If the phone has moved at all it may be inaccurate. On the other hand it might still be correct, and you really can't be sure until new results come in. Nevertheless it's often useful to throw away any data from Core Location where the timestamp is from before your app started up-- it might be good data but there's a decent chance that it's not. Later readings will be new and are as trustworthy as the phone can make them.

可能对某些人有帮助的一件事是检查你获得的位置的时间戳。核心位置将缓存数据,您获得的第一个结果可能是一个非常古老的读数。如果手机完全移动,则可能不准确。另一方面,它可能仍然是正确的,并且在新结果出现之前你真的无法确定。但是,从应用程序启动之前的时间戳开始的Core Location中丢弃任何数据通常很有用 - 它可能是一个很好的数据,但它有一个不错的机会。后来的读物将是新的,并且与手机可以制造的一样值得信赖。

#3


Also, if the horizontal accuracy is negative, then the latitude and longitude are invalid.

此外,如果水平精度为负,则纬度和经度无效。