diff options
author | Evan Siroky <evan.siroky@yahoo.com> | 2017-07-04 09:53:36 -0700 |
---|---|---|
committer | Evan Siroky <evan.siroky@yahoo.com> | 2017-07-04 09:53:36 -0700 |
commit | 081648a645f500780ac70f1fe7734eab2ded35f9 (patch) | |
tree | c03e8d6a0cd7d86a6982dcc1eebb4fad48f6fcf8 | |
parent | 60b8fd8945c514caee85205bab111b1e969f224c (diff) | |
download | timezone-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.md | 8 | ||||
-rw-r--r-- | index.js | 31 |
2 files changed, 38 insertions, 1 deletions
@@ -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. @@ -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') |