颤振位置跟踪问题

问题描述 投票:0回答:1

我正在尝试在我的应用程序上使用实时GPS跟踪来跟踪用户的移动,但整个过程是如此不一致。我正在使用两个推荐的库来实现此目的。这是我正在使用的两个库:

这里是问题。这两个库都返回坐标,但是每当我死了时,GPS坐标就会不断跳来跳去。我确实将手机放在桌子上,我会看到这两个库每秒都给我不同的坐标,即使我的手机还是死了。我通常会说坐标通常在10米以内,但绝对不符合我的核心应用功能,因为至少我需要准确性或一致性。我很可能会缺少一些东西,如果可以的话,请有人帮助。这是同时使用两个库的代码:

位置库:

var location = new Location();

        location.onLocationChanged().listen((LocationData currentLocation) {
          print("Coord: ${currentLocation.latitude} ${currentLocation.longitude}");
          _approachingGate
              .getApproachingGate(
                  Position(
                      latitude: currentLocation.latitude,
                      longitude: currentLocation.longitude),
                  _userGates,
                  distance: 0)
              .then((Map<String, Object> value) {
            _nearbyGate = value[Constants.GATE];
            notifyListeners();
          });
        });

Geolocator库:

var geoLocator = Geolocator();
        var locationOptions = LocationOptions(
            accuracy: LocationAccuracy.bestForNavigation,);

        Position position = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.best);
        _approachingGate
            .getApproachingGate(position, _userGates,distance: 8)
            .then((Map<String, Object> value) {
          _nearbyGate = value[Constants.GATE];
          notifyListeners();

        });

        _positionStream = geoLocator
            .getPositionStream(locationOptions)
            .listen((Position position) {
              print("Coord: ${position.latitude} ${position.longitude}");
          _position = position;
          var x = 2.0;
          _approachingGate
              .getApproachingGate(position, _userGates,distance: x)
              .then((Map<String, Object> value) {
            _nearbyGate = value[Constants.GATE];

            notifyListeners();

          });

GeoLocator库允许我使用distanceFilter仅在移动一定距离后进行更新,由于某种原因,它仅在需要时才可用。

[这里是我在忙于键入而设备仍然在桌子上的时候刚刚得到的一些输出。

I/flutter ( 7705): Coord: -26.1010019 28.0388391
I/flutter ( 7705): Coord: -26.101002 28.0388395
I/flutter ( 7705): Coord: -26.1010019 28.0388403
I/flutter ( 7705): Coord: -26.1010018 28.0388407
I/flutter ( 7705): Coord: -26.1010018 28.0388393
I/flutter ( 7705): Coord: -26.1010026 28.0388364
I/flutter ( 7705): Coord: -26.1010022 28.0388392
I/flutter ( 7705): Coord: -26.101002 28.0388393
I/flutter ( 7705): Coord: -26.1010021 28.0388405
I/flutter ( 7705): Coord: -26.1010024 28.03884
I/flutter ( 7705): Coord: -26.1010025 28.038839
I/flutter ( 7705): Coord: -26.1010022 28.0388383
I/flutter ( 7705): Coord: -26.1010423 28.0388409
I/flutter ( 7705): Coord: -26.1010033 28.0388375
flutter dart geolocation location
1个回答
0
投票

问题是您做对了。我的意思是,我与Flutter Geolocator一起工作了很多(与Location在一起的时间很少),但我遇到了同样的问题。我深入研究了API和Android的来源。您可以在Android核心库的Javadoc(FusedLocationProviderClient和Location)中找到相应的说明。例如,在此链接中,您可以看到Android本身返回的GPS位置的“准确性”为68%(或多或少一个sigma,具有高斯分布)。Javadoc警告您:

我们将水平精度定义为68%置信度的半径。换句话说,如果您绘制一个以该位置的纬度为中心的圆和经度,并且半径等于精度,则是真实位置在圆内的概率为68%

因此,您每次启动服务时都会产生数据,并且没有任何抽象库(如Geolocator或类似的东西)能比Android更好或解决错误。IO应该更准确,但是我主要使用Android,因此我几乎没有数据。文档的两个链接:

位置:

https://developer.android.com/reference/android/location/Location#getAccuracy()

FusedLocationProviderClient:

https://developers.google.com/android/reference/com/google/android/gms/location/FusedLocationProviderClient

我希望有帮助,问候。

© www.soinside.com 2019 - 2024. All rights reserved.