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

Function linestrings_intersect

nodedb-spatial/src/predicates/intersects.rs:125–134  ·  view source on GitHub ↗

Two linestrings intersect if any of their segments cross.

(la: &[[f64; 2]], lb: &[[f64; 2]])

Source from the content-addressed store, hash-verified

123
124/// Two linestrings intersect if any of their segments cross.
125fn linestrings_intersect(la: &[[f64; 2]], lb: &[[f64; 2]]) -> bool {
126 for i in 0..la.len().saturating_sub(1) {
127 for j in 0..lb.len().saturating_sub(1) {
128 if segments_intersect(la[i], la[i + 1], lb[j], lb[j + 1]) {
129 return true;
130 }
131 }
132 }
133 false
134}
135
136/// LineString intersects polygon — any edge crossing, or any point inside.
137fn linestring_intersects_polygon(line: &[[f64; 2]], rings: &[Vec<[f64; 2]>]) -> bool {

Callers 1

st_intersectsFunction · 0.85

Calls 2

segments_intersectFunction · 0.85
lenMethod · 0.45

Tested by

no test coverage detected