Commit 6098df0e authored by alain's avatar alain 🐙
Browse files

update settings

parent 31df97f1
import { appSettingsDefault } from '../data-on-a-map-app/config/default/app'
export const appSettings = {
...appSettingsDefault,
yAxisWidth: 40
}
\ No newline at end of file
......@@ -30,20 +30,21 @@ export const dataGroups = [
legend: {
1: { label: "Good", color: colors[0] },
10: { label: "Good", color: colors[0] },
//100: { label: "Bad", color: colors[1] },
10000: { label: "Very bad", color: colors[1] },
}
},
// {
// id: "µSv",
// label: " µSv/h",
// conversion: function(d){ return d * 0.9 },
// range: [0, 250],
// legend: {
// 0: { label: "Good", color: colors[0] },
// 50: { label: "Bad", color: colors[1] },
// 250: { label: "Very bad", color: colors[2] },
// }
// id: "µSv",
// label: " µSv/h",
// scale: "log",
// conversion: function(d){ return d * 5.6 },
// range: [1, 56000],
// legend: {
// 1: { label: "Good", color: colors[0] },
// 56: { label: "Bad", color: colors[0] },
// 56000: { label: "Very bad", color: colors[1] },
// },
// tooltip: "<p>Dit wordt berekend door ...</p>"
// }
]
},
......
......@@ -31,6 +31,7 @@ export const mapItemSettings = {
sizeMax: 1500,
elevationMaxMin: 250,
elevationMaxMax: 15000,
colorOffline: "#fff"
}
export const lightSettings = {
......
import { roundBy } from "../../data-on-a-map-app/src/util/math"
import { addMissingHours } from "../../data-on-a-map-app/src/util/data"
import { addMissingDataPoints } from "../../data-on-a-map-app/src/util/data"
import { getDataAge } from "../../data-on-a-map-app/src/util/time"
export default {
......@@ -7,6 +8,15 @@ export default {
sides: 6,
angle: 0,
factor: 1,
daysToFetch: 90,
dataStreams: {
gamma: {
single: {
mean: { key: "cpm_mean", type: "line", active: true, color: true }
}
}
},
all: async function getAll(parameter) {
try {
......@@ -28,18 +38,22 @@ export default {
name: sensor.id,
source: "gammasense",
coordinates: sensor.coordinates.reverse(),
mean: null
mean: null,
timestamp: null,
dataAge: null
}
if(sensorData) {
const dataAge = (new Date() - new Date(sensorData.timestamp))
//console.log(sensor.id, sensorData.timestamp, `${roundBy(dataAge / 1000 / 60 / 60, 2)} uur`)
const dataAgeInHours = getDataAge(sensorData.timestamp, "hourly")
// 3 hours
if(dataAge < 10800000) {
sensorDataReturn.mean = sensorData.cpm_mean
} else {
if(dataAgeInHours > 48) {
sensorDataReturn.name = sensorDataReturn.name + " (offline)"
} else if(dataAgeInHours > 8) {
sensorDataReturn.name = sensorDataReturn.name + " (geen recente data)"
} else {
sensorDataReturn.mean = sensorData.cpm_mean
sensorDataReturn.timestamp = sensorData.timestamp
sensorDataReturn.dataAge = dataAgeInHours
}
} else {
offlineSensors.push(sensor.id)
......@@ -50,9 +64,6 @@ export default {
})
latest.forEach(sensor => {
const dataAge = (new Date() - new Date(sensor.timestamp))
//console.log(sensor.id, dataAge, `${roundBy(dataAge / 1000 / 60 / 60, 2)} uur`)
if(!all.find(o => o.id === sensor.id)) {
unregisteredSensors.push(sensor.id)
}
......@@ -68,33 +79,41 @@ export default {
}
},
detail: async function getDetail(station, parameter, start, end) {
try {
const stationMeta = {
type: station.id,
name: station.name,
description: "This sensorkit mearures gamma radiation in CPM.<br><br><a class='more' href='https://gammasense.org/sensorkit/' target='_blank' rel='noopener noreferrer'>Read more about the sensorkit</a><br><a class='more' href='https://gammasense.org/about/' target='_blank' rel='noopener noreferrer'>Read more about Gamma radiation</a>"
}
stationMeta: function(station, parameter) {
const stationMeta = {
type: station.id,
name: station.name,
description: "This sensorkit mearures gamma radiation in CPM.<br><br><a class='more' href='https://gammasense.org/sensorkit/' target='_blank' rel='noopener noreferrer'>Read more about the sensorkit</a><br><a class='more' href='https://gammasense.org/about/' target='_blank' rel='noopener noreferrer'>Read more about Gamma radiation</a>"
}
return stationMeta
},
stationData: async function(station, parameter, start, end, granularity) {
try {
const response = await fetch(`https://data.waag.org/api/gammasense/hourly?sensor_id=${station.id}&start=${start}&end=${end}`)
const responseData = await response.json()
const conformedData = responseData.map(d => {
let data = responseData.map(d => {
d.timestamp = new Date(d.time).getTime()
delete d.time
d.value = d.cpm_mean
delete d.cpm_mean
return d
})
const data = addMissingHours(conformedData)
if(data.length > 0) {
const dataStart = data[0].timestamp
const dataEnd = new Date(end).getTime()
data = addMissingDataPoints(data, dataStart, dataEnd, granularity)
}
return { stationMeta, data }
return { status: "success", data }
} catch (error) {
console.log(error)
return { status: "error" }
}
}
}
\ No newline at end of file
import { textsNL } from '../data-on-a-map-app/config/default/texts'
export const texts = {
pilotLocations: "Pilot locations",
loading: "Bezig met laden...",
loadingError: "Laden mislukt...",
loadingRetry: "Probeer opnieuw",
lastMean: "laatste uurgemiddelde",
lastPeak: "laatste piekwaarde",
mean: "gemiddelde",
peak: "piekwaarde"
...textsNL
}
data-on-a-map-app @ f08ac5f9
Subproject commit 59d55e29d2a6900e380b2323a216a26a27d9b94f
Subproject commit f08ac5f96a72e3d810dd8f4b920ab07a1c37aa55
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