Skip to content
Snippets Groups Projects
Commit 7dd499d2 authored by jonschi's avatar jonschi
Browse files

fix more or less all trailing bugs with missing data

parent 9095e8e6
Branches
No related tags found
No related merge requests found
...@@ -45,7 +45,7 @@ Promise.all([ ...@@ -45,7 +45,7 @@ Promise.all([
textures.value.skyboxTexture = loadedSkyboxTexture; textures.value.skyboxTexture = loadedSkyboxTexture;
firstDate = getFirstDate(covidData); firstDate = getFirstDate(covidData);
lastDate = getLastDate(covidData); lastDate = getLastDate(covidData);
registerRegions(geoData); registerRegions(geoData, covidData);
selectedDate.value = new Date(lastDate); selectedDate.value = new Date(lastDate);
}); });
......
...@@ -24,6 +24,7 @@ const cameraTargetPosition = new THREE.Vector3(370, 370, -15); ...@@ -24,6 +24,7 @@ const cameraTargetPosition = new THREE.Vector3(370, 370, -15);
const cameraInitialPosition = new THREE.Vector3(1000, 500, 2000); const cameraInitialPosition = new THREE.Vector3(1000, 500, 2000);
const selectedColor = 0x0588e6; const selectedColor = 0x0588e6;
const hoverColor = 0x6dc1fd; const hoverColor = 0x6dc1fd;
const unavailableColor = "#333333";
const regionMeshData = {}; const regionMeshData = {};
// structure of this variable: // structure of this variable:
// ATT2: [ // ATT2: [
...@@ -219,10 +220,17 @@ function updateRegions(animationTime) { ...@@ -219,10 +220,17 @@ function updateRegions(animationTime) {
for (const nuts in regionMeshData) { for (const nuts in regionMeshData) {
regionMeshData[nuts].forEach(({ mesh, shape }) => { regionMeshData[nuts].forEach(({ mesh, shape }) => {
const covidDataWeek = props.covidData[props.selectedDate.toJSON()][nuts]; const covidDataWeek = props.covidData[props.selectedDate.toJSON()][nuts];
const color = new THREE.Color( let color;
let extrusion;
if (covidDataWeek?.incidence) {
color = new THREE.Color(
visualization.colorByIncidence(covidDataWeek.incidence) visualization.colorByIncidence(covidDataWeek.incidence)
); );
const extrusion = visualization.extrusion(covidDataWeek.incidence); extrusion = visualization.extrusion(covidDataWeek.incidence);
} else {
color = new THREE.Color(unavailableColor);
extrusion = visualization.extrusion(100);
}
const shapeGeometry = createShapeGeometry(shape, extrusion); const shapeGeometry = createShapeGeometry(shape, extrusion);
// animate color if necessary // animate color if necessary
...@@ -250,31 +258,29 @@ function updateRegions(animationTime) { ...@@ -250,31 +258,29 @@ function updateRegions(animationTime) {
} }
} }
function onNutsCodeSelected(newValue, oldValue) { function setRegionColor(nuts, color) {
if (oldValue) { if (!color) {
// reset color on previously selected mesh const covidDataWeek = props.covidData[props.selectedDate.toJSON()][nuts];
const covidDataWeek = color = new THREE.Color(
props.covidData[props.selectedDate.toJSON()][oldValue]; covidDataWeek?.incidence
const color = new THREE.Color( ? visualization.colorByIncidence(covidDataWeek.incidence)
visualization.colorByIncidence(covidDataWeek.incidence) : unavailableColor
); );
const selectedRegion = regionMeshData[oldValue]; }
selectedRegion.forEach(({ mesh, shape }) => { const selectedRegion = regionMeshData[nuts];
selectedRegion.forEach(({ mesh }) => {
mesh.material.color.set(color); mesh.material.color.set(color);
}); });
} }
if (newValue) { function onNutsCodeSelected(newValue, oldValue) {
// set color on newly selected mesh if (oldValue) setRegionColor(oldValue);
const selectedRegion = regionMeshData[newValue]; if (newValue) setRegionColor(newValue, selectedColor);
selectedRegion.forEach(({ mesh, shape }) => {
mesh.material.color.setHex(selectedColor);
});
}
} }
const animateToRegion = function () { const animateToRegion = function () {
const vertex = regionMeshData[props.selectedNutsCode][0].mesh.geometry.vertices[0]; const vertex =
regionMeshData[props.selectedNutsCode][0].mesh.geometry.vertices[0];
const vertexVector = new THREE.Vector3(vertex.x, vertex.y, vertex.z); const vertexVector = new THREE.Vector3(vertex.x, vertex.y, vertex.z);
const cameraDistance = camera.position.length(); const cameraDistance = camera.position.length();
vertexVector.multiplyScalar(cameraDistance / vertexVector.length()); vertexVector.multiplyScalar(cameraDistance / vertexVector.length());
...@@ -283,14 +289,15 @@ const animateToRegion = function() { ...@@ -283,14 +289,15 @@ const animateToRegion = function() {
.to(vertexVector, 2000) .to(vertexVector, 2000)
.easing(TWEEN.Easing.Cubic.Out) .easing(TWEEN.Easing.Cubic.Out)
.start(); .start();
} };
defineExpose({animateToRegion}) defineExpose({ animateToRegion });
// TODO: prettify tooltip // TODO: prettify tooltip
function updateTooltip() { function updateTooltip() {
const covidDataWeek = const covidDataWeek =
props.covidData[props.selectedDate.toJSON()][hoveredNutsCode]; props.covidData[props.selectedDate.toJSON()][hoveredNutsCode];
tooltipString.value = `${getRegionName(covidDataWeek.nuts)}: ${covidDataWeek.incidence}`; const incidence = covidDataWeek?.incidence ? parseInt(covidDataWeek.incidence) : "no disponible";
tooltipString.value = `${getRegionName(hoveredNutsCode)}: ${incidence}`;
} }
onMounted(async () => { onMounted(async () => {
...@@ -353,19 +360,6 @@ onMounted(async () => { ...@@ -353,19 +360,6 @@ onMounted(async () => {
false false
); );
function setRegionColor(nuts, color) {
if (!color) {
const covidDataWeek = props.covidData[props.selectedDate.toJSON()][nuts];
color = new THREE.Color(
visualization.colorByIncidence(covidDataWeek.incidence)
);
}
const selectedRegion = regionMeshData[nuts];
selectedRegion.forEach(({ mesh }) => {
mesh.material.color.set(color);
});
}
const tick = () => { const tick = () => {
renderer.autoClear = true; renderer.autoClear = true;
camera.layers.set(worldLayer); camera.layers.set(worldLayer);
......
...@@ -8,12 +8,11 @@ import { onMounted, watch } from "vue"; ...@@ -8,12 +8,11 @@ import { onMounted, watch } from "vue";
import DatePicker from "vue-datepicker-next"; import DatePicker from "vue-datepicker-next";
import "vue-datepicker-next/index.css"; import "vue-datepicker-next/index.css";
import BarChart from "./BarChart.vue"; import BarChart from "./BarChart.vue";
import { getFlagUrl } from "../helpers/flags.js";
import VCenter from "./VCenter.vue"; import VCenter from "./VCenter.vue";
import visualization from "../helpers/visualization.js"; import visualization from "../helpers/visualization.js";
import SimpleTypeahead from "vue3-simple-typeahead"; import SimpleTypeahead from "vue3-simple-typeahead";
import "vue3-simple-typeahead/dist/vue3-simple-typeahead.css"; import "vue3-simple-typeahead/dist/vue3-simple-typeahead.css";
import { getRegionName, getRegionList } from "../helpers/regionNames.js"; import { getRegionName, getCountryName, getRegionList, getFlagUrl } from "../helpers/regionNames.js";
import Gradient from "./Gradient.vue"; import Gradient from "./Gradient.vue";
import { getFirstDate, getLastDate } from "../helpers/dates.js"; import { getFirstDate, getLastDate } from "../helpers/dates.js";
...@@ -39,7 +38,7 @@ const emit = defineEmits([ ...@@ -39,7 +38,7 @@ const emit = defineEmits([
]); ]);
function numberWithDots(x) { function numberWithDots(x) {
if (!x) return ""; if (!x) return "no disponible";
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "."); return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
} }
...@@ -108,14 +107,13 @@ const chartDataIncidence = computed({ ...@@ -108,14 +107,13 @@ const chartDataIncidence = computed({
const data = []; const data = [];
const colors = []; const colors = [];
accessors.forEach((date) => { accessors.forEach((date) => {
let covidDataForDate = props.covidData[date] const element = props.covidData[date]?.[props.selectedNutsCode];
if (!covidDataForDate) { if (element?.incidence) {
data.push(null)
colors.push(null)
} else {
let element = covidDataForDate[props.selectedNutsCode];
data.push(parseFloat(element.incidence)); data.push(parseFloat(element.incidence));
colors.push(visualization.colorByIncidence(element.incidence)); colors.push(visualization.colorByIncidence(element.incidence));
} else {
data.push(null)
colors.push(null)
} }
}); });
...@@ -140,15 +138,14 @@ const chartDataNewCases = computed({ ...@@ -140,15 +138,14 @@ const chartDataNewCases = computed({
const data = []; const data = [];
const colors = []; const colors = [];
accessors.forEach((date) => { accessors.forEach((date) => {
let covidDataForDate = props.covidData[date]; const element = props.covidData[date]?.[props.selectedNutsCode];
if (!covidDataForDate) { if (element) {
data.push(null); const proportion = parseFloat(element.count) / parseFloat(element.population);
colors.push(null);
} else {
let element = covidDataForDate[props.selectedNutsCode];
let proportion = parseFloat(element.count) / parseFloat(element.population);
data.push(casesChartDivide.value ? proportion : parseFloat(element.count)); data.push(casesChartDivide.value ? proportion : parseFloat(element.count));
colors.push(visualization.colorByProportion(proportion)); colors.push(visualization.colorByProportion(proportion));
} else {
data.push(null);
colors.push(null);
} }
}); });
...@@ -247,13 +244,13 @@ onMounted(() => { ...@@ -247,13 +244,13 @@ onMounted(() => {
<div class="card-content"> <div class="card-content">
<div class="media"> <div class="media">
<div class="media-content"> <div class="media-content">
<p class="title is-4">{{ getRegionName(currentCovidElement?.nuts) }}</p> <p class="title is-4">{{ getRegionName(selectedNutsCode) }}</p>
<p class="subtitle is-6">{{ currentCovidElement?.country }}</p> <p class="subtitle is-6">{{ getCountryName(selectedNutsCode) }}</p>
</div> </div>
<div class="media-right"> <div class="media-right">
<figure class="image is-48x48"> <figure class="image is-48x48">
<img <img
:src="getFlagUrl(currentCovidElement?.country)" :src="getFlagUrl(selectedNutsCode)"
alt="Placeholder image" alt="Placeholder image"
/> />
</figure> </figure>
......
// taken from https://flagcdn.com/en/codes.json
// for a current version make an api call
const countries = {
"Andorra": "ad",
"United Arab Emirates": "ae",
"Afghanistan": "af",
"Antigua and Barbuda": "ag",
"Anguilla": "ai",
"Albania": "al",
"Armenia": "am",
"Angola": "ao",
"Antarctica": "aq",
"Argentina": "ar",
"American Samoa": "as",
"Austria": "at",
"Australia": "au",
"Aruba": "aw",
"Åland Islands": "ax",
"Azerbaijan": "az",
"Bosnia and Herzegovina": "ba",
"Barbados": "bb",
"Bangladesh": "bd",
"Belgium": "be",
"Burkina Faso": "bf",
"Bulgaria": "bg",
"Bahrain": "bh",
"Burundi": "bi",
"Benin": "bj",
"Saint Barthélemy": "bl",
"Bermuda": "bm",
"Brunei": "bn",
"Bolivia": "bo",
"Caribbean Netherlands": "bq",
"Brazil": "br",
"Bahamas": "bs",
"Bhutan": "bt",
"Bouvet Island": "bv",
"Botswana": "bw",
"Belarus": "by",
"Belize": "bz",
"Canada": "ca",
"Cocos (Keeling) Islands": "cc",
"DR Congo": "cd",
"Central African Republic": "cf",
"Republic of the Congo": "cg",
"Switzerland": "ch",
"Côte d'Ivoire (Ivory Coast)": "ci",
"Cook Islands": "ck",
"Chile": "cl",
"Cameroon": "cm",
"China": "cn",
"Colombia": "co",
"Costa Rica": "cr",
"Cuba": "cu",
"Cape Verde": "cv",
"Curaçao": "cw",
"Christmas Island": "cx",
"Cyprus": "cy",
"Czechia": "cz",
"Germany": "de",
"Djibouti": "dj",
"Denmark": "dk",
"Dominica": "dm",
"Dominican Republic": "do",
"Algeria": "dz",
"Ecuador": "ec",
"Estonia": "ee",
"Egypt": "eg",
"Western Sahara": "eh",
"Eritrea": "er",
"Spain": "es",
"Ethiopia": "et",
"European Union": "eu",
"Finland": "fi",
"Fiji": "fj",
"Falkland Islands": "fk",
"Micronesia": "fm",
"Faroe Islands": "fo",
"France": "fr",
"Gabon": "ga",
"United Kingdom": "gb",
"Grenada": "gd",
"Georgia": "ge",
"French Guiana": "gf",
"Guernsey": "gg",
"Ghana": "gh",
"Gibraltar": "gi",
"Greenland": "gl",
"Gambia": "gm",
"Guinea": "gn",
"Guadeloupe": "gp",
"Equatorial Guinea": "gq",
"Greece": "gr",
"South Georgia": "gs",
"Guatemala": "gt",
"Guam": "gu",
"Guinea-Bissau": "gw",
"Guyana": "gy",
"Hong Kong": "hk",
"Heard Island and McDonald Islands": "hm",
"Honduras": "hn",
"Croatia": "hr",
"Haiti": "ht",
"Hungary": "hu",
"Indonesia": "id",
"Ireland": "ie",
"Israel": "il",
"Isle of Man": "im",
"India": "in",
"British Indian Ocean Territory": "io",
"Iraq": "iq",
"Iran": "ir",
"Iceland": "is",
"Italy": "it",
"Jersey": "je",
"Jamaica": "jm",
"Jordan": "jo",
"Japan": "jp",
"Kenya": "ke",
"Kyrgyzstan": "kg",
"Cambodia": "kh",
"Kiribati": "ki",
"Comoros": "km",
"Saint Kitts and Nevis": "kn",
"North Korea": "kp",
"South Korea": "kr",
"Kuwait": "kw",
"Cayman Islands": "ky",
"Kazakhstan": "kz",
"Laos": "la",
"Lebanon": "lb",
"Saint Lucia": "lc",
"Liechtenstein": "li",
"Sri Lanka": "lk",
"Liberia": "lr",
"Lesotho": "ls",
"Lithuania": "lt",
"Luxembourg": "lu",
"Latvia": "lv",
"Libya": "ly",
"Morocco": "ma",
"Monaco": "mc",
"Moldova": "md",
"Montenegro": "me",
"Saint Martin": "mf",
"Madagascar": "mg",
"Marshall Islands": "mh",
"North Macedonia": "mk",
"Mali": "ml",
"Myanmar": "mm",
"Mongolia": "mn",
"Macau": "mo",
"Northern Mariana Islands": "mp",
"Martinique": "mq",
"Mauritania": "mr",
"Montserrat": "ms",
"Malta": "mt",
"Mauritius": "mu",
"Maldives": "mv",
"Malawi": "mw",
"Mexico": "mx",
"Malaysia": "my",
"Mozambique": "mz",
"Namibia": "na",
"New Caledonia": "nc",
"Niger": "ne",
"Norfolk Island": "nf",
"Nigeria": "ng",
"Nicaragua": "ni",
"Netherlands": "nl",
"Norway": "no",
"Nepal": "np",
"Nauru": "nr",
"Niue": "nu",
"New Zealand": "nz",
"Oman": "om",
"Panama": "pa",
"Peru": "pe",
"French Polynesia": "pf",
"Papua New Guinea": "pg",
"Philippines": "ph",
"Pakistan": "pk",
"Poland": "pl",
"Saint Pierre and Miquelon": "pm",
"Pitcairn Islands": "pn",
"Puerto Rico": "pr",
"Palestine": "ps",
"Portugal": "pt",
"Palau": "pw",
"Paraguay": "py",
"Qatar": "qa",
"Réunion": "re",
"Romania": "ro",
"Serbia": "rs",
"Russia": "ru",
"Rwanda": "rw",
"Saudi Arabia": "sa",
"Solomon Islands": "sb",
"Seychelles": "sc",
"Sudan": "sd",
"Sweden": "se",
"Singapore": "sg",
"Saint Helena, Ascension and Tristan da Cunha": "sh",
"Slovenia": "si",
"Svalbard and Jan Mayen": "sj",
"Slovakia": "sk",
"Sierra Leone": "sl",
"San Marino": "sm",
"Senegal": "sn",
"Somalia": "so",
"Suriname": "sr",
"South Sudan": "ss",
"São Tomé and Príncipe": "st",
"El Salvador": "sv",
"Sint Maarten": "sx",
"Syria": "sy",
"Eswatini (Swaziland)": "sz",
"Turks and Caicos Islands": "tc",
"Chad": "td",
"French Southern and Antarctic Lands": "tf",
"Togo": "tg",
"Thailand": "th",
"Tajikistan": "tj",
"Tokelau": "tk",
"Timor-Leste": "tl",
"Turkmenistan": "tm",
"Tunisia": "tn",
"Tonga": "to",
"Turkey": "tr",
"Trinidad and Tobago": "tt",
"Tuvalu": "tv",
"Taiwan": "tw",
"Tanzania": "tz",
"Ukraine": "ua",
"Uganda": "ug",
"United States Minor Outlying Islands": "um",
"United Nations": "un",
"United States": "us",
"Uruguay": "uy",
"Uzbekistan": "uz",
"Vatican City (Holy See)": "va",
"Saint Vincent and the Grenadines": "vc",
"Venezuela": "ve",
"British Virgin Islands": "vg",
"United States Virgin Islands": "vi",
"Vietnam": "vn",
"Vanuatu": "vu",
"Wallis and Futuna": "wf",
"Samoa": "ws",
"Kosovo": "xk",
"Yemen": "ye",
"Mayotte": "yt",
"South Africa": "za",
"Zambia": "zm",
"Zimbabwe": "zw",
}
const getFlagUrl = function(country) {
const short = countries[country];
return `https://flagcdn.com/w160/${short}.png`;
}
export {
getFlagUrl
}
const countries = {
"Andorra": "ad",
"United Arab Emirates": "ae",
"Afghanistan": "af",
"Antigua and Barbuda": "ag",
"Anguilla": "ai",
"Albania": "al",
"Armenia": "am",
"Angola": "ao",
"Antarctica": "aq",
"Argentina": "ar",
"American Samoa": "as",
"Austria": "at",
"Australia": "au",
"Aruba": "aw",
"Åland Islands": "ax",
"Azerbaijan": "az",
"Bosnia and Herzegovina": "ba",
"Barbados": "bb",
"Bangladesh": "bd",
"Belgium": "be",
"Burkina Faso": "bf",
"Bulgaria": "bg",
"Bahrain": "bh",
"Burundi": "bi",
"Benin": "bj",
"Saint Barthélemy": "bl",
"Bermuda": "bm",
"Brunei": "bn",
"Bolivia": "bo",
"Caribbean Netherlands": "bq",
"Brazil": "br",
"Bahamas": "bs",
"Bhutan": "bt",
"Bouvet Island": "bv",
"Botswana": "bw",
"Belarus": "by",
"Belize": "bz",
"Canada": "ca",
"Cocos (Keeling) Islands": "cc",
"DR Congo": "cd",
"Central African Republic": "cf",
"Republic of the Congo": "cg",
"Switzerland": "ch",
"Côte d'Ivoire (Ivory Coast)": "ci",
"Cook Islands": "ck",
"Chile": "cl",
"Cameroon": "cm",
"China": "cn",
"Colombia": "co",
"Costa Rica": "cr",
"Cuba": "cu",
"Cape Verde": "cv",
"Curaçao": "cw",
"Christmas Island": "cx",
"Cyprus": "cy",
"Czechia": "cz",
"Germany": "de",
"Djibouti": "dj",
"Denmark": "dk",
"Dominica": "dm",
"Dominican Republic": "do",
"Algeria": "dz",
"Ecuador": "ec",
"Estonia": "ee",
"Egypt": "eg",
"Western Sahara": "eh",
"Eritrea": "er",
"Spain": "es",
"Ethiopia": "et",
"European Union": "eu",
"Finland": "fi",
"Fiji": "fj",
"Falkland Islands": "fk",
"Micronesia": "fm",
"Faroe Islands": "fo",
"France": "fr",
"Gabon": "ga",
"United Kingdom": "gb",
"Grenada": "gd",
"Georgia": "ge",
"French Guiana": "gf",
"Guernsey": "gg",
"Ghana": "gh",
"Gibraltar": "gi",
"Greenland": "gl",
"Gambia": "gm",
"Guinea": "gn",
"Guadeloupe": "gp",
"Equatorial Guinea": "gq",
"Greece": "gr",
"South Georgia": "gs",
"Guatemala": "gt",
"Guam": "gu",
"Guinea-Bissau": "gw",
"Guyana": "gy",
"Hong Kong": "hk",
"Heard Island and McDonald Islands": "hm",
"Honduras": "hn",
"Croatia": "hr",
"Haiti": "ht",
"Hungary": "hu",
"Indonesia": "id",
"Ireland": "ie",
"Israel": "il",
"Isle of Man": "im",
"India": "in",
"British Indian Ocean Territory": "io",
"Iraq": "iq",
"Iran": "ir",
"Iceland": "is",
"Italy": "it",
"Jersey": "je",
"Jamaica": "jm",
"Jordan": "jo",
"Japan": "jp",
"Kenya": "ke",
"Kyrgyzstan": "kg",
"Cambodia": "kh",
"Kiribati": "ki",
"Comoros": "km",
"Saint Kitts and Nevis": "kn",
"North Korea": "kp",
"South Korea": "kr",
"Kuwait": "kw",
"Cayman Islands": "ky",
"Kazakhstan": "kz",
"Laos": "la",
"Lebanon": "lb",
"Saint Lucia": "lc",
"Liechtenstein": "li",
"Sri Lanka": "lk",
"Liberia": "lr",
"Lesotho": "ls",
"Lithuania": "lt",
"Luxembourg": "lu",
"Latvia": "lv",
"Libya": "ly",
"Morocco": "ma",
"Monaco": "mc",
"Moldova": "md",
"Montenegro": "me",
"Saint Martin": "mf",
"Madagascar": "mg",
"Marshall Islands": "mh",
"North Macedonia": "mk",
"Mali": "ml",
"Myanmar": "mm",
"Mongolia": "mn",
"Macau": "mo",
"Northern Mariana Islands": "mp",
"Martinique": "mq",
"Mauritania": "mr",
"Montserrat": "ms",
"Malta": "mt",
"Mauritius": "mu",
"Maldives": "mv",
"Malawi": "mw",
"Mexico": "mx",
"Malaysia": "my",
"Mozambique": "mz",
"Namibia": "na",
"New Caledonia": "nc",
"Niger": "ne",
"Norfolk Island": "nf",
"Nigeria": "ng",
"Nicaragua": "ni",
"Netherlands": "nl",
"Norway": "no",
"Nepal": "np",
"Nauru": "nr",
"Niue": "nu",
"New Zealand": "nz",
"Oman": "om",
"Panama": "pa",
"Peru": "pe",
"French Polynesia": "pf",
"Papua New Guinea": "pg",
"Philippines": "ph",
"Pakistan": "pk",
"Poland": "pl",
"Saint Pierre and Miquelon": "pm",
"Pitcairn Islands": "pn",
"Puerto Rico": "pr",
"Palestine": "ps",
"Portugal": "pt",
"Palau": "pw",
"Paraguay": "py",
"Qatar": "qa",
"Réunion": "re",
"Romania": "ro",
"Serbia": "rs",
"Russia": "ru",
"Rwanda": "rw",
"Saudi Arabia": "sa",
"Solomon Islands": "sb",
"Seychelles": "sc",
"Sudan": "sd",
"Sweden": "se",
"Singapore": "sg",
"Saint Helena, Ascension and Tristan da Cunha": "sh",
"Slovenia": "si",
"Svalbard and Jan Mayen": "sj",
"Slovakia": "sk",
"Sierra Leone": "sl",
"San Marino": "sm",
"Senegal": "sn",
"Somalia": "so",
"Suriname": "sr",
"South Sudan": "ss",
"São Tomé and Príncipe": "st",
"El Salvador": "sv",
"Sint Maarten": "sx",
"Syria": "sy",
"Eswatini (Swaziland)": "sz",
"Turks and Caicos Islands": "tc",
"Chad": "td",
"French Southern and Antarctic Lands": "tf",
"Togo": "tg",
"Thailand": "th",
"Tajikistan": "tj",
"Tokelau": "tk",
"Timor-Leste": "tl",
"Turkmenistan": "tm",
"Tunisia": "tn",
"Tonga": "to",
"Turkey": "tr",
"Trinidad and Tobago": "tt",
"Tuvalu": "tv",
"Taiwan": "tw",
"Tanzania": "tz",
"Ukraine": "ua",
"Uganda": "ug",
"United States Minor Outlying Islands": "um",
"United Nations": "un",
"United States": "us",
"Uruguay": "uy",
"Uzbekistan": "uz",
"Vatican City (Holy See)": "va",
"Saint Vincent and the Grenadines": "vc",
"Venezuela": "ve",
"British Virgin Islands": "vg",
"United States Virgin Islands": "vi",
"Vietnam": "vn",
"Vanuatu": "vu",
"Wallis and Futuna": "wf",
"Samoa": "ws",
"Kosovo": "xk",
"Yemen": "ye",
"Mayotte": "yt",
"South Africa": "za",
"Zambia": "zm",
"Zimbabwe": "zw",
}
let regions = {}; let regions = {};
const registerRegions = (geoData) => { const registerRegions = (geoData, covidData) => {
geoData.value.features.forEach((region) => { geoData.value.features.forEach((region) => {
regions[region.properties.NUTS_ID] = region.properties.NAME_LATN; const nuts = region.properties.NUTS_ID
const name = region.properties.NAME_LATN;
const covidWeekData = Object.values(covidData.value).find((weekData) => weekData[nuts] != undefined)
const country = covidWeekData[nuts].country;
regions[nuts] = {
name,
country,
}
}); });
} }
const getRegionName = function (nuts) { const getRegionName = function (nuts) {
return regions[nuts]; return regions[nuts].name;
}
const getCountryName = function (nuts) {
return regions[nuts].country;
} }
const getNutsCode = function (regionName) { const getNutsCode = function (regionName) {
return Object.keys(regions).find(key => regions[key] === regionName); return Object.keys(regions).find(key => regions[key].name === regionName);
} }
const getRegionList = function () { const getRegionList = function () {
return Object.values(regions); return Object.values(regions).map(region => region.name);
}
const getFlagUrl = function(nuts) {
const short = countries[regions[nuts].country];
return `https://flagcdn.com/w160/${short}.png`;
} }
export { export {
registerRegions, registerRegions,
getRegionName, getRegionName,
getCountryName,
getNutsCode, getNutsCode,
getRegionList, getRegionList,
getFlagUrl,
} }
...@@ -10,9 +10,12 @@ const mediumValue = 0.7; ...@@ -10,9 +10,12 @@ const mediumValue = 0.7;
const bestHue = 138; const bestHue = 138;
const insulation = 0.8; const insulation = 0.8;
const minExtrusion = 0.1;
const extrusion = function (incidence) { const extrusion = function (incidence) {
incidence = parseFloat(incidence) incidence = parseFloat(incidence)
return incidence / mediumIncidence * 5 const extrusion = incidence / mediumIncidence * 5
return extrusion < minExtrusion ? minExtrusion : extrusion
} }
function HSVtoRGB(h, s, v) { function HSVtoRGB(h, s, v) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment