geohash

package
v0.0.0-...-9b3b26b Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WGS84_LAT_MIN  = -85.05112878
	WGS84_LAT_MAX  = 85.05112878
	WGS84_LONG_MIN = -180
	WGS84_LONG_MAX = 180
	WGS84_GEO_STEP = 26
)
View Source
const (
	MERCATOR_MAX float64 = 20037726.37

	EARTH_RADIUS_IN_METERS float64 = 6372797.560856

	D_R = (math.Pi / 180.0)
)

Variables

View Source
var (
	WGS84_LONG_RANGE = &Range{Max: WGS84_LONG_MAX, Min: WGS84_LONG_MIN}
	WGS84_LAT_RANGE  = &Range{Max: WGS84_LAT_MAX, Min: WGS84_LAT_MIN}
)
View Source
var (
	ErrPositionOutOfRange = errors.New("position out of range of WGS84")
	ErrStepOutOfRange     = errors.New("geohash encode step must less-equal than 32 and greater than 0")
)

Functions

func DecodeAreaToLongLat

func DecodeAreaToLongLat(area *Area) (float64, float64)

func DecodeToLongLatWGS84

func DecodeToLongLatWGS84(bits uint64) (float64, float64)

func DistBetweenGeoHashWGS84

func DistBetweenGeoHashWGS84(hash0 uint64, hash1 uint64) float64

func EncodeToBase32

func EncodeToBase32(hash uint64) []byte

func EncodeWGS84

func EncodeWGS84(longitude, latitude float64) (uint64, error)

func GetDistance

func GetDistance(lon0d, lat0d, lon1d, lat1d float64) float64

Types

type Area

type Area struct {
	Hash      HashBits
	Longitude Range
	Latitude  Range
}

func DecodeWGS84

func DecodeWGS84(bits uint64) *Area

type HashBits

type HashBits struct {
	Bits uint64
	Step uint8
}

func Encode

func Encode(
	longRange, latRange *Range,
	longitude, latitude float64,
	step uint8) (HashBits, error)

func (*HashBits) Clean

func (hash *HashBits) Clean()

func (HashBits) IsZero

func (hash HashBits) IsZero() bool

type Neighbors

type Neighbors struct {
	North     HashBits
	East      HashBits
	West      HashBits
	South     HashBits
	NorthEast HashBits
	SouthEast HashBits
	NorthWest HashBits
	SouthWest HashBits
}

func GetNeighbors

func GetNeighbors(hash HashBits) *Neighbors

type Point

type Point struct {
	Longitude float64
	Latitude  float64
}

type Radius

type Radius struct {
	Area
	Hash HashBits
	*Neighbors
}

func GetAreasByRadiusWGS84

func GetAreasByRadiusWGS84(longitude, latitude, radius float64) (*Radius, error)

type Range

type Range struct {
	Max float64
	Min float64
}

Jump to

Keyboard shortcuts

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