GithubHelp home page GithubHelp logo

isabella232 / geohashi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bsm/geohashi

0.0 0.0 0.0 22 KB

Go(lang) clone of geohash-int

License: BSD 3-Clause "New" or "Revised" License

Makefile 0.52% Go 99.48%

geohashi's Introduction

GeoHashi

Build Status GoDoc Go Report Card License

Geohash library for Go, optimised for performance. Inspired by geohash-int.

Examples

Encode coordinates:

func Encode() {
	lat, lon := 51.52463, -0.08411

	hash1 := geohashi.EncodeWithPrecision(lat, lon, 10)
	fmt.Printf("%d (%d)\n", hash1, hash1.Precision())

	hash2 := geohashi.EncodeWithPrecision(lat, lon, 20)
	fmt.Printf("%d (%d)\n", hash2, hash2.Precision())
}

Decode hash:

func Decode() {
	hash := geohashi.Hash(90072520759854475)
	area := hash.Decode()
	lat, lon := area.Center()

	fmt.Printf("%.5f,%.5f\n", lat, lon)
	fmt.Println(area.Contains(51.52463, -0.08411))
}

Precision

This library allows you to select the precision of the hash you want to create, up to a maximum of 26 bits.

The following table shows the maximum uncertainty (at the equator) for a given bit-precision:

Bits Uncertainty
26 ±0.35m
25 ±0.65m
24 ±1.3m
23 ±2.6m
22 ±5.3m
21 ±11m
20 ±21m
19 ±42m
18 ±84m
17 ±170m
16 ±340m
15 ±680m
14 ±1400m
13 ±2700m
12 ±5400m
11 ±11000m
10 ±22000m
9 ±43000m
8 ±86000m
7 ±170000m
6 ±350000m
5 ±690000m
4 ±1400000m
3 ±2800000m
2 ±5400000m
1 ±10000000m

geohashi's People

Contributors

dim 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.