且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

iPhone CoreLocation:如何获得最准确的速度

更新时间:2023-02-26 17:21:26

为了获得***效果,应该使用kCLLocationAccuracyBest。你把你的距离过滤器取决于你愿意放置哪些故障。基本上,你将必须根据准确性与可用性做出决策。也就是说,在没有***准确度答案的期间,您将显示什么?



一种方法是让手机提供不太准确的答案,



也就是说,假设我以6英里/小时的速度慢跑北方。你沿着点A,点B,点C绘制我...然后你得到一个低精度的答案(也许kCLLocationAccuracyNearest100Meters。)看看它说,我的地方,并找出我可以得到了如果我继续沿着我的当前路径,对点C的点,对速度的可能变化进行合理的调整?如果是这样,那么新点在可能性的范围之内。 (如果没有,然后抛弃它。)然后从点C以我最后知道的速度项目,并计算出你认为我可能是,弹道的地方。保存为弹道点D。



当然,你使用加速度计得到某种惯性的感觉,我走了,对吧?所以,你不能知道方向(你不知道手机指向什么方式),但你可以在远处做出合理的刺。



使用所有这些信息,绘制你认为我可能是最可能的地方。



注意:测试时,不要只是在良好的小区覆盖区域。查看您的应用在山上的运行情况,远离手机。很多人喜欢自行车&慢跑这些区域!


I'm experimenting with adding the GPS functionality to my iPhone app. It's a workout app that will be used while walking or running. So what I want to use GPS for is to show the speed that the person is moving in Mph and minute/mile.

How should I configure the CLLocationManager so I get the best possible results? What should I set desiredAccuracy and distanceFilter?

I've tried with:

distanceFilter = 10 and desiredAccuracy = kCLLocationAccuracyNearestTenMeters

and reading

CLLocation.speed property

Testing while driving around in my car the accuracy seems good compared to the car speedometer although it takes a while to update. I realize that the update delay may very well be the time it takes to query the GPS location, but I'm not sure if changing the above two parameters would give better results.

Should I use kCLLocationAccuracyBest and some other value for distanceFilter?

I'm interested to hear from others using CoreLocation to get speed. What are you doing to get more accurate results?

For best results, you should use kCLLocationAccuracyBest. What you put into your distance filter depends on up with which faults you're willing to put. Basically, you're going to have to make decisions based on accuracy vs availability. That is, during periods when a best-accuracy answer is not available, what will you display?

One approach is to let the phone deliver less-accurate answers and, using a projection of what was happening the last time you had best-accuracy information, see if what you have makes sense.

That is, suppose I'm jogging at 6mph to the North. You plot me along point-A, point-B, point-C... then you get a low-accuracy answer (maybe kCLLocationAccuracyNearest100Meters.) Look at the spot where it says I am and figure out "could I have gotten to that spot from point-C if I'd continued along my current path, making reasonable adjustments for possible changes in speed?" If so, then the new point is within the realm of possibility. (If not, then toss it out.) Then project from point-C at my last-known speed and figure out where you think I probably am, ballistically. Save that as ballistic-point-D.

Of course, you're using the accelerometer to get some sort of inertial sense of which way I went, right? So, you can't know direction (you don't know what way the phone is pointing), but you can make a reasonable stab at distance.

Using all this information, plot the most likely spot where you think I probably am.

NOTE: When testing, don't just drive in good-cell coverage areas. See how your app performs out in the hills, away from cell phones. A lot of people like to bike & jog those areas!