Point intersects polygon — inside OR on boundary.
(pt: [f64; 2], rings: &[Vec<[f64; 2]>])
| 94 | |
| 95 | /// Point intersects polygon — inside OR on boundary. |
| 96 | fn point_intersects_polygon(pt: [f64; 2], rings: &[Vec<[f64; 2]>]) -> bool { |
| 97 | let Some(exterior) = rings.first() else { |
| 98 | return false; |
| 99 | }; |
| 100 | |
| 101 | // On exterior boundary → intersects. |
| 102 | if point_on_ring_boundary(pt, exterior) { |
| 103 | return true; |
| 104 | } |
| 105 | |
| 106 | // Must be inside exterior. |
| 107 | if !point_in_polygon(pt[0], pt[1], exterior) { |
| 108 | return false; |
| 109 | } |
| 110 | |
| 111 | // Must not be inside a hole (but on hole boundary counts as intersects). |
| 112 | for hole in &rings[1..] { |
| 113 | if point_on_ring_boundary(pt, hole) { |
| 114 | return true; |
| 115 | } |
| 116 | if point_in_polygon(pt[0], pt[1], hole) { |
| 117 | return false; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | true |
| 122 | } |
| 123 | |
| 124 | /// Two linestrings intersect if any of their segments cross. |
| 125 | fn linestrings_intersect(la: &[[f64; 2]], lb: &[[f64; 2]]) -> bool { |
no test coverage detected