Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Methods to check if batch of cells are neighbours #291

Closed
AltaherPresto opened this issue Oct 21, 2022 · 1 comment
Closed

Methods to check if batch of cells are neighbours #291

AltaherPresto opened this issue Oct 21, 2022 · 1 comment

Comments

@AltaherPresto
Copy link

I'm looking for a way to check if a list of cell id's (all same resolution) is a contiguous bloc.
My use case is a map picker where the user selects multiple hexagons but the selection must constitute one contiguous bloc.
My initial thought was to use h3.are_neighbor_cells (https://uber.github.io/h3-py/api_reference.html#h3.are_neighbor_cells but then I realised that not every cell has to be neighbours with every other cell to satisfy this contiguous bloc requirement.

Is there a method to perform such a check?

@nrabinowitz
Copy link
Collaborator

I assume you found a solution here. My suggestion would be:

  • Add all cells to a set
  • For each cell, assert that at least one of its immediate neighbors (from grid_disk(cell, 1)) are in the set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants