spb/countryatlas
Public
TypeScript 57%
Python 38.6%
JavaScript 3.6%
CSS 0.6%
1import 'server-only';2import { isoLookupFromCountries, worldPaths } from '@/lib/map-geo';3import type { CountrySummary } from '@/lib/types';4import type { BaseFeature } from './indicator-map';56/** Server-side: world geometry joined with the country list (slug, flag) — values are added client-side. */7export function baseFeatures(countries: CountrySummary[]): { features: BaseFeature[]; sphere: string } {8 const { paths, sphere } = worldPaths();9 const byId = new Map(countries.map((c) => [c.id, c]));10 const numeric = isoLookupFromCountries(countries as Array<{ id: string; iso_numeric?: string | null }>);11 const features = paths.map((p) => {12 const iso3 = p.iso3 ?? (p.numeric ? numeric.get(p.numeric) ?? null : null);13 const c = iso3 ? byId.get(iso3) : undefined;14 return { iso3, name: c?.name ?? p.name, slug: c?.slug ?? null, flag: c?.flag ?? null, d: p.d };15 });16 return { features, sphere };17}18