Skip to content

Commit 16b2d05

Browse files
authored
Merge pull request #1093 from urschrei/polydistenvelope
Use cached envelope for polygon-polygon euclidean distance
2 parents 263caab + aed06ea commit 16b2d05

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

geo/CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
* Use `CachedEnvelope` in R-Trees when computing euclidean distance between polygons
6+
* <https://github.com/georust/geo/pull/1093>
57
* Add an `inverse` method to `AffineTransform`
68
* <https://github.com/georust/geo/pull/1092>
79
* Fix `Densify` trait to avoid panic with empty line string.

geo/src/algorithm/euclidean_distance.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::{
77
};
88
use num_traits::{float::FloatConst, Bounded, Float, Signed};
99

10+
use rstar::primitives::CachedEnvelope;
1011
use rstar::RTree;
1112
use rstar::RTreeNum;
1213

@@ -585,8 +586,8 @@ pub fn nearest_neighbour_distance<T>(geom1: &LineString<T>, geom2: &LineString<T
585586
where
586587
T: GeoFloat + RTreeNum,
587588
{
588-
let tree_a: RTree<Line<_>> = RTree::bulk_load(geom1.lines().collect::<Vec<_>>());
589-
let tree_b: RTree<Line<_>> = RTree::bulk_load(geom2.lines().collect::<Vec<_>>());
589+
let tree_a = RTree::bulk_load(geom1.lines().map(CachedEnvelope::new).collect());
590+
let tree_b = RTree::bulk_load(geom2.lines().map(CachedEnvelope::new).collect());
590591
// Return minimum distance between all geom a points and geom b lines, and all geom b points and geom a lines
591592
geom2
592593
.points()

0 commit comments

Comments
 (0)