Documentation ¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( LatMin = -85.05112878 LatMax = -LatMin LonMin = -180.0 LonMax = -LonMin PrecisionMin = 1 PrecisionMax = 26 )
Limits from EPSG:900913 / EPSG:3785 / OSGEO:41001
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Area ¶
type Area struct{ MinLat, MaxLat, MinLon, MaxLon float64 }
Area is a rectangle area defined through a min and max lat/lon
type Hash ¶
type Hash uint64
A Hash a numeric geohash value
Example ¶
package main import ( "fmt" "github.com/bsm/geohashi" ) func main() { 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)) }
Output: 51.52460,-0.08394 true
func Encode ¶
Encode converts a lat/lon to an geohash with maximum precision
Example ¶
package main import ( "fmt" "github.com/bsm/geohashi" ) func main() { 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()) }
Output: 45035996274208702 (10) 90072520759854475 (20)
func EncodeWithPrecision ¶
EncodeWithPrecision converts a lat/lon to an numeric geohash
func (Hash) Children ¶
Children zooms in, returning four child hashes, in the following order SW, SE, NW, NE. This function may return nil if unable to zoom in further
func (Hash) MoveX ¶
MoveX moves n steps east (positive number) or west (negative number) and returns the resulting hash
func (Hash) MoveY ¶
MoveY moves n steps north (positive number) or south (negative number) and returns the resulting hash
Click to show internal directories.
Click to hide internal directories.