geohash

package module
v0.0.0-...-755e5f5 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2019 License: MIT Imports: 1 Imported by: 0

README

GeoHash Algororithm in Go

Example

package main

import "github.com/vectorhacker/go.geohash"

func main() {
  box := geohash.Encode(46.7666, -101.4650, 0) // 0 is the same as full presicion

  boxes := box.Neighbors()

  boxesBoxes := boxes[0].Neighbors()


  // ....

  box1 := geohash.Decode("c8rf51e7n", 12)
  box1.Neighbors()

  // ...
}

Documentation

Overview

Package geohash is a simple implementation of the Public Domain Geohash algorithm. It represents the hashes using boxes which contain the resulting hashes and can reverse the box, using the geohash and the precision to recreate it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Box

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

Box represents a coordinate box. It knows it's width and height, and can figure out it's neighbors. It implements the Stringer interface, printing out the geohash value.

func Decode

func Decode(hash string) *Box

Decode creates a new box from an initial hash

func Encode

func Encode(lat, lon float64, pres int) *Box

Encode takes coordinates and makes a geohash box

func (Box) Hash

func (b Box) Hash() string

Hash returns the geohash

func (Box) Height

func (b Box) Height() float64

Height returns the height of the box

func (Box) Lat

func (b Box) Lat() float64

Lat returns the latitude of a box

func (Box) Lon

func (b Box) Lon() float64

Lon returns the longitude of a box

func (Box) Neighbors

func (b Box) Neighbors() []*Box

Neighbors calculates the 8 neighboring boxes of a box

func (Box) Precision

func (b Box) Precision() int

Precision returns the precision of a box

func (Box) String

func (b Box) String() string

String returns the geohash of the box

func (Box) Width

func (b Box) Width() float64

Width returns the width of the box

Jump to

Keyboard shortcuts

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