MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / point_on_ring_boundary

Function point_on_ring_boundary

nodedb-spatial/src/predicates/edge.rs:88–105  ·  view source on GitHub ↗

Whether a point lies on any edge of a polygon ring.

(pt: [f64; 2], ring: &[[f64; 2]])

Source from the content-addressed store, hash-verified

86
87/// Whether a point lies on any edge of a polygon ring.
88pub 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///

Callers 11

st_intersectsFunction · 0.85
point_intersects_polygonFunction · 0.85
st_containsFunction · 0.85
polygon_contains_pointFunction · 0.85
polygon_contains_polygonFunction · 0.85
st_intersectionFunction · 0.85

Calls 4

point_on_segmentFunction · 0.85
firstMethod · 0.80
lenMethod · 0.45
lastMethod · 0.45

Tested by

no test coverage detected