placekey

package module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

README

placekey

Unofficial port of the Python library placekey-py, not affiliated with the Placekey project.

Install

go get github.com/diegosz/placekey

This package requires Go 1.18 or later.

Prerequisites

This library depends on uber/h3-go and inherits the same prerequisites. It requires CGO (CGO_ENABLED=1) in order to be built.

If you see errors/warnings like "build constraints exclude all Go files...", then the cgo build constraint is likely disabled; try setting CGO_ENABLED=1 environment variable for your build step.

References

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidLatLngRange = errors.New("invalid lat/lng range")
View Source
var ErrInvalidParts = errors.New("invalid parts")
View Source
var ErrInvalidResolution = errors.New("invalid resolution")

Functions

func Distance

func Distance(placeKey1, placeKey2 string) (float64, error)

Distance returns the distance in meters between the centers of two PlaceKeys.

func FormatIsValid

func FormatIsValid(placeKey string) bool

FormatIsValid returns a boolean for whether or not the format of a PlaceKey is valid, including checks for valid encoding of location.

func FromGeo

func FromGeo(lat, lng float64) (string, error)

FromGeo converts a (latitude, longitude) into a PlaceKey.

func FromH3Index

func FromH3Index(index h3.H3Index) (string, error)

FromH3Index converts an H3 index into a PlaceKey string.

func FromH3Int

func FromH3Int(h3Int uint64) (string, error)

FromH3Int converts an H3 integer into a PlaceKey.

func FromH3String

func FromH3String(h3String string) (string, error)

FromH3String converts an H3 hexadecimal string into a PlaceKey string.

func GetPrefixDistanceMap

func GetPrefixDistanceMap() map[int]float64

GetPrefixDistanceMap returns a map of the length of a shared PlaceKey prefix to the maximal distance in meters between two PlaceKeys sharing a prefix of that length.

func ToGeo

func ToGeo(placeKey string) (lat, lng float64, err error)

ToGeo converts a PlaceKey into a (latitude, longitude).

func ToGeoBoundary added in v0.2.0

func ToGeoBoundary(placeKey string) ([][]float64, error)

ToGeoBoundary returns the hexagonal polygon boundary of a PlaceKey as a slice of (latitude, longitude) coordinates.

func ToH3Index

func ToH3Index(placeKey string) (h3.H3Index, error)

ToH3Index converts a PlaceKey string into an H3 index.

func ToH3Int

func ToH3Int(placeKey string) (uint64, error)

ToH3Int converts a PlaceKey to an H3 integer.

func ToH3String

func ToH3String(placeKey string) (string, error)

ToH3String converts a PlaceKey string into an H3 string.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL