Giter VIP home page Giter VIP logo

Comments (3)

nmandery avatar nmandery commented on June 6, 2024

There is not really a lot of documentation for the experimental CoordIJ functions sadly. A little bit exists here. I played around with these functions a while ago trying to implement a region-growing algorithm, but abandoned it after a while. I just had a quick look, but seems I do not have that anymore - and to be honest - I do not remember to many details of CoordIJ anymore.

I also had that expectation in the beginning that all indices of ring 1 around an origin index are in the range of '(-1..1, -1..1)', but the last bullet point of the link above mentions

the origin may not be at (0, 0) in the local coordinate space.

So origin seems to be only used to determinate which local coordinate system to use. I just modified the unittest to this:

    #[test]
    fn test_local_ij() {
        let index = Index::try_from(0x89283080ddbffff_u64).unwrap();
        let ring = index.k_ring(1);
        assert_ne!(ring.len(), 0);
        let other = ring.iter().find(|i| **i != index).unwrap().clone();

        let coordij1 = h3_to_local_ij(&index, &index).unwrap();
        dbg!(coordij1.i);
        dbg!(coordij1.j);
        let coordij = h3_to_local_ij(&index, &other).unwrap();
        dbg!(coordij.i);
        dbg!(coordij.j);
        let other2 = local_ij_to_h3(&index, &coordij).unwrap();
        assert_eq!(other, other2);
    }

Looking at the output, there is exactly the behaviour we both expected with Index i having an offset of -1..1 in both directions. It is just that origin is not at (0, 0):

[h3ron/src/experimental.rs:65] coordij1.i = 1110
[h3ron/src/experimental.rs:66] coordij1.j = 619
[h3ron/src/experimental.rs:68] coordij.i = 1111
[h3ron/src/experimental.rs:69] coordij.j = 620

Hope this helps a bit.

from h3ron.

ManevilleF avatar ManevilleF commented on June 6, 2024

You are right we can do:

        let local_ijk = h3_to_local_ij(&index, &index).unwrap();
        let diff_ijk = h3_to_local_ij(&index, &neighbor_index).unwrap();
        let ijk = CoordIJ {
            i: diff_ijk.i - local_ijk.i,
            j: diff_ijk.j - local_ijk.j,
        };
        assert_eq!(ijk, CoordIJ { i: -1, j: -1 });

And the other way around

        let local_ijk = h3_to_local_ij(&neighbor_index, &neighbor_index).unwrap();
        let diff_ijk = h3_to_local_ij(&neighbor_index, &index).unwrap();
        let ijk = CoordIJ {
            i: diff_ijk.i - local_ijk.i,
            j: diff_ijk.j - local_ijk.j,
        };
        assert_eq!(ijk, CoordIJ { i: 1, j: 1 });

It would be nice to implement CoordIJ - CoordIj to avoid doing the substraction directly

from h3ron.

nmandery avatar nmandery commented on June 6, 2024

Here is some more documentation on the topic: uber/h3#242

from h3ron.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.