Polygon (with holes) contains a point — strict DE-9IM (boundary = false).
(rings: &[Vec<[f64; 2]>], pt: [f64; 2])
| 106 | |
| 107 | /// Polygon (with holes) contains a point — strict DE-9IM (boundary = false). |
| 108 | fn polygon_contains_point(rings: &[Vec<[f64; 2]>], pt: [f64; 2]) -> bool { |
| 109 | let Some(exterior) = rings.first() else { |
| 110 | return false; |
| 111 | }; |
| 112 | |
| 113 | // Point on exterior boundary → NOT contained (DE-9IM). |
| 114 | if point_on_ring_boundary(pt, exterior) { |
| 115 | return false; |
| 116 | } |
| 117 | |
| 118 | // Point must be inside exterior ring. |
| 119 | if !point_in_polygon(pt[0], pt[1], exterior) { |
| 120 | return false; |
| 121 | } |
| 122 | |
| 123 | // Point must not be inside any hole. |
| 124 | for hole in &rings[1..] { |
| 125 | if point_in_polygon(pt[0], pt[1], hole) { |
| 126 | return false; |
| 127 | } |
| 128 | // Point on hole boundary is also outside (it's on A's boundary). |
| 129 | if point_on_ring_boundary(pt, hole) { |
| 130 | return false; |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | true |
| 135 | } |
| 136 | |
| 137 | /// Polygon contains a linestring — all vertices inside, no edge crossings with exterior. |
| 138 | fn polygon_contains_linestring(rings: &[Vec<[f64; 2]>], line: &[[f64; 2]]) -> bool { |
no test coverage detected