Ironholds / geohash

Geohash generation, decoding and manipulation in R
Other
40 stars 9 forks source link

FR: gh_neighbors(hashes, n_neighbors) #15

Open MichaelChirico opened 6 years ago

MichaelChirico commented 6 years ago

It might be nice to allow gh_neighbors to more flexibly return not just the neighbors, but the neighbors' neighbors (up to distinctness, i.e. for n_neighbors = k there should be (k+2)^2 - 1 geohashes returned), e.g.

# would return the same information as does currently gh_neighbours('dqcjqc')
gh_neighbours('dqcjqc', n_neighbors = 1)
# would return 24 geohashes
gh_neighbours('dqcjqc', n_neighbors = 2)

The 24 GH returned would be: 1 . NW-NW - dqcjq7

  1. NW-N - dqcjqe
  2. N-N - dqcjqg
  3. N-NE - dqcjr5
  4. NE-NE - dqcjr7
  5. NE-E - dqcjr6
  6. E-E - dqcjr3
  7. SE-E - dqcjr2
  8. SE-SE - dqcjpr
  9. SE-S - dqcjpp
  10. S-S - dqcjnz
  11. SW-S - dqcjnx
  12. SW-SW - dqcjnr
  13. SW-W - dqcjq2
  14. W-W - dqcjq3
  15. NW-W - dqcjq6
  16. NW - dqcjqd
  17. N - dqcjqf
  18. NE - dqcjr4
  19. E - dqcjr1
  20. SE - dqcjr0
  21. S - dqcjqb
  22. SW - dqcjq8
  23. W - dqcjq9

A few potential issues:

Ironholds commented 6 years ago

Yeah, those'd be my concerns too

MichaelChirico commented 6 years ago

I'm just noticing the gh_neighbour internal function... with that, the names of the neighbors are well-defined, i.e. geohash:::gh_neighbour('dqcjqc', c(1, -2)) gives dqcjq6 unambiguously.

Corollary: