Go bindings for H3, a hierarchical hexagonal geospatial indexing system
Switch branches/tags
Nothing to show
Clone or download
joegilley Merge pull request #5 from uber/joegilley-patch-1
update README.md with badges
Latest commit 476e8ec Sep 18, 2018
Permalink
Failed to load latest commit information.
include fetch h3 c source to compile with cgo Sep 11, 2018
.gitattributes c source and headers have binary gitattr Sep 12, 2018
.gitignore gitignore *.dylib Sep 12, 2018
.travis.yml add coveralls.io integration Sep 18, 2018
CHANGELOG.md add readme, contribution guide, and changelog files Sep 12, 2018
CONTRIBUTING.md direct questions to stackoverflow Sep 12, 2018
H3_VERSION fetch h3 c source to compile with cgo Sep 11, 2018
LICENSE add LICENSE file Sep 11, 2018
README.md remove dupe space Sep 18, 2018
bench_test.go improve perf of (To|From)String Sep 12, 2018
example_test.go add bindings for C API Sep 12, 2018
h3.go link math library Sep 17, 2018
h3_algos.c fetch h3 c source to compile with cgo Sep 11, 2018
h3_baseCells.c fetch h3 c source to compile with cgo Sep 11, 2018
h3_bbox.c fetch h3 c source to compile with cgo Sep 11, 2018
h3_coordijk.c fetch h3 c source to compile with cgo Sep 11, 2018
h3_faceijk.c fetch h3 c source to compile with cgo Sep 11, 2018
h3_geoCoord.c fetch h3 c source to compile with cgo Sep 11, 2018
h3_h3Index.c fetch h3 c source to compile with cgo Sep 11, 2018
h3_h3UniEdge.c fetch h3 c source to compile with cgo Sep 11, 2018
h3_linkedGeo.c fetch h3 c source to compile with cgo Sep 11, 2018
h3_mathExtensions.c fetch h3 c source to compile with cgo Sep 11, 2018
h3_test.go handle pentagon unidirectional edges Sep 13, 2018
h3_vec2d.c fetch h3 c source to compile with cgo Sep 11, 2018
h3_vec3d.c fetch h3 c source to compile with cgo Sep 11, 2018
h3_vertexGraph.c fetch h3 c source to compile with cgo Sep 11, 2018
update-h3.sh fix shellcheck warnings for update-h3.sh Sep 12, 2018

README.md

Build Status Coverage Status License

H3-Go

This library provides Golang bindings for the H3 Core Library. For API reference, please see the H3 Documentation.

Usage

Installation

golang/dep

dep ensure -add github.com/uber/h3-go

golang/cmd/go

go get github.com/uber/h3-go

Glide

glide install github.com/uber/h3-go

Quickstart

import "github.com/uber/h3-go"

func ExampleFromGeo() {
	geo := h3.GeoCoord{
		Latitude:  37.775938728915946,
		Longitude: -122.41795063018799,
	}
	resolution := 9
	fmt.Printf("%#x\n", h3.FromGeo(geo, resolution))
	// Output:
	// 0x8928308280fffff
}

Notes

API Differences

  • All GeoCoord structs return Latitude and Longitude as degrees, instead of radians.

Some superficial changes have been made relative to the H3 C core API in order to adhere to idiomatic Go styling. Most notable are the following:

  • H3 C API function prefixes of H3 have been dropped to reduce stutter in usage, e.g. h3.ToGeo(h).
  • H3 C functions that convert to H3Index have their names inverted to convert from something else to H3Index, e.g. GeoToH3 is renamed to h3.FromGeo.
  • H3 C API function prefixes of Get have been dropped in support of Golang's Getter naming style.

CGO

The H3 C source code and header files are copied into this project to optimize for portability. By including the C source files in the h3 Go package, there is no need to introduce a build process or a system dependency on an H3 binary. Effectively, this decision makes h3 as easy to use in a Go project as adding it as a dependency with your favorite dependency manager.

Contributing

Pull requests and Github issues are welcome. Please read our contributing guide for more information.

Legal and Licensing

H3-Go is licensed under the Apache 2.0 License.