-
Notifications
You must be signed in to change notification settings - Fork 200
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
Proof of concept: Allow custom earth radii #1220
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use crate::CoordNum; | ||
use num_traits::FromPrimitive; | ||
|
||
/// Trait representing different mean earth radii | ||
pub trait MeanEarthRadius { | ||
const VALUE: f64; | ||
|
||
fn value<T: CoordNum + FromPrimitive>() -> T { | ||
T::from(Self::VALUE).unwrap() | ||
} | ||
} | ||
|
||
/// Represents the WGS84 mean earth radius. | ||
/// | ||
/// The WGS84 (World Geodetic System 1984) is a standard for use in cartography, geodesy, and satellite navigation. | ||
/// The mean earth radius for WGS84 is approximately 6378137.0 meters. | ||
pub struct Wgs84; | ||
|
||
/// Represents the GRS80 mean earth radius. | ||
/// | ||
/// The GRS80 (Geodetic Reference System 1980) is a geodetic reference system consisting of a global reference ellipsoid and a gravity field model. | ||
/// The mean earth radius for GRS80 is approximately 6378137.0 meters. | ||
pub struct Grs80; | ||
|
||
/// Represents the mean earth radius as recommended by the IUGG. | ||
/// | ||
/// The mean earth radius for this model is approximately 6371008.8 meters. | ||
/// This value is recommended by the IUGG: | ||
/// Moritz, H. (2000). Geodetic Reference System 1980. Journal of Geodesy, 74(1), 128–133. doi:10.1007/s001900050278 | ||
/// "Derived Geometric Constants: mean radius" (p133) | ||
/// https://link.springer.com/article/10.1007/s001900050278 | ||
/// https://sci-hub.se/https://doi.org/10.1007/s001900050278 | ||
/// https://en.wikipedia.org/wiki/Earth_radius#Mean_radius | ||
pub struct Iugg; | ||
|
||
/// Represents a spherical mean earth radius. | ||
/// | ||
/// This is a simplified model assuming the Earth is a perfect sphere. | ||
/// The mean earth radius for a sphere is approximately 6371000.0 meters. | ||
/// This value is commonly used in various scientific, educational, and engineering contexts for simplicity. | ||
pub struct Sphere; | ||
|
||
impl MeanEarthRadius for Wgs84 { | ||
const VALUE: f64 = 6378137.0; | ||
} | ||
|
||
impl MeanEarthRadius for Grs80 { | ||
const VALUE: f64 = 6378137.0; | ||
} | ||
|
||
impl MeanEarthRadius for Iugg { | ||
const VALUE: f64 = 6371008.8; | ||
} | ||
|
||
impl MeanEarthRadius for Sphere { | ||
const VALUE: f64 = 6371000.0; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not at all attached to these particular struct names or this particular set of options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly rust doesn't allow us to do something like this: