Orange-OpenSource / Orange-OpenSource/its-client

Fix `distance_to_polyline` function in `position.rs`

Open
#97 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Rust
Dominant language
Java
Stars
19
Forks
12
Avg merge
6d 8h
Merged PRs (30d)
3

Description

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
    );

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in position.rs by locating distance_to_polyline and the related distance_to_line tests shown in the issue. Run the failing unit tests and inspect how geo 0.27 calculates Euclidean distance with the refactored Position type. Done means determining whether the test data or implementation is wrong and making the tests pass with the expected distances.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.