GithubHelp home page GithubHelp logo

abel-wanglei / geohash Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mmcloughlin/geohash

0.0 2.0 0.0 386 KB

Golang geohash library

Home Page: https://godoc.org/github.com/mmcloughlin/geohash

License: MIT License

Assembly 0.13% Go 99.87%

geohash's Introduction

geohash

Go geohash library offering encoding and decoding for string and integer geohashes.

GoDoc Reference Build status Coverage Go Report Card

Install

Fetch the package with

go get github.com/mmcloughlin/geohash

And import it into your programs with

import "github.com/mmcloughlin/geohash"

Usage

func Decode

func Decode(hash string) (lat, lng float64)

Decode the string geohash to a (lat, lng) point.

func DecodeInt

func DecodeInt(hash uint64) (lat, lng float64)

DecodeInt decodes the provided 64-bit integer geohash to a (lat, lng) point.

func DecodeIntWithPrecision

func DecodeIntWithPrecision(hash uint64, bits uint) (lat, lng float64)

DecodeIntWithPrecision decodes the provided integer geohash with bits of precision to a (lat, lng) point.

func Encode

func Encode(lat, lng float64) string

Encode the point (lat, lng) as a string geohash with the standard 12 characters of precision.

func EncodeInt

func EncodeInt(lat, lng float64) uint64

EncodeInt encodes the point (lat, lng) to a 64-bit integer geohash.

func EncodeIntWithPrecision

func EncodeIntWithPrecision(lat, lng float64, bits uint) uint64

EncodeIntWithPrecision encodes the point (lat, lng) to an integer with the specified number of bits.

func EncodeWithPrecision

func EncodeWithPrecision(lat, lng float64, chars uint) string

EncodeWithPrecision encodes the point (lat, lng) as a string geohash with the specified number of characters of precision (max 12).

func Neighbors

func Neighbors(hash string) []string

Neighbors returns a slice of geohash strings that correspond to the provided geohash's neighbors.

func NeighborsInt

func NeighborsInt(hash uint64) []uint64

NeighborsInt returns a slice of uint64s that correspond to the provided hash's neighbors at 64-bit precision.

func NeighborsIntWithPrecision

func NeighborsIntWithPrecision(hash uint64, bits uint) []uint64

NeighborsIntWithPrecision returns a slice of uint64s that correspond to the provided hash's neighbors at the given precision.

type Box

type Box struct {
	MinLat float64
	MaxLat float64
	MinLng float64
	MaxLng float64
}

Box represents a rectangle in latitude/longitude space.

func BoundingBox

func BoundingBox(hash string) Box

BoundingBox returns the region encoded by the given string geohash.

func BoundingBoxInt

func BoundingBoxInt(hash uint64) Box

BoundingBoxInt returns the region encoded by the given 64-bit integer geohash.

func BoundingBoxIntWithPrecision

func BoundingBoxIntWithPrecision(hash uint64, bits uint) Box

BoundingBoxIntWithPrecision returns the region encoded by the integer geohash with the specified precision.

func (Box) Center

func (b Box) Center() (lat, lng float64)

Center returns the center of the box.

func (Box) Contains

func (b Box) Contains(lat, lng float64) bool

Contains decides whether (lat, lng) is contained in the box. The containment test is inclusive of the edges and corners.

func (Box) Round

func (b Box) Round() (lat, lng float64)

Round returns a point inside the box, making an effort to round to minimal precision.

geohash's People

Contributors

mmcloughlin avatar tidwall avatar dc0d avatar richardartoul avatar

Watchers

James Cloos avatar abel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.