h3js index find all children using index values
See original GitHub issueHello,
Suppose we are storing h3 indexes in a database column. To perform a parent/child query I was thinking of using h3 indexes. Lets say we have this index 832834fffffffff
. This cell’s children are[ '8428341ffffffff', '8428343ffffffff', '8428345ffffffff', '8428347ffffffff', '8428349ffffffff', '842834bffffffff', '842834dffffffff']
. What is the logic to tell if an h3index id is a child of another id. Is there any way that we can find a range of indexies that are child of the specific id.
I already found https://github.com/uber/h3/issues/320 and https://stackoverflow.com/questions/53911322/is-the-h3index-ordered but could not find my answer.
Thanks
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
H3 to children — h3_to_children • h3js
Get the children /descendents of the given hexagon at a particular resolution. h3_to_children(h3Index, res) ... H3Index H3 index to get children for.
Read more >H3 Tutorial: Intro to h3-js (v3) / Nick Rabinowitz | Observable
The core of the h3-js library are the functions that provide the H3 index for geographic coordinates and vice versa. Finding an H3...
Read more >Get child node index - javascript - Stack Overflow
I've become fond of using indexOf for this. Because indexOf is on Array.prototype and parent.children is a NodeList , you have to use...
Read more >R: get child H3 cell indices - R-Project.org
This function returns the children of a particular H3 cell at the requested resolution. Usage. get_children(h3_address = NULL, res = NULL, simple =...
Read more >h3-js - NPM Package Overview - Socket - Socket.dev
Start using Socket to analyze h3-js and its 0 dependencies to secure your app ... Get the indices of all icosahedron faces intersected...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So, yes, the underlying C implementation of
h3ToParent
andh3ToChildren
is relatively straitghtforward (parent is much easier than children, though).h3ToParent
is some sanity checking up front, and then some bit masking to replace the resolution with the new parent resolution and write1
s to all of the bits for the resolutions that are larger than that.h3ToChildren
has to allocate memory for the maximum number of children possible at that child level, then it loops through the possible children with special logic to detect and handle “missing children” if one of the indexes is actually a pentagon, and writes them into the allocated memory. This one would be hard to replicate in a database, but not impossible.Oh, and the second piece “find a range of indexes that are all children of a specified id” is just
h3.h3ToChildren(index, childResolution)