Documentation ¶
Overview ¶
Package tz provides timezone lookup for a given location
Features ¶
* The timezone shapefile is embedded in the build binary using go-bindata
* Supports overlapping zones
* You can load your own geojson shapefile if you want
* Sub millisecond lookup even on old hardware
Problems ¶
* The shapefile is simplified using a lossy method so it may be innacurate along the borders
* This is purerly in-memory. Uses ~50MB of ram
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoZoneFound = errors.New("no corresponding zone found in shapefile")
ErrNoZoneFound is returned when a zone for the given point is not found in the shapefile
var ErrOutOfRange = errors.New("point's coordinates out of range")
ErrOutOfRange is returned when latitude exceeds 90 degrees or longitude exceeds 180 degrees
Functions ¶
func GetZone ¶
GetZone returns a slice of strings containing time zone id's for a given Point
Example ¶
// Loading Zone for Line Islands, Kiritimati p := tz.Point{ Lon: -157.21328, Lat: 1.74294, } zone, err := tz.GetZone(p) if err != nil { panic(err) } fmt.Println(zone[0])
Output: Pacific/Kiritimati
func LoadGeoJSON ¶
LoadGeoJSON loads a custom GeoJSON shapefile from a Reader
Types ¶
type FeatureCollection ¶
type FeatureCollection struct {
// contains filtered or unexported fields
}
FeatureCollection ...
type Geometry ¶
type Geometry struct {
// contains filtered or unexported fields
}
Geometry ...
func (*Geometry) UnmarshalJSON ¶
UnmarshalJSON ...
Directories ¶
Path | Synopsis |
---|---|
Code generation tool for embedding the timezone shapefile in the gotz package run "go generate" in the parent directory after changing the -release flag in gen.go You need mapshaper to be installed and it must be in your $PATH More info on mapshaper: https://github.com/mbloch/mapshaper
|
Code generation tool for embedding the timezone shapefile in the gotz package run "go generate" in the parent directory after changing the -release flag in gen.go You need mapshaper to be installed and it must be in your $PATH More info on mapshaper: https://github.com/mbloch/mapshaper |