georust / rstar

R*-tree spatial index for the Rust ecosystem
https://docs.rs/rstar
Apache License 2.0
414 stars 68 forks source link

Better distance_2 docs #136

Closed urschrei closed 1 year ago

urschrei commented 1 year ago
adamreichold commented 1 year ago

I think the Envelope trait has the same issue for its distance_2 method.

urschrei commented 1 year ago

@adamreichold Good catch. Is it worth cautioning implementers that the two trait method implementations should use the same metric? I.e. can you imagine a situation in which they might be different?

adamreichold commented 1 year ago

@adamreichold Good catch. Is it worth cautioning implementers that the two trait method implementations should use the same metric? I.e. can you imagine a situation in which they might be different?

From how it is used in the nearest neighbour search, I think these two implementations of the underlying metric must definitely agree as the distance from envelopes to points is used as a lower bound for the distance between objects inside these envelopes to these points.

(From a semantics point of view, it would probably be nicer if the envelope type would implement PointDistance just as the object type does to stress this equivalence, but I guess this is not worth it to change retroactively.)