The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
serve each country's regions from its own file, so the server no longer holds them all
Vini7277e35a96a5
diff --git a/Dockerfile b/Dockerfileindex d425e8549..6253a8eaf 100644--- a/Dockerfile+++ b/Dockerfile@@ -91,7 +91,8 @@ ENV KITINERARY_EXTRACTOR_PATH=/usr/local/bin/kitinerary-extractorCOPY --chown=node:node --from=server-builder /app/server/dist ./server/dist# Runtime data assets read from server/assets at runtime: airports.json (flight-# transport search) and atlas/*.geojson.gz (Atlas country/region map). The build+# transport search) and atlas/*.geojson.gz + atlas/admin1/*.geojson.gz (Atlas+# country/region map). The build# only emits dist, so these must be copied explicitly or the features silently# degrade to empty in the image.COPY --chown=node:node --from=server-builder /app/server/assets ./server/assetsdiff --git a/NOTICE.md b/NOTICE.mdindex db202a80f..8a0a6ed79 100644--- a/NOTICE.md+++ b/NOTICE.md@@ -5,8 +5,9 @@ TREK bundles and uses third-party data that requires attribution.## geoBoundaries — country & sub-national boundariesThe Atlas map's administrative boundaries (admin-0 countries and admin-1-provinces/counties), shipped at `server/assets/atlas/admin0.geojson.gz` and-`server/assets/atlas/admin1.geojson.gz` and generated by+provinces/counties), shipped at `server/assets/atlas/admin0.geojson.gz`,+`server/assets/atlas/admin1.geojson.gz` and `server/assets/atlas/admin1/<ISO_A2>.geojson.gz`+(the same regions, one file per country) and generated by`server/scripts/build-atlas-geo.mjs`, are derived from **geoBoundaries**.> Runfola, D. et al. (2020) geoBoundaries: A global database of politicaldiff --git a/client/scripts/eslint-baseline.json b/client/scripts/eslint-baseline.jsonindex a54f8e616..41c27b43c 100644--- a/client/scripts/eslint-baseline.json+++ b/client/scripts/eslint-baseline.json@@ -5,7 +5,7 @@"no-console": 88,"complexity": 218,"@typescript-eslint/no-explicit-any": 144,- "trek/no-swallowed-catch": 129,+ "trek/no-swallowed-catch": 128,"max-params": 32,"trek/store-without-selector": 67,"react-hooks/refs": 555,diff --git a/client/scripts/size-baseline.json b/client/scripts/size-baseline.jsonindex 0cd9653d3..80083bf96 100644--- a/client/scripts/size-baseline.json+++ b/client/scripts/size-baseline.json@@ -22,7 +22,7 @@"src/pages/JourneyDetailPage.test.tsx": 4030,"src/pages/LoginPage.tsx": 1348,"src/pages/TripPlannerPage.tsx": 1128,- "src/pages/atlas/useAtlas.ts": 1211,+ "src/pages/atlas/useAtlas.ts": 1210,"src/pages/tripPlanner/useTripPlanner.roadtrip.test.tsx": 3518,"src/pages/tripPlanner/useTripPlanner.test.tsx": 3270,"src/styles/studio.css": 1918diff --git a/client/src/pages/AtlasPage.test.tsx b/client/src/pages/AtlasPage.test.tsxindex ead8ebea6..f9d5a4cd2 100644--- a/client/src/pages/AtlasPage.test.tsx+++ b/client/src/pages/AtlasPage.test.tsx@@ -215,7 +215,7 @@ function useDefaultAtlasHandlers() {// country features override this handler via server.use(...).http.get('/api/addons/atlas/countries/geo', () => HttpResponse.json({ type: 'FeatureCollection', features: [] })),// Handler for region GeoJSON fetch (triggered by loadRegionsForViewport when intersects=true)- http.get('/api/addons/atlas/regions/geo', () => HttpResponse.json({ features: [] })),+ http.get('/api/addons/atlas/regions/geo/:code', () => HttpResponse.json({ features: [] })),);}@@ -1589,7 +1589,7 @@ describe('AtlasPage', () => {);server.use(- http.get('/api/addons/atlas/regions/geo', () => HttpResponse.json({ features: [] })),+ http.get('/api/addons/atlas/regions/geo/:code', () => HttpResponse.json({ features: [] })),);render(<AtlasPage />);@@ -1746,7 +1746,7 @@ describe('AtlasPage', () => {type: 'FeatureCollection',features: [{ type: 'Feature', properties: { ISO_A2: 'FR', ADM0_A3: 'FRA', ISO_A3: 'FRA', NAME: 'France', ADMIN: 'France' }, geometry: null }],})),- http.get('/api/addons/atlas/regions/geo', () => HttpResponse.json({+ http.get('/api/addons/atlas/regions/geo/:code', () => HttpResponse.json({type: 'FeatureCollection',features: [{ type: 'Feature', properties: { iso_a2: 'FR', iso_3166_2: 'FR-IDF', name: 'Île-de-France', name_en: 'Île-de-France', admin: 'France' }, geometry: null }],})),diff --git a/client/src/pages/atlas/useAtlas.test.tsx b/client/src/pages/atlas/useAtlas.test.tsxindex 2f2001e70..4063fdd6f 100644--- a/client/src/pages/atlas/useAtlas.test.tsx+++ b/client/src/pages/atlas/useAtlas.test.tsx@@ -274,7 +274,7 @@ function installAtlasHandlers(over: Partial<Record<string, unknown>> = {}) {http.get('/api/addons/atlas/bucket-list', () => HttpResponse.json({ items: over.bucket ?? [] })),http.get('/api/addons/atlas/regions', () => HttpResponse.json({ regions: over.regions ?? {} })),http.get('/api/addons/atlas/countries/geo', () => HttpResponse.json(over.geo ?? { type: 'FeatureCollection', features: [] })),- http.get('/api/addons/atlas/regions/geo', () => HttpResponse.json(over.regionGeo ?? { features: [] })),+ http.get('/api/addons/atlas/regions/geo/:code', () => HttpResponse.json(over.regionGeo ?? { features: [] })),http.get('/api/atlas-layers', () => HttpResponse.json({ layers: over.layers ?? [] })),);}@@ -1053,8 +1053,8 @@ describe('useAtlas', () => {await waitFor(() => expect(atlas.atlas_country_options.length).toBe(seen.length));const requested: string[] = [];- server.use(http.get('/api/addons/atlas/regions/geo', ({ request }) => {- requested.push(new URL(request.url).searchParams.get('countries') ?? '');+ server.use(http.get('/api/addons/atlas/regions/geo/:code', ({ params }) => {+ requested.push(String(params.code));return HttpResponse.json(regionGeo);}));diff --git a/client/src/pages/atlas/useAtlas.ts b/client/src/pages/atlas/useAtlas.tsindex 679621008..d5556389d 100644--- a/client/src/pages/atlas/useAtlas.ts+++ b/client/src/pages/atlas/useAtlas.ts@@ -317,18 +317,18 @@ export function useAtlas() {}if (!toLoad.length) returnfor (const code of toLoad) pendingRegionCodes.current.add(code)- apiClient.get(`/addons/atlas/regions/geo?countries=${toLoad.join(',')}`)+ // One stable URL per country, so a country evicted by REGION_CACHE_MAX or seen on an earlier+ // visit comes back from the browser cache. Every request settles; the layer rebuilds once.+ void Promise.all(toLoad.map(c => apiClient.get(`/addons/atlas/regions/geo/${c}`).then(geoRes => {- const geo = geoRes.data- if (!geo?.features) return- let added = false- for (const c of toLoad) {- const features = geo.features.filter((f: any) => f.properties?.iso_a2?.toUpperCase() === c)- if (features.length > 0) { regionGeoCache.current[c] = { type: 'FeatureCollection', features }; touchRegionCode(c); added = true }- }- if (added) { evictRegionCache(); setRegionGeoLoaded(v => v + 1) }+ const features = (geoRes.data?.features || []).filter((f: any) => f.properties?.iso_a2?.toUpperCase() === c)+ if (features.length === 0) return false+ regionGeoCache.current[c] = { type: 'FeatureCollection', features }+ touchRegionCode(c)+ return true})- .catch(() => {})+ .catch(() => false)))+ .then(added => { if (added.some(Boolean)) { evictRegionCache(); setRegionGeoLoaded(v => v + 1) } }).finally(() => { for (const code of toLoad) pendingRegionCodes.current.delete(code) })}loadRegionsForViewportRef.current = loadRegionsForViewportdiff --git a/server/assets/atlas/admin1/AD.geojson.gz b/server/assets/atlas/admin1/AD.geojson.gznew file mode 100644index 000000000..fb4339f7fBinary files /dev/null and b/server/assets/atlas/admin1/AD.geojson.gz differdiff --git a/server/assets/atlas/admin1/AE.geojson.gz b/server/assets/atlas/admin1/AE.geojson.gznew file mode 100644index 000000000..b0eb08ea1Binary files /dev/null and b/server/assets/atlas/admin1/AE.geojson.gz differdiff --git a/server/assets/atlas/admin1/AF.geojson.gz b/server/assets/atlas/admin1/AF.geojson.gznew file mode 100644index 000000000..742b48e32Binary files /dev/null and b/server/assets/atlas/admin1/AF.geojson.gz differdiff --git a/server/assets/atlas/admin1/AG.geojson.gz b/server/assets/atlas/admin1/AG.geojson.gznew file mode 100644index 000000000..bd8efae6bBinary files /dev/null and b/server/assets/atlas/admin1/AG.geojson.gz differdiff --git a/server/assets/atlas/admin1/AL.geojson.gz b/server/assets/atlas/admin1/AL.geojson.gznew file mode 100644index 000000000..beb9f1f34Binary files /dev/null and b/server/assets/atlas/admin1/AL.geojson.gz differdiff --git a/server/assets/atlas/admin1/AM.geojson.gz b/server/assets/atlas/admin1/AM.geojson.gznew file mode 100644index 000000000..f2a09f8a1Binary files /dev/null and b/server/assets/atlas/admin1/AM.geojson.gz differdiff --git a/server/assets/atlas/admin1/AO.geojson.gz b/server/assets/atlas/admin1/AO.geojson.gznew file mode 100644index 000000000..951b2e6d3Binary files /dev/null and b/server/assets/atlas/admin1/AO.geojson.gz differdiff --git a/server/assets/atlas/admin1/AR.geojson.gz b/server/assets/atlas/admin1/AR.geojson.gznew file mode 100644index 000000000..87d2c8297Binary files /dev/null and b/server/assets/atlas/admin1/AR.geojson.gz differdiff --git a/server/assets/atlas/admin1/AT.geojson.gz b/server/assets/atlas/admin1/AT.geojson.gznew file mode 100644index 000000000..ae6b2de1eBinary files /dev/null and b/server/assets/atlas/admin1/AT.geojson.gz differdiff --git a/server/assets/atlas/admin1/AU.geojson.gz b/server/assets/atlas/admin1/AU.geojson.gznew file mode 100644index 000000000..123846fb5Binary files /dev/null and b/server/assets/atlas/admin1/AU.geojson.gz differdiff --git a/server/assets/atlas/admin1/AZ.geojson.gz b/server/assets/atlas/admin1/AZ.geojson.gznew file mode 100644index 000000000..10464c199Binary files /dev/null and b/server/assets/atlas/admin1/AZ.geojson.gz differdiff --git a/server/assets/atlas/admin1/BA.geojson.gz b/server/assets/atlas/admin1/BA.geojson.gznew file mode 100644index 000000000..afbda8b6eBinary files /dev/null and b/server/assets/atlas/admin1/BA.geojson.gz differdiff --git a/server/assets/atlas/admin1/BB.geojson.gz b/server/assets/atlas/admin1/BB.geojson.gznew file mode 100644index 000000000..5253b36faBinary files /dev/null and b/server/assets/atlas/admin1/BB.geojson.gz differdiff --git a/server/assets/atlas/admin1/BD.geojson.gz b/server/assets/atlas/admin1/BD.geojson.gznew file mode 100644index 000000000..e13a0f56dBinary files /dev/null and b/server/assets/atlas/admin1/BD.geojson.gz differdiff --git a/server/assets/atlas/admin1/BE.geojson.gz b/server/assets/atlas/admin1/BE.geojson.gznew file mode 100644index 000000000..0a642d811Binary files /dev/null and b/server/assets/atlas/admin1/BE.geojson.gz differdiff --git a/server/assets/atlas/admin1/BF.geojson.gz b/server/assets/atlas/admin1/BF.geojson.gznew file mode 100644index 000000000..cc932c4b9Binary files /dev/null and b/server/assets/atlas/admin1/BF.geojson.gz differdiff --git a/server/assets/atlas/admin1/BG.geojson.gz b/server/assets/atlas/admin1/BG.geojson.gznew file mode 100644index 000000000..8349a49abBinary files /dev/null and b/server/assets/atlas/admin1/BG.geojson.gz differdiff --git a/server/assets/atlas/admin1/BH.geojson.gz b/server/assets/atlas/admin1/BH.geojson.gznew file mode 100644index 000000000..5269d039bBinary files /dev/null and b/server/assets/atlas/admin1/BH.geojson.gz differdiff --git a/server/assets/atlas/admin1/BI.geojson.gz b/server/assets/atlas/admin1/BI.geojson.gznew file mode 100644index 000000000..85421e7b4Binary files /dev/null and b/server/assets/atlas/admin1/BI.geojson.gz differdiff --git a/server/assets/atlas/admin1/BJ.geojson.gz b/server/assets/atlas/admin1/BJ.geojson.gznew file mode 100644index 000000000..7a53c8dafBinary files /dev/null and b/server/assets/atlas/admin1/BJ.geojson.gz differdiff --git a/server/assets/atlas/admin1/BN.geojson.gz b/server/assets/atlas/admin1/BN.geojson.gznew file mode 100644index 000000000..0d28b8feeBinary files /dev/null and b/server/assets/atlas/admin1/BN.geojson.gz differdiff --git a/server/assets/atlas/admin1/BO.geojson.gz b/server/assets/atlas/admin1/BO.geojson.gznew file mode 100644index 000000000..65c09919eBinary files /dev/null and b/server/assets/atlas/admin1/BO.geojson.gz differdiff --git a/server/assets/atlas/admin1/BR.geojson.gz b/server/assets/atlas/admin1/BR.geojson.gznew file mode 100644index 000000000..be682c651Binary files /dev/null and b/server/assets/atlas/admin1/BR.geojson.gz differdiff --git a/server/assets/atlas/admin1/BS.geojson.gz b/server/assets/atlas/admin1/BS.geojson.gznew file mode 100644index 000000000..36536fcdaBinary files /dev/null and b/server/assets/atlas/admin1/BS.geojson.gz differdiff --git a/server/assets/atlas/admin1/BT.geojson.gz b/server/assets/atlas/admin1/BT.geojson.gznew file mode 100644index 000000000..7ffd8e039Binary files /dev/null and b/server/assets/atlas/admin1/BT.geojson.gz differdiff --git a/server/assets/atlas/admin1/BW.geojson.gz b/server/assets/atlas/admin1/BW.geojson.gznew file mode 100644index 000000000..b674a7d14Binary files /dev/null and b/server/assets/atlas/admin1/BW.geojson.gz differdiff --git a/server/assets/atlas/admin1/BY.geojson.gz b/server/assets/atlas/admin1/BY.geojson.gznew file mode 100644index 000000000..61a6a7caaBinary files /dev/null and b/server/assets/atlas/admin1/BY.geojson.gz differdiff --git a/server/assets/atlas/admin1/BZ.geojson.gz b/server/assets/atlas/admin1/BZ.geojson.gznew file mode 100644index 000000000..1ad34e2e6Binary files /dev/null and b/server/assets/atlas/admin1/BZ.geojson.gz differdiff --git a/server/assets/atlas/admin1/CA.geojson.gz b/server/assets/atlas/admin1/CA.geojson.gznew file mode 100644index 000000000..419b97096Binary files /dev/null and b/server/assets/atlas/admin1/CA.geojson.gz differdiff --git a/server/assets/atlas/admin1/CD.geojson.gz b/server/assets/atlas/admin1/CD.geojson.gznew file mode 100644index 000000000..4269b4249Binary files /dev/null and b/server/assets/atlas/admin1/CD.geojson.gz differdiff --git a/server/assets/atlas/admin1/CF.geojson.gz b/server/assets/atlas/admin1/CF.geojson.gznew file mode 100644index 000000000..1a630297cBinary files /dev/null and b/server/assets/atlas/admin1/CF.geojson.gz differdiff --git a/server/assets/atlas/admin1/CG.geojson.gz b/server/assets/atlas/admin1/CG.geojson.gznew file mode 100644index 000000000..3addca65fBinary files /dev/null and b/server/assets/atlas/admin1/CG.geojson.gz differdiff --git a/server/assets/atlas/admin1/CH.geojson.gz b/server/assets/atlas/admin1/CH.geojson.gznew file mode 100644index 000000000..6c8fb2aafBinary files /dev/null and b/server/assets/atlas/admin1/CH.geojson.gz differdiff --git a/server/assets/atlas/admin1/CI.geojson.gz b/server/assets/atlas/admin1/CI.geojson.gznew file mode 100644index 000000000..2f0344e83Binary files /dev/null and b/server/assets/atlas/admin1/CI.geojson.gz differdiff --git a/server/assets/atlas/admin1/CL.geojson.gz b/server/assets/atlas/admin1/CL.geojson.gznew file mode 100644index 000000000..9b7f489e8Binary files /dev/null and b/server/assets/atlas/admin1/CL.geojson.gz differdiff --git a/server/assets/atlas/admin1/CM.geojson.gz b/server/assets/atlas/admin1/CM.geojson.gznew file mode 100644index 000000000..eff0d5375Binary files /dev/null and b/server/assets/atlas/admin1/CM.geojson.gz differdiff --git a/server/assets/atlas/admin1/CN.geojson.gz b/server/assets/atlas/admin1/CN.geojson.gznew file mode 100644index 000000000..2cb47aa16Binary files /dev/null and b/server/assets/atlas/admin1/CN.geojson.gz differdiff --git a/server/assets/atlas/admin1/CO.geojson.gz b/server/assets/atlas/admin1/CO.geojson.gznew file mode 100644index 000000000..1ff6713b9Binary files /dev/null and b/server/assets/atlas/admin1/CO.geojson.gz differdiff --git a/server/assets/atlas/admin1/CR.geojson.gz b/server/assets/atlas/admin1/CR.geojson.gznew file mode 100644index 000000000..67b015397Binary files /dev/null and b/server/assets/atlas/admin1/CR.geojson.gz differdiff --git a/server/assets/atlas/admin1/CU.geojson.gz b/server/assets/atlas/admin1/CU.geojson.gznew file mode 100644index 000000000..779f395e9Binary files /dev/null and b/server/assets/atlas/admin1/CU.geojson.gz differdiff --git a/server/assets/atlas/admin1/CV.geojson.gz b/server/assets/atlas/admin1/CV.geojson.gznew file mode 100644index 000000000..9acf07324Binary files /dev/null and b/server/assets/atlas/admin1/CV.geojson.gz differdiff --git a/server/assets/atlas/admin1/CY.geojson.gz b/server/assets/atlas/admin1/CY.geojson.gznew file mode 100644index 000000000..68e6b295aBinary files /dev/null and b/server/assets/atlas/admin1/CY.geojson.gz differdiff --git a/server/assets/atlas/admin1/CZ.geojson.gz b/server/assets/atlas/admin1/CZ.geojson.gznew file mode 100644index 000000000..2509eaafbBinary files /dev/null and b/server/assets/atlas/admin1/CZ.geojson.gz differdiff --git a/server/assets/atlas/admin1/DE.geojson.gz b/server/assets/atlas/admin1/DE.geojson.gznew file mode 100644index 000000000..0ff6a2227Binary files /dev/null and b/server/assets/atlas/admin1/DE.geojson.gz differdiff --git a/server/assets/atlas/admin1/DJ.geojson.gz b/server/assets/atlas/admin1/DJ.geojson.gznew file mode 100644index 000000000..c2e095a22Binary files /dev/null and b/server/assets/atlas/admin1/DJ.geojson.gz differdiff --git a/server/assets/atlas/admin1/DK.geojson.gz b/server/assets/atlas/admin1/DK.geojson.gznew file mode 100644index 000000000..be0e97ac0Binary files /dev/null and b/server/assets/atlas/admin1/DK.geojson.gz differdiff --git a/server/assets/atlas/admin1/DM.geojson.gz b/server/assets/atlas/admin1/DM.geojson.gznew file mode 100644index 000000000..ea2abe7c7Binary files /dev/null and b/server/assets/atlas/admin1/DM.geojson.gz differdiff --git a/server/assets/atlas/admin1/DO.geojson.gz b/server/assets/atlas/admin1/DO.geojson.gznew file mode 100644index 000000000..fd38e76d4Binary files /dev/null and b/server/assets/atlas/admin1/DO.geojson.gz differdiff --git a/server/assets/atlas/admin1/DZ.geojson.gz b/server/assets/atlas/admin1/DZ.geojson.gznew file mode 100644index 000000000..fe2fbfc93Binary files /dev/null and b/server/assets/atlas/admin1/DZ.geojson.gz differdiff --git a/server/assets/atlas/admin1/EC.geojson.gz b/server/assets/atlas/admin1/EC.geojson.gznew file mode 100644index 000000000..f680e60eaBinary files /dev/null and b/server/assets/atlas/admin1/EC.geojson.gz differdiff --git a/server/assets/atlas/admin1/EE.geojson.gz b/server/assets/atlas/admin1/EE.geojson.gznew file mode 100644index 000000000..89cebda33Binary files /dev/null and b/server/assets/atlas/admin1/EE.geojson.gz differdiff --git a/server/assets/atlas/admin1/EG.geojson.gz b/server/assets/atlas/admin1/EG.geojson.gznew file mode 100644index 000000000..21ac5942bBinary files /dev/null and b/server/assets/atlas/admin1/EG.geojson.gz differdiff --git a/server/assets/atlas/admin1/ER.geojson.gz b/server/assets/atlas/admin1/ER.geojson.gznew file mode 100644index 000000000..20ce2389aBinary files /dev/null and b/server/assets/atlas/admin1/ER.geojson.gz differdiff --git a/server/assets/atlas/admin1/ES.geojson.gz b/server/assets/atlas/admin1/ES.geojson.gznew file mode 100644index 000000000..3cdc56e05Binary files /dev/null and b/server/assets/atlas/admin1/ES.geojson.gz differdiff --git a/server/assets/atlas/admin1/ET.geojson.gz b/server/assets/atlas/admin1/ET.geojson.gznew file mode 100644index 000000000..cc51d4b2dBinary files /dev/null and b/server/assets/atlas/admin1/ET.geojson.gz differdiff --git a/server/assets/atlas/admin1/FI.geojson.gz b/server/assets/atlas/admin1/FI.geojson.gznew file mode 100644index 000000000..b0a0fae01Binary files /dev/null and b/server/assets/atlas/admin1/FI.geojson.gz differdiff --git a/server/assets/atlas/admin1/FJ.geojson.gz b/server/assets/atlas/admin1/FJ.geojson.gznew file mode 100644index 000000000..0ff5db3adBinary files /dev/null and b/server/assets/atlas/admin1/FJ.geojson.gz differdiff --git a/server/assets/atlas/admin1/FM.geojson.gz b/server/assets/atlas/admin1/FM.geojson.gznew file mode 100644index 000000000..fdae40c92Binary files /dev/null and b/server/assets/atlas/admin1/FM.geojson.gz differdiff --git a/server/assets/atlas/admin1/FR.geojson.gz b/server/assets/atlas/admin1/FR.geojson.gznew file mode 100644index 000000000..6870e60c8Binary files /dev/null and b/server/assets/atlas/admin1/FR.geojson.gz differdiff --git a/server/assets/atlas/admin1/GA.geojson.gz b/server/assets/atlas/admin1/GA.geojson.gznew file mode 100644index 000000000..1e3c94b82Binary files /dev/null and b/server/assets/atlas/admin1/GA.geojson.gz differdiff --git a/server/assets/atlas/admin1/GB.geojson.gz b/server/assets/atlas/admin1/GB.geojson.gznew file mode 100644index 000000000..15144a181Binary files /dev/null and b/server/assets/atlas/admin1/GB.geojson.gz differdiff --git a/server/assets/atlas/admin1/GD.geojson.gz b/server/assets/atlas/admin1/GD.geojson.gznew file mode 100644index 000000000..0eb36cf51Binary files /dev/null and b/server/assets/atlas/admin1/GD.geojson.gz differdiff --git a/server/assets/atlas/admin1/GE.geojson.gz b/server/assets/atlas/admin1/GE.geojson.gznew file mode 100644index 000000000..5d62ec000Binary files /dev/null and b/server/assets/atlas/admin1/GE.geojson.gz differdiff --git a/server/assets/atlas/admin1/GH.geojson.gz b/server/assets/atlas/admin1/GH.geojson.gznew file mode 100644index 000000000..93a18cdb4Binary files /dev/null and b/server/assets/atlas/admin1/GH.geojson.gz differdiff --git a/server/assets/atlas/admin1/GL.geojson.gz b/server/assets/atlas/admin1/GL.geojson.gznew file mode 100644index 000000000..fc3850477Binary files /dev/null and b/server/assets/atlas/admin1/GL.geojson.gz differdiff --git a/server/assets/atlas/admin1/GM.geojson.gz b/server/assets/atlas/admin1/GM.geojson.gznew file mode 100644index 000000000..cb9a8b020Binary files /dev/null and b/server/assets/atlas/admin1/GM.geojson.gz differdiff --git a/server/assets/atlas/admin1/GN.geojson.gz b/server/assets/atlas/admin1/GN.geojson.gznew file mode 100644index 000000000..314fe794dBinary files /dev/null and b/server/assets/atlas/admin1/GN.geojson.gz differdiff --git a/server/assets/atlas/admin1/GQ.geojson.gz b/server/assets/atlas/admin1/GQ.geojson.gznew file mode 100644index 000000000..908d27b17Binary files /dev/null and b/server/assets/atlas/admin1/GQ.geojson.gz differdiff --git a/server/assets/atlas/admin1/GR.geojson.gz b/server/assets/atlas/admin1/GR.geojson.gznew file mode 100644index 000000000..a9396dac1Binary files /dev/null and b/server/assets/atlas/admin1/GR.geojson.gz differdiff --git a/server/assets/atlas/admin1/GT.geojson.gz b/server/assets/atlas/admin1/GT.geojson.gznew file mode 100644index 000000000..319555787Binary files /dev/null and b/server/assets/atlas/admin1/GT.geojson.gz differdiff --git a/server/assets/atlas/admin1/GW.geojson.gz b/server/assets/atlas/admin1/GW.geojson.gznew file mode 100644index 000000000..a5e5030abBinary files /dev/null and b/server/assets/atlas/admin1/GW.geojson.gz differdiff --git a/server/assets/atlas/admin1/GY.geojson.gz b/server/assets/atlas/admin1/GY.geojson.gznew file mode 100644index 000000000..2336802e3Binary files /dev/null and b/server/assets/atlas/admin1/GY.geojson.gz differdiff --git a/server/assets/atlas/admin1/HN.geojson.gz b/server/assets/atlas/admin1/HN.geojson.gznew file mode 100644index 000000000..75839c452Binary files /dev/null and b/server/assets/atlas/admin1/HN.geojson.gz differdiff --git a/server/assets/atlas/admin1/HR.geojson.gz b/server/assets/atlas/admin1/HR.geojson.gznew file mode 100644index 000000000..c23685bc7Binary files /dev/null and b/server/assets/atlas/admin1/HR.geojson.gz differdiff --git a/server/assets/atlas/admin1/HT.geojson.gz b/server/assets/atlas/admin1/HT.geojson.gznew file mode 100644index 000000000..d182bbc95Binary files /dev/null and b/server/assets/atlas/admin1/HT.geojson.gz differdiff --git a/server/assets/atlas/admin1/HU.geojson.gz b/server/assets/atlas/admin1/HU.geojson.gznew file mode 100644index 000000000..32a7f0fc4Binary files /dev/null and b/server/assets/atlas/admin1/HU.geojson.gz differdiff --git a/server/assets/atlas/admin1/ID.geojson.gz b/server/assets/atlas/admin1/ID.geojson.gznew file mode 100644index 000000000..04cfe018eBinary files /dev/null and b/server/assets/atlas/admin1/ID.geojson.gz differdiff --git a/server/assets/atlas/admin1/IE.geojson.gz b/server/assets/atlas/admin1/IE.geojson.gznew file mode 100644index 000000000..966bc8936Binary files /dev/null and b/server/assets/atlas/admin1/IE.geojson.gz differdiff --git a/server/assets/atlas/admin1/IL.geojson.gz b/server/assets/atlas/admin1/IL.geojson.gznew file mode 100644index 000000000..3227ed63aBinary files /dev/null and b/server/assets/atlas/admin1/IL.geojson.gz differdiff --git a/server/assets/atlas/admin1/IN.geojson.gz b/server/assets/atlas/admin1/IN.geojson.gznew file mode 100644index 000000000..89eadac40Binary files /dev/null and b/server/assets/atlas/admin1/IN.geojson.gz differdiff --git a/server/assets/atlas/admin1/IQ.geojson.gz b/server/assets/atlas/admin1/IQ.geojson.gznew file mode 100644index 000000000..dceec057aBinary files /dev/null and b/server/assets/atlas/admin1/IQ.geojson.gz differdiff --git a/server/assets/atlas/admin1/IR.geojson.gz b/server/assets/atlas/admin1/IR.geojson.gznew file mode 100644index 000000000..0ce550bdcBinary files /dev/null and b/server/assets/atlas/admin1/IR.geojson.gz differdiff --git a/server/assets/atlas/admin1/IS.geojson.gz b/server/assets/atlas/admin1/IS.geojson.gznew file mode 100644index 000000000..8dcd647fbBinary files /dev/null and b/server/assets/atlas/admin1/IS.geojson.gz differdiff --git a/server/assets/atlas/admin1/IT.geojson.gz b/server/assets/atlas/admin1/IT.geojson.gznew file mode 100644index 000000000..18ce45512Binary files /dev/null and b/server/assets/atlas/admin1/IT.geojson.gz differdiff --git a/server/assets/atlas/admin1/JM.geojson.gz b/server/assets/atlas/admin1/JM.geojson.gznew file mode 100644index 000000000..1a8f291c1Binary files /dev/null and b/server/assets/atlas/admin1/JM.geojson.gz differdiff --git a/server/assets/atlas/admin1/JO.geojson.gz b/server/assets/atlas/admin1/JO.geojson.gznew file mode 100644index 000000000..6fac17f78Binary files /dev/null and b/server/assets/atlas/admin1/JO.geojson.gz differdiff --git a/server/assets/atlas/admin1/JP.geojson.gz b/server/assets/atlas/admin1/JP.geojson.gznew file mode 100644index 000000000..83a605f6cBinary files /dev/null and b/server/assets/atlas/admin1/JP.geojson.gz differdiff --git a/server/assets/atlas/admin1/KE.geojson.gz b/server/assets/atlas/admin1/KE.geojson.gznew file mode 100644index 000000000..1cefe2218Binary files /dev/null and b/server/assets/atlas/admin1/KE.geojson.gz differdiff --git a/server/assets/atlas/admin1/KG.geojson.gz b/server/assets/atlas/admin1/KG.geojson.gznew file mode 100644index 000000000..376fbee9fBinary files /dev/null and b/server/assets/atlas/admin1/KG.geojson.gz differdiff --git a/server/assets/atlas/admin1/KH.geojson.gz b/server/assets/atlas/admin1/KH.geojson.gznew file mode 100644index 000000000..7a980cb3bBinary files /dev/null and b/server/assets/atlas/admin1/KH.geojson.gz differdiff --git a/server/assets/atlas/admin1/KI.geojson.gz b/server/assets/atlas/admin1/KI.geojson.gznew file mode 100644index 000000000..c1d14dc5fBinary files /dev/null and b/server/assets/atlas/admin1/KI.geojson.gz differdiff --git a/server/assets/atlas/admin1/KM.geojson.gz b/server/assets/atlas/admin1/KM.geojson.gznew file mode 100644index 000000000..3c43ef225Binary files /dev/null and b/server/assets/atlas/admin1/KM.geojson.gz differdiff --git a/server/assets/atlas/admin1/KN.geojson.gz b/server/assets/atlas/admin1/KN.geojson.gznew file mode 100644index 000000000..d8ee5cd1bBinary files /dev/null and b/server/assets/atlas/admin1/KN.geojson.gz differdiff --git a/server/assets/atlas/admin1/KP.geojson.gz b/server/assets/atlas/admin1/KP.geojson.gznew file mode 100644index 000000000..59cba1189Binary files /dev/null and b/server/assets/atlas/admin1/KP.geojson.gz differdiff --git a/server/assets/atlas/admin1/KR.geojson.gz b/server/assets/atlas/admin1/KR.geojson.gznew file mode 100644index 000000000..7d395f35fBinary files /dev/null and b/server/assets/atlas/admin1/KR.geojson.gz differdiff --git a/server/assets/atlas/admin1/KW.geojson.gz b/server/assets/atlas/admin1/KW.geojson.gznew file mode 100644index 000000000..fdf66e88aBinary files /dev/null and b/server/assets/atlas/admin1/KW.geojson.gz differdiff --git a/server/assets/atlas/admin1/KZ.geojson.gz b/server/assets/atlas/admin1/KZ.geojson.gznew file mode 100644index 000000000..7a006db6fBinary files /dev/null and b/server/assets/atlas/admin1/KZ.geojson.gz differdiff --git a/server/assets/atlas/admin1/LA.geojson.gz b/server/assets/atlas/admin1/LA.geojson.gznew file mode 100644index 000000000..18e9283f3Binary files /dev/null and b/server/assets/atlas/admin1/LA.geojson.gz differdiff --git a/server/assets/atlas/admin1/LB.geojson.gz b/server/assets/atlas/admin1/LB.geojson.gznew file mode 100644index 000000000..ddadf6d2bBinary files /dev/null and b/server/assets/atlas/admin1/LB.geojson.gz differdiff --git a/server/assets/atlas/admin1/LC.geojson.gz b/server/assets/atlas/admin1/LC.geojson.gznew file mode 100644index 000000000..16c7049baBinary files /dev/null and b/server/assets/atlas/admin1/LC.geojson.gz differdiff --git a/server/assets/atlas/admin1/LI.geojson.gz b/server/assets/atlas/admin1/LI.geojson.gznew file mode 100644index 000000000..84b9da672Binary files /dev/null and b/server/assets/atlas/admin1/LI.geojson.gz differdiff --git a/server/assets/atlas/admin1/LK.geojson.gz b/server/assets/atlas/admin1/LK.geojson.gznew file mode 100644index 000000000..f6c800401Binary files /dev/null and b/server/assets/atlas/admin1/LK.geojson.gz differdiff --git a/server/assets/atlas/admin1/LR.geojson.gz b/server/assets/atlas/admin1/LR.geojson.gznew file mode 100644index 000000000..e67152cbfBinary files /dev/null and b/server/assets/atlas/admin1/LR.geojson.gz differdiff --git a/server/assets/atlas/admin1/LS.geojson.gz b/server/assets/atlas/admin1/LS.geojson.gznew file mode 100644index 000000000..eb1461d0dBinary files /dev/null and b/server/assets/atlas/admin1/LS.geojson.gz differdiff --git a/server/assets/atlas/admin1/LT.geojson.gz b/server/assets/atlas/admin1/LT.geojson.gznew file mode 100644index 000000000..051006101Binary files /dev/null and b/server/assets/atlas/admin1/LT.geojson.gz differdiff --git a/server/assets/atlas/admin1/LU.geojson.gz b/server/assets/atlas/admin1/LU.geojson.gznew file mode 100644index 000000000..4adb4f82cBinary files /dev/null and b/server/assets/atlas/admin1/LU.geojson.gz differdiff --git a/server/assets/atlas/admin1/LV.geojson.gz b/server/assets/atlas/admin1/LV.geojson.gznew file mode 100644index 000000000..6ec6af989Binary files /dev/null and b/server/assets/atlas/admin1/LV.geojson.gz differdiff --git a/server/assets/atlas/admin1/LY.geojson.gz b/server/assets/atlas/admin1/LY.geojson.gznew file mode 100644index 000000000..0b1f56864Binary files /dev/null and b/server/assets/atlas/admin1/LY.geojson.gz differdiff --git a/server/assets/atlas/admin1/MA.geojson.gz b/server/assets/atlas/admin1/MA.geojson.gznew file mode 100644index 000000000..ffcfc9dcdBinary files /dev/null and b/server/assets/atlas/admin1/MA.geojson.gz differdiff --git a/server/assets/atlas/admin1/MC.geojson.gz b/server/assets/atlas/admin1/MC.geojson.gznew file mode 100644index 000000000..fdbbbad71Binary files /dev/null and b/server/assets/atlas/admin1/MC.geojson.gz differdiff --git a/server/assets/atlas/admin1/MD.geojson.gz b/server/assets/atlas/admin1/MD.geojson.gznew file mode 100644index 000000000..3f1921167Binary files /dev/null and b/server/assets/atlas/admin1/MD.geojson.gz differdiff --git a/server/assets/atlas/admin1/ME.geojson.gz b/server/assets/atlas/admin1/ME.geojson.gznew file mode 100644index 000000000..63c9fcca5Binary files /dev/null and b/server/assets/atlas/admin1/ME.geojson.gz differdiff --git a/server/assets/atlas/admin1/MG.geojson.gz b/server/assets/atlas/admin1/MG.geojson.gznew file mode 100644index 000000000..9c50b35cbBinary files /dev/null and b/server/assets/atlas/admin1/MG.geojson.gz differdiff --git a/server/assets/atlas/admin1/MH.geojson.gz b/server/assets/atlas/admin1/MH.geojson.gznew file mode 100644index 000000000..3ad65d604Binary files /dev/null and b/server/assets/atlas/admin1/MH.geojson.gz differdiff --git a/server/assets/atlas/admin1/MK.geojson.gz b/server/assets/atlas/admin1/MK.geojson.gznew file mode 100644index 000000000..d7b817cdaBinary files /dev/null and b/server/assets/atlas/admin1/MK.geojson.gz differdiff --git a/server/assets/atlas/admin1/ML.geojson.gz b/server/assets/atlas/admin1/ML.geojson.gznew file mode 100644index 000000000..dcea97c19Binary files /dev/null and b/server/assets/atlas/admin1/ML.geojson.gz differdiff --git a/server/assets/atlas/admin1/MM.geojson.gz b/server/assets/atlas/admin1/MM.geojson.gznew file mode 100644index 000000000..e531b5494Binary files /dev/null and b/server/assets/atlas/admin1/MM.geojson.gz differdiff --git a/server/assets/atlas/admin1/MN.geojson.gz b/server/assets/atlas/admin1/MN.geojson.gznew file mode 100644index 000000000..55fe055b6Binary files /dev/null and b/server/assets/atlas/admin1/MN.geojson.gz differdiff --git a/server/assets/atlas/admin1/MR.geojson.gz b/server/assets/atlas/admin1/MR.geojson.gznew file mode 100644index 000000000..25a876239Binary files /dev/null and b/server/assets/atlas/admin1/MR.geojson.gz differdiff --git a/server/assets/atlas/admin1/MT.geojson.gz b/server/assets/atlas/admin1/MT.geojson.gznew file mode 100644index 000000000..1f37b56d0Binary files /dev/null and b/server/assets/atlas/admin1/MT.geojson.gz differdiff --git a/server/assets/atlas/admin1/MU.geojson.gz b/server/assets/atlas/admin1/MU.geojson.gznew file mode 100644index 000000000..8b665567aBinary files /dev/null and b/server/assets/atlas/admin1/MU.geojson.gz differdiff --git a/server/assets/atlas/admin1/MV.geojson.gz b/server/assets/atlas/admin1/MV.geojson.gznew file mode 100644index 000000000..09599e0a0Binary files /dev/null and b/server/assets/atlas/admin1/MV.geojson.gz differdiff --git a/server/assets/atlas/admin1/MW.geojson.gz b/server/assets/atlas/admin1/MW.geojson.gznew file mode 100644index 000000000..fd3a3eb45Binary files /dev/null and b/server/assets/atlas/admin1/MW.geojson.gz differdiff --git a/server/assets/atlas/admin1/MX.geojson.gz b/server/assets/atlas/admin1/MX.geojson.gznew file mode 100644index 000000000..89e6c57bdBinary files /dev/null and b/server/assets/atlas/admin1/MX.geojson.gz differdiff --git a/server/assets/atlas/admin1/MY.geojson.gz b/server/assets/atlas/admin1/MY.geojson.gznew file mode 100644index 000000000..097562f46Binary files /dev/null and b/server/assets/atlas/admin1/MY.geojson.gz differdiff --git a/server/assets/atlas/admin1/MZ.geojson.gz b/server/assets/atlas/admin1/MZ.geojson.gznew file mode 100644index 000000000..3326d7ce9Binary files /dev/null and b/server/assets/atlas/admin1/MZ.geojson.gz differdiff --git a/server/assets/atlas/admin1/NA.geojson.gz b/server/assets/atlas/admin1/NA.geojson.gznew file mode 100644index 000000000..7c9ebaa42Binary files /dev/null and b/server/assets/atlas/admin1/NA.geojson.gz differdiff --git a/server/assets/atlas/admin1/NE.geojson.gz b/server/assets/atlas/admin1/NE.geojson.gznew file mode 100644index 000000000..a612504baBinary files /dev/null and b/server/assets/atlas/admin1/NE.geojson.gz differdiff --git a/server/assets/atlas/admin1/NG.geojson.gz b/server/assets/atlas/admin1/NG.geojson.gznew file mode 100644index 000000000..2f3e8b8eaBinary files /dev/null and b/server/assets/atlas/admin1/NG.geojson.gz differdiff --git a/server/assets/atlas/admin1/NI.geojson.gz b/server/assets/atlas/admin1/NI.geojson.gznew file mode 100644index 000000000..1327550f7Binary files /dev/null and b/server/assets/atlas/admin1/NI.geojson.gz differdiff --git a/server/assets/atlas/admin1/NL.geojson.gz b/server/assets/atlas/admin1/NL.geojson.gznew file mode 100644index 000000000..7af0ced06Binary files /dev/null and b/server/assets/atlas/admin1/NL.geojson.gz differdiff --git a/server/assets/atlas/admin1/NO.geojson.gz b/server/assets/atlas/admin1/NO.geojson.gznew file mode 100644index 000000000..751e362adBinary files /dev/null and b/server/assets/atlas/admin1/NO.geojson.gz differdiff --git a/server/assets/atlas/admin1/NP.geojson.gz b/server/assets/atlas/admin1/NP.geojson.gznew file mode 100644index 000000000..fe1706a92Binary files /dev/null and b/server/assets/atlas/admin1/NP.geojson.gz differdiff --git a/server/assets/atlas/admin1/NR.geojson.gz b/server/assets/atlas/admin1/NR.geojson.gznew file mode 100644index 000000000..55baf15c2Binary files /dev/null and b/server/assets/atlas/admin1/NR.geojson.gz differdiff --git a/server/assets/atlas/admin1/NU.geojson.gz b/server/assets/atlas/admin1/NU.geojson.gznew file mode 100644index 000000000..825e2dc31Binary files /dev/null and b/server/assets/atlas/admin1/NU.geojson.gz differdiff --git a/server/assets/atlas/admin1/NZ.geojson.gz b/server/assets/atlas/admin1/NZ.geojson.gznew file mode 100644index 000000000..cb9b9970fBinary files /dev/null and b/server/assets/atlas/admin1/NZ.geojson.gz differdiff --git a/server/assets/atlas/admin1/OM.geojson.gz b/server/assets/atlas/admin1/OM.geojson.gznew file mode 100644index 000000000..4706f142cBinary files /dev/null and b/server/assets/atlas/admin1/OM.geojson.gz differdiff --git a/server/assets/atlas/admin1/PA.geojson.gz b/server/assets/atlas/admin1/PA.geojson.gznew file mode 100644index 000000000..23c7c16b6Binary files /dev/null and b/server/assets/atlas/admin1/PA.geojson.gz differdiff --git a/server/assets/atlas/admin1/PE.geojson.gz b/server/assets/atlas/admin1/PE.geojson.gznew file mode 100644index 000000000..029afd353Binary files /dev/null and b/server/assets/atlas/admin1/PE.geojson.gz differdiff --git a/server/assets/atlas/admin1/PG.geojson.gz b/server/assets/atlas/admin1/PG.geojson.gznew file mode 100644index 000000000..ed707a59cBinary files /dev/null and b/server/assets/atlas/admin1/PG.geojson.gz differdiff --git a/server/assets/atlas/admin1/PH.geojson.gz b/server/assets/atlas/admin1/PH.geojson.gznew file mode 100644index 000000000..aedcdbce7Binary files /dev/null and b/server/assets/atlas/admin1/PH.geojson.gz differdiff --git a/server/assets/atlas/admin1/PK.geojson.gz b/server/assets/atlas/admin1/PK.geojson.gznew file mode 100644index 000000000..e0a6fec3eBinary files /dev/null and b/server/assets/atlas/admin1/PK.geojson.gz differdiff --git a/server/assets/atlas/admin1/PL.geojson.gz b/server/assets/atlas/admin1/PL.geojson.gznew file mode 100644index 000000000..38e6b79e5Binary files /dev/null and b/server/assets/atlas/admin1/PL.geojson.gz differdiff --git a/server/assets/atlas/admin1/PS.geojson.gz b/server/assets/atlas/admin1/PS.geojson.gznew file mode 100644index 000000000..112a53afdBinary files /dev/null and b/server/assets/atlas/admin1/PS.geojson.gz differdiff --git a/server/assets/atlas/admin1/PT.geojson.gz b/server/assets/atlas/admin1/PT.geojson.gznew file mode 100644index 000000000..34dd65fe7Binary files /dev/null and b/server/assets/atlas/admin1/PT.geojson.gz differdiff --git a/server/assets/atlas/admin1/PW.geojson.gz b/server/assets/atlas/admin1/PW.geojson.gznew file mode 100644index 000000000..efb750ff5Binary files /dev/null and b/server/assets/atlas/admin1/PW.geojson.gz differdiff --git a/server/assets/atlas/admin1/PY.geojson.gz b/server/assets/atlas/admin1/PY.geojson.gznew file mode 100644index 000000000..2232b8fb5Binary files /dev/null and b/server/assets/atlas/admin1/PY.geojson.gz differdiff --git a/server/assets/atlas/admin1/QA.geojson.gz b/server/assets/atlas/admin1/QA.geojson.gznew file mode 100644index 000000000..d80a06aefBinary files /dev/null and b/server/assets/atlas/admin1/QA.geojson.gz differdiff --git a/server/assets/atlas/admin1/RO.geojson.gz b/server/assets/atlas/admin1/RO.geojson.gznew file mode 100644index 000000000..e5a208a95Binary files /dev/null and b/server/assets/atlas/admin1/RO.geojson.gz differdiff --git a/server/assets/atlas/admin1/RS.geojson.gz b/server/assets/atlas/admin1/RS.geojson.gznew file mode 100644index 000000000..b4c98dc85Binary files /dev/null and b/server/assets/atlas/admin1/RS.geojson.gz differdiff --git a/server/assets/atlas/admin1/RU.geojson.gz b/server/assets/atlas/admin1/RU.geojson.gznew file mode 100644index 000000000..ecbe45106Binary files /dev/null and b/server/assets/atlas/admin1/RU.geojson.gz differdiff --git a/server/assets/atlas/admin1/RW.geojson.gz b/server/assets/atlas/admin1/RW.geojson.gznew file mode 100644index 000000000..0716ed463Binary files /dev/null and b/server/assets/atlas/admin1/RW.geojson.gz differdiff --git a/server/assets/atlas/admin1/SA.geojson.gz b/server/assets/atlas/admin1/SA.geojson.gznew file mode 100644index 000000000..64cc84d62Binary files /dev/null and b/server/assets/atlas/admin1/SA.geojson.gz differdiff --git a/server/assets/atlas/admin1/SB.geojson.gz b/server/assets/atlas/admin1/SB.geojson.gznew file mode 100644index 000000000..3316b372cBinary files /dev/null and b/server/assets/atlas/admin1/SB.geojson.gz differdiff --git a/server/assets/atlas/admin1/SC.geojson.gz b/server/assets/atlas/admin1/SC.geojson.gznew file mode 100644index 000000000..e2ff5a6f5Binary files /dev/null and b/server/assets/atlas/admin1/SC.geojson.gz differdiff --git a/server/assets/atlas/admin1/SD.geojson.gz b/server/assets/atlas/admin1/SD.geojson.gznew file mode 100644index 000000000..339afd18bBinary files /dev/null and b/server/assets/atlas/admin1/SD.geojson.gz differdiff --git a/server/assets/atlas/admin1/SE.geojson.gz b/server/assets/atlas/admin1/SE.geojson.gznew file mode 100644index 000000000..8220faee2Binary files /dev/null and b/server/assets/atlas/admin1/SE.geojson.gz differdiff --git a/server/assets/atlas/admin1/SG.geojson.gz b/server/assets/atlas/admin1/SG.geojson.gznew file mode 100644index 000000000..2a9958400Binary files /dev/null and b/server/assets/atlas/admin1/SG.geojson.gz differdiff --git a/server/assets/atlas/admin1/SI.geojson.gz b/server/assets/atlas/admin1/SI.geojson.gznew file mode 100644index 000000000..e59939258Binary files /dev/null and b/server/assets/atlas/admin1/SI.geojson.gz differdiff --git a/server/assets/atlas/admin1/SK.geojson.gz b/server/assets/atlas/admin1/SK.geojson.gznew file mode 100644index 000000000..690c6d36aBinary files /dev/null and b/server/assets/atlas/admin1/SK.geojson.gz differdiff --git a/server/assets/atlas/admin1/SL.geojson.gz b/server/assets/atlas/admin1/SL.geojson.gznew file mode 100644index 000000000..14f903421Binary files /dev/null and b/server/assets/atlas/admin1/SL.geojson.gz differdiff --git a/server/assets/atlas/admin1/SM.geojson.gz b/server/assets/atlas/admin1/SM.geojson.gznew file mode 100644index 000000000..37e4e13a7Binary files /dev/null and b/server/assets/atlas/admin1/SM.geojson.gz differdiff --git a/server/assets/atlas/admin1/SN.geojson.gz b/server/assets/atlas/admin1/SN.geojson.gznew file mode 100644index 000000000..81468cd8aBinary files /dev/null and b/server/assets/atlas/admin1/SN.geojson.gz differdiff --git a/server/assets/atlas/admin1/SO.geojson.gz b/server/assets/atlas/admin1/SO.geojson.gznew file mode 100644index 000000000..3b5c88505Binary files /dev/null and b/server/assets/atlas/admin1/SO.geojson.gz differdiff --git a/server/assets/atlas/admin1/SR.geojson.gz b/server/assets/atlas/admin1/SR.geojson.gznew file mode 100644index 000000000..a11863f36Binary files /dev/null and b/server/assets/atlas/admin1/SR.geojson.gz differdiff --git a/server/assets/atlas/admin1/SS.geojson.gz b/server/assets/atlas/admin1/SS.geojson.gznew file mode 100644index 000000000..b6b890a09Binary files /dev/null and b/server/assets/atlas/admin1/SS.geojson.gz differdiff --git a/server/assets/atlas/admin1/ST.geojson.gz b/server/assets/atlas/admin1/ST.geojson.gznew file mode 100644index 000000000..2ef741ec5Binary files /dev/null and b/server/assets/atlas/admin1/ST.geojson.gz differdiff --git a/server/assets/atlas/admin1/SV.geojson.gz b/server/assets/atlas/admin1/SV.geojson.gznew file mode 100644index 000000000..d43ebc335Binary files /dev/null and b/server/assets/atlas/admin1/SV.geojson.gz differdiff --git a/server/assets/atlas/admin1/SY.geojson.gz b/server/assets/atlas/admin1/SY.geojson.gznew file mode 100644index 000000000..85fe93698Binary files /dev/null and b/server/assets/atlas/admin1/SY.geojson.gz differdiff --git a/server/assets/atlas/admin1/SZ.geojson.gz b/server/assets/atlas/admin1/SZ.geojson.gznew file mode 100644index 000000000..a3cdf350eBinary files /dev/null and b/server/assets/atlas/admin1/SZ.geojson.gz differdiff --git a/server/assets/atlas/admin1/TD.geojson.gz b/server/assets/atlas/admin1/TD.geojson.gznew file mode 100644index 000000000..ed10616a0Binary files /dev/null and b/server/assets/atlas/admin1/TD.geojson.gz differdiff --git a/server/assets/atlas/admin1/TG.geojson.gz b/server/assets/atlas/admin1/TG.geojson.gznew file mode 100644index 000000000..b41f08a17Binary files /dev/null and b/server/assets/atlas/admin1/TG.geojson.gz differdiff --git a/server/assets/atlas/admin1/TH.geojson.gz b/server/assets/atlas/admin1/TH.geojson.gznew file mode 100644index 000000000..76246da05Binary files /dev/null and b/server/assets/atlas/admin1/TH.geojson.gz differdiff --git a/server/assets/atlas/admin1/TJ.geojson.gz b/server/assets/atlas/admin1/TJ.geojson.gznew file mode 100644index 000000000..520bee6edBinary files /dev/null and b/server/assets/atlas/admin1/TJ.geojson.gz differdiff --git a/server/assets/atlas/admin1/TL.geojson.gz b/server/assets/atlas/admin1/TL.geojson.gznew file mode 100644index 000000000..8da4a8f20Binary files /dev/null and b/server/assets/atlas/admin1/TL.geojson.gz differdiff --git a/server/assets/atlas/admin1/TM.geojson.gz b/server/assets/atlas/admin1/TM.geojson.gznew file mode 100644index 000000000..501954b19Binary files /dev/null and b/server/assets/atlas/admin1/TM.geojson.gz differdiff --git a/server/assets/atlas/admin1/TN.geojson.gz b/server/assets/atlas/admin1/TN.geojson.gznew file mode 100644index 000000000..f1503c2e4Binary files /dev/null and b/server/assets/atlas/admin1/TN.geojson.gz differdiff --git a/server/assets/atlas/admin1/TO.geojson.gz b/server/assets/atlas/admin1/TO.geojson.gznew file mode 100644index 000000000..563cf7007Binary files /dev/null and b/server/assets/atlas/admin1/TO.geojson.gz differdiff --git a/server/assets/atlas/admin1/TR.geojson.gz b/server/assets/atlas/admin1/TR.geojson.gznew file mode 100644index 000000000..97f91dff6Binary files /dev/null and b/server/assets/atlas/admin1/TR.geojson.gz differdiff --git a/server/assets/atlas/admin1/TT.geojson.gz b/server/assets/atlas/admin1/TT.geojson.gznew file mode 100644index 000000000..22322ec61Binary files /dev/null and b/server/assets/atlas/admin1/TT.geojson.gz differdiff --git a/server/assets/atlas/admin1/TV.geojson.gz b/server/assets/atlas/admin1/TV.geojson.gznew file mode 100644index 000000000..c9c9460e2Binary files /dev/null and b/server/assets/atlas/admin1/TV.geojson.gz differdiff --git a/server/assets/atlas/admin1/TW.geojson.gz b/server/assets/atlas/admin1/TW.geojson.gznew file mode 100644index 000000000..896ac13c7Binary files /dev/null and b/server/assets/atlas/admin1/TW.geojson.gz differdiff --git a/server/assets/atlas/admin1/TZ.geojson.gz b/server/assets/atlas/admin1/TZ.geojson.gznew file mode 100644index 000000000..e420d64f5Binary files /dev/null and b/server/assets/atlas/admin1/TZ.geojson.gz differdiff --git a/server/assets/atlas/admin1/UA.geojson.gz b/server/assets/atlas/admin1/UA.geojson.gznew file mode 100644index 000000000..fe4239014Binary files /dev/null and b/server/assets/atlas/admin1/UA.geojson.gz differdiff --git a/server/assets/atlas/admin1/UG.geojson.gz b/server/assets/atlas/admin1/UG.geojson.gznew file mode 100644index 000000000..397261685Binary files /dev/null and b/server/assets/atlas/admin1/UG.geojson.gz differdiff --git a/server/assets/atlas/admin1/US.geojson.gz b/server/assets/atlas/admin1/US.geojson.gznew file mode 100644index 000000000..3c28be666Binary files /dev/null and b/server/assets/atlas/admin1/US.geojson.gz differdiff --git a/server/assets/atlas/admin1/UY.geojson.gz b/server/assets/atlas/admin1/UY.geojson.gznew file mode 100644index 000000000..d536db239Binary files /dev/null and b/server/assets/atlas/admin1/UY.geojson.gz differdiff --git a/server/assets/atlas/admin1/UZ.geojson.gz b/server/assets/atlas/admin1/UZ.geojson.gznew file mode 100644index 000000000..1e955afacBinary files /dev/null and b/server/assets/atlas/admin1/UZ.geojson.gz differdiff --git a/server/assets/atlas/admin1/VC.geojson.gz b/server/assets/atlas/admin1/VC.geojson.gznew file mode 100644index 000000000..5a33b66f0Binary files /dev/null and b/server/assets/atlas/admin1/VC.geojson.gz differdiff --git a/server/assets/atlas/admin1/VE.geojson.gz b/server/assets/atlas/admin1/VE.geojson.gznew file mode 100644index 000000000..53c8b6be9Binary files /dev/null and b/server/assets/atlas/admin1/VE.geojson.gz differdiff --git a/server/assets/atlas/admin1/VN.geojson.gz b/server/assets/atlas/admin1/VN.geojson.gznew file mode 100644index 000000000..9c68abe89Binary files /dev/null and b/server/assets/atlas/admin1/VN.geojson.gz differdiff --git a/server/assets/atlas/admin1/VU.geojson.gz b/server/assets/atlas/admin1/VU.geojson.gznew file mode 100644index 000000000..cdae4914aBinary files /dev/null and b/server/assets/atlas/admin1/VU.geojson.gz differdiff --git a/server/assets/atlas/admin1/WS.geojson.gz b/server/assets/atlas/admin1/WS.geojson.gznew file mode 100644index 000000000..da17e0704Binary files /dev/null and b/server/assets/atlas/admin1/WS.geojson.gz differdiff --git a/server/assets/atlas/admin1/XK.geojson.gz b/server/assets/atlas/admin1/XK.geojson.gznew file mode 100644index 000000000..c862b894dBinary files /dev/null and b/server/assets/atlas/admin1/XK.geojson.gz differdiff --git a/server/assets/atlas/admin1/YE.geojson.gz b/server/assets/atlas/admin1/YE.geojson.gznew file mode 100644index 000000000..386c2d8f1Binary files /dev/null and b/server/assets/atlas/admin1/YE.geojson.gz differdiff --git a/server/assets/atlas/admin1/ZA.geojson.gz b/server/assets/atlas/admin1/ZA.geojson.gznew file mode 100644index 000000000..434ce3237Binary files /dev/null and b/server/assets/atlas/admin1/ZA.geojson.gz differdiff --git a/server/assets/atlas/admin1/ZM.geojson.gz b/server/assets/atlas/admin1/ZM.geojson.gznew file mode 100644index 000000000..b4fd66e5dBinary files /dev/null and b/server/assets/atlas/admin1/ZM.geojson.gz differdiff --git a/server/assets/atlas/admin1/ZW.geojson.gz b/server/assets/atlas/admin1/ZW.geojson.gznew file mode 100644index 000000000..81719c19fBinary files /dev/null and b/server/assets/atlas/admin1/ZW.geojson.gz differdiff --git a/server/scripts/build-atlas-geo.mjs b/server/scripts/build-atlas-geo.mjsindex ff856d309..9560c27a7 100644--- a/server/scripts/build-atlas-geo.mjs+++ b/server/scripts/build-atlas-geo.mjs@@ -1,5 +1,6 @@#!/usr/bin/env node-// Build server/assets/atlas/{admin0,admin1}.geojson.gz from geoBoundaries (gbOpen).+// Build server/assets/atlas/{admin0,admin1}.geojson.gz and server/assets/atlas/admin1/<ISO_A2>.geojson.gz+// from geoBoundaries (gbOpen).//// Why: Atlas previously fetched country + sub-national boundaries from Natural Earth's// GitHub `master` at runtime. Natural Earth is stale (e.g. it still shows Norway's@@ -9,8 +10,9 @@//// This downloads the *simplified* per-country gbOpen ADM0 (countries) and ADM1// (regions) layers from a pinned geoBoundaries revision, normalizes each feature to-// the property names the Atlas client/server already read, and writes two gzipped-// FeatureCollections that the server serves at runtime (no network at boot).+// the property names the Atlas client/server already read, and writes gzipped+// FeatureCollections that the server serves at runtime (no network at boot): one for+// every country's borders, and one per country for its regions.//// geoBoundaries: CC BY 4.0 — https://www.geoboundaries.org/ (attribution required).import fs from 'node:fs';@@ -461,7 +463,7 @@ function normalizeAdm1(geo, a3, countryName) {}return {type: 'Feature',- // Property names the Atlas region layer + server getRegionGeo already read.+ // Property names the Atlas region layer + server region lookup already read.properties: {iso_a2: a2,iso_3166_2: code,@@ -516,8 +518,25 @@ async function main() {};write('admin0', adm0Features);+ // Read only by two shipped migrations (Migration20200101021500/…031500), whose bodies+ // never change; the server itself reads the per-country files below.write('admin1', adm1Features);+ // admin1 also goes out as one file per country, named by ISO_A2, so the server can hand+ // a country's regions to the map straight from disk and read only the country it needs+ // for a lookup — the single bundle had to be held whole in memory to do either. A+ // feature with no alpha-2 code has no file to go in, and nothing could look it up.+ const byCountry = new Map();+ for (const f of adm1Features) {+ const a2 = f.properties.iso_a2;+ if (!a2) continue;+ if (!byCountry.has(a2)) byCountry.set(a2, []);+ byCountry.get(a2).push(f);+ }+ fs.rmSync(path.join(OUT_DIR, 'admin1'), { recursive: true, force: true });+ fs.mkdirSync(path.join(OUT_DIR, 'admin1'));+ for (const [a2, features] of byCountry) write(`admin1/${a2}`, features);+const missing1 = COUNTRIES.filter((a3, i) => !normalizeAdm1(adm1Raw[i], a3, '').length);console.log(`[atlas-geo] ADM0 country features: ${adm0Features.length}`);console.log(`[atlas-geo] ADM1 countries without regions (skipped/404): ${missing1.length}`);diff --git a/server/scripts/eslint-baseline.json b/server/scripts/eslint-baseline.jsonindex 51de21574..efa01fcb2 100644--- a/server/scripts/eslint-baseline.json+++ b/server/scripts/eslint-baseline.json@@ -6,7 +6,7 @@"@typescript-eslint/no-unsafe-function-type": 1,"@typescript-eslint/no-unused-vars": 36,"no-await-in-loop": 562,- "no-console": 235,+ "no-console": 234,"no-empty": 6},"suppressed": {@@ -16,7 +16,7 @@"no-misleading-character-class": 1},"tests": {- "@typescript-eslint/no-explicit-any": 1562,+ "@typescript-eslint/no-explicit-any": 1559,"@typescript-eslint/no-non-null-assertion": 1755,"@typescript-eslint/no-require-imports": 25,"@typescript-eslint/no-unsafe-function-type": 7,diff --git a/server/scripts/size-baseline.json b/server/scripts/size-baseline.jsonindex d36978050..5462aae78 100644--- a/server/scripts/size-baseline.json+++ b/server/scripts/size-baseline.json@@ -5,7 +5,7 @@"src/db/repositories/Reservations.repository.ts": 1604,"src/db/repositories/Trips.repository.ts": 1121,"src/db/repositories/Users.repository.ts": 1445,- "src/nest/atlas/atlas.service.ts": 1182,+ "src/nest/atlas/atlas.service.ts": 1177,"src/nest/auth/auth.service.ts": 1143,"src/nest/budget/budget.service.ts": 1617,"src/nest/collections/collections.service.ts": 1478,diff --git a/server/scripts/test-size-baseline.json b/server/scripts/test-size-baseline.jsonindex b30382988..a461eb9e1 100644--- a/server/scripts/test-size-baseline.json+++ b/server/scripts/test-size-baseline.json@@ -1,5 +1,5 @@{- "tests/unit/nest/atlas.service.test.ts": 2193,+ "tests/unit/nest/atlas.service.test.ts": 2154,"tests/unit/nest/budget.service.db.test.ts": 2220,"tests/unit/nest/doc-sync/doc-sync.service.test.ts": 2511,"tests/unit/nest/journey-domain.service.test.ts": 3876,diff --git a/server/src/nest/atlas/atlas-geo.ts b/server/src/nest/atlas/atlas-geo.tsindex 7653fa506..ee84f9f6d 100644--- a/server/src/nest/atlas/atlas-geo.ts+++ b/server/src/nest/atlas/atlas-geo.ts@@ -1,10 +1,10 @@import { Place } from '../../types';import fs from 'fs';+import path from 'path';import zlib from 'zlib';import {- assetPath,- createFeatureSplitter,+ admin1AssetPath,getCountryFromCoords,isPointInCountryBox,loadAdmin0Gz,@@ -17,7 +17,7 @@ import { cacheKeyFor, getCached, nominatimFetch, setCached } from '../geo/nomina// ── Pure geo machinery for the atlas domain ─────────────────────────────────//// Plain module on purpose (same class as maps.helpers.ts / tripAccess): no DI,-// no DB access, no Nest imports. The caches below (admin1 per-country store,+// no DB access, no Nest imports. The caches below (parsed admin1 region features,// geocode/region caches, the shared Nominatim throttle and the geocodingInFlight// dedup set) are file-scoped so their lifetime stays process-global no matter how// many AtlasService instances exist (container singleton + test helpers) —@@ -37,10 +37,10 @@ export { getCountryFromCoords, isPointInCountryBox };//// Neither parsed bundle is cached. admin0 (~145MB) and admin1 (~260MB) parsed at once are// what exhausted a 512MB host while using Atlas (#1576). Instead we retain only compact-// derivatives: the raw admin0 .gz bytes for direct serving, a Float64Array poly/box index-// for server-side point-in-polygon (see buildCountryIndexes in utils/country-borders.ts),-// and admin1 pre-split per country into ready-to-serve GeoJSON strings, built by-// streaming the gz so the full bundle is never materialised in one piece.+// derivatives: the raw admin0 .gz bytes for direct serving and a Float64Array poly/box+// index for server-side point-in-polygon (see buildCountryIndexes in+// utils/country-borders.ts). admin1 ships as one gzipped file per country, which is+// served from disk as it is and read one country at a time for region lookups./** admin-0 country borders as gzipped GeoJSON bytes, served to the client map with* Content-Encoding: gzip so the server never holds the parsed FeatureCollection. */@@ -57,75 +57,68 @@ export function getCountryGeo(): any {return JSON.parse(zlib.gunzipSync(gz).toString('utf8'));}-export async function getRegionGeo(countryCodes: string[]): Promise<any> {- const store = await getAdmin1Store();- const seen = new Set<string>();- const parts: string[] = [];- for (const code of countryCodes) {- const c = code.toUpperCase();- if (seen.has(c)) continue;- seen.add(c);- const s = store.get(c);- if (s) parts.push(s);+// A country's admin-1 file, or null for anything that is not a two-letter code, so+// nothing a client sends can name a path outside the folder. A country without a file+// has no regions; the whole folder missing is a broken install, said once.+let admin1Checked = false;+function admin1File(countryCode: string): string | null {+ const cc = countryCode.toUpperCase();+ if (!/^[A-Z]{2}$/.test(cc)) return null;+ const file = admin1AssetPath(cc);+ if (!admin1Checked) {+ admin1Checked = true;+ if (!fs.existsSync(path.dirname(file))) {+ console.warn(`[Atlas] admin1 region files missing — run \`node scripts/build-atlas-geo.mjs\``);+ }}- if (parts.length === 0) return { type: 'FeatureCollection', features: [] };- // Each stored value is that country's features as comma-joined GeoJSON text; wrap the- // requested subset into one FeatureCollection and parse only that (per-viewport, small).- return JSON.parse(`{"type":"FeatureCollection","features":[${parts.join(',')}]}`);+ return file;}-// admin1 regions, pre-split per ISO_A2 into comma-joined feature text. Built once by-// streaming the gz through a brace-depth splitter that emits one Feature at a time, so the-// ~260MB full parse never happens (it OOMs a 512MB host). Concurrent first-callers share-// one in-flight build via admin1Building.-let admin1Store: Map<string, string> | null = null;-let admin1Building: Promise<Map<string, string>> | null = null;--function getAdmin1Store(): Promise<Map<string, string>> {- if (admin1Store) return Promise.resolve(admin1Store);- // `=== null`, not `!admin1Building`: a Promise in a boolean condition is what- // no-misused-promises/checksConditionals exists to catch, and the distinction- // matters once every DB-touching method returns one.- if (admin1Building === null) {- admin1Building = buildAdmin1Store().then((s) => {- admin1Store = s;- admin1Building = null;- return s;- });+// A country's admin-1 FeatureCollection as JSON bytes, or null when the bundle has no+// regions for it. Synchronous like the parse that follows it; one country is a small file.+function readAdmin1Json(countryCode: string): Buffer | null {+ const file = admin1File(countryCode);+ if (!file) return null;+ try {+ return zlib.gunzipSync(fs.readFileSync(file));+ } catch {+ return null;}- return admin1Building;}-function buildAdmin1Store(): Promise<Map<string, string>> {- const file = assetPath('admin1');- if (!fs.existsSync(file)) {- console.warn(`[Atlas] admin1.geojson.gz missing — run \`node scripts/build-atlas-geo.mjs\``);- return Promise.resolve(new Map());+/** One country's admin-1 regions as gzipped GeoJSON bytes, served to the client map with+ * Content-Encoding: gzip like getCountryGeoGz, so the server never parses them. */+export async function getRegionGeoGz(countryCode: string): Promise<Buffer | null> {+ const file = admin1File(countryCode);+ if (!file) return null;+ try {+ return await fs.promises.readFile(file);+ } catch {+ return null;+ }+}++// How build-atlas-geo.mjs writes every per-country file; atlasBundle.test.ts holds it to that.+const FC_HEAD = '{"type":"FeatureCollection","features":[';+const FC_TAIL = ']}';++/**+ * Several countries' regions as one FeatureCollection, for clients that still ask+ * /regions/geo?countries=… from before the map fetched one country per request. Each+ * file's features are cut out and joined as bytes, never parsed (#1576).+ */+export function getRegionGeoJson(countryCodes: string[]): Buffer {+ const parts: Buffer[] = [Buffer.from(FC_HEAD)];+ let first = true;+ for (const cc of new Set(countryCodes.map((c) => c.toUpperCase()))) {+ const json = readAdmin1Json(cc);+ if (!json) continue;+ if (!first) parts.push(Buffer.from(','));+ parts.push(json.subarray(FC_HEAD.length, json.length - FC_TAIL.length));+ first = false;}- // Concatenate each country's features straight into the store as we stream, rather than- // collecting arrays and joining at the end (that doubling, plus the source bundle's- // whitespace, peaked high enough to OOM a 512MB host on the first build). Re-serialising- // each feature via JSON drops the source formatting (~114MB → ~68MB retained) and the- // parse/stringify garbage is per-feature and short-lived.- const store = new Map<string, string>();- const split = createFeatureSplitter((text) => {- const f = JSON.parse(text);- const code = f.properties?.iso_a2?.toUpperCase();- if (!code) return; // features with a null iso_a2 are skipped, matching the old filter- const compact = JSON.stringify(f);- const prev = store.get(code);- store.set(code, prev ? prev + ',' + compact : compact);- });- return new Promise((resolve, reject) => {- fs.createReadStream(file)- .pipe(zlib.createGunzip())- .on('data', (chunk: Buffer) => split(chunk.toString('utf8')))- .on('end', () => {- console.log(`[Atlas] Indexed admin1 GeoJSON: ${store.size} countries`);- resolve(store);- })- .on('error', reject);- });+ parts.push(Buffer.from(FC_TAIL));+ return Buffer.concat(parts);}// ── Country names, for the address fallback ─────────────────────────────────@@ -524,9 +517,9 @@ const regionCache = new Map<string, RegionInfo | null>();// getCountryFromCoords does for admin0 (#1331) — sidesteps the whole class of bug: the// stored region_code/region_name are then guaranteed to equal a bundle feature.//-// The admin1 bundle is streamed and held as per-country GeoJSON text (never parsed whole,-// #1576), so a country's region features are parsed and flattened to CompactGeom on first-// use and cached — only visited countries ever pay the parse.+// The admin1 regions ship as one file per country (never parsed whole, #1576), so a+// country's region features are read, parsed and flattened to CompactGeom on first use+// and cached — only visited countries ever pay the parse.type RegionFeature = { code: string; name: string; nameEn: string; geom: CompactGeom; boxes: Box[] };const regionFeatureCache = new Map<string, RegionFeature[]>();@@ -534,15 +527,14 @@ async function getRegionFeatures(countryCode: string): Promise<RegionFeature[]>const cc = countryCode.toUpperCase();const cached = regionFeatureCache.get(cc);if (cached) return cached;- const store = await getAdmin1Store();- const text = store.get(cc);- if (!text) {+ const json = readAdmin1Json(cc);+ if (!json) {regionFeatureCache.set(cc, []);return [];}let features: { properties?: Record<string, string>; geometry?: { type: string; coordinates: unknown } }[];try {- features = JSON.parse(`{"type":"FeatureCollection","features":[${text}]}`).features ?? [];+ features = JSON.parse(json.toString('utf8')).features ?? [];} catch {regionFeatureCache.set(cc, []);return [];diff --git a/server/src/nest/atlas/atlas.controller.ts b/server/src/nest/atlas/atlas.controller.tsindex 45e04cf36..84767242d 100644--- a/server/src/nest/atlas/atlas.controller.ts+++ b/server/src/nest/atlas/atlas.controller.ts@@ -1,6 +1,8 @@import type { User } from '../../types';import { CurrentUser } from '../auth-core/current-user.decorator';import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';+import { ZodValidationPipe } from '../common/zod-validation.pipe';+import { getRegionGeoGz, getRegionGeoJson } from './atlas-geo';import { AtlasWritesService } from './atlas-writes.service';import { AtlasMarkRegionDto, AtlasCreateBucketItemDto, AtlasUpdateBucketItemDto } from './atlas.dto';import { AtlasService, BucketItemExistsError } from './atlas.service';@@ -20,7 +22,8 @@ import {Res,UseGuards,} from '@nestjs/common';-import type { AtlasLocateResponse, RegionGeo } from '@trek/shared';+import { regionGeoParamsSchema } from '@trek/shared';+import type { AtlasLocateResponse, RegionGeoParams } from '@trek/shared';import type { Response } from 'express';@@ -78,20 +81,42 @@ export class AtlasController {return this.atlas.locate(latNum, lngNum);}+ // Kept for clients from before the map asked for one country at a time (below). They+ // get the same FeatureCollection as before, joined from the per-country files without+ // a parse; drop it once those clients are gone.@Get('regions/geo')- async regionGeo(- @Query('countries') countries: string | undefined,- @Res({ passthrough: true }) res: Response,- ): Promise<RegionGeo> {+ regionGeo(@Query('countries') countries: string | undefined, @Res() res: Response): void {const list = (countries || '').split(',').filter(Boolean);if (list.length === 0) {- return { type: 'FeatureCollection', features: [] };+ res.json({ type: 'FeatureCollection', features: [] });+ return;}- const geo = await this.atlas.regionGeo(list);+ const json = getRegionGeoJson(list);// Cache only a non-empty result, matching the legacy route (the empty// short-circuit above sends no Cache-Control header).res.setHeader('Cache-Control', 'public, max-age=86400');- return geo;+ res.type('application/json').send(json);+ }++ // response-contract-exempt: sends a gzipped file through @Res() as it is, there is no JSON body to check.+ @Get('regions/geo/:code')+ async regionGeoForCountry(+ @Param(new ZodValidationPipe(regionGeoParamsSchema)) params: RegionGeoParams,+ @Res() res: Response,+ ): Promise<void> {+ // One country's pre-gzipped admin-1 file, served the way countries/geo is: the server+ // never parses or holds it (#1576), and the browser caches every country on its own. A+ // country the bundle has no regions for gets an empty FeatureCollection, cached the+ // same, so it is not asked again; a code that is not two letters is a 400.+ const gz = await getRegionGeoGz(params.code);+ res.setHeader('Cache-Control', 'public, max-age=86400');+ if (!gz) {+ res.json({ type: 'FeatureCollection', features: [] });+ return;+ }+ res.setHeader('Content-Type', 'application/json; charset=utf-8');+ res.setHeader('Content-Encoding', 'gzip');+ res.send(gz);}@Get('countries/geo')diff --git a/server/src/nest/atlas/atlas.service.ts b/server/src/nest/atlas/atlas.service.tsindex 47ee26905..00a0aac7b 100644--- a/server/src/nest/atlas/atlas.service.ts+++ b/server/src/nest/atlas/atlas.service.ts@@ -28,7 +28,6 @@ import {getCountryFromCoords,getCountryGeoGz,getRegionFromCoords,- getRegionGeo,geocodingInFlight,resolveCountryCodeSync,resolveRegionFromBundle,@@ -877,10 +876,6 @@ export class AtlasService {};}- regionGeo(countries: string[]) {- return getRegionGeo(countries);- }-countryGeoGz(): Buffer | null {return getCountryGeoGz();}diff --git a/server/src/utils/country-borders.ts b/server/src/utils/country-borders.tsindex b184130b1..8fb5b738f 100644--- a/server/src/utils/country-borders.ts+++ b/server/src/utils/country-borders.ts@@ -11,8 +11,8 @@ import zlib from 'zlib';// for the country an index suggestion names. Importing it from atlas tied maps into// an import cycle with atlas (lint:boundaries).//-// atlas-geo builds its admin-1 region index on the asset path, the feature splitter-// and the ring test exported here. The admin0 gz bytes and the country poly/box+// atlas-geo resolves admin-1 regions with the per-country asset path and the ring test+// exported here. The admin0 gz bytes and the country poly/box// indexes below are file-scoped for the reason atlas-geo gives: their lifetime stays// process-global however many callers there are, so the indexes are built once per// process, which the #1576 OOM fix depends on.@@ -20,18 +20,24 @@ import zlib from 'zlib';// ── Bundled boundary GeoJSON (admin-0 countries + admin-1 regions) ─────────//// Sourced from geoBoundaries (CC BY 4.0), normalized + quantized offline by-// scripts/build-atlas-geo.mjs into gzipped FeatureCollections under server/assets.-// They are read + decompressed once and cached in memory — no network at runtime.+// scripts/build-atlas-geo.mjs into gzipped FeatureCollections under server/assets:+// admin0 as one file, admin1 as one file per country (the whole admin1 bundle ships+// too, for two migrations that read it). No network at runtime.// (Replaces the previous runtime fetch of Natural Earth, which was stale for recent// sub-national reforms and depicts some contested borders in unwanted ways.)//// __dirname is server/dist/utils at runtime and server/src/utils under vitest;// both resolve ../../assets to server/assets.-export function assetPath(name: 'admin0' | 'admin1'): string {+function assetPath(name: 'admin0'): string {return path.join(__dirname, '..', '..', 'assets', 'atlas', `${name}.geojson.gz`);}+/** One country's admin-1 regions, a FeatureCollection of its own, named by ISO_A2. */+export function admin1AssetPath(countryCode: string): string {+ return path.join(__dirname, '..', '..', 'assets', 'atlas', 'admin1', `${countryCode}.geojson.gz`);+}+let admin0Gz: Buffer | null | undefined;export function loadAdmin0Gz(): Buffer | null {if (admin0Gz !== undefined) return admin0Gz;@@ -46,13 +52,14 @@ export function loadAdmin0Gz(): Buffer | null {// Feed arbitrary gunzip chunks; invokes onFeature(text) once per top-level Feature object// inside "features":[ … ]. `pending` holds only the unconsumed tail (at most one partial// feature + the current chunk), keeping memory flat regardless of bundle size.-export function createFeatureSplitter(onFeature: (text: string) => void): (chunk: string) => void {+function createFeatureSplitter(onFeature: (text: string) => void): (chunk: string) => void {let pending = '';let started = false;// Scan progress is carried across chunks so each character is examined exactly once.// A large Feature (e.g. Canada, ~5.5MB) spans hundreds of gunzip chunks; re-scanning the// accumulated partial from the start on every chunk was O(n²) per feature and pushed the- // one-time admin1 build past the 15s test timeout under coverage/CI (#1576-followup).+ // one-time admin1 build (since replaced by per-country files) past the 15s test timeout+ // under coverage/CI (#1576-followup).let scanning = false; // currently inside a Feature object?let depth = 0,inStr = false,diff --git a/server/tests/integration/atlas.test.ts b/server/tests/integration/atlas.test.tsindex fe63d47a9..f70050545 100644--- a/server/tests/integration/atlas.test.ts+++ b/server/tests/integration/atlas.test.ts@@ -5,7 +5,6 @@import { buildApp } from '../../src/bootstrap';import { db as testDb } from '../../src/db/database';import { PlaceRegions } from '../../src/db/entities/PlaceRegions.entity';-import { getRegionGeo } from '../../src/nest/atlas/atlas-geo';import { authCookie } from '../helpers/auth';import { createUser, createTrip } from '../helpers/factories';import type { FactoryOrm } from '../helpers/factories/context';@@ -53,12 +52,6 @@ beforeAll(async () => {nestApp = await buildApp();app = nestApp.getHttpAdapter().getInstance();-- // Warm the admin-1 store here rather than inside ATLAS-013. The first call streams- // the multi-MB bundle through the brace-depth splitter and caches it for the process,- // which costs ~3s on a quiet machine and more when every worker is busy — so whichever- // test hit it first used to pay for it inside its own 5s budget and fail under load.- await getRegionGeo(['ZZ']);}, 60_000);beforeEach(async () => {@@ -497,6 +490,49 @@ describe('Regions geo', () => {expect(res.status).toBe(200);expect(res.body).toHaveProperty('type', 'FeatureCollection');+ expect(+ new Set((res.body.features as { properties: { iso_a2: string } }[]).map((f) => f.properties.iso_a2)),+ ).toEqual(new Set(['DE', 'FR']));+ });++ it('ATLAS-016 — GET /regions/geo/:code serves that country gzipped, cached for a day', async () => {+ const { user } = createUser(testDb);++ const res = await request(app)+ .get('/api/addons/atlas/regions/geo/no')+ .set('Accept-Encoding', 'gzip')+ .set('Cookie', authCookie(user.id));++ expect(res.status).toBe(200);+ expect(res.headers['content-encoding']).toBe('gzip');+ expect(res.headers['cache-control']).toBe('public, max-age=86400');+ expect(res.body.type).toBe('FeatureCollection');+ expect(res.body.features.length).toBeGreaterThan(0);+ expect((res.body.features as { properties: { iso_a2: string } }[]).every((f) => f.properties.iso_a2 === 'NO')).toBe(+ true,+ );+ });++ it('ATLAS-017 — GET /regions/geo/:code answers a country without regions with an empty FeatureCollection', async () => {+ const { user } = createUser(testDb);++ const res = await request(app).get('/api/addons/atlas/regions/geo/ZZ').set('Cookie', authCookie(user.id));++ expect(res.status).toBe(200);+ expect(res.body).toEqual({ type: 'FeatureCollection', features: [] });+ });++ it('ATLAS-018 — GET /regions/geo/:code refuses a code that is not two letters with a 400', async () => {+ const { user } = createUser(testDb);++ const codes = ['NOR', '..%2Fadmin0'];+ const answers = await Promise.all(+ codes.map((code) => request(app).get(`/api/addons/atlas/regions/geo/${code}`).set('Cookie', authCookie(user.id))),+ );+ for (const [i, res] of answers.entries()) {+ expect(res.status, codes[i]).toBe(400);+ expect(res.body.error, codes[i]).toMatch(/^code: /);+ }});});diff --git a/server/tests/unit/nest/atlas-region-files.test.ts b/server/tests/unit/nest/atlas-region-files.test.tsnew file mode 100644index 000000000..4d11555c2--- /dev/null+++ b/server/tests/unit/nest/atlas-region-files.test.ts@@ -0,0 +1,59 @@+import { getRegionGeoGz, getRegionGeoJson } from '../../../src/nest/atlas/atlas-geo';++import { describe, it, expect } from 'vitest';+import zlib from 'zlib';++// The admin-1 regions behind the Atlas region layer and region lookups, read from the+// committed geoBoundaries files (server/assets/atlas/admin1/<ISO_A2>.geojson.gz), so these+// double as a guard that the bundle ships current sub-national data (#1119).++type RegionFeature = { properties: { iso_a2: string; iso_3166_2: string; name: string } };+type RegionGeo = { type: string; features: RegionFeature[] };++const regionGeo = (codes: string[]) => JSON.parse(getRegionGeoJson(codes).toString('utf8')) as RegionGeo;+const countriesOf = (geo: RegionGeo) => new Set(geo.features.map((f) => f.properties.iso_a2));++describe('getRegionGeoJson', () => {+ it('ATLAS-SVC-017: returns an empty FeatureCollection for a country with no admin-1 features', () => {+ expect(regionGeo(['ZZ'])).toEqual({ type: 'FeatureCollection', features: [] });+ });++ it('ATLAS-SVC-018: returns the current geoBoundaries regions for a country, case-insensitively', () => {+ const result = regionGeo(['no']);++ expect(result.type).toBe('FeatureCollection');+ expect(result.features.length).toBeGreaterThan(0);+ expect(countriesOf(result)).toEqual(new Set(['NO']));++ const names = result.features.map((f) => f.properties.name);+ const codes = result.features.map((f) => f.properties.iso_3166_2);+ // Post-2020 reform is present…+ expect(codes).toContain('NO-34'); // Innlandet+ expect(codes).toContain('NO-46'); // Vestland+ // …and the merged-away pre-2020 counties are gone (the original #1119 bug).+ expect(names).not.toContain('Oppland');+ expect(names).not.toContain('Hordaland');+ expect(names).not.toContain('Sogn og Fjordane');+ });++ it('ATLAS-SVC-048: joins several countries into one FeatureCollection, each once, skipping unknown codes', () => {+ const result = regionGeo(['DE', 'zz', 'FR', 'de']);+ expect(countriesOf(result)).toEqual(new Set(['DE', 'FR']));+ expect(result.features.length).toBe(regionGeo(['DE']).features.length + regionGeo(['FR']).features.length);+ });+});++describe('getRegionGeoGz', () => {+ it("ATLAS-SVC-049: returns the country's gzipped FeatureCollection, case-insensitively", async () => {+ const gz = await getRegionGeoGz('no');+ expect(gz).toBeInstanceOf(Buffer);+ const geo = JSON.parse(zlib.gunzipSync(gz ?? Buffer.alloc(0)).toString('utf8')) as RegionGeo;+ expect(geo.type).toBe('FeatureCollection');+ expect(countriesOf(geo)).toEqual(new Set(['NO']));+ });++ it('ATLAS-SVC-050: returns null for a country without regions and for anything that is not a two-letter code', async () => {+ const codes = ['ZZ', 'NOR', '', '../admin0', '..', 'N/'];+ expect(await Promise.all(codes.map((code) => getRegionGeoGz(code)))).toEqual(codes.map(() => null));+ });+});diff --git a/server/tests/unit/nest/atlas.controller.test.ts b/server/tests/unit/nest/atlas.controller.test.tsindex 34fee5412..6e3186c7b 100644--- a/server/tests/unit/nest/atlas.controller.test.ts+++ b/server/tests/unit/nest/atlas.controller.test.ts@@ -9,6 +9,7 @@ import { HttpException, RequestMethod } from '@nestjs/common';import type { Response } from 'express';import { describe, it, expect, vi } from 'vitest';+import zlib from 'zlib';const user = { id: 8 } as User;@@ -18,10 +19,13 @@ function makeController(svc: Partial<AtlasService> & Partial<AtlasWritesService>}function makeRes() {- return { setHeader: vi.fn(), send: vi.fn(), json: vi.fn() } as unknown as Response & {+ const res = { setHeader: vi.fn(), send: vi.fn(), json: vi.fn(), type: vi.fn() };+ res.type.mockReturnValue(res);+ return res as unknown as Response & {setHeader: ReturnType<typeof vi.fn>;send: ReturnType<typeof vi.fn>;json: ReturnType<typeof vi.fn>;+ type: ReturnType<typeof vi.fn>;};}@@ -43,23 +47,45 @@ describe('AtlasController (parity with the legacy /api/addons/atlas route)', ()expect(stats).toHaveBeenCalledWith(8);});+ // The region routes read the committed per-country files (server/assets/atlas/admin1).+ type RegionFeatures = { features: { properties: { iso_a2: string } }[] };+ const countriesOf = (geo: RegionFeatures) => new Set(geo.features.map((f) => f.properties.iso_a2));+describe('GET /regions/geo', () => {- it('returns an empty FeatureCollection without a cache header when no countries given', async () => {- const regionGeo = vi.fn();+ it('returns an empty FeatureCollection without a cache header when no countries given', () => {const res = makeRes();- const out = await makeController({ regionGeo }).regionGeo(undefined, res);- expect(out).toEqual({ type: 'FeatureCollection', features: [] });- expect(regionGeo).not.toHaveBeenCalled();+ makeController({}).regionGeo(undefined, res);+ expect(res.json).toHaveBeenCalledWith({ type: 'FeatureCollection', features: [] });expect(res.setHeader).not.toHaveBeenCalled();});- it('caches a non-empty result for a day', async () => {- const regionGeo = vi.fn().mockResolvedValue({ type: 'FeatureCollection', features: [{ id: 1 }] });+ it('sends the countries joined into one FeatureCollection and caches them for a day', () => {+ const res = makeRes();+ makeController({}).regionGeo('DE,FR', res);+ expect(res.type).toHaveBeenCalledWith('application/json');+ expect(res.setHeader).toHaveBeenCalledWith('Cache-Control', 'public, max-age=86400');+ const body = JSON.parse(String(res.send.mock.calls[0][0])) as RegionFeatures;+ expect(countriesOf(body)).toEqual(new Set(['DE', 'FR']));+ });+ });++ describe('GET /regions/geo/:code', () => {+ it("serves the country's gzipped admin-1 file with Content-Encoding and a day of cache", async () => {+ const res = makeRes();+ await makeController({}).regionGeoForCountry({ code: 'NO' }, res);+ expect(res.setHeader).toHaveBeenCalledWith('Content-Type', 'application/json; charset=utf-8');+ expect(res.setHeader).toHaveBeenCalledWith('Content-Encoding', 'gzip');+ expect(res.setHeader).toHaveBeenCalledWith('Cache-Control', 'public, max-age=86400');+ const body = JSON.parse(zlib.gunzipSync(res.send.mock.calls[0][0] as Buffer).toString()) as RegionFeatures;+ expect(countriesOf(body)).toEqual(new Set(['NO']));+ });++ it('answers a country without regions with a cached empty FeatureCollection', async () => {const res = makeRes();- const out = await makeController({ regionGeo }).regionGeo('DE,FR', res);- expect(out).toEqual({ type: 'FeatureCollection', features: [{ id: 1 }] });- expect(regionGeo).toHaveBeenCalledWith(['DE', 'FR']);+ await makeController({}).regionGeoForCountry({ code: 'ZZ' }, res);+ expect(res.json).toHaveBeenCalledWith({ type: 'FeatureCollection', features: [] });expect(res.setHeader).toHaveBeenCalledWith('Cache-Control', 'public, max-age=86400');+ expect(res.setHeader).not.toHaveBeenCalledWith('Content-Encoding', 'gzip');});});diff --git a/server/tests/unit/nest/atlas.service.test.ts b/server/tests/unit/nest/atlas.service.test.tsindex f2446d2eb..bb758cbe7 100644--- a/server/tests/unit/nest/atlas.service.test.ts+++ b/server/tests/unit/nest/atlas.service.test.ts@@ -28,7 +28,7 @@ vi.mock('../../../src/db/database', async () => {import { db as testDb } from '../../../src/db/database';import { resetTestDb } from '../../helpers/test-db';import { createUser, createTrip, createReservation } from '../../helpers/factories';-import { getCountryFromCoords, getCountryFromAddress, isPointInCountryBox, reverseGeocodeCountry, getRegionGeo, getCountryGeo } from '../../../src/nest/atlas/atlas-geo';+import { getCountryFromCoords, getCountryFromAddress, isPointInCountryBox, reverseGeocodeCountry, getCountryGeo } from '../../../src/nest/atlas/atlas-geo';import { cacheKeyFor, getCached, setCached } from '../../../src/nest/geo/nominatim.client';import { AtlasService, BucketItemExistsError, bucketRegionCode } from '../../../src/nest/atlas/atlas.service';import { createTestUnitOfWork, createTestTripsRepo, createTestPlacesRepo, createTestReservationEndpointsRepo, sharedTestOrm } from '../../helpers/test-uow';@@ -687,45 +687,6 @@ describe('reverseGeocodeCountry', () => {});});-// ── getRegionGeo ────────────────────────────────────────────────────────────--// These read the committed geoBoundaries bundle (server/assets/atlas/admin1.geojson.gz),-// so they double as a guard that the bundle ships current sub-national data (#1119).-describe('getRegionGeo', () => {- // The first call streams the multi-MB admin1.geojson.gz through the brace-depth- // splitter and caches the result for the process. That build alone takes ~2.5s on a- // quiet machine and more when every vitest worker is busy, so whichever test called- // getRegionGeo first used to pay for it and blow the 5s default. Warm the store here- // with a budget that fits the build; the tests below then measure only the lookup.- beforeAll(async () => {- await getRegionGeo(['ZZ']);- }, 60_000);-- it('ATLAS-SVC-017: returns an empty FeatureCollection for a country with no admin-1 features', async () => {- const result = await getRegionGeo(['ZZ']);- expect(result).toEqual({ type: 'FeatureCollection', features: [] });- });-- it('ATLAS-SVC-018: returns the current geoBoundaries regions for a country, case-insensitively', async () => {- // Pass lowercase 'no' — getRegionGeo uppercases internally for matching.- const result = await getRegionGeo(['no']);-- expect(result.type).toBe('FeatureCollection');- expect(result.features.length).toBeGreaterThan(0);- expect(result.features.every((f: any) => f.properties.iso_a2 === 'NO')).toBe(true);-- const names = result.features.map((f: any) => f.properties.name);- const codes = result.features.map((f: any) => f.properties.iso_3166_2);- // Post-2020 reform is present…- expect(codes).toContain('NO-34'); // Innlandet- expect(codes).toContain('NO-46'); // Vestland- // …and the merged-away pre-2020 counties are gone (the original #1119 bug).- expect(names).not.toContain('Oppland');- expect(names).not.toContain('Hordaland');- expect(names).not.toContain('Sogn og Fjordane');- });-});-describe('getCountryGeo', () => {it('ATLAS-SVC-019: returns the admin-0 FeatureCollection with ISO_A2/ADM0_A3 properties', () => {const geo = getCountryGeo();diff --git a/server/tests/unit/nest/atlasBundle.test.ts b/server/tests/unit/nest/atlasBundle.test.tsindex 229e069f4..ab28e47e6 100644--- a/server/tests/unit/nest/atlasBundle.test.ts+++ b/server/tests/unit/nest/atlasBundle.test.ts@@ -27,13 +27,43 @@ describe('Atlas admin0 country bundle (#1609)', () => {});describe('Atlas admin1 region bundle (#1217)', () => {- const bundlePath = path.join(__dirname, '..', '..', '..', 'assets', 'atlas', 'admin1.geojson.gz');- const features = JSON.parse(zlib.gunzipSync(fs.readFileSync(bundlePath)).toString()).features as {+ const dir = path.join(__dirname, '..', '..', '..', 'assets', 'atlas', 'admin1');+ const files = fs+ .readdirSync(dir)+ .filter((name) => name.endsWith('.geojson.gz'))+ .map((name) => ({ name, text: zlib.gunzipSync(fs.readFileSync(path.join(dir, name))).toString() }));+ const features = files.flatMap(({ text }) => JSON.parse(text).features) as {properties: { iso_a2: string | null; iso_3166_2: string };}[];const regions = (a2: string) => features.filter((f) => f.properties.iso_a2 === a2);+ // The server joins countries for /regions/geo?countries= by cutting each file's+ // features out between these two, and a lookup reads the file its name points at.+ it('ATLAS-BUNDLE-007 — one compact FeatureCollection per country, named by its ISO_A2', () => {+ expect(files.length).toBeGreaterThan(150);+ for (const { name, text } of files) {+ expect(text.startsWith('{"type":"FeatureCollection","features":[{'), name).toBe(true);+ expect(text.endsWith('}]}'), name).toBe(true);+ const a2s = new Set(+ JSON.parse(text).features.map((f: { properties: { iso_a2: string } }) => f.properties.iso_a2),+ );+ expect(+ [...a2s].map((a2) => `${a2}.geojson.gz`),+ name,+ ).toEqual([name]);+ }+ });++ // admin1.geojson.gz stays for the two shipped migrations that read it; the server reads+ // the per-country files. Both have to carry the same regions.+ it('ATLAS-BUNDLE-008 — the per-country files hold exactly the features of admin1.geojson.gz', () => {+ const bundle = JSON.parse(zlib.gunzipSync(fs.readFileSync(path.join(dir, '..', 'admin1.geojson.gz'))).toString())+ .features as unknown[];+ const key = (f: unknown) => JSON.stringify(f);+ expect(features.map(key).sort()).toEqual(bundle.map(key).sort());+ });+it('ATLAS-BUNDLE-001 — previously-broken countries now have distinct region codes', () => {for (const a2 of ['ES', 'CN', 'CL', 'OM']) {const f = regions(a2);diff --git a/shared/src/atlas/atlas.schema.spec.ts b/shared/src/atlas/atlas.schema.spec.tsindex 458c5a7e1..4aa6c537e 100644--- a/shared/src/atlas/atlas.schema.spec.ts+++ b/shared/src/atlas/atlas.schema.spec.ts@@ -2,6 +2,7 @@ import {markRegionRequestSchema,createBucketItemRequestSchema,regionGeoSchema,+ regionGeoParamsSchema,visitStatusSchema,todayUtc,tripVisitStatus,@@ -76,6 +77,19 @@ describe('regionGeoSchema', () => {});});+describe('regionGeoParamsSchema', () => {+ it('takes a two-letter code from the path and uppercases it', () => {+ expect(regionGeoParamsSchema.parse({ code: 'no' })).toEqual({ code: 'NO' });+ expect(regionGeoParamsSchema.parse({ code: 'GB' })).toEqual({ code: 'GB' });+ });++ it('refuses anything that is not two letters', () => {+ for (const code of ['NOR', 'N', '', '..', '../admin0', 'N/', '12']) {+ expect(regionGeoParamsSchema.safeParse({ code }).success, code).toBe(false);+ }+ });+});+describe('visitStatusSchema', () => {it('accepts the three buckets and nothing else', () => {expect(visitStatusSchema.safeParse('visited').success).toBe(true);diff --git a/shared/src/atlas/atlas.schema.ts b/shared/src/atlas/atlas.schema.tsindex ebe48d6a1..ef7a9ef4b 100644--- a/shared/src/atlas/atlas.schema.ts+++ b/shared/src/atlas/atlas.schema.ts@@ -71,6 +71,15 @@ export const regionGeoSchema = z.object({});export type RegionGeo = z.infer<typeof regionGeoSchema>;+/** GET /regions/geo/:code — one country's regions, by ISO 3166-1 alpha-2 code in any case. */+export const regionGeoParamsSchema = z.object({+ code: z+ .string()+ .regex(/^[A-Za-z]{2}$/, 'a two-letter country code')+ .transform((code) => code.toUpperCase()),+});+export type RegionGeoParams = z.infer<typeof regionGeoParamsSchema>;+/*** Where a coordinate lands on the atlas map (#1115). Both fields are nullable: the* point may sit outside every bundled polygon (open sea, a simplification gap at a