georust / rstar

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

Better distance_2 docs #136

Closed urschrei closed 10 months ago

urschrei commented 10 months ago
adamreichold commented 10 months ago

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

urschrei commented 10 months 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 10 months 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.)