Skip to content

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

Merged
smallsaucepan merged 1 commit intoTurfjs:masterfrom
IvoBiaus:earth-radius
Feb 18, 2025
Merged

Fix - Documented unit used for Earth's radius#2842
smallsaucepan merged 1 commit intoTurfjs:masterfrom
IvoBiaus:earth-radius

Conversation

@IvoBiaus
Copy link
Copy Markdown
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
@smallsaucepan
Copy link
Copy Markdown
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