Whether a point lies on any edge of a polygon ring.
(pt: [f64; 2], ring: &[[f64; 2]])
| 86 | |
| 87 | /// Whether a point lies on any edge of a polygon ring. |
| 88 | pub fn point_on_ring_boundary(pt: [f64; 2], ring: &[[f64; 2]]) -> bool { |
| 89 | if ring.len() < 2 { |
| 90 | return false; |
| 91 | } |
| 92 | for i in 0..ring.len() - 1 { |
| 93 | if point_on_segment(pt, ring[i], ring[i + 1]) { |
| 94 | return true; |
| 95 | } |
| 96 | } |
| 97 | // Check closing segment if ring isn't explicitly closed. |
| 98 | if ring.first() != ring.last() |
| 99 | && let (Some(&first), Some(&last)) = (ring.first(), ring.last()) |
| 100 | && point_on_segment(pt, last, first) |
| 101 | { |
| 102 | return true; |
| 103 | } |
| 104 | false |
| 105 | } |
| 106 | |
| 107 | /// Minimum squared distance from a point to a line segment. |
| 108 | /// |
no test coverage detected