Calculating Speed for a navigation app without getSpeed() method

前端 未结 4 1105
野性不改
野性不改 2020-12-28 23:42

I am developing an app which is more of a time-shift racing between your friends.

I need to calculate speed of a moving vehicle, and I don\'t want to use Locat

4条回答
  •  礼貌的吻别
    2020-12-29 00:42

    If the algorithm is correct?

    The distance calculation looks like the haversine formula which is correct. (There are much faster formulas for small distances (and you only use small distances), but haversine will work)

    Should I calculate in Centimeters instead of meters?

    Never use centimeter, stay with SI units, the unit of speed is meter/s. just use meter as floating point (double).

    Ios, where I am developping a tracking App, seems to be more friendly related to the getSpeed() nethod from Location class.

    But I (again?) warn you to use speeds at slow speed. If you get an invalid speed, then just stop calculation or mark it as invalid in your app. If the GPS chip cannot deliver a valid speed, it has good reason to do so, and it's an interesting question whether you will do it better. At low speed GPS tends to randomly jump around the true position, giving 5-30m jumps. It's very likely that your self calculated speed shows much more speed that the device is (not) moving. Try to fix your app, that it does not need speeds at low speeds.

提交回复
热议问题