Home > Back-end >  Official android.location.Location.getBearing() documentation out of sync with Android project sourc
Official android.location.Location.getBearing() documentation out of sync with Android project sourc

Time:05-02

The source code for getBearing() method states:

    /**
     * Get the bearing, in degrees.
     *
     * <p>Bearing is the horizontal direction of travel of this device,
     * and is not related to the device orientation. It is guaranteed to
     * be in the range (0.0, 360.0] if the device has a bearing.
     *
     * <p>If this location does not have a bearing then 0.0 is returned.
     */

But the official Android docs for that class have the range defined as:

The bearing is guaranteed to be in the range [0, 360). 

which clearly differs in whether 0 or 360 is valid or invalid.

The weird thing the source for this class has basically stayed the same for years and the documentation for it in developer portal has changed only recently to this.

If there is a place where I could report this issue to the maintainers of the developer portal, please let me know.

CodePudding user response:

If you think about it: 360 degrees are a full turn. So 0° is equal to 360° degrees after normalization. the desync is propably because of a different version, cause the official doku is also javadoc.

CodePudding user response:

The documentation is generated from the source code. So I would expect the code to be correct, and the documentation just to need to be re uploaded. The difference between these two can be solved by using getBearing()60.0f, which will force it into [0,360.0)

  • Related