Skip to content

Commit

Permalink
Introduce Error Codes
Browse files Browse the repository at this point in the history
  • Loading branch information
charlespnh committed Dec 1, 2023
1 parent a6e5063 commit aafb59d
Show file tree
Hide file tree
Showing 5 changed files with 726 additions and 210 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ func ExampleLatLngToCell() {
latLng := h3.NewLatLng(37.775938728915946, -122.41795063018799)
resolution := 9 // between 0 (biggest cell) and 15 (smallest cell)

cell := h3.LatLngToCell(latLng, resolution)
cell, err := h3.LatLngToCell(latLng, resolution)
if err != nil {
fmt.Printf("%s", err.Error())
} else {
fmt.Printf("%s", cell)
}

fmt.Printf("%s", cell)
// Output:
// 8928308280fffff
}
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 @@ -30,30 +30,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)
}
}
10 changes: 8 additions & 2 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ import (
func ExampleLatLngToCell() {
latLng := h3.NewLatLng(37.775938728915946, -122.41795063018799)
resolution := 9
c := h3.LatLngToCell(latLng, resolution)
fmt.Printf("%s", c)

cell, err := h3.LatLngToCell(latLng, resolution)
if err != nil {
fmt.Printf("%s", err.Error())

Check failure on line 15 in example_test.go

View workflow job for this annotation

GitHub Actions / lint (1.18)

File is not `gofmt`-ed with `-s` (gofmt)
} else {
fmt.Printf("%s", cell)
}

// Output:
// 8928308280fffff
}
Loading

0 comments on commit aafb59d

Please sign in to comment.