commit | ea9f51a223670a93a67fe6fdaf63958fac423974 | [log] [tgz] |
---|---|---|
author | Neil Fuller <nfuller@google.com> | Tue Jul 28 10:58:03 2020 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Tue Jul 28 10:58:03 2020 +0000 |
tree | 0539b5049b8d29df0549410582f811b2743aace8 | |
parent | e60d5eeb1ae1b70d9ea3dd0ad376f02b0473c4c1 [diff] | |
parent | f53dbbf64fa027ec43b8ab8d544bd695cbe73493 [diff] |
Add required Android license tracking files am: 29d2134951 am: f53dbbf64f Original change: https://android-review.googlesource.com/c/platform/external/timezone-boundary-builder/+/1283946 Change-Id: Ica80b4e0469774961b9f8e12c91fc2f19bee4921
The goal of this project is to produce a shapefile with the boundaries of the world's timezones using OpenStreetMap data.
The shapefiles are available for download in this project's releases. As of release 2018d shapefiles are available with or without oceans. Each shape or geojson object has a single attribute or property respectively called tzid
. The tzid corresponds to the timezone name as defined in the timezone database (for example: America/Los_Angeles
or Asia/Shanghai
).
This project aims to stay up-to-date with all of the currently valid timezones that are defined in the timezone database. This project also will attempt to provide the most accurate possible boundaries of timezones according to community input.
The underlying data is downloaded from OpenStreetMap via the overpass turbo API. Various boundaries are assembled together to produce each zone with various geographic operations. In numerous edge cases arbitrary boundaries get created in various zones which are noted in the timezones.json
file.
To maintain consistency with the timezone database, this project will only create a new release after the timezone database creates a new release. If there are no new timezones created or deleted in a timezone database release, then this project will only create a release if there have been changes performed to the boundary definitions of an existing zone within this project.
A few common languages already have libraries with an API that can be used to lookup the timezone name at a particular GPS coordinate. Here are some libraries that use the data produced by timezone-boundary-builder:
Library | Language |
---|---|
ZoneDetect | C |
go-tz | Go |
timezoneLookup | Go |
TimeZoneMap | Java & Android |
Timeshape | Java |
node-geo-tz | JavaScript (node.js only) |
timespace | JavaScript (node.js and in browser) |
tz-lookup | JavaScript (node.js and in browser) |
GeoTimezone | .NET |
Geo-Timezone | php |
timezonefinder | Python |
lutz | R |
Another common way to use the data for lookup purposes is to load the shapefile into a spatially-aware database. See this blog post for an example of how that can be done.
If the data in the releases are not sufficiently recent or you want to build the latest from master, it is possible to run the script to generate the timezones. However, due to the ever-changing nature of OpenStreetMap, the script should be considered unstable. The script frequently breaks when unexpected data is received or changes in OpenStreetMap cause validation issues. Please see the troubleshooting guide for help with common errors.
Run the script to generate timezones for all timezones.
node --max-old-space-size=8192 index.js
Run the script to generate timezones for only specified timezones.
node --max-old-space-size=8192 index.js --filtered-zones "America/New_York,America/Chicago"
There are three config files that describe the boundary building process. The osmBoundarySources.json
file lists all of the needed boundaries to extract via queries to the Overpass API. The timezones.json
file lists all of the timezones and various operations to perform to build the boundaries. The expectedZoneOverlaps.json
file lists all timezones that are allowed to overlap each other and the acceptable bounds of a particular overlap.
The index.js
file downloads all of the required geometries, builds the specified geometries, validates that there aren't large areas of overlap (other than those that are expected), outputs one huge geojson file, and finally zips up the geojson file using the zip
cli and also converts the geojson to a shapefile using the ogr2ogr
cli. The script has only been verified to run with Node.js 10 on the MacOS platform.
The code does query the publicly available Overpass API, but it self-throttles the making of requests to have a minimum of 4 seconds gap between requests. If the Overpass API throttles the download, then the gap will be increased exponentially.
The data is almost completely comprised of OpenStreetMap data which is editable by anyone. There are a few guesses on where to draw an arbitrary border in the open waters and a few sparsely inhabited areas. Some uninhabited islands are omitted from this project. This project does include timezones in the oceans, but strictly uses territorial waters or Etc/GMT timezones instead of unofficially observed areas such as Exclusive Economic Zones.
Pull requests are welcome! Please follow the guidelines listed below:
Will be approved subject to code review.
Any change to the boundary of existing timezones must have some explanation of why the change is necessary. If there are official, publicly available documents of administrative areas describing their timezone boundary please link to them when making your case. All changes involving an administrative area changing their observed time should instead be sent to the timezone database.
A linting script will verify the integrity of the timezones.json
, osmBoundarySources.json
and expectedZoneOverlaps.json
files. The script verifies if all needed overpass sources are properly defined and that there aren't any unneeded overpass downloads. If an operation to make a timezone boundary requires the use of a manual geometry, a description must be added explaining the operation. All expected zone overlaps must have a description.
Thanks to following people whose open-source and open-data contributions have made this project possible:
The code used to construct the timezone boundaries is licensed under the MIT License.
The outputted data is licensed under the Open Data Commons Open Database License (ODbL).