GithubHelp home page GithubHelp logo

photoprism / go-tz Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ugjka/go-tz

1.0 2.0 0.0 230.5 MB

Go library for fast offline timezone lookup by latitude and longitude.

Home Page: https://docs.photoprism.app/developer-guide/

License: MIT License

Go 100.00% Makefile 0.01%
geocoding golang offline timezones

go-tz's Introduction

gopkg.in/photoprism/go-tz.v2

GoDoc Go Report Card License: MIT

Go library for fast offline timezone lookup by latitude and longitude. This is a fork of ugjka/go-tz that includes the latest timezone boundaries data and a Makefile for build automation.

Uses a simplified shapefile from timezone-boundary-builder for the lookups. The GeoJSON simplification was done with mapshaper.

Usage Example

import "gopkg.in/photoprism/go-tz.v2/tz"

func TimeZone(lat, lng float64) (result string) {
    result = "UTC"

    zones, err := tz.GetZone(tz.Point{Lat: lat, Lon: lng})

    if err == nil && len(zones) > 0 {
        result = zones[0]
    }

    return result
}

Key Features

  • Fast sub-millisecond lookups, even on old hardware
  • Timezone shapefile for lookups is embedded in the build binary
  • Supports overlapping timezones
  • You can load your own geojson shapefile if you want

Known Issues

  • The shapefile is simplified using a lossy method, so it may be inaccurate along the boundaries
  • Since the library runs completely in memory, it requires about 50 MB of RAM

Licensing

The embedded timezone data is licensed under the Open Data Commons Open Database License (ODbL). Any other code in this library can be used under the terms of the MIT License.

go-tz's People

Contributors

fossabot avatar lastzero avatar ugjka avatar

Stargazers

 avatar

Watchers

 avatar  avatar

go-tz's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.