Skip to content

Commit

Permalink
Support the European Union (EU27) as a “country”
Browse files Browse the repository at this point in the history
  • Loading branch information
clementprdhomme committed Nov 9, 2023
1 parent 11a6ef6 commit 3e80423
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
43 changes: 40 additions & 3 deletions components/tool/world-map/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,38 @@ import WORLD_GEOGRAPHIES from './WORLD.topo.json';
import './style.scss';
import TraseLink from '../trase-link';

// For some combinations such as Colombia / Cocoa, we don't have information at the country level
// but economic bloc instead. For this reason, we're adding EU 27 here.
const EU_COUNTRIES = [
'AT',
'BE',
'BG',
'HR',
'CY',
'CZ',
'DK',
'EE',
'FI',
'FR',
'DE',
'GR',
'HU',
'IE',
'IT',
'LV',
'LT',
'LU',
'MT',
'NL',
'PL',
'PT',
'RO',
'SK',
'SI',
'ES',
'SE',
];

class WorldMap extends React.PureComponent {
state = {
tooltipContent: null,
Expand All @@ -30,7 +62,9 @@ class WorldMap extends React.PureComponent {
const { mapData } = this.props;

const { iso2 } = properties;
const flow = mapData.find(flow => flow.iso === iso2);
const flow = mapData.find(
flow => flow.iso === iso2 || (flow.iso === 'EU' && EU_COUNTRIES.indexOf(iso2) !== -1)
);

if (!iso2 || !flow) {
this.setState({ tooltipContent: null });
Expand Down Expand Up @@ -60,9 +94,12 @@ class WorldMap extends React.PureComponent {
return geographies.map(geography => {
const iso = geography.properties.iso2;
let fillColor = '#dedede';
if (iso === countryIso) {
if (iso === countryIso || (countryIso === 'EU' && EU_COUNTRIES.indexOf(iso) !== -1)) {
fillColor = '#f1ba30';
} else if (destinationCountriesIso.indexOf(iso) !== -1) {
} else if (
destinationCountriesIso.indexOf(iso) !== -1 ||
(destinationCountriesIso.indexOf('EU') !== -1 && EU_COUNTRIES.indexOf(iso) !== -1)
) {
fillColor = '#03755e';
}

Expand Down
3 changes: 3 additions & 0 deletions modules/tool/world-map/trase-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ export const COUNTRIES_COORDINATES = {
ER: [39, 15],
ES: [-4, 40],
ET: [38, 8],
// For some combinations such as Colombia / Cocoa, we don't have information at the country level
// but economic bloc instead. For this reason, we're adding EU 27 here.
EU: [14.22160493, 48.67716049],
FI: [26, 64],
FJ: [175, -18],
FK: [-59, -51.75],
Expand Down

0 comments on commit 3e80423

Please sign in to comment.