问题描述
我正在构建一个Android应用,我需要以非常高的频率获得非常准确的位置。
我在Google Play服务api中寻找位置,并发现LocationRequest.setSmallestDisplacement对于限制电池消耗非常有用。然而,当我在室内测试它时,我得到的地点的准确度有很大的不同(有时候是10米,有时候是96米......),即使我将我的请求的优先级设置为高精度。
我的问题是setSmallestDisplacement没有提供最后返回的准确性。
所以如果我的位置精确度很低,我仍然需要走我的最小位移距离来获得一个新位置,希望更准确。
我想知道是否有办法避免这样的数据(我不能使用不够准确的位置),或者如果我不得不跳过setSmallestDisplacement部分(对电池消耗不好)。
您的快乐代码:
mLocationRequest = LocationRequest.create();
mLocationRequest.setInterval(100); //我们每100ms获得一个新位置
//mLocationRequest.setSmallestDisplacement(5); //但是只有当我们走过5m
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
谢谢。
LocationRequest.setSmallestDisplacement对于准确性无关紧要,只是为了避免不必要的更新,您可以继续使用它。
没有方法来提高准确性,如果您对低准确度的头寸没有兴趣,只需跳过这个位置并等待更好的头寸就可以得到一个准确的点(好或坏)。
本页面可以帮助您了解准确度和消耗量,但请记住没有完美的准确度,Wi-Fi准确度为100m,准确度更差。
在这里你有每个优先级的准确性。
这里来自Google工程师的IO Session, ry很有用,您也可以在那里获得PDF。
更新的链接brokens
$ b
希望这有助于:D 。
I'm building an Android app in which I need to have a very accurate location at a very high frequency.I dove into google play services api for location, and found the LocationRequest.setSmallestDisplacement very useful to limit battery consumption.
However, as I am testing it indoor, the locations I get have an accuracy that varies a lot (sometimes 10m, sometimes 96m...), even when I set the Priority of my request as high accuracy.
My prob1em is that setSmallestDisplacement doesn't give a sh*it about the accuracy that is returned last.So if I get a location with a very low accuracy, I will still have to walk my "smallest displacement" distance to get a new one, hopefully more accuracte.
I wonder if there is a way to avoid such data (I can't use location that are not accurate enough) or if I have to skip the setSmallestDisplacement part (bad for battery consumption).
Some code for your pleasure:
mLocationRequest = LocationRequest.create();
mLocationRequest.setInterval(100); //We get a new location every 100ms or so
//mLocationRequest.setSmallestDisplacement(5); //but only if we traveled 5m
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
Thanks.
The "LocationRequest.setSmallestDisplacement" doesn't matter for accuracy, it's just to avoid unnecessary updates, you can continuing using that.
There is no method to enhance low accuracy, you just get a point with some accuracy (better or worse), if you are not interested on positions with low accuracy just skip this location and wait for a better one.
This page could help you about accuracy and consumption, but take in mind no perfect accuracy exist, with Wi-Fi the accuracy is 100m for worse accuracy.
Here you have the accuracy for each priority.
https://developer.android.com/training/location/receive-location-updates.html#location-request
Here the IO Session from Google engineers, very useful, you can get the PDF there too.
Updated Links brokens
The PDF Presentation
The IO session
Hope this helps :D.
这篇关于LocationRequest最小位移和准确性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!