Skip to content

Commit ccab867

Browse files
Mavrick-Fclaude
andcommitted
perf(analysis): start the nearest-pair search from the features' first vertices
They are a pair of the features' points, so the first pass prunes segment pairs from its first edge rather than only after measuring one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 9bd2a5d commit ccab867

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎crates/analysis/src/join.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ pub fn first_coord(g: &Geometry) -> Option<Coord> {
3535
/// in one centred between the pair found, where the plane is true near the answer however large
3636
/// the features are.
3737
pub fn distance_m(a: &Geometry, b: &Geometry) -> Option<f64> {
38-
let (p, q) = nearest_pair(a, b, &Aeqd::new(geodesic_interpolate(first_coord(a)?, first_coord(b)?, 0.5)), None)?;
38+
// The features' first vertices are a pair of their points: the search starts from them.
39+
let (fa, fb) = (first_coord(a)?, first_coord(b)?);
40+
let (p, q) = nearest_pair(a, b, &Aeqd::new(geodesic_interpolate(fa, fb, 0.5)), Some((fa, fb)))?;
3941
let (p, q) = nearest_pair(a, b, &Aeqd::new(geodesic_interpolate(p, q, 0.5)), Some((p, q))).unwrap_or((p, q));
4042
let d = haversine_m(p, q);
4143
d.is_finite().then_some(d)

0 commit comments

Comments
 (0)