Mejoras generales
This commit is contained in:
12
libs/api.js
12
libs/api.js
@@ -15,7 +15,7 @@ async function subirDato(datos) {
|
||||
}
|
||||
const datosParaEnviar = {
|
||||
created_at: datos.datetime,
|
||||
delta_t: 1,
|
||||
//delta_t: 1, // Activar si da problemas con el tiempo
|
||||
field1: datos.paquetes,
|
||||
field2: datos.temperatura,
|
||||
field3: datos.presion,
|
||||
@@ -27,11 +27,6 @@ async function subirDato(datos) {
|
||||
longitude: datos.longitud
|
||||
};
|
||||
|
||||
//console.log(datos);
|
||||
//console.log(datosParaEnviar);
|
||||
|
||||
// Guardar datos en archivo: https://nodejs.org/en/learn/manipulating-files/writing-files-with-nodejs
|
||||
|
||||
peticionesRetrasadas.push(datosParaEnviar);
|
||||
saveDataInFile(datos);
|
||||
}
|
||||
@@ -69,7 +64,7 @@ async function subirDatosDeGolpe(datosParaSubir) {
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
//console.log(data);
|
||||
console.log(data);
|
||||
resultado = true; // Si todo sale bien, devolvemos true
|
||||
})
|
||||
.catch(error => {
|
||||
@@ -100,7 +95,8 @@ async function bucleSubidaDatos() {
|
||||
}
|
||||
|
||||
export {
|
||||
subirDato
|
||||
subirDato,
|
||||
subirDatosDeGolpe
|
||||
}
|
||||
|
||||
bucleSubidaDatos();
|
||||
|
||||
@@ -14,7 +14,8 @@ if (!fs.existsSync('logs')) {
|
||||
function dataLineToObject(line) {
|
||||
//Separamos nuestra línea en diferentes trozos usando como separador el ';'
|
||||
const lineArray = line.split(";");
|
||||
console.log(line);
|
||||
|
||||
console.log("Línea de datos: " + line);
|
||||
saveDataInCSVFile(line);
|
||||
|
||||
//Devolvemos un objeto con sus propiedades convertidas
|
||||
@@ -39,7 +40,8 @@ function dataLineToObject(line) {
|
||||
datetime: new Date().toISOString() // Obtenemos la fecha/hora actual
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error al convertir los datos:', error);
|
||||
console.warn('No se ha podido convertir la línea de datos, es posible que se hayan perdido parte de los datos, por lo que esta línea será ignorada');
|
||||
//console.error('Error al convertir los datos:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -98,7 +100,11 @@ async function saveDataInGeoJSONFile(data) {
|
||||
type: "Feature",
|
||||
properties: {
|
||||
numPaquete: data.paquetes,
|
||||
temperatura: data.temperatura
|
||||
temperatura: data.temperatura,
|
||||
altitudSegunPresion: data.altitudSegunPresion,
|
||||
altitudMetros: data.altitudMetros,
|
||||
velocidadKmph: data.velocidadKmph,
|
||||
numSatelites: data.numSatelites,
|
||||
},
|
||||
geometry: {
|
||||
type: "Point",
|
||||
|
||||
Reference in New Issue
Block a user