Documentation ¶
Overview ¶
Package geohash provides a 30W compatible implementation of the XKCD Geohashing algorithm.
Index ¶
- Variables
- type GeoHashProvider
- func (provider *GeoHashProvider) Geo(latArea, lonArea int, date time.Time, ctx context.Context) (lat, lon float64, err error)
- func (provider *GeoHashProvider) GeoNext(latArea, lonArea int, date time.Time, ctx context.Context) (locs [][]float64, err error)
- func (provider *GeoHashProvider) Global(date time.Time, ctx context.Context) (lat, lon float64, err error)
- func (provider *GeoHashProvider) GlobalNext(date time.Time, ctx context.Context) (locs [][]float64, err error)
Constants ¶
This section is empty.
Variables ¶
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.
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.