question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

h3js index find all children using index values

See original GitHub issue

Hello, 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:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
dfelliscommented, May 25, 2021

So, yes, the underlying C implementation of h3ToParent and h3ToChildren 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 write 1s 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.

1reaction
dfelliscommented, May 25, 2021

Oh, and the second piece “find a range of indexes that are all children of a specified id” is just h3.h3ToChildren(index, childResolution)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found