Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - Documented unit used for Earth's radius #2842

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

IvoBiaus
Copy link
Contributor

@IvoBiaus IvoBiaus commented Feb 17, 2025

Corrected the "unit" that is documented as the one being used for the Earth's radius, from "kilometers" to "meters".

The constant value is: 6371008.8, which is + 6 million, that would be meters.
As mentioned in the Wikipedia that is referenced in the documentation https://en.wikipedia.org/wiki/Earth_radius#Arithmetic_mean_radius

For Earth, the arithmetic mean radius is 6,371.0088 km (3,958.7613 mi).

6371 km are 6.371.000 meters.


This change should not bring any errors, since only changes the documentation, instead of changing the constant value to kilometers.

I took a quick look, and the code seems to have been done using the correct "meters" unit, for example when checking out the factors constant:

export const factors: Record<Units, number> = {
  centimeters: earthRadius * 100,
  centimetres: earthRadius * 100,
  degrees: 360 / (2 * Math.PI),
  feet: earthRadius * 3.28084,
  inches: earthRadius * 39.37,
  kilometers: earthRadius / 1000,  // <------
  kilometres: earthRadius / 1000,  // <------
  meters: earthRadius,  // <------
  metres: earthRadius,  // <------
  miles: earthRadius / 1609.344,
  millimeters: earthRadius * 1000,
  millimetres: earthRadius * 1000,
  nauticalmiles: earthRadius / 1852,
  radians: 1,
  yards: earthRadius * 1.0936,
};

@IvoBiaus IvoBiaus changed the title Fix - Documented used for Earth's radius Fix - Documented unit used for Earth's radius Feb 17, 2025
@smallsaucepan smallsaucepan merged commit e6d540a into Turfjs:master Feb 18, 2025
3 checks passed
@smallsaucepan
Copy link
Member

Thanks for fixing this @IvoBiaus 👍

@IvoBiaus IvoBiaus deleted the earth-radius branch February 18, 2025 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants