Skip to content

Rhumb destinations do not wrap angles after the first pole intersection #1152

@joe-saronic

Description

@joe-saronic

Given that a rhumb line has finite length to a given pole, and that RhumbDestination appears to wrap correctly in one direction, one would expect that latitude would be bounded to +/-90 and longitude to +/-180 as the path length increased. Instead, we see the following:

image

Here is a rust program that dumps the data:

use geo::{Point, RhumbDestination};

use std::fs::OpenOptions;
use std::io::{BufWriter, Error, Write};

fn main() -> Result<(), Error> {
    let write = OpenOptions::new().write(true).create(true).open("./rhumb.csv");
    let mut writer = BufWriter::new(write.unwrap());
    let origin = Point::new(0.0, 0.0);
    for i in 0..1000000 {
        let dist = 100.0 * (i as f64);
        let dest = origin.rhumb_destination(45.0, dist);
        let lon = dest.x();
        let lat = dest.y();
        writer.write(format!("{dist:.16},{lon:.16},{lat:.16}\n").as_bytes())?;
    }
    Ok(())
}

and some python code to load and plot:

import pandas as pd
from matplotlib import pyplot as plt

df = pd.read_csv('rhumb.csv', header=None)
fig, ax = plt.subplots(2, 1, constrained_layout=True)
ax[0].plot(df[0], df[1])
ax[1].plot(df[0], df[2])
ax[0].set_title('Lon vs Dist')
ax[1].set_title('Lat vs Dist')

The expected fix would be that latitude would be clamped, either by taking the modulo of the path length from pole to pole, or empirically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions