颤音位置返回速度准确性为-1

发布于 2025-02-10 19:19:29 字数 1073 浏览 3 评论 0原文

我正在使用ios真实设备(iPhonexs-也许是iOS 13)在调试模式下定期测量速度,并在室内运行。

这是我的代码。

class _TimerScreenState extends State<TimerScreen> {
  Timer? timer;
  int restMilliSec = 0;
  int setCnt = 0;
  @override
  void initState() {
    super.initState();

    bool canVibrate;
    restMilliSec = decideTimerTime(currentType) * 1000; 
    timer = Timer.periodic(Duration(milliseconds: 1), (timer) async {
        // ... other code for another logic... //
        if (canVibrate) Vibrate.vibrate();
        setLocation();
      }
    });
  }

    void setLocation() async {
        Location location = Location();
        LocationData _currentPosition = await location.getLocation();
        print("accuracy : ${_currentPosition.accuracy}, speed: ${_currentPosition.speed}");
        print("Speed Accuracy : ${_currentPosition.speedAccuracy}");
    }
}

我不知道-1的含义是什么。 如何获得速度的正数? 其他值打印得很好。

I'm using Flutter and location package for measuring speed periodically in my iOS real device(iPhoneXS - maybe iOS 13) in debug mode and also running indoors.

This is my code.

class _TimerScreenState extends State<TimerScreen> {
  Timer? timer;
  int restMilliSec = 0;
  int setCnt = 0;
  @override
  void initState() {
    super.initState();

    bool canVibrate;
    restMilliSec = decideTimerTime(currentType) * 1000; 
    timer = Timer.periodic(Duration(milliseconds: 1), (timer) async {
        // ... other code for another logic... //
        if (canVibrate) Vibrate.vibrate();
        setLocation();
      }
    });
  }

    void setLocation() async {
        Location location = Location();
        LocationData _currentPosition = await location.getLocation();
        print("accuracy : ${_currentPosition.accuracy}, speed: ${_currentPosition.speed}");
        print("Speed Accuracy : ${_currentPosition.speedAccuracy}");
    }
}

I don't know what's the meaning of -1.
How can I get positive number for speed?
Other values are printed well.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

葮薆情 2025-02-17 19:19:29

iOS上的coreLocation的文档(在其上flutter 位置软件包是建立的)指定-1的含义for a>:

负值表示无效的速度。

speedaccuracy

此属性包含一个负数时,速度属性中的值无效。

因此,随着您的推论,负值表示无效或不可用的速度。 为什么在没有更多信息的情况下,很难说您的速度像无效一样回来。

The documentation for CoreLocation on iOS (upon which the Flutter location package is built) specifies the meaning of -1 for speed:

A negative value indicates an invalid speed.

and speedAccuracy:

When this property contains a negative number, the value in the speed property is invalid.

Thus, as you've deduced, negative values indicate an invalid or unavailable speed. Why your speed as coming back as invalid is difficult to say without more information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文