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

Best way to take a set of geohashes and determine which ones are neighbors? #4

Open
Broham opened this issue Feb 12, 2018 · 0 comments

Comments

@Broham
Copy link

Broham commented Feb 12, 2018

I'm not sure if this is the right place for a questions like this, if it's not I apologize. I'm trying to figure out the optimal way to take a list of geohashes and return a sub-list that contains the geohashes that are direct neighbors or have direct neighbors in common (aka - creating groups of contiguous geohashes).

The only way I can think to do this is by looping through the geohashes, getting neighbors and adding them to a new list. Something like the psudo code below:

startingGeoHashes = ["9qczj5t",
                     "9qczj5s", # directly west of the above
                     "9qczj5e", # directly west of the above
                     "9qczjhh" # not a direct neighbor
]
neighborGroup = []
foreach startingGeoHash in startingGeohashes
   if any of startingGeoHashes in getGeoHashNeighbors(startingGeoHash):
      add both to neighborGroups if they aren't already in there

But I'm wondering if there is a set based approach that could return the subset of direct neighbors without looping through ever record and getting the neighbors. Is this possible?

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

1 participant