[Feature] Add getGridMaxDistance() — True maximum distance from vertex to farthest vertex in gridDisk(k) #1083
leilton-zildus
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
🧭 Problem: The term “Effective radius” is misleading
The H3 documentation and many examples describe the effective radius of a
gridDisk(k)as:However, this underestimates the real coverage when the origin is a vertex of the central cell —
a very common case in ride-matching, geospatial search, and proximity filtering.
For example, at resolution 9:
Users typically expect “up to X meters” to mean the farthest possible point,
not merely to the center of the farthest cell.
✅ Solution: Exact maximum distance formula
We derived the exact maximum distance from a vertex of the central hexagon to the farthest vertex in
gridDisk(k)using pure hexagonal geometry:
Let:
L= average edge length at resolutionr(fromgetHexagonEdgeLengthAvgM(r))Then, for all resolutions and any integer
k ≥ 0:This formula was derived using the Law of Cosines on an equilateral triangle
with sides
(2k + 2)L.🔍 Verified values (Resolution 9, L = 200.786148 m)
These match real H3 boundary distances, verified via
cellToBoundary()andgreatCircleDistance().🧩 Proposed API addition (C + bindings)
🚀 Use cases
📚 References
(PA = (k+2)L,\ AC = (2k+2)L,\ \angle A = 60°)
🙏 Proposal
Please consider adding
h3_get_grid_max_distance_m()to the core H3 library.
It’s a small but high-impact improvement for real-world geospatial applications.
Thanks!
— Leilton Ribeiro, Alfenas, MG, Brazil
Beta Was this translation helpful? Give feedback.
All reactions