vvanouytsel / jetspotter

MIT License
21 stars 2 forks source link

Fix conversion of kilometers to miles #17

Closed vvanouytsel closed 1 year ago

vvanouytsel commented 1 year ago

The bug is explained below via a copy paste of a reddit comment:

This is not correct:

// convertKilometersToMiles converts kilometers into miles. The miles are rounded.
func convertKilometersToMiles(kilometers float64) int {
    return int(kilometers / 1.60934)
}

Well, I mean it is, except that the API you’re using requires nautical miles not statute miles.

The ‘miles’ used by Americans and Brits to measure distance on the ground are ‘statute miles’. The distances used historically by boats on the water and adopted by airplanes are measured in ‘nautical miles’ which are 15% larger than statute miles.(*)

(*) well, except in USA aviation weather reports give the visibility in statute miles.

(**) And no doubt there are many more peculiarities in the way USA aviation reports and measures distances.

The divider is 1.852 to convert kilometers to nautical miles.

https://github.com/ADSB-One/api/blob/main/README.md

vvanouytsel commented 1 year ago

Fixed in https://github.com/vvanouytsel/jetspotter/pull/19