SPB Git

spb/countryatlas

Public
922 B · 18 lines typescript
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
Files · d588bee37a233436d1bef2f0970b4b557e87e5f7
Menu

Theme