Commit c127d421 authored by alain's avatar alain 🐙
Browse files

var name change and some first code for rivm api

parent 3744f4be
......@@ -13,15 +13,63 @@ export default {
const all = await allResponse.json()
const latestResponse = await fetch(`https://data.waag.org/api/getAllSensors`)
const latest = await latestResponse.json()
//const latestResponse = await fetch(`http://localhost:4567/sensor/${parameter}`)
let latest = await latestResponse.json()
// NEW
// latest = latest.map(s => {
// const key = Object.keys(s)[0]
// return {
// id: key.slice(-3),
// data: s[key]
// }
// })
let offlineSensors = []
let unregisteredSensors = []
let places = {}
const data = all.map(sensor => {
let sensorData = latest.find(o => +o.id === +sensor.id)
const sensorData = latest.find(o => {
//console.log(+o.id, +sensor.id)
return +o.id === +sensor.id
//return +o.id === 219
})
// NEW
// 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 dataAgeInDays = (new Date() - new Date(sensorDataToUse.timestamp)) / 86400000
// if(dataAgeInDays === 0) {
// return {
// id: sensor.id.toString(),
// name: "HOLU-sensor " + sensor.id.toString() + ": " + sensor.name,
// type: "HOLU-sensor",
// source: "holu",
// coordinates: [sensor.longitude, sensor.latitude],
// mean: sensorDataToUse.value,
// max: null
// }
// } else {
// return {
// id: sensor.id.toString(),
// name: "HOLU-sensor " + sensor.id.toString() + ": " + sensor.name + " (" + (dataAgeInDays < 1 ? "geen data van laatste uur" : "offline" ) + ")",
// type: "HOLU-sensor",
// source: "holu",
// coordinates: [sensor.longitude, sensor.latitude],
// mean: null,
// max: null
// }
// }
// OLD
if(sensorData) {
if(!places[sensor.tag]) places[sensor.tag] = {
allAverages: [],
......@@ -81,7 +129,7 @@ export default {
detail: async function getDetailHolu(station, parameter, start, end) {
try {
const stationInfo = {
const stationMeta = {
type: (station.type === "extended" ? "Extended" : "Basic" ) + " HOLU-meetstation " + station.id,
name: station.name,
description: (station.type === "extended" ? (
......@@ -91,9 +139,11 @@ export default {
)
)
}
//console.log(start.slice(0,10))
const response = await fetch(`https://data.waag.org/api/getHourlyValuesSensor?sensor_id=${station.id}&start=${start}&end=${end}`)
//const response = await fetch(`http://localhost:4567/sensor/${station.id}/${parameter}?start=${start.slice(0,10)}&end=${end.slice(0,10)}`)
const responseData = await response.json()
var prefix
......@@ -112,7 +162,7 @@ export default {
const data = addMissingHours(conformedData)
return { stationInfo, data }
return { stationMeta, data }
} catch (error) {
console.log(error)
}
......
......@@ -112,7 +112,7 @@ export default {
detail: async function getDetailLuchtmeetnet(station, parameter, start, end) {
try {
const stationInfo = {
const stationMeta = {
name: station.name,
description: `<span>${station.description}<br /><br /><em>bron data: <a href="https://www.luchtmeetnet.nl/" target="_blank" rel="noopener noreferrer">luchtmeetnet.nl</a></em></span>`
}
......@@ -130,7 +130,7 @@ export default {
const data = addMissingHours(conformedData)
return { stationInfo, data }
return { stationMeta, data }
} catch (error) {
console.log(error)
}
......
......@@ -47,7 +47,7 @@ export default {
detail: async function getDetailTeom(station, parameter, start, end) {
try {
const stationInfo = {
const stationMeta = {
type: station.type,
name: station.name,
description: "Op deze locatie wordt gemeten met monitoren die voorheen (tot 2008) in het meetnet werden gebruikt, de zogenaamde TEOM. Het zijn monitoren die zeer snel reageren op wisselende PM concentraties. Ze benaderen de nauwkeurigheid van de officiële meetapparatuur maar voldoen echter niet aan de huidige Europese eisen voor het doen van officiële metingen. Elke 10 seconden registreert deze meter een waarde. Alle meetwaarden zijn opgehoogd met een factor 1,3 omdat de TEOM meter een onderschatting van gemiddeld 30% kent."
......@@ -65,7 +65,7 @@ export default {
const data = addMissingHours(conformedData)
return { stationInfo, data }
return { stationMeta, data }
} catch (error) {
console.log(error)
}
......
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