aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorevansiroky <evan.siroky@yahoo.com>2020-04-28 01:31:38 -0700
committerevansiroky <evan.siroky@yahoo.com>2020-04-28 01:31:38 -0700
commit96dfadc3cd460b14dbd3a29513efd987fd07cc2a (patch)
tree553558a8673aa1efcc1ca226d07c0ce47b36a8ca
parent5ce291934eba5a2d114b756f33ff62f9ac0db632 (diff)
downloadtimezone-boundary-builder-96dfadc3cd460b14dbd3a29513efd987fd07cc2a.tar.gz
WIP on download cleanup and version diff analysis
Refs #82 Refs #83
-rw-r--r--index.js66
1 files changed, 64 insertions, 2 deletions
diff --git a/index.js b/index.js
index 56e8c02..49b096e 100644
--- a/index.js
+++ b/index.js
@@ -47,6 +47,7 @@ var geoJsonWriter = new jsts.io.GeoJSONWriter()
var precisionModel = new jsts.geom.PrecisionModel(1000000)
var precisionReducer = new jsts.precision.GeometryPrecisionReducer(precisionModel)
var distZones = {}
+var lastReleaseJSONfile
var minRequestGap = 4
var curRequestGap = 4
@@ -653,6 +654,47 @@ var combineAndWriteZones = function (callback) {
], callback)
}
+var cleanDownloadsDir = function (cb) {
+ // TODO:
+
+ // list all files in downloads dir
+ // for each file
+ // if file does not exist in osmBoundarySources.json file, then remove
+ cb()
+}
+
+var downloadLastRelease = function (cb) {
+ // TODO:
+
+ // download latest release info
+ // determine last release version name
+ lastReleaseJSONfile = `./dist/${lastReleaseName}.json`
+
+ // check if file already downloaded, if so immediately callback
+ fetchIfNeeded(lastReleaseJSONfile, cb, cb, function () {
+ // find download link for geojson with oceans
+ // download the latest release data into the dist directory
+ // unzip geojson
+ cb()
+ })
+}
+
+var analyzeChangesFromLastRelease = function (cb) {
+ // TODO
+
+ // load last release data into memory
+
+ // generate set of keys from last release and current
+
+ // for each zone
+ // diff current - last = additions
+ // diff last - current = removals
+
+ // write file of additions
+ // write file of removals
+ cb()
+}
+
const autoScript = {
makeDownloadsDir: function (cb) {
overallProgress.beginTask('Creating downloads dir')
@@ -662,14 +704,26 @@ const autoScript = {
overallProgress.beginTask('Creating dist dir')
safeMkdir('./dist', cb)
},
+ cleanDownloadsDir: ['makeDownloadsDir', function (results, cb) {
+ overallProgress.beginTask('Cleaning downloads directory of unused files')
+ cleanDownloadsDir(cb)
+ }],
getOsmBoundaries: ['makeDownloadsDir', function (results, cb) {
overallProgress.beginTask('Downloading osm boundaries')
asynclib.eachSeries(Object.keys(osmBoundarySources), downloadOsmBoundary, cb)
}],
- zipInputData: ['makeDistDir', 'getOsmBoundaries', function (results, cb) {
+ zipInputData: ['cleanDownloadsDir', 'makeDistDir', 'getOsmBoundaries', function (results, cb) {
overallProgress.beginTask('Zipping up input data')
exec('zip dist/input-data.zip downloads/* timezones.json osmBoundarySources.json expectedZoneOverlaps.json', cb)
}],
+ downloadLastRelease: ['makeDistDir', function (results, cb) {
+ if (process.argv.indexOf('analyze-changes') > -1) {
+ overallProgress.beginTask('Downloading last release for analysis')
+ downloadLastRelease(cb)
+ } else {
+ overallProgress.beginTask('WARNING: Skipping download of last release for analysis!')
+ }
+ }],
createZones: ['makeDistDir', 'getOsmBoundaries', function (results, cb) {
overallProgress.beginTask('Creating timezone boundaries')
asynclib.each(Object.keys(zoneCfg), makeTimezoneBoundary, cb)
@@ -736,7 +790,15 @@ const autoScript = {
JSON.stringify(zoneNames),
cb
)
- }
+ },
+ analyzeChangesFromLastRelease: ['downloadLastRelease', 'mergeZones', function (results, cb) {
+ if (process.argv.indexOf('analyze-changes') > -1) {
+ overallProgress.beginTask('Analyzing changes from last release')
+ analyzeChangesFromLastRelease(cb)
+ } else {
+ overallProgress.beginTask('WARNING: Skipping analysis of changes from last release!')
+ }
+ }]
}
const overallProgress = new ProgressStats('Overall', Object.keys(autoScript).length)