- fixed quantità

- creazione mappa numero utenti per provincia !
This commit is contained in:
Surya Paolo
2024-03-19 00:21:54 +01:00
parent 44b25fdf33
commit 3e0d0bf018
6 changed files with 209 additions and 52 deletions

View File

@@ -7,6 +7,8 @@ require('../models/subscribers');
const printf = require('util').format;
const axios = require('axios');
const CryptoJS = require('crypto-js');
const Url = require('url-parse');
@@ -4879,4 +4881,22 @@ module.exports = {
}
},
// Funzione per ottenere le coordinate di una singola città
async getCityCoordinates(city) {
try {
const response = await axios.get(`https://nominatim.openstreetmap.org/search?format=json&q=${city.descr},${city.prov},Italia`);
if (response.data.length > 0) {
city.lat = parseFloat(response.data[0].lat);
city.long = parseFloat(response.data[0].lon);
// console.log(`${city.descr}: Lat ${city.lat}, Long ${city.long}`);
return city;
} else {
console.error(`Coordinate non trovate per ${city.descr}, ${city.prov}`);
}
return null;
} catch (error) {
console.error(`Errore durante il recupero delle coordinate per ${city.descr}, ${city.prov}:`, error.message);
}
},
};