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

Proof of concept: Allow custom earth radii #1220

Closed
wants to merge 1 commit into from

Conversation

frewsxcv
Copy link
Member

  • I agree to follow the project's code of conduct.
  • I added an entry to CHANGES.md if knowledge of this change could be valuable to users.

@@ -37,16 +37,20 @@ pub trait RhumbDistance<T, Rhs = Self> {
/// ```
///
/// [rhumb line]: https://en.wikipedia.org/wiki/Rhumb_line
fn rhumb_distance(&self, rhs: &Rhs) -> T;
fn rhumb_distance(&self, rhs: &Rhs) -> T {
Copy link
Member Author

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:

fn rhumb_distance<Radius: MeanEarthRadius = Iugg>(&self, rhs: &Rhs) -> T {


impl MeanEarthRadius for Sphere {
const VALUE: f64 = 6371000.0;
}
Copy link
Member Author

Choose a reason for hiding this comment

The 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

@michaelkirk
Copy link
Member

michaelkirk commented Sep 30, 2024

With my work on #1216, I've been thinking about this too!

I was imagining something kind of like what you've laid out here. Here's a POC with configurable haversine: b89c07e

It's built on top of #1216 + the unified length trait I mentioned in #256 (I haven't opened a PR for #256 yet, I'm waiting on #1216 first).

One thing that my POC does not account for are methods on geometries - e.g. I haven't come up with a nice way to use a parameterized instance of a metric space (Haversine/Geodesic) to implement the unified Length trait. It seems likely doing so would require moving the implementation off of the geometry and onto an instance of Haversine.

So (e.g.) instead of line_string.length::<Haversine>() you'd do Haversine::wgs84().length(&line_string), Haversine::default().length(&line_string), etc.

@frewsxcv frewsxcv closed this Oct 25, 2024
@frewsxcv frewsxcv deleted the frewsxcv-24F31D92-9B4B-434B-9455-87902FCFB3BC branch October 25, 2024 22:37
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