aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Siroky <evan.siroky@yahoo.com>2017-07-04 09:53:36 -0700
committerEvan Siroky <evan.siroky@yahoo.com>2017-07-04 09:53:36 -0700
commit081648a645f500780ac70f1fe7734eab2ded35f9 (patch)
treec03e8d6a0cd7d86a6982dcc1eebb4fad48f6fcf8
parent60b8fd8945c514caee85205bab111b1e969f224c (diff)
downloadtimezone-boundary-builder-081648a645f500780ac70f1fe7734eab2ded35f9.tar.gz
Add ability to build only certain zones
…and to skip validation, but I’d rather not say that skipping validation is possible in readme.
-rw-r--r--README.md8
-rw-r--r--index.js31
2 files changed, 38 insertions, 1 deletions
diff --git a/README.md b/README.md
index aa801b8..c773388 100644
--- a/README.md
+++ b/README.md
@@ -16,10 +16,18 @@ The code does query the publicly available overpass API, but it self-throttles t
### Running the project
+#### All the zones!
+
```shell
node --max-old-space-size=8192 index.js
```
+#### Only certain zones
+
+```shell
+node --max-old-space-size=8192 index.js --filtered-zones "America/New_York,America/Chicago"
+```
+
## How is this different from the shapefile over at efele.net?
The primary motivation for this project was to develop a dataset of the timezones that includes territorial waters as part of its output. Another goal is to use as much data as possible about the boundaries from OSM. In doing these two items, it is intended for the resulting data to allow more accurate predictions on what time it is at any point in the world.
diff --git a/index.js b/index.js
index 5d61aa5..c5f850b 100644
--- a/index.js
+++ b/index.js
@@ -11,6 +11,30 @@ var overpass = require('query-overpass')
var osmBoundarySources = require('./osmBoundarySources.json')
var zoneCfg = require('./timezones.json')
+
+// allow building of only a specified zones
+var filteredIndex = process.argv.indexOf('--filtered-zones')
+if (filteredIndex > -1 && process.argv[filteredIndex + 1]) {
+ filteredZones = process.argv[filteredIndex + 1].split(',')
+ var newZoneCfg = {}
+ filteredZones.forEach((zoneName) => {
+ newZoneCfg[zoneName] = zoneCfg[zoneName]
+ })
+ zoneCfg = newZoneCfg
+
+ // filter out unneccessary downloads
+ var newOsmBoundarySources = {}
+ Object.keys(zoneCfg).forEach((zoneName) => {
+ zoneCfg[zoneName].forEach((op) => {
+ if (op.source === 'overpass') {
+ newOsmBoundarySources[op.id] = osmBoundarySources[op.id]
+ }
+ })
+ })
+
+ osmBoundarySources = newOsmBoundarySources
+}
+
var geoJsonReader = new jsts.io.GeoJSONReader()
var geoJsonWriter = new jsts.io.GeoJSONWriter()
var distZones = {}
@@ -349,7 +373,12 @@ asynclib.auto({
validateZones: ['createZones', function (results, cb) {
console.log('validating zones')
loadDistZonesIntoMemory()
- cb(validateTimezoneBoundaries())
+ if (process.argv.indexOf('no-validation') > -1) {
+ console.warn('WARNING: Skipping validation!')
+ cb()
+ } else {
+ cb(validateTimezoneBoundaries())
+ }
}],
mergeZones: ['validateZones', function (results, cb) {
console.log('merge zones')