geohash

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package geohash : go版的redis-geo模块,貌似有内存泄露问题,待查找和修正,目前不建议使用

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(code uint64) (float64, float64)

Decode converts uint64 geohash code to latitude and longitude

func Distance

func Distance(longitude1, latitude1, longitude2, latitude2 float64) float64

Distance computes the distance between two given coordinates in meter

func Encode

func Encode(longitude, latitude float64) uint64

Encode converts latitude and longitude to uint64 geohash code

func FromUInt64

func FromUInt64(code uint64) []byte

FromUInt64 converts uint64 geohash code to bytes

func GetNeighbours

func GetNeighbours(longitude, latitude, radiusMeters float64) [][2]uint64

GetNeighbours returns geohash code of blocks within radiusMeters to the given coordinate

func ToString

func ToString(buf []byte) string

ToString converts bytes geohash code to base32 string

func ToUInt64

func ToUInt64(buf []byte) uint64

ToUInt64 converts bytes geohash code to uint64 code

Types

type GeoCache

type GeoCache struct {
	// contains filtered or unexported fields
}

GeoCache geo数据缓存集

func NewGeoCache

func NewGeoCache(name string) *GeoCache

NewGeoCache 初始化一个新的geocache

func (*GeoCache) GeoAdd

func (g *GeoCache) GeoAdd(points ...*GeoPoint) int

GeoAdd 添加geo点,返回成功添加的数量

func (*GeoCache) GeoDist

func (g *GeoCache) GeoDist(name1, name2 string) (float64, error)

GeoDist 计算距离,单位米

func (*GeoCache) GeoDistPoint

func (g *GeoCache) GeoDistPoint(lng1, lat1, lng2, lat2 float64) (float64, error)

GeoDistPoint 计算距离,单位米

func (*GeoCache) GeoPos

func (g *GeoCache) GeoPos(names ...string) []*GeoPoint

GeoPos 返回指定名称的信息

func (*GeoCache) GeoRadius

func (g *GeoCache) GeoRadius(longitude, latitude, radius float64) []*GeoPoint

GeoRadius 获取半径内的点

func (*GeoCache) GeoRadiusByMember

func (g *GeoCache) GeoRadiusByMember(name string, radius float64) []*GeoPoint

GeoRadiusByMember 获取指定成员半径内的点

func (*GeoCache) GeoRem

func (g *GeoCache) GeoRem(names ...string) int

GeoRem 删除指定点

func (*GeoCache) Len

func (g *GeoCache) Len() int64

Len 长度

func (*GeoCache) LoadFromFile

func (g *GeoCache) LoadFromFile() error

LoadFromFile 从文件读取缓存

func (*GeoCache) Reset

func (g *GeoCache) Reset()

Reset 重置geo缓存

func (*GeoCache) SaveToFile

func (g *GeoCache) SaveToFile() error

SaveToFile 保存到文件

type GeoPoint

type GeoPoint struct {
	Name string  `json:"aid,omitempty"`
	Lng  float64 `json:"lng,omitempty"`
	Lat  float64 `json:"lat,omitempty"`
	// contains filtered or unexported fields
}

GeoPoint geo点

func (*GeoPoint) String

func (gp *GeoPoint) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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