- Versione 1.0.33
- Aggiornato le varie librerie package
This commit is contained in:
@@ -517,6 +517,11 @@ async function resetProcessingJob() {
|
||||
async function inizia() {
|
||||
|
||||
try {
|
||||
if (true) {
|
||||
const outputPath = './comuni_italia_geojson.json';
|
||||
downloadGeoJSON('', outputPath);
|
||||
}
|
||||
|
||||
mycron_everyday();
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
|
||||
@@ -4923,5 +4923,23 @@ module.exports = {
|
||||
console.error(`Errore durante il recupero delle coordinate per ${city.descr}, ${city.prov}:`, error.message);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Funzione per scaricare dati GeoJSON dei comuni d'Italia e salvarli localmente.
|
||||
* @param {string} url - L'URL dal quale scaricare i dati GeoJSON.
|
||||
* @param {string} outputPath - Il percorso del file in cui salvare i dati GeoJSON.
|
||||
*/
|
||||
async downloadGeoJSON(url, outputPath) {
|
||||
try {
|
||||
// Effettua una richiesta GET all'URL specificato per scaricare i dati.
|
||||
const response = await axios.get(url);
|
||||
const data = response.data;
|
||||
|
||||
// Salva i dati GeoJSON in un file locale.
|
||||
await fs.writeFile(outputPath, JSON.stringify(data, null, 2));
|
||||
console.log(`Dati GeoJSON salvati in ${outputPath}`);
|
||||
} catch (error) {
|
||||
console.error('Errore durante il download o il salvataggio dei dati GeoJSON:', error);
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user