Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated namespace with keyInfo item; added 'anyOption' to records #383

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions frontend/src/data_sockets/PandemosContext.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR)
// SPDX-License-Identifier: Apache-2.0

import React, {createContext, useCallback, useEffect, useMemo, useState} from 'react';
import React, {createContext, useEffect, useMemo, useState} from 'react';
import crossfilter, {Crossfilter} from 'crossfilter2';
import agentList from '../../assets/pandemos/agents_lookup.json?url';
import locationList from '../../assets/pandemos/locations_lookup.json?url';
import trajectories from '../../assets/pandemos/trajectories.json?url';
import hash from 'object-hash';
import {Agent, Location, Trip, TripExpanded, TripChain} from 'types/pandemos';
/**
* Data context for the pandemos data.
Expand Down Expand Up @@ -90,9 +89,9 @@ export const PandemosProvider = ({children}: {children: React.ReactNode}) => {
trips?.map((trip) => {
return {
...trip,
agent_age_group: agents![trip.agent_id].age_group,
start_location_type: locations![trip.start_location].location_type,
end_location_type: locations![trip.end_location].location_type,
agent_age_group: agents[trip.agent_id].age_group,
start_location_type: locations[trip.start_location].location_type,
end_location_type: locations[trip.end_location].location_type,
} as TripExpanded;
})
);
Expand Down Expand Up @@ -120,7 +119,7 @@ export const PandemosProvider = ({children}: {children: React.ReactNode}) => {
tripChains.push({agent_id: trip.agent_id, chain_id: chain_id++, trips: tripChain.slice(start, index + 1)});
});
}
return tripChains
return tripChains;
}, [trips, locations]);

return (
Expand Down
77 changes: 45 additions & 32 deletions frontend/src/types/pandemos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,39 @@
// SPDX-License-Identifier: Apache-2.0

/** Display names for the diffent enums of the pandemos data */
/* eslint-disable @typescript-eslint/no-namespace */
export namespace KeyInfo {
export const anyOption: KeyInfoItem = {
icon: '🤷',
fullName: 'Any',
};
/** Locations */
export const location_type: Record<number, string> = {
/** Home */ 0: '🏡',
/** School */ 1: '🏫',
/** Work */ 2: '🏭/🏢',
/** Social Event */ 3: '🏟',
/** Shopping */ 4: '🏪',
/** Hospital */ 5: '🏥❗',
/** ICU */ 6: '🏥‼',
/** Car */ 7: '🚘',
/** Public */ 8: '⛲',
/** Transport */ 9: '🚍',
/** Cemetery */ 10: '⚰',
export const location_type: Record<number, KeyInfoItem> = {
/** Any */ 0: anyOption,
/** Home */ 1: {icon: '🏡', fullName: 'Home'},
/** School */ 2: {icon: '🏫', fullName: 'School'},
/** Work */ 3: {icon: '🏭/🏢', fullName: 'Workplace'},
/** Social Event */ 4: {icon: '🏟', fullName: 'Social Event'},
/** Shopping */ 5: {icon: '🏪', fullName: 'Shopping'},
/** Hospital */ 6: {icon: '🏥❗', fullName: 'Hospital'},
/** ICU */ 7: {icon: '🏥‼', fullName: 'Intensive Care'},
/** Car */ 8: {icon: '🚘', fullName: 'Car'},
/** Public */ 9: {icon: '⛲', fullName: 'Public Space'},
/** Transport */ 10: {icon: '🚍', fullName: 'Public Transport'},
/** Cemetery */ 11: {icon: '⚰', fullName: 'Cemetery'},
};

export const transport_mode: Record<number, string> = {
/** Bike */ 0: '🚴‍♀️',
/** Car (Driver) */ 1: '🚘👤',
/** Car (Passenger) */ 2: '🚘👥',
/** Bus */ 3: '🚍',
/** Walking */ 4: '🚶‍♀️',
/** Other */ 5: '🛸',
/** Unknown */ 6: '❓',
export const transport_mode: Record<number, KeyInfoItem> = {
/** Any */ 0: anyOption,
/** Bike */ 1: {icon: '🚴‍♀️', fullName: 'Bicycle'},
/** Car (Driver) */ 2: {icon: '🚘👤', fullName: 'Car as Driver'},
/** Car (Passenger) */ 3: {icon: '🚘👥', fullName: 'Car as Passenger'},
/** Bus */ 4: {icon: '🚍', fullName: 'Bus'},
/** Walking */ 5: {icon: '🚶‍♀️', fullName: 'Walking'},
/** Other */ 6: {icon: '🛸', fullName: 'Other'},
/** Unknown */ 7: {icon: '❓', fullName: 'Unknown'},
};

export const activity: Record<number, string> = {
/** Workplace */ 0: 'Workplace',
/** Education */ 1: 'Education',
Expand All @@ -38,16 +45,17 @@ export namespace KeyInfo {
/** Going Home */ 6: 'Going Home',
/** Unknown */ 7: 'Unknown',
};
export const infection_state: Record<number, string> = {
/** Susceptible */ 0: '🙂',
/** Infected with no symptoms */ 1: '🤔',
/** Infected with symptoms */ 2: '🤧',
/** Infected with severe symptoms */ 3: '🤒',
/** Infected with critical symptoms */ 4: '🤮',
/** Recovered */ 5: '😀',
/** Dead */ 6: '💀',
/** Unknown */ 7: '❓',
};
export const infection_state: Record<number, KeyInfoItem> = {
/** Any */ 0: anyOption,
/** Susceptible */ 1: {icon: '🙂', fullName: 'Susceptible to Infection'},
/** Infected with no symptoms */ 2: {icon: '🤔', fullName: 'Asymptomatic Infection'},
/** Infected with symptoms */ 3: {icon: '🤧', fullName: 'Symptomatic Infection'},
/** Infected with severe symptoms */ 4: {icon: '🤒', fullName: 'Severely Symptomatic'},
/** Infected with critical symptoms */ 5: {icon: '🤮', fullName: 'Critically Symptomatic'},
/** Recovered */ 6: {icon: '😀', fullName: 'Recovered from Infection'},
/** Dead */ 7: {icon: '💀', fullName: 'Deceased'},
/** Unknown */ 8: {icon: '❓', fullName: 'Unknown'},
};
}

export interface Agent {
Expand Down Expand Up @@ -103,4 +111,9 @@ export interface TripChain {
chain_id: number;
agent_id: number;
trips: Array<Trip>;
}
}

export interface KeyInfoItem {
icon: string;
fullName: string;
}
Loading