georust / geo

Geospatial primitives and algorithms for Rust
https://crates.io/crates/geo
Other
1.49k stars 194 forks source link

Panic in the intersection function #1053

Open wzjsun opened 11 months ago

wzjsun commented 11 months ago

Code to reproduce::

use geo::{BooleanOps, Polygon, Coord, LineString};

#[test]
fn test() {
        // Reproduction occurs when intersecting Polygon<f32> types, but Polygon<f64> does not reproduce.
    let geo1 = Polygon::<f32>::new(LineString(vec![Coord { x: 0.0, y: 0.0 }, Coord { x: 0.0, y: 200.0 }, Coord { x: 200.0, y: 200.0 }, Coord { x: 200.0, y: 0.0 }, Coord { x: 0.0, y: 0.0 }]), vec![] );
    let geo2 = Polygon::<f32>::new(LineString(vec![Coord { x: -0.17588139, y: 0.0015348792 }, Coord { x: 1.5845897, y: 201.73154 }, Coord { x: 200.1759, y: 199.99846 }, Coord { x: 198.41544, y: -1.7315454 }, Coord { x: -0.17588139, y: 0.0015348792 }]), vec![] );
    let r = geo1.intersection(&geo2);
    println!("r=================={:?}", r);
}

Output::

---- test stdout ----
thread 'test' panicked at 'segment not found in active-vec-set: 1', C:\Users\chuanyan\.cargo\registry\src\github.com-1ecc6299db9ec823\geo-0.26.0\src\algorithm\sweep\vec_set.rs:22:14 
RobWalt commented 10 months ago

You encountered one of the many issues that are still left open with the implementation of BoolOps in geo. Please refer to #976

Edit: And thanks for the example test! 👍

RobWalt commented 9 months ago

I added this as a test to https://github.com/georust/geo/pull/1089 and it passes.