You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

47 lines
1.4 KiB

var stations = require('./server/stations.js');
var meteo = require('./server/meteorological.js');
var Promise = require('es6-promise').Promise;
var chalk = require('chalk');
//===== Weather data scraper
// var date = new Date();
var len = stations.stations.length;
//===== Meteorological data scraping - careful!
(function scrapeMeteo(currentStation) {
if (currentStation !== 0) {
console.log(chalk.cyan('=== Finished.\n'));
}
if (currentStation >= len) {
// if (currentStation > 1) {
return;
}
var arr = [];
console.log(chalk.cyan('\n=== (' + currentStation + ') Starting ' + stations.stations[currentStation]));
// Monthly files
// for (var m = 0; m < 12; m++) {
// arr.push(meteo.getInconsistent(stations.stations[currentStation], m, 2015));
// arr.push(meteo.getMonth(stations.stations[currentStation], m));
// }
// TODO refactor to above format
// TODO refactor station requests into promises format
// for (var year = 1982; year < date.getFullYear() - 1; year++) {
// getYear(stationIDs[i], year);
// }
// getCurrent(stationIDs[i]);
// Wait for all to resolve, then recurse.
Promise.all(arr).then(scrapeMeteo.bind(null, currentStation + 1));
})(0);
//===== Station data scraping - shouldn't need to change often.
// stations.downloadAllMetadata();
// stations.parseAllMetadata();