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 distance_to_polyline function in position.rs #97

Open
nbuffon opened this issue Nov 22, 2023 · 0 comments
Open

Fix distance_to_polyline function in position.rs #97

nbuffon opened this issue Nov 22, 2023 · 0 comments
Labels
bug Something isn't working enhancement New feature or request Rust Rust code
Milestone

Comments

@nbuffon
Copy link
Member

nbuffon commented Nov 22, 2023

The current implementation uses geo:0.27 euclidean distance to get the distance between a point and a "polyline" object composed of several positions

The implementation has been here due to refactoring adaptation to the new Positionstruct and testing it is required

Problem is that the following unit tests fail
Is it dues to data or implementation ?

    macro_rules! test_distance_to_line {
        ($test_name:ident, $position:expr, $line:expr, $expected:expr) => {
            #[test]
            fn $test_name() {
                let epsilon = 1e-7;

                let distance = distance_to_line(&$position, $line);
                let delta = (distance - $expected).abs();

                assert!(
                    delta <= epsilon,
                    "Actual: {} (expected: {}",
                    distance,
                    $expected
                );
            }
        };
    }
    test_distance_to_line!(
        fifty_meters_north,
        position_from_degrees(48.62564545754, 2.24150940001, 0.),
        &[position_from_degrees(48.62519582726, 2.24150938995, 0.),
            position_from_degrees(48.62519580005, 2.24175355955, 0.)],
        50_f64
    );
    test_distance_to_line!(
        eigthen_meters_east,
        position_from_degrees(48.62519580005, 2.24175355955, 0.),
        &[position_from_degrees(48.62519582726, 2.24150938995, 0.),
            position_from_degrees(48.62564545754, 2.24150940001, 0.)],
        18_f64
    );
@nbuffon nbuffon added bug Something isn't working enhancement New feature or request Rust Rust code labels Nov 22, 2023
@nbuffon nbuffon added this to the 2.1.0 milestone Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request Rust Rust code
Projects
Status: No status
Development

No branches or pull requests

1 participant