Skip to content

UA3MQJ/wheretz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WhereTZ: timezone lookup

License Build Status Hex.pm Version Coverage Status Inline docs

WhereTZ is elixir version of Ruby gem for lookup of timezone by georgraphic coordinates.

https://github.com/zverok/wheretz

Features:

  • no calls to external services, works without Internet connection;
  • Timezone result is %Timex.TimezoneInfo

Usage

Add to project from hex.pm

def deps do
  [
    {:wheretz, "~> 0.1.17"},
  ]
end

or from github

def deps do
  [
    {:wheretz, git: "[email protected]:UA3MQJ/wheretz.git", tag: "v0.1.17"},
  ]
end

Before the first start, you need to download the geo and initializse the database.

mix where_tz.init 

usage

iex(1)> WhereTZ.get(50.004444, 36.231389)   
#<TimezoneInfo(Europe/Kiev - EET (+02:00:00))>
iex(2)> WhereTZ.lookup(50.004444, 36.231389)
"Europe/Kiev"

How it works

  1. Latest version of timezone-boundary-builder dataset is converted into mnesia table (125Mb);
  2. For each time zone, store timezone name, geo polygon and calculate bounding box (min and max latitude and longitude);
  3. On each lookup WhereTZ first checks provided coordinates by bounding boxes, and if only one bbox, corresponds to them, returns timezone name immediately;
  4. If there's several intersecting bounding boxes, WhereTZ checks which polygon actually contains the point.

Known problems

  • ?

Author

Alexey Bolshakov

Thanks to

Victor Shepelev

License

Data license is ODbL.

Code license is usual MIT.

About

Time zone by geo coordinates lookup

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages