go-tz

module
v1.0.23 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2018 License: MIT

README

go-tz

tz-lookup by lon and lat

GoDoc Go Report Card Donate FOSSA Status

lookup timezone for a given location

// Loading Zone for Line Islands, Kiritimati
zone, err := gotz.GetZone(gotz.Point{
    Lon: -157.21328, Lat: 1.74294,
})
if err != nil {
    panic(err)
}
fmt.Println(zone[0])
[ugjka@archee example]$ go run main.go
Pacific/Kiritimati

Uses simplified shapefile from timezone-boundary-builder

GeoJson Simplification done with mapshaper

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

  • Shapefile is simplified using a lossy method so it may be innacurate along the borders
  • This is purerly in-memory. Uses ~50MB of ram
  • Nautical timezones are not included for practical reasons

Licenses

The code used to lookup the timezone for a location is licensed under the MIT License.

The data in timezone shapefile is licensed under the Open Data Commons Open Database License (ODbL).

FOSSA Status

Directories

Path Synopsis
Example program
Example program
tz module
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 gotz.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 gotz.go You need mapshaper to be installed and it must be in your $PATH More info on mapshaper: https://github.com/mbloch/mapshaper

Jump to

Keyboard shortcuts

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