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

feat: added full support for vertex mode #71

Merged
merged 11 commits into from
Aug 26, 2024
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func ExampleLatLngToCell() {
| `cellToVertex` | TODO |
| `cellToVertexes` | TODO |
| `vertexToLatLng` | TODO |
| `isValidVertex` | TODO |
| `isValidVertex` | `IsValidVertex` |
| `gridDistance` | `GridDistance`, `Cell#GridDistance` |
| `gridPathCells` | `GridPath`, `Cell#GridPath` |
| `cellToLocalIj` | `CellToLocalIJ` |
Expand Down
4 changes: 4 additions & 0 deletions h3.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,10 @@ func LocalIJToCell(origin Cell, ij CoordIJ) Cell {
return Cell(out)
}

func IsValidVertex(c Cell) bool {
return C.isValidVertex(C.H3Index(c)) == 1
}

func maxGridDiskSize(k int) int {
return 3*k*(k+1) + 1
}
Expand Down
8 changes: 8 additions & 0 deletions h3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ func TestPentagons(t *testing.T) {
t.Parallel()

for _, res := range []int{0, 8, 15} {
res := res
jogly marked this conversation as resolved.
Show resolved Hide resolved
t.Run(fmt.Sprintf("res=%d", res), func(t *testing.T) {
t.Parallel()
pentagons := Pentagons(res)
Expand All @@ -621,6 +622,13 @@ func TestPentagons(t *testing.T) {
}
}

func TestIsValidVertex(t *testing.T) {
t.Parallel()

assertFalse(t, IsValidVertex(0))
assertTrue(t, IsValidVertex(2473183460575936511))
}

func equalEps(expected, actual float64) bool {
return math.Abs(expected-actual) < eps
}
Expand Down
Loading