georust / rstar

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

Envelope on Point<f32> fails since v0.10 #128

Closed culebron closed 1 year ago

culebron commented 1 year ago

I wonder if PR #103 is the reason why simple code now fails to compile:

use geo::{Point, Translate};
use rstar::{RTreeObject, AABB};

#[derive(Debug, Clone)]
pub struct Stop {
    pub id: u32,
    pub geom: Point<f32>,
    pub buff: f32,
}

impl RTreeObject for Stop {
    type Envelope = AABB<Point<f32>>;
    fn envelope(&self) -> Self::Envelope {
        let p1 = self.geom.translate(-self.buff, -self.buff);
        let p2 = self.geom.translate(self.buff, self.buff);
        AABB::from_corners(p1, p2)
    }
}

Compiles with v0.9, fails since v0.10:

fn envelope(&self) -> Self::Envelope {
                      ^^^^^^^^^^^^^^ the trait `rstar::Point` is not implemented for `geo::Point<f32>`

Treating this literally, I can't fix it at all, because I own neither Point, nor rstar::Point, they're from other crates.

And from the discussion, I don't see how to fix it. Removing Copy bound seems to relax requirements, so things should have still worked, but they don't.

culebron commented 1 year ago

One more check: this works with geo = "^0.23" and rstar = "^0.9.3". Newer versions of any of them break it.

adamreichold commented 1 year ago

I think geo, in contrast to geo-types with its multiple use-rstar_0_x features, only supports one version of rstar, i.e. geo 0.23 uses rstar 0.9, but geo 0.24 and 0.25 use rstar 0.10. (I think neither geo nor geo-types have had releases supporting the current rstar 0.11 yet.)

adamreichold commented 1 year ago

I just checked and your code compiles using e.g.

[dependencies]
geo = "0.24"
rstar = "0.10"

or

[dependencies]
geo = "0.25"
rstar = "0.10"
culebron commented 1 year ago

Oh, I didn't know about use-rstar.. features, thanks! I'll check that out.

0.25 & 0.10 worked for me. I wonder why it fails with 0.25.1 & 0.11?

adamreichold commented 1 year ago

0.25 & 0.10 worked for me.

So we can close this?

I wonder why it fails with 0.25.1 & 0.11?

Because geo 0.25.1 uses rstar 0.10, it is just not compatible with rstar 0.11.

urschrei commented 1 year ago

0.25 & 0.10 worked for me.

So we can close this?

I wonder why it fails with 0.25.1 & 0.11?

Because geo 0.25.1 uses rstar 0.10, it is just not compatible with rstar 0.11.

Note that there is a PR open to make geo 0.25.2 compatible with rstar 0.11

culebron commented 1 year ago

So we can close this?

Yes. Thanks for help!

culebron commented 1 year ago

I've just ran into this issue another way: importing objects from one crate into another, I got same error, because in the target crate, versions combination was incorrect: geo 0.25 & rstar 0.11.

Here's the talk

urschrei commented 1 year ago

What crate is using rstar 0.11?