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 /index.js | |
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.
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 31 |
1 files changed, 30 insertions, 1 deletions
@@ -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') |