Skip to content

Commit e913e82

Browse files
authored
Merge pull request #163 from evansiroky/multiple-datasets
2023d update including multiple datasets
2 parents 0608027 + 786b315 commit e913e82

25 files changed

+10127
-7267
lines changed

.github/FUNDING.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [evansiroky]
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Incorrect Result
3+
about: Submit an issue about a result that is believed to be incorrect.
4+
title: 'Incorrect Result: '
5+
labels: ''
6+
assignees: ''
7+
---
8+
9+
## Query Details
10+
11+
**Input Coordinates:** *lat, lon*
12+
13+
**Expected Result:** *['America/New_York']*
14+
15+
**Actual Result:** *['Indian/Kerguelen']*
16+
17+
## Discussion
18+
19+
*A discussion of why this result is believe to be incorrect. Please include as much details as possible.*

.npmignore

+4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ $RECYCLE.BIN/
8181

8282
# project exclusions
8383
.gitattributes
84+
.github
85+
.eslintrc.json
86+
.prettierrc.json
87+
.travis.yml
8488
downloads
8589
scripts
8690
tests

.travis.yml

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
sudo: false
2+
dist: jammy
23
language: node_js
3-
44
node_js:
5+
- "21"
6+
- "20"
7+
- "19"
8+
- "18"
59
- "17"
610
- "16"
7-
- "14"
8-
- "12"
911

1012
env:
1113
- COVERAGE=false
1214

1315
matrix:
1416
fast_finish: true
1517
include:
16-
- node_js: "16"
18+
- node_js: "20"
1719
env: COVERAGE=true
1820
script:
1921
- "npm run cover"
@@ -23,17 +25,11 @@ matrix:
2325
- npm run build
2426
- npm run semantic-release
2527
allow_failures:
26-
- node_js: "16"
28+
- node_js: "20"
2729
env: COVERAGE=true
2830
script:
2931
- "npm run cover"
3032
- bash <(curl -s https://codecov.io/bash)
31-
- node_js: "12"
32-
env: COVERAGE=false
33-
script:
34-
- npm run lint
35-
- npm t
36-
- npm run build
3733

3834
script:
3935
- npm run lint

README.md

+71-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# node-geo-tz
2-
[![npm version](https://badge.fury.io/js/geo-tz.svg)](http://badge.fury.io/js/geo-tz) [![Build Status](https://travis-ci.org/evansiroky/node-geo-tz.svg?branch=master)](https://travis-ci.org/evansiroky/node-geo-tz) [![Dependency Status](https://david-dm.org/evansiroky/node-geo-tz.svg)](https://david-dm.org/evansiroky/node-geo-tz) [![Test Coverage](https://img.shields.io/codecov/c/github/evansiroky/node-geo-tz.svg)](https://codecov.io/github/evansiroky/node-geo-tz)
2+
[![npm version](https://badge.fury.io/js/geo-tz.svg)](http://badge.fury.io/js/geo-tz) [![Test Coverage](https://img.shields.io/codecov/c/github/evansiroky/node-geo-tz.svg)](https://codecov.io/github/evansiroky/node-geo-tz)
33

44
The most up-to-date and accurate node.js geographical timezone lookup package. It's fast too!
55

@@ -10,25 +10,72 @@ The most up-to-date and accurate node.js geographical timezone lookup package.
1010
## Usage
1111

1212
```js
13-
const { find } = require('geo-tz')
13+
const { find } = require('geo-tz')
1414

15-
find(47.650499, -122.350070) // ['America/Los_Angeles']
16-
find(43.839319, 87.526148) // ['Asia/Shanghai', 'Asia/Urumqi']
15+
find(47.650499, -122.350070) // ['America/Los_Angeles']
16+
find(43.839319, 87.526148) // ['Asia/Shanghai', 'Asia/Urumqi']
1717
```
1818

19-
## API Docs:
19+
## Data Source and Architecture
2020

21-
As of Version 7, there is no longer a default import. The `find` function should be used instead.
21+
This library aims to do one thing and do it well: find the timezone(s) in use at a GPS coordinate. The output consists of timezone identifiers as defined in the [timezone database](https://www.iana.org/time-zones). The underlying geographic data is obtained from the [timezone-boudary-builder](https://github.com/evansiroky/timezone-boundary-builder) project. The data is indexed for fast analysis by caching subregions of geographic data when a precise lookup is needed.
2222

23-
As of Version 5, the API now returns a list of possible timezones. There are certain coordinates where the timekeeping method will depend on the person you ask. Also, another case where 2 or more timezones could be returned is when a request is made with a coordinate that happens to be exactly on the border between two or more timezones.
23+
This library does an exact geographic lookup which has tradeoffs. The results are more accurate than other libraries that compromise by approximating the lookup of the data. However, it is perhaps a little bit slower that other libraries, has a larger installation size on disk and may encounter difficulties when bundling.
24+
25+
## Entry Points
26+
27+
As of version 8, node-geo-tz offers the ability to choose from the three different timezone boundary products that the [timezone-boudary-builder](https://github.com/evansiroky/timezone-boundary-builder) project produces.
28+
29+
### Alike Since 1970 (default)
30+
31+
The default data product used by this library are unioned timezones that are alike since 1970. This is a breaking change from versions below version 8 that used timezone identifiers that generally had a minimum of one timezone per country. In a number of places, the timezone identifier returned will be that which has the highest population among all timezone identifiers with similar timekeeping methods since 1970.
32+
33+
```js
34+
const { find } = require('geo-tz')
35+
36+
find(12.826174, 45.036933) // ['Asia/Riyadh']
37+
```
38+
39+
When using this product, it is possible that the timezone identifier returned will not be appropriate for calculating the observed time at the GPS coordinate prior to the year 1970.
40+
41+
### Comprehensive
42+
43+
A comprehensive dataset is available to query for all timezone identifiers available. This has the same behavior of this library prior to version 8. This version has the largest file size to accomodate all the needed boundaries. In this dataset, with a few rare exceptions, there is at least one unique timezone identifier per country.
44+
45+
```js
46+
const { find } = require('geo-tz/all')
47+
48+
find(12.826174, 45.036933) // ['Asia/Aden']
49+
```
50+
51+
When using this product, the timezone identifier returned will be appropriate for calculating the observed time at the GPS coordinate including years prior to 1970.
52+
53+
### Same since now
54+
55+
A dataset containing a unioned set of timezones that share the same timekeeping method into the future is the final data product available. This version has the smallest file size as it does not include as many timezones and boundaries. In a number of places, the timezone identifier returned will be that which has the highest population among all timezone identifiers with similar timekeeping methods since the current time.
56+
57+
```js
58+
const { find } = require('geo-tz/now')
59+
60+
find(12.826174, 45.036933) // ['Europe/Moscow']
61+
```
62+
63+
When using this product, the timezone identifier returned will only be appropriate for calculating the observed time at the GPS coordinate for the current and future time.
64+
65+
## API Docs
66+
67+
The API available is the same for each data product.
2468

2569
### find(lat, lon)
2670

27-
Returns the timezone names found at `lat`, `lon`. The timezone names will be the timezone identifiers as defined in the [timezone database](https://www.iana.org/time-zones). The underlying geographic data is obtained from the [timezone-boudary-builder](https://github.com/evansiroky/timezone-boundary-builder) project.
71+
Returns the timezone identifiers found at `lat`, `lon`. There are certain coordinates where the timekeeping method will depend on the person you ask. Also, another case where 2 or more timezones could be returned is when a request is made with a coordinate that happens to be exactly on the border between two or more timezones. If the GPS coordinate does not fall inside any timezone boundary on land, then a timezone at sea will be returned.
2872

29-
This library does an exact geographic lookup which has tradeoffs. It is perhaps a little bit slower that other libraries, has a larger installation size on disk and cannot be used in the browser. However, the results are more accurate than other libraries that compromise by approximating the lookup of the data.
73+
```js
74+
const { find } = require('geo-tz')
3075

31-
The data is indexed for fast analysis by caching subregions of geographic data when a precise lookup is needed.
76+
find(47.650499, -122.350070) // ['America/Los_Angeles']
77+
find(43.839319, 87.526148) // ['Asia/Shanghai', 'Asia/Urumqi']
78+
```
3279

3380
### setCache(options)
3481

@@ -48,8 +95,20 @@ setCache({ store: map }) // pass a Map-like storage object
4895

4996
## Limitations
5097

51-
This library is not intended to be used in the browser due to the large amount of files that are included to perform exact geographic lookups.
98+
### Performance
99+
100+
This library relies on reading a large data file from disk to perform exact geographic lookups. Therefore, it is not intended to be used in the browser and may have issues with bundlers if they don't include the necessary file.
101+
102+
### Accuracy of Output
103+
104+
The underlying data is obtained from the [timezone-boudary-builder](https://github.com/evansiroky/timezone-boundary-builder) project. The data from that project is mostly sourced from OpenStreetMap which is editable by anyone. In most cases, the timezone boundaries follow officially observed boundaries, but often times some communities near timezone boundaries may follow whichever timekeeping method works best for them.
105+
106+
The boundaries in the ocean come from the [timezone-boudary-builder](https://github.com/evansiroky/timezone-boundary-builder) project which only includes territorial waters and not exclusive economic zones. Additionally, special cases where the GPS coordinate falls with an area of [Terra nullius](https://en.wikipedia.org/wiki/Terra_nullius) will also have an ocean zone(s) returned.
107+
108+
The resulting timezone identifiers will represent the timekeeping method as is cataloged to the best of the knowledge of the maintainers of the timezone database. This could be wrong in the past (especially prior to 1970) and could change in the future should an area change the way they keep track of time.
109+
110+
Any concerns about the correctness of results are encouraged to be submitted as issues using the [Incorrect Result Issue Template](https://github.com/evansiroky/node-geo-tz/issues/new?assignees=&labels=&projects=&template=incorrect-result.md&title=Incorrect%20Result%3A+).
52111

53112
## An Important Note About Maintenance
54113

55-
Due to the ever-changing nature of timezone data, it is critical that you always use the latest version of this package. If you use old versions, there will be a few edge cases where the calculated time is wrong. If you use greenkeeper, please be sure to specify an exact target version so you will always get PR's for even patch-level releases.
114+
Due to the ever-changing nature of timezone data, it is critical that the latest version of this package is used. If older versions are used, there will be a few edge cases where the calculated time is wrong.

data/index.json

-1
This file was deleted.

data/timezones-1970.geojson.geo.dat

23 MB
Binary file not shown.

data/timezones-1970.geojson.index.json

+1
Large diffs are not rendered by default.

data/timezones-now.geojson.geo.dat

13.8 MB
Binary file not shown.

data/timezones-now.geojson.index.json

+1
Large diffs are not rendered by default.
25.1 MB
Binary file not shown.

data/timezones.geojson.index.json

+1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)