Comments (3)
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.
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.
Here is some more documentation on the topic: uber/h3#242
from h3ron.
Related Issues (20)
- Provide h3ronpy binaries for more platforms HOT 1
- Rust 1.53+ warns about undefined behavior in bindgen-generated code
- Implement more advanced routing algorithms HOT 2
- h3-sys WASM support HOT 7
- Create DOI HOT 1
- Publish h3ron 0.13 HOT 2
- Cleanup graph traits
- error: building the downstream libh3 C library using the Solana SDK via cmake HOT 23
- Rewrite C dependency in Rust? HOT 22
- Upgrade to H3 v4.0 HOT 1
- A faster h3IsValid HOT 3
- Reduce the number of dependencies HOT 1
- Use heap allocations for longedges to reduce memory usage of prepared graphs
- docs.rs build is currently broken due to cmake version HOT 2
- FYI: HexSet HOT 6
- Build ontop of arrow Extension datatype HOT 5
- Feature indexmap is not defined in Cargo.toml HOT 1
- Bumping h3ron-sys HOT 4
- Open to inline comments? HOT 1
- Build problem due to geo dependency HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from h3ron.