geohash

package module
v0.0.0-...-bd24b4b Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2015 License: Apache-2.0 Imports: 2 Imported by: 2

README

Go GeoHash Library

This is very much a "work in progress". It was created as I was unable to (quickly) find a geohashing library for golang that cause produce/handle integers instead of string encoding.

The initial version was heavily inspired by: https://github.com/sunng87/node-geohash Thanks!

Current plans: -Use it and see how it needs to be evolved.
-Add more tests -Add more documentation -Add Travis build -If there happens to be a need, perhaps add the string encoding/decoding

Documentation

Index

Constants

View Source
const (
	// MaxBitDepth defines both the maximum and default geohash accuracy.
	MaxBitDepth int64 = 52
)

Variables

View Source
var East = bearing{0, 1}

East bearing from reference point X

View Source
var North = bearing{1, 0}

North bearing from reference point X

View Source
var NorthEast = bearing{1, 1}

NorthEast bearing from reference point X

View Source
var NorthWest = bearing{1, -1}

NorthWest bearing from reference point X

View Source
var South = bearing{-1, 0}

South bearing from reference point X

View Source
var SouthEast = bearing{-1, 1}

SouthEast bearing from reference point X

View Source
var SouthWest = bearing{-1, -1}

SouthWest bearing from reference point X

View Source
var West = bearing{0, -1}

West bearing from reference point X

Functions

func BboxesInt

func BboxesInt(minLat float64, minLon float64, maxLat float64, maxLon float64, bitDepth int64) []int64

BboxesInt will return all the hash integers between minLat, minLon, maxLat, maxLon at the requested bitDepth

func DecodeBboxInt

func DecodeBboxInt(geohash int64, bitDepth int64) (minLat float64, minLng float64, maxLat float64, maxLng float64)

DecodeBboxInt will decode a geohash integer into the bounding box that matches it.

Returned as a four corners of a square region.

func DecodeInt

func DecodeInt(geohash int64, bitDepth int64) (lat float64, lng float64, latErr float64, lngErr float64)

DecodeInt with decode a integer geohashed number into pair of latitude and longitude value approximations.

Returned values include a latitude and longitude along with the maximum error of the calculation. This effectively means that a geohash integer will not return a location but an "area". The size of the area returned will be vary with different bitDepth settings.

Note: You should provide the same bitDepth to decode the number as was used to produce the geohash originally.

func EncodeInt

func EncodeInt(latitude float64, longitude float64, bitDepth int64) int64

EncodeInt will encode a pair of latitude and longitude values into a geohash integer.

The third argument is the bitDepth of this number, which affects the precision of the geohash but also must be used consistently when decoding. Bit depth must be even.

func FindBitDepth

func FindBitDepth(distanceMeters float64) int64

FindBitDepth will attempt to find the maximum bitdepth which contains the supplied distance

func NeighborInt

func NeighborInt(geohash int64, bearing bearing, bitDepth int64) int64

NeighborInt will find the neighbor of a integer geohash in certain bearing/direction.

The bitDepth should be specified and the same as the value used to generate the hash.

func NeighborsInt

func NeighborsInt(geohash int64, bitDepth int64) []int64

NeighborsInt is the same as calling NeighborInt for each direction and will return all 8 neighbors and the center location.

func Shift

func Shift(value int64, bitDepth int64) int64

Shift provides a convenient way to convert from MaxBitDepth to another

Types

This section is empty.

Jump to

Keyboard shortcuts

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