Commit 9a799284 authored by alain's avatar alain 🐙
Browse files

adjust settings

parent e24965ab
export const appSettings = {
language: "nl",
panelBreakpoint: 800
}
\ No newline at end of file
......@@ -28,7 +28,7 @@ export const dataGroups = [
id: "db",
label: " dB",
range: [0, 120],
ticks: [0, 60, 120],
ticks: [0, 30, 60, 90, 120],
legend: {
0: { label: "", color: colors[0] },
80: { label: "", color: colors[0] },
......
......@@ -50,8 +50,8 @@ export const lightSettings = {
const colors = {
background: "#FFF",
water: "#2FB6BC",
//water: "#000",
//water: "#2FB6BC",
water: "#666",
road: "#ccc",
wood: "#c6ddca",
text: "#000",
......
import { roundBy } from "../../data-on-a-map-app/src/util/math"
import { addMissingHours } from "../../data-on-a-map-app/src/util/data"
//import { roundBy } from "../../data-on-a-map-app/src/util/math"
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,11 +8,21 @@ export default {
sides: 24,
angle: 0,
factor: 0.5,
daysToFetch: 90,
//dataStart: "2019-06-25T00:00:00.000Z",
granularity: ["minutely", "hourly", "daily"],
dataStreams: {
db: {
single: {
minmax: { key: "db_minmax", type: "area", active: true, color: true },
mean: { key: "db_avg", type: "line", active: true, color: true }
}
}
},
all: async function getAll(parameter) {
all: async function(parameter) {
try {
const allResponse = await fetch(`https://data.waag.org/api/asounds/asokit/stations`)
const all = await allResponse.json()
......@@ -33,14 +44,16 @@ export default {
}
if(sensorData) {
const dataAge = (new Date() - new Date(sensorData.time))
//console.log(sensor.id, sensorData.timestamp, `${roundBy(dataAge / 1000 / 60 / 60, 2)} uur`)
const dataAgeInHours = getDataAge(sensorData.time, "hourly")
// 3 hours
if(dataAge < 10800000) {
sensorDataReturn.mean = sensorData.db_avg
} else {
if(dataAgeInHours > 48) {
sensorDataReturn.name = sensorDataReturn.name + " (offline)"
} else if(dataAgeInHours > 8) {
sensorDataReturn.name = sensorDataReturn.name + " (geen recente data)"
} else {
sensorDataReturn.mean = sensorData.db_avg
sensorDataReturn.timestamp = sensorData.time
sensorDataReturn.dataAge = dataAgeInHours
}
} else {
offlineSensors.push(sensor.id)
......@@ -51,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)
}
......@@ -69,37 +79,46 @@ export default {
}
},
detail: async function getDetail(station, parameter, start, end) {
try {
const stationMeta = {
type: station.id,
name: station.name,
description: "[description]"
}
stationMeta: function(station, parameter) {
const stationMeta = {
type: station.id,
name: station.name,
description: "[description]"
}
return stationMeta
},
stationData: async function(station, parameter, start, end, granularity) {
try {
const response = await fetch(`https://data.waag.org/api/asounds/asokit?granularity=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.db_avg
delete d.db_avg
d.minmax = [d.db_min, d.db_max]
d.db_minmax = [d.db_min, d.db_max]
delete d.db_min
delete d.db_max
return d
})
const data = addMissingHours(conformedData)
if(data.length > 0) {
const dataStart = data[0].timestamp
const dataEnd = new Date(end).getTime()
return { stationMeta, data }
data = addMissingDataPoints(data, dataStart, dataEnd, granularity)
}
return { status: "success", data }
} catch (error) {
console.log(error)
return { status: "error" }
}
}
}
\ No newline at end of file
import { roundBy } from "../../data-on-a-map-app/src/util/math"
import { addMissingHours } from "../../data-on-a-map-app/src/util/data"
//import { roundBy } from "../../data-on-a-map-app/src/util/math"
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,10 +8,21 @@ export default {
sides: 4,
angle: 0,
factor: 0.75,
daysToFetch: 120,
//dataStart: "2019-06-25T00:00:00.000Z",
granularity: ["minutely", "hourly", "daily"],
dataStreams: {
db: {
single: {
minmax: { key: "db_minmax", type: "area", active: true, color: true },
mean: { key: "db_avg", type: "line", active: true, color: true }
}
}
},
all: async function getAll(parameter) {
all: async function(parameter) {
try {
const allResponse = await fetch(`https://data.waag.org/api/asounds/cidata/stations`)
const all = await allResponse.json()
......@@ -28,18 +40,22 @@ export default {
name: `Type 1 mic: ${sensor.name}`,
source: "cidata",
coordinates: sensor.coordinates.reverse(),
mean: null
mean: null,
timestamp: null,
dataAge: null
}
if(sensorData) {
const dataAge = (new Date() - new Date(sensorData.time))
//console.log(sensor.id, sensorData.timestamp, `${roundBy(dataAge / 1000 / 60 / 60, 2)} uur`)
const dataAgeInHours = getDataAge(sensorData.time, "hourly")
// 3 hours
if(dataAge < 10800000) {
sensorDataReturn.mean = sensorData.db_avg
} else {
if(dataAgeInHours > 48) {
sensorDataReturn.name = sensorDataReturn.name + " (offline)"
} else if(dataAgeInHours > 8) {
sensorDataReturn.name = sensorDataReturn.name + " (geen recente data)"
} else {
sensorDataReturn.mean = sensorData.db_avg
sensorDataReturn.timestamp = sensorData.time
sensorDataReturn.dataAge = dataAgeInHours
}
} else {
offlineSensors.push(sensor.id)
......@@ -50,9 +66,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,37 +81,45 @@ export default {
}
},
detail: async function getDetail(station, parameter, start, end) {
try {
const stationMeta = {
type: station.id,
name: station.name,
description: "Convergence Instruments NSRTW mk3 type1 mic"
}
stationMeta: function(station, parameter) {
const stationMeta = {
type: station.id,
name: station.name,
description: "Convergence Instruments NSRTW mk3 type1 mic"
}
return stationMeta
},
stationData: async function(station, parameter, start, end, granularity) {
try {
const response = await fetch(`https://data.waag.org/api/asounds/cidata?granularity=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.db_avg
delete d.db_avg
d.minmax = [d.db_min, d.db_max]
d.db_minmax = [d.db_min, d.db_max]
delete d.db_min
delete d.db_max
return d
})
const data = addMissingHours(conformedData)
if(data.length > 0) {
const dataStart = data[0].timestamp
const dataEnd = new Date(end).getTime()
return { stationMeta, data }
data = addMissingDataPoints(data, dataStart, dataEnd, granularity)
}
return { status: "success", data }
} catch (error) {
console.log(error)
return { status: "error" }
}
}
}
\ No newline at end of file
......@@ -8,13 +8,23 @@ export const texts = {
loading: "Bezig met laden...",
loadingError: "Laden mislukt...",
loadingRetry: "Probeer opnieuw",
nodata: "geen data...",
lastMean: "laatste uurgemiddelde",
lastPeak: "piekwaarde laatste uur",
lastHour: "afgelopen uur",
hoursAgo: "uur geleden",
hour: "uur",
hourShort: "u",
mean: "gemiddelde",
peak: "piekwaarde",
dataStreams: {
mean: "gemiddelde",
minmax: "min-max waarde",
},
downloadData: "download data",
startDate: "startdatum",
endDate: "einddatum",
timeSelectionHint: "↖ tijdselectie",
downloadCsv: "download csv",
downloadInfo: "<small><a class='more' href='https://amsterdamsounds.waag.org/data-downloaden/' target='_blank' rel='noopener noreferrer'>meer info over data downloaden en de API</a></small>",
}
data-on-a-map-app @ fd02f179
Subproject commit 24e41a4c49669ed26b82d20ee3949206cbfd3317
Subproject commit fd02f17946dbe3594fb568a429a374ffd77d2ea4
Supports Markdown
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