平滑从 CoreLocation 接收的数据
我正在尝试开发一个应用程序,它可以让你四处走动,并且你走过的地方会被绘制在地图上。我已经一切正常,但我发现即使有相当准确的 GPS 位置,这些点仍然会有点跳动。当在地图上绘制时,这会产生创建波浪线或锯齿线的效果。
我正在寻找有关如何平滑数据的建议/策略,以便地图上绘制的线条更加平滑、最佳拟合,而不是精确的点对点绘制。
I'm trying to develop an app which allows you to walk around, and where you walked will be drawn on a map. I have this all working fine, but I'm finding that even with a reasonably accurate GPS location the points still jump around a bit. When drawn on a map this has the effect of creating a squiggly or zig-zag line.
I'm looking for suggestions/strategies on how to smooth the data, so that the line drawn on the map is more of a smooth best fit, rather than an accurate point to point drawing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以对数据应用许多不同类型的平滑算法(有关一些起点,请参阅这篇维基百科文章)。确定哪些方法适合您的应用程序的唯一方法是实施和测试它们。
简单或加权移动平均线相当常见(获取最后n个样本并对它们求平均值),但存在滞后于数据的问题。过滤信号噪声的一种常见方法是高通滤波器,它可以在通过较大的运动时衰减较小的(有噪声的)运动。 Apple 在其 AccelerometerGraph 示例中提供了一些相关代码。
我建议先尝试这些,因为它们很容易实现,然后再考虑移动复杂的。
There are many different types of smoothing algorithms you could apply to the data (for a few starting points, see this Wikipedia article). The only way to know for sure which is/are suitable for your application is to implement and test them.
Simple or weighted moving averages are fairly common (taking the last n samples and averaging them), but have the problem of lagging behind the data. A common one for filtering signal noise is a high-pass filter, which attenuates small (noisy) movements while passing through larger ones. Apple has some code for this in their AccelerometerGraph sample.
I'd suggest trying those out first as they're easy to implement, before looking at the move complex ones.