Add new aurora-data mappers

parent bc055de7
import { Data } from "plotly.js";
interface iLocation {
average_deviation: number,
average_total: number,
kp: number,
lat: number,
long: number,
quiet_mean_tot: number
average_deviation: number;
average_total: number;
human_readable_name: string;
kp: number;
lat: number;
long: number;
quiet_mean_tot: number;
}
interface iAuroraData {
......@@ -24,27 +25,6 @@ interface iAuroraData {
type iLocationName = "andenes" | "beerenberg" | "jackvik_se" | "karmoy" | "nordkap" | "svalbard" | "tromso";
const humanizeLocationName = (location: iLocationName) => {
switch (location) {
case "andenes":
return "Andenes"
case "beerenberg":
return "Beerenberg"
case "jackvik_se":
return "Jackvik"
case "karmoy":
return "Karmoy"
case "nordkap":
return "Nordkap"
case "svalbard":
return "Svalbard"
case "tromso":
return "Tromsø"
default:
return "Unknown"
}
}
export const getAuroraData = async () => {
const response = await fetch('https://aurora.hendrikpeter.net/api/aurora_data.json')
if (response.status !== 200) throw new Error('connection error');
......@@ -72,7 +52,7 @@ export const auroraDataToGraphData = async () => {
size: (((location.kp || 0) + 1) * 3) + 5,
color,
},
text:[`${humanizeLocationName(name)} ${kpText}`],
text:[`${location.human_readable_name} ${kpText}`],
name: '',
} as Data
});
......
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