Commit 622c2f62 authored by alain's avatar alain 🐙

more on holu-rivm source

parent 6f087c6a
import { roundBy } from "../../data-on-a-map-app/src/util/math"
import { addMissingHours, pad } from "../../data-on-a-map-app/src/util/data"
export default {
......@@ -27,41 +28,47 @@ export default {
let offlineSensors = []
let unregisteredSensors = []
let places = {}
const data = all.map(sensor => {
const sensorData = latest.find(o => {
//return +o.id === +sensor.id
return +o.id === 211
return +o.id === +sensor.id
})
let sensorDataToUse
if(sensorData.data[0][Object.keys(sensorData.data[0])[0]].value) {
sensorDataToUse = sensorData.data[0][Object.keys(sensorData.data[0])[0]]
} else {
sensorDataToUse = sensorData.data[1][Object.keys(sensorData.data[1])[0]]
const sensorDataReturn = {
id: sensor.id.toString(),
name: "HoLu-kit " + sensor.id.toString() + ": " + sensor.name,
source: "holu",
coordinates: [sensor.longitude, sensor.latitude],
mean: null,
max: null
}
const dataAge = (new Date() - new Date(sensorDataToUse.timestamp))
if(sensorData) {
let sensorDataToUse
//if(sensorData.data[0][Object.keys(sensorData.data[0])[0]].value) {
if(sensorData.data[0]) {
sensorDataToUse = sensorData.data[0][Object.keys(sensorData.data[0])[0]]
} else {
sensorDataToUse = sensorData.data[1][Object.keys(sensorData.data[1])[0]]
}
if(dataAge < 3600000) {
return {
id: sensor.id.toString(),
name: "HoLu-kit " + sensor.id.toString() + ": " + sensor.name,
source: "holu",
coordinates: [sensor.longitude, sensor.latitude],
mean: sensorDataToUse.value,
max: null
console.log(sensor.id, sensorDataToUse.timestamp)
const dataAge = (new Date() - new Date(sensorDataToUse.timestamp))
console.log(`${roundBy(dataAge / 1000 / 60 / 60, 2)} uur`)
// + " (" + (dataAge < 86400000 ? "geen recente data" : "offline" ) + ")"
if(dataAge < 3600000) {
sensorDataReturn.mean = sensorDataToUse.value
} else {
sensorDataReturn.name = sensorDataReturn.name + " (geen recente data)"
}
} else {
return {
id: sensor.id.toString(),
name: "HoLu-kit " + sensor.id.toString() + ": " + sensor.name + " (" + (dataAge < 86400000 ? "geen recente data" : "offline" ) + ")",
source: "holu",
coordinates: [sensor.longitude, sensor.latitude],
mean: null,
max: null
}
sensorDataReturn.name = sensorDataReturn.name + " (offline)"
}
return sensorDataReturn
})
latest.forEach(sensor => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment