aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Fuller <nfuller@google.com>2020-07-29 14:46:16 +0100
committerNeil Fuller <nfuller@google.com>2020-07-29 14:46:16 +0100
commit6128709e84cc8c8e7bcfe0193cab9f409d9afe43 (patch)
treefb59c15854a0c50118e647e5312fcc6a2b7ed513
parenta83cc6d35635387e98bae2ae1ce27964d3a80fb0 (diff)
downloadtimezone-boundary-builder-6128709e84cc8c8e7bcfe0193cab9f409d9afe43.tar.gz
Changes to address review comments
Updated README.md and index.js Tested by running: $ 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 $ node --max-old-space-size=8192 index.js \ --included_zones America/New_York America/Chicago \ --excluded_zones America/New_York \ --dist_dir ./dist2 \ --downloads_dir ./downloads2 $ node --max-old-space-size=8192 index.js \ --included_zones America/New_York America/Chicago \ --excluded_zones America/New_York [No failures, assumed output is as it was before changes]
-rw-r--r--README.md28
-rw-r--r--index.js76
2 files changed, 65 insertions, 39 deletions
diff --git a/README.md b/README.md
index c085e70..b582024 100644
--- a/README.md
+++ b/README.md
@@ -54,9 +54,35 @@ node --max-old-space-size=8192 index.js
node --max-old-space-size=8192 index.js --included_zones America/New_York America/Chicago
```
+**Run the script to generate timezones while excluding specified timezones.**
+
+```shell
+node --max-old-space-size=8192 index.js --excluded_zones America/New_York America/Chicago
+```
+
+**Run the script with custom working / output directories.**
+
+timezone-boundary-builder downloads boundaries from OpenStreetMap and places them in the `./downloads` directory by default. It generates output files in the `./dist` directory by default.
+
+If you want to use different directories, you can do so with the `--downloads_dir` and `--dist_dir` flags.
+
+```shell
+node --max-old-space-size=8192 index.js --downloads_dir ./downloads2 --dist_dir ./dist2
+```
+
+**Other command line flags**
+
+Other command line flags:
+
+ + `--help` - show some basic usage information
+ + `--no_validation` - do not validate the time zone boundaries
+ + `--skip_zip` - do not zip the generated geojson files
+ + `--skip_shapefile` - do not create the shapefile from the geojson file
+
+
### What the script does
-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.
+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.
diff --git a/index.js b/index.js
index bfcb001..3425eb5 100644
--- a/index.js
+++ b/index.js
@@ -747,60 +747,60 @@ const autoScript = {
zipGeoJson: ['mergeZones', function (results, 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)
+ return 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)
}],
zipGeoJsonWithOceans: ['mergeZones', function (results, 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)
+ return 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)
}],
makeShapefile: ['mergeZones', function (results, 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)
- }
- )
+ return 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)
+ }
+ )
}],
makeShapefileWithOceans: ['mergeZones', function (results, 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)
- }
- )
+ return 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)
+ }
+ )
}],
makeListOfTimeZoneNames: function (cb) {
overallProgress.beginTask('Writing timezone names to file')