Commit 622c2f62 authored by alain's avatar alain 🐙
Browse files

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" import { addMissingHours, pad } from "../../data-on-a-map-app/src/util/data"
export default { export default {
...@@ -27,41 +28,47 @@ export default { ...@@ -27,41 +28,47 @@ export default {
let offlineSensors = [] let offlineSensors = []
let unregisteredSensors = [] let unregisteredSensors = []
let places = {} let places = {}
const data = all.map(sensor => { const data = all.map(sensor => {
const sensorData = latest.find(o => { const sensorData = latest.find(o => {
//return +o.id === +sensor.id return +o.id === +sensor.id
return +o.id === 211
}) })
let sensorDataToUse const sensorDataReturn = {
if(sensorData.data[0][Object.keys(sensorData.data[0])[0]].value) { id: sensor.id.toString(),
sensorDataToUse = sensorData.data[0][Object.keys(sensorData.data[0])[0]] name: "HoLu-kit " + sensor.id.toString() + ": " + sensor.name,
} else { source: "holu",
sensorDataToUse = sensorData.data[1][Object.keys(sensorData.data[1])[0]] 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) { console.log(sensor.id, sensorDataToUse.timestamp)
return {
id: sensor.id.toString(),
name: "HoLu-kit " + sensor.id.toString() + ": " + sensor.name, const dataAge = (new Date() - new Date(sensorDataToUse.timestamp))
source: "holu",
coordinates: [sensor.longitude, sensor.latitude], console.log(`${roundBy(dataAge / 1000 / 60 / 60, 2)} uur`)
mean: sensorDataToUse.value, // + " (" + (dataAge < 86400000 ? "geen recente data" : "offline" ) + ")"
max: null if(dataAge < 3600000) {
sensorDataReturn.mean = sensorDataToUse.value
} else {
sensorDataReturn.name = sensorDataReturn.name + " (geen recente data)"
} }
} else { } else {
return { sensorDataReturn.name = sensorDataReturn.name + " (offline)"
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
}
} }
return sensorDataReturn
}) })
latest.forEach(sensor => { 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