Skip to content

Commit

Permalink
feat: added error codes (#73)
Browse files Browse the repository at this point in the history
* feat: added error codes

* feat: add error codes for LatLngToCell function

* feat: add error codes for CellToLatLng function

* feat: add error codes for cellToBoundary function

* feat: add tests for getIcosahedronFaces function

* feat: add error codes for gridDisk function

* feat: add error codes for gridDiskDistances function

* feat: add error codes for gridPathCells function

* feat: add error codes for gridDistance function

* feat: add error codes for cellToLocalIj function

* feat: add error codes for localIjToCell function

* feat: add error codes for cellToParent function

* feat: added error codes for cellToChildren function

* feat: added error codes for cellToCenterChild function

* feat: added error codes for cellToChildPos function

* feat: added error codes for childPosToCell function

* feat: added error codes for compactCells function

* feat: add error codes for uncompactCells function

* feat: added error codes for polygonToCells function

* feat: added error codes for areNeighborCells function

* feat: added error codes for cellsToDirectedEdge function

* feat: added error codes for originToDirectedEdges function

* feat: added error codes for directedEdgeToBoundary function

* feat: added error codes for origin and destination of directed edge

* feat: added error codes for directedEdgeToCells function

* feat: added error codes for area functions

* feat: add error codes for length functions

* feat: add error codes for res0cells and pentagons functions

* feat: added error codes for vertex functions

* feat: added error codes for cellsToLinkedMultiPolygon function

* chore: upgrade to go 1.21

* fix: fix lint issues

* fix: use any instead of interface{}

* fix: use C.uint32_t instead of uint32

* fix: handle unknown error codes returned by h3

* fix: use toErr function instead of errMap

* feat: upgraded golang-ci
  • Loading branch information
mojixcoder authored Dec 27, 2024
1 parent d93ec71 commit 0b255e8
Show file tree
Hide file tree
Showing 7 changed files with 727 additions and 251 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ["1.20"]
go-version: ["1.21"]

steps:
- uses: actions/setup-go@v5
Expand All @@ -21,17 +21,17 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60.3
version: v1.62.2

test:
name: test
runs-on: ubuntu-latest
strategy:
matrix:
go-version:
- "1.20"
- "1.21"
- "1.22"
- "1.23"

steps:
- uses: actions/setup-go@v5
Expand Down
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
linters-settings:
errcheck:
check-type-assertions: true
exhaustive:
default-signifies-exhaustive: true
goconst:
min-len: 2
min-occurrences: 3
Expand Down
12 changes: 6 additions & 6 deletions bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var (
Lat: 37,
Lng: -122,
}
cell = LatLngToCell(geo, 15)
cell, _ = LatLngToCell(geo, 15)
addr = cell.String()
geoBndry CellBoundary
cells []Cell
Expand All @@ -31,30 +31,30 @@ func BenchmarkFromString(b *testing.B) {

func BenchmarkToGeoRes15(b *testing.B) {
for n := 0; n < b.N; n++ {
geo = CellToLatLng(cell)
geo, _ = CellToLatLng(cell)
}
}

func BenchmarkFromGeoRes15(b *testing.B) {
for n := 0; n < b.N; n++ {
cell = LatLngToCell(geo, 15)
cell, _ = LatLngToCell(geo, 15)
}
}

func BenchmarkToGeoBndryRes15(b *testing.B) {
for n := 0; n < b.N; n++ {
geoBndry = CellToBoundary(cell)
geoBndry, _ = CellToBoundary(cell)
}
}

func BenchmarkHexRange(b *testing.B) {
for n := 0; n < b.N; n++ {
cells = cell.GridDisk(10)
cells, _ = cell.GridDisk(10)
}
}

func BenchmarkPolyfill(b *testing.B) {
for n := 0; n < b.N; n++ {
cells = PolygonToCells(validGeoPolygonHoles, 15)
cells, _ = PolygonToCells(validGeoPolygonHoles, 15)
}
}
7 changes: 6 additions & 1 deletion example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import (
func ExampleLatLngToCell() {
latLng := h3.NewLatLng(37.775938728915946, -122.41795063018799)
resolution := 9
c := h3.LatLngToCell(latLng, resolution)

c, err := h3.LatLngToCell(latLng, resolution)
if err != nil {
panic(err)
}

fmt.Printf("%s", c)
// Output:
// 8928308280fffff
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/uber/h3-go/v4

go 1.20
go 1.21
Loading

0 comments on commit 0b255e8

Please sign in to comment.