Commit 50f00521 authored by alain's avatar alain 🐙
Browse files

gammasense config

parent 6b573b78
import gammasense from "./sources/gammasense"
import wise from "./sources/wise"
const colors = [
"#54c627",
"#54c627",
"#e12023",
]
export const initialLayers = ["gamma", "poi"]
export const dataGroups = [
{
title: "layers",
parameters: {
"gamma": {
id: "gamma",
label: "gamma radiation",
type: "StationLayer",
sources: [ gammasense ],
tooltip: "...",
units: [
{
id: "cpm",
label: " CPM",
range: [0, 500],
legend: {
0: { label: "Good", color: colors[0] },
100: { label: "Bad", color: colors[1] },
500: { label: "Very bad", color: colors[2] },
}
},
{
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] },
}
}
],
unit: " CPM",
range: [0, 500],
legend: {
0: { label: "Good", color: colors[0] },
100: { label: "Bad", color: colors[1] },
500: { label: "Very bad", color: colors[2] },
}
},
"poi": {
id: "poi",
label: "poi's",
type: "IconLayer",
sources: [ wise ],
tooltip: "",
iconKeys: ["type", "status"],
iconAtlas: 'images/gammasense-icons.png',
iconMapping: {
"Uranium mine - Operational": { x: 0, y: 0, width: 56, height: 90, anchorY: 90, mask: false },
"Nuclear research facility - Operational": { x: 56, y: 0, width: 56, height: 90, anchorY: 90, mask: false },
"Nuclear power station - Operational": { x: 112, y: 0, width: 56, height: 90, anchorY: 90, mask: false },
"Uranium mine - Under construction": { x: 0, y: 90, width: 56, height: 90, anchorY: 90, mask: false },
"Nuclear research facility - Under construction": { x: 56, y: 90, width: 56, height: 90, anchorY: 90, mask: false },
"Nuclear power station - Under construction": { x: 112, y: 90, width: 56, height: 90, anchorY: 90, mask: false },
"Uranium mine - Closed": { x: 0, y: 180, width: 56, height: 90, anchorY: 90, mask: false },
"Nuclear research facility - Closed": { x: 56, y: 180, width: 56, height: 90, anchorY: 90, mask: false },
"Nuclear power station - Closed": { x: 112, y: 180, width: 56, height: 90, anchorY: 90, mask: false },
},
keysTooltip: ["type", "status"],
keysModalFilter: ["coordinates", "title"]
}
}
}
]
import gammasense from "./sources/gammasense"
const colors = [
"#f1aa2a",
"#db246b",
"#552a80"
]
export const initialLayers = ["pm25"]
export const dataGroups = [
{
title: "data",
parameters: {
"pm25": {
id: "pm25",
label: "gamma radiation",
unit: " μg/m3",
range: [0, 150],
legend: {
0: { label: "Good", color: colors[0] },
70: { label: "Bad", color: colors[1] },
150: { label: "Very bad", color: colors[2] },
},
tooltip: "",
type: "StationLayer",
sources: [ gammasense ]
}
}
}
]
import { color } from "d3-color"
export const texts = {
pilotLocations: "Pilot locations",
loading: "Loading...",
lastMean: "last hourly average",
lastPeak: "peak value last hour",
mean: "mean",
peak: "peak value"
}
export const mapLocations = null
export const mapDefaults = {
latitude: 46.6957637170966,
longitude: 5.765113549054841,
zoom: 4.5,
pitch: 45,
bearing: 0
}
export const mapLocations = [
{
name: "Amsterdam",
latitude: 52.371828,
longitude: 4.901642,
zoom: 12
},
{
name: "Barcelona",
latitude: 41.40370281706366,
longitude: 2.1432531593864312,
zoom: 12
},
{
name: "Helsinki",
latitude: 60.17226969670993,
longitude: 24.900654954799048,
zoom: 12
},
{
name: "Palermo",
latitude: 38.12088554193859,
longitude: 13.352510065410891,
zoom: 12
bounds: [
[3.7, 53.1],
[6.9, 50.7]
],
viewport: {
pitch: 35,
bearing: 0
}
]
}
export const mapControlSettings = {
......@@ -58,10 +27,10 @@ export const mapControlSettings = {
}
export const mapItemSettings = {
sizeMin: 12,
sizeMax: 200,
elevationMaxMin: 120,
elevationMaxMax: 2000,
sizeMin: 24,
sizeMax: 2048,
elevationMaxMin: 240,
elevationMaxMax: 20480,
}
export const lightSettings = {
......@@ -74,9 +43,9 @@ export const lightSettings = {
}
const colors = {
background: "#eee",
water: "#61bcdb",
road: "#ddd",
background: "#222",
water: "#000",
road: "#555",
wood: "#c6ddca",
text: "#000",
textHalo: "#eee"
......@@ -208,62 +177,23 @@ export const mapStyle = {
}
}
},
{
"id": "landcover_wood",
"type": "fill",
"source": "waag",
"source-layer": "landcover",
"minzoom": 10,
"filter": [
"all",
[
"==",
"$type",
"Polygon"
],
[
"==",
"class",
"wood"
]
],
"layout": {
"visibility": "visible"
},
"paint": {
"fill-color": colors.wood,
"fill-opacity": {
"base": 1,
"stops": [
[
8,
0
],
[
12,
1
]
]
}
}
},
{
"id": "waterway",
"type": "line",
"source": "waag",
"source-layer": "waterway",
"filter": [
"==",
"$type",
"LineString"
],
"layout": {
"visibility": "visible"
},
"paint": {
"line-color": "hsl(195, 17%, 78%)"
}
},
// {
// "id": "waterway",
// "type": "line",
// "source": "waag",
// "source-layer": "waterway",
// "filter": [
// "==",
// "$type",
// "LineString"
// ],
// "layout": {
// "visibility": "visible"
// },
// "paint": {
// "line-color": "hsl(195, 17%, 78%)"
// }
// },
{
"id": "water_name",
"type": "symbol",
......@@ -1297,6 +1227,45 @@ export const mapStyle = {
"text-halo-blur": 1
}
},
{
"id": "boundary_country",
"type": "line",
"metadata": {
"mapbox:group": "a14c9607bc7954ba1df7205bf660433f"
},
"source": "waag",
"source-layer": "boundary",
"filter": [
"==",
"admin_level",
2
],
"layout": {
"line-cap": "round",
"line-join": "round"
},
"paint": {
"line-color": colors.water,
"line-width": {
"base": 1.5,
"stops": [
[
3,
1.25
],
[
22,
10
]
]
},
"line-opacity": 1,
"line-dasharray": [
3,
1.5
]
}
},
{
"id": "place_other",
"type": "symbol",
......
import { addMissingHours, calculateHourlyData } from "../../data-on-a-map-app/src/util/data"
import { roundBy } from "../../data-on-a-map-app/src/util/math"
import { addMissingHours } from "../../data-on-a-map-app/src/util/data"
export default {
name: "gammasense",
sides: 5,
sides: 6,
angle: 0,
factor: 0.5,
factor: 1,
all: async function getAll(parameter) {
try {
const allResponse = await fetch(`http://localhost:8080/api/v1/get_stations`)
const allResponse = await fetch(`https://data.waag.org/api/gammasense/stations`)
const all = await allResponse.json()
const latestResponse = await fetch(`http://localhost:8080/api/v1/get_latest_value?sensor_id=all`)
const latestResponse = await fetch(`https://data.waag.org/api/gammasense/recent`)
const latest = await latestResponse.json()
let offlineSensors = []
let unregisteredSensors = []
let places = {}
var prefix
if (parameter === "pm25") prefix = "p25"
const data = all.map(sensor => {
let sensorData = latest.find(o => o.ms === sensor.ms)
const place = (sensor.city_id ? sensor.city_id.city_name : null)
let sensorData = latest.find(o => o.id === sensor.id)
const returnSensorData = {
id: sensor.id,
name: sensor.id,
source: "gammasense",
coordinates: sensor.coordinates,
mean: null
}
if(sensorData) {
if(sensor.city_id) {
if(!places[place]) places[place] = {
all: [],
}
places[place].all.push(sensorData[`${prefix}`])
}
return {
id: sensor.ms.toString(),
name: sensor.ms.toString() + " " + place,
type: null,
source: "muv",
coordinates: [sensor.latitude, sensor.longitude].reverse(),
place: place,
mean: sensorData[`${prefix}`]
//max: sensorData[`${parameter}_max`]
}
returnSensorData.mean = sensorData.cpm_mean
} else {
offlineSensors.push(sensor.ms)
return {
id: sensor.ms.toString(),
name: sensor.ms.toString() + " " + (sensor.city_id ? sensor.city_id.city_name : null) + " (offline)",
type: null,
source: "muv",
coordinates: [sensor.latitude, sensor.longitude].reverse(),
mean: null,
max: null
}
offlineSensors.push(sensor.id)
returnSensorData.name = returnSensorData.name + " (offline)"
}
return returnSensorData
})
latest.forEach(sensor => {
if(!all.find(o => +o.ms === +sensor.ms)) {
unregisteredSensors.push(sensor.ms)
if(!all.find(o => o.id === sensor.id)) {
unregisteredSensors.push(sensor.id)
}
})
console.log(`Offline Sensors (${offlineSensors.length}):`, offlineSensors.sort((a, b) => a - b).join(', '))
console.log(`Unregistered Sensors (${unregisteredSensors.length}):`, unregisteredSensors.sort((a, b) => a - b).join(', '))
Object.keys(places).forEach(function(place) {
console.log(place)
places[place].amount = places[place].all.length
places[place].average = roundBy(places[place].all.reduce((a, b) => a + b, 0) / places[place].all.length, 1)
places[place].highest = Math.max(...places[place].all)
})
console.log(places)
return data
} catch (error) {
......@@ -88,24 +58,29 @@ export default {
detail: async function getDetail(station, parameter, start, end) {
try {
const stationInfo = {
const stationMeta = {
type: station.id,
name: station.name,
description: ""
}
const response = await fetch(`http://localhost:8080/api/v1/get_sensor_value?sensor_id=${station.id}&start=${start}&end=${end}`)
const response = await fetch(`https://data.waag.org/api/gammasense/hourly?sensor_id=${station.id}&start=${start}&end=${end}`)
const responseData = await response.json()
var prefix
if (parameter === "pm25") prefix = "p25"
const conformedData = 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)
return { stationMeta, data }
const hourlyData = calculateHourlyData(responseData, prefix).reverse()
const conformedData = hourlyData.map(m => { return { ...m, timestamp: new Date(m.timestamp).getTime() }})
const data = addMissingHours(conformedData) //.reverse()
return { stationInfo, data }
} catch (error) {
console.log(error)
}
......
import data from "./wiseData"
export default {
name: "wise",
all: async function getAll() {
return [].concat(
data[0], // Uranium mine
data[1], // Nuclear research facility
data[2], // Nuclear power station
//data[3] // Organisation
)
}
}
\ No newline at end of file
This diff is collapsed.
:root {
--color-loading: #e12023;
--color-true: #54c627;
--heading-weight: 500;
}
......
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"
}
data-on-a-map-app @ 627b2212
Subproject commit 96f16bf26d3d979a319bc5caab394aed04842bad
Subproject commit 627b2212ebd798b179397097370b20714d0b3458
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