geohash

package
v0.0.0-...-49caf5a Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package geohash provides a 30W compatible implementation of the XKCD Geohashing algorithm.

Index

Constants

This section is empty.

Variables

View Source
var ErrW30NotYetAvailable = errors.New("coordinates west of 30 deg west are not yet available, 30W rule")

ErrW30NotYetAvailable is returned if coordinates should be calculated west of 30 deg west before the New York Stock Exchange (NYSE) has opened, 09:30.

https://geohashing.site/geohashing/30W_Time_Zone_Rule

Functions

This section is empty.

Types

type GeoHashProvider

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

GeoHashProvider to calculate Geohashing locations.

To get an instance, call GetGeoHashProvider.

func GetGeoHashProvider

func GetGeoHashProvider() *GeoHashProvider

GetGeoHashProvider returns a singleton instance of the GeoHashProvider.

func (*GeoHashProvider) Geo

func (provider *GeoHashProvider) Geo(latArea, lonArea int, date time.Time, ctx context.Context) (lat, lon float64, err error)

Geo hash for a given location, latitude and longitude reduced to an integer, and a date.

func (*GeoHashProvider) GeoNext

func (provider *GeoHashProvider) GeoNext(latArea, lonArea int, date time.Time, ctx context.Context) (locs [][]float64, err error)

GeoNext calculates all possible future Geohashes after the given date.

It returns an array of a two dimensional float64 array, representing lat and lon. The index of the outer array is offset of days to the requested date parameter, e.g., 0 is the requested date, 1 is the following one, and so on.

On weekends or NYSE holidays, the last known Dow Jones Industrial Average indicator will be used. For example, on Saturdays western of 30W, both the date for tomorrow's Sunday as well as the DJIA value is known. Thus, the Geohash's location for the following day can already be calculated.

func (*GeoHashProvider) Global

func (provider *GeoHashProvider) Global(date time.Time, ctx context.Context) (lat, lon float64, err error)

Global hash for a given date.

Location information will be stripped to normalize the time.

func (*GeoHashProvider) GlobalNext

func (provider *GeoHashProvider) GlobalNext(date time.Time, ctx context.Context) (locs [][]float64, err error)

GlobalNext calculates all possible future Globalhashes after the given date.

For more information look at the documentation for GeoHashProvider.GeoNext.

Jump to

Keyboard shortcuts

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