aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Fuller <nfuller@google.com>2020-04-30 18:37:08 +0100
committerNeil Fuller <nfuller@google.com>2020-04-30 18:44:46 +0100
commita83cc6d35635387e98bae2ae1ce27964d3a80fb0 (patch)
tree4e5da43fc5ca42b2d0eeef90073835f1712b0aaa
parenta4e7327bd2c082c6cdcb44b49f095705204b728e (diff)
downloadtimezone-boundary-builder-a83cc6d35635387e98bae2ae1ce27964d3a80fb0.tar.gz
Add flags to turn off of the later steps
Add flags to turn off of the later steps when not required. Tested with: $ node --max-old-space-size=8192 index.js \ --included_zones America/New_York America/Chicago \ --excluded_zones America/New_York \ --dist_dir ./dist3 \ --downloads_dir ./downloads2 \ --skip_zip \ --skip_shapefile
-rw-r--r--index.js92
1 files changed, 58 insertions, 34 deletions
diff --git a/index.js b/index.js
index 771ad24..bfcb001 100644
--- a/index.js
+++ b/index.js
@@ -42,6 +42,14 @@ const argv = yargs
description: 'Skip validation',
type: 'boolean'
})
+ .option('skip_zip', {
+ description: 'Skip zip creation',
+ type: 'boolean'
+ })
+ .option('skip_shapefile', {
+ description: 'Skip shapefile creation',
+ type: 'boolean'
+ })
.help()
.strict()
.alias('help', 'h')
@@ -737,46 +745,62 @@ const autoScript = {
combineAndWriteZones(cb)
}],
zipGeoJson: ['mergeZones', function (results, cb) {
- overallProgress.beginTask('Zipping geojson')
- let zipFile = argv.dist_dir + '/timezones.geojson.zip'
- let jsonFile = argv.dist_dir + '/combined.json'
- exec('zip ' + zipFile + ' ' + jsonFile, cb)
+ if (argv.skip_zip) {
+ overallProgress.beginTask('Skipping zip')
+ } else {
+ overallProgress.beginTask('Zipping geojson')
+ let zipFile = argv.dist_dir + '/timezones.geojson.zip'
+ let jsonFile = argv.dist_dir + '/combined.json'
+ exec('zip ' + zipFile + ' ' + jsonFile, cb)
+ }
}],
zipGeoJsonWithOceans: ['mergeZones', function (results, cb) {
- overallProgress.beginTask('Zipping geojson with oceans')
- let zipFile = argv.dist_dir + '/timezones-with-oceans.geojson.zip'
- let jsonFile = argv.dist_dir + '/combined-with-oceans.json'
- exec('zip ' + zipFile + ' ' + jsonFile, cb)
+ if (argv.skip_zip) {
+ overallProgress.beginTask('Skipping with oceans zip')
+ } else {
+ overallProgress.beginTask('Zipping geojson with oceans')
+ let zipFile = argv.dist_dir + '/timezones-with-oceans.geojson.zip'
+ let jsonFile = argv.dist_dir + '/combined-with-oceans.json'
+ exec('zip ' + zipFile + ' ' + jsonFile, cb)
+ }
}],
makeShapefile: ['mergeZones', function (results, cb) {
- overallProgress.beginTask('Converting from geojson to shapefile')
- let shapeFileGlob = argv.dist_dir + '/combined-shapefile.*'
- rimraf.sync(shapeFileGlob)
- let shapeFile = argv.dist_dir + '/combined-shapefile.shp'
- let jsonFile = argv.dist_dir + '/combined.json'
- exec(
- 'ogr2ogr -f "ESRI Shapefile" ' + shapeFile + ' ' + jsonFile,
- function (err, stdout, stderr) {
- if (err) { return cb(err) }
- let shapeFileZip = argv.dist_dir + '/timezones.shapefile.zip'
- exec('zip ' + shapeFileZip + ' ' + shapeFileGlob, cb)
- }
- )
+ if (argv.skip_shapefile) {
+ overallProgress.beginTask('Skipping shapefile creation')
+ } else {
+ overallProgress.beginTask('Converting from geojson to shapefile')
+ let shapeFileGlob = argv.dist_dir + '/combined-shapefile.*'
+ rimraf.sync(shapeFileGlob)
+ let shapeFile = argv.dist_dir + '/combined-shapefile.shp'
+ let jsonFile = argv.dist_dir + '/combined.json'
+ exec(
+ 'ogr2ogr -f "ESRI Shapefile" ' + shapeFile + ' ' + jsonFile,
+ function (err, stdout, stderr) {
+ if (err) { return cb(err) }
+ let shapeFileZip = argv.dist_dir + '/timezones.shapefile.zip'
+ exec('zip ' + shapeFileZip + ' ' + shapeFileGlob, cb)
+ }
+ )
+ }
}],
makeShapefileWithOceans: ['mergeZones', function (results, cb) {
- overallProgress.beginTask('Converting from geojson with oceans to shapefile')
- let shapeFileGlob = argv.dist_dir + '/combined-shapefile-with-oceans.*'
- rimraf.sync(shapeFileGlob)
- let shapeFile = argv.dist_dir + '/combined-shapefile-with-oceans.shp'
- let jsonFile = argv.dist_dir + '/combined-with-oceans.json'
- exec(
- 'ogr2ogr -f "ESRI Shapefile" ' + shapeFile + ' ' + jsonFile,
- function (err, stdout, stderr) {
- if (err) { return cb(err) }
- let shapeFileZip = argv.dist_dir + '/timezones-with-oceans.shapefile.zip'
- exec('zip ' + shapeFileZip + ' ' + shapeFileGlob, cb)
- }
- )
+ if (argv.skip_shapefile) {
+ overallProgress.beginTask('Skipping with oceans shapefile creation')
+ } else {
+ overallProgress.beginTask('Converting from geojson with oceans to shapefile')
+ let shapeFileGlob = argv.dist_dir + '/combined-shapefile-with-oceans.*'
+ rimraf.sync(shapeFileGlob)
+ let shapeFile = argv.dist_dir + '/combined-shapefile-with-oceans.shp'
+ let jsonFile = argv.dist_dir + '/combined-with-oceans.json'
+ exec(
+ 'ogr2ogr -f "ESRI Shapefile" ' + shapeFile + ' ' + jsonFile,
+ function (err, stdout, stderr) {
+ if (err) { return cb(err) }
+ let shapeFileZip = argv.dist_dir + '/timezones-with-oceans.shapefile.zip'
+ exec('zip ' + shapeFileZip + ' ' + shapeFileGlob, cb)
+ }
+ )
+ }
}],
makeListOfTimeZoneNames: function (cb) {
overallProgress.beginTask('Writing timezone names to file')