diff --git a/internal/check-batch-selection-export.mjs b/internal/check-batch-selection-export.mjs index 4429205cd..0766f00a3 100644 --- a/internal/check-batch-selection-export.mjs +++ b/internal/check-batch-selection-export.mjs @@ -103,6 +103,12 @@ for (const [name, sel] of Object.entries(REGROUP_CASES)) { const tool = dry(X.selectionClipboard(sel, {})) === 'ok' if (X.regroupable(sel) !== tool) disagree.push(`${name}: regroupable ${X.regroupable(sel)}, apply-grouping ${tool ? 'accepts' : 'refuses'}`) } +// …and the COUNTRY an ADM1 territory needs for that verdict is always known: from the feature's own props on a +// map tap, else from the baked table (a props-only toggle once left it null, which read as a false warning). +const { resolveTerritory, ADM1_COUNTS, ADM1_COUNTRY } = await import(pathToFileURL(P('plugin-designs/my-upg-100-list/data/territory-counts.js')).href) +const noCountry = Object.keys(ADM1_COUNTS).filter((n) => !['IND', 'CHN'].includes(ADM1_COUNTRY[n])) +ok(!noCountry.length && resolveTerritory({ shapeName: 'Mahārāshtra' }).country === 'IND' && resolveTerritory({ shapeName: 'Guizhou Province' }).country === 'CHN', + `an ADM1 territory without a known country: ${noCountry.slice(0, 5).join(', ') || 'a props-only toggle'}`, 'every ADM1 name resolves its country, even from a props-only toggle') ok(!disagree.length, `Copy's regroup warning disagrees with apply-grouping: ${disagree.join('; ')}`, `the regroup warning matches apply-grouping's own verdict in all ${Object.keys(REGROUP_CASES).length} cases (India, China, countries, and the three it refuses)`) diff --git a/plugin-designs/my-upg-100-list/data/territory-counts.js b/plugin-designs/my-upg-100-list/data/territory-counts.js index fa719b7e2..13b3dd0ae 100644 --- a/plugin-designs/my-upg-100-list/data/territory-counts.js +++ b/plugin-designs/my-upg-100-list/data/territory-counts.js @@ -26,8 +26,8 @@ // ── (1) ADM1 territory counts (India states + China provinces) ─────────────── // Verbatim from data/admin-counts.json (IND 34 + CHN 12 = 46), keyed by the // EXACT shapeName the gb-IND-ADM1 / gb-CHN-ADM1 features carry. -export const ADM1_COUNTS = { - // IND (34) +// India's 34 and China's 12, kept apart so each name's COUNTRY is known too (ADM1_COUNTRY below). +const ADM1_COUNTS_IND = { 'Andaman and Nicobar Islands': 9, 'Andhra Pradesh': 81, 'Arunāchal Pradesh': 7, @@ -62,7 +62,8 @@ export const ADM1_COUNTS = { 'Uttar Pradesh': 23, 'Uttarākhand': 7, 'West Bengal': 30, - // CHN (12) +}; +const ADM1_COUNTS_CHN = { 'Gansu Province': 3, 'Guangxi Zhuang Autonomous Region': 6, 'Guizhou Province': 34, @@ -76,6 +77,11 @@ export const ADM1_COUNTS = { 'Xinjiang Uyghur Autonomous Region': 7, 'Yunnan Province': 61, }; +export const ADM1_COUNTS = { ...ADM1_COUNTS_IND, ...ADM1_COUNTS_CHN }; +// name → 'IND' | 'CHN': the fallback when a feature does not carry shapeGroup / iso3 (a gate's props-only toggle). +export const ADM1_COUNTRY = Object.fromEntries([ + ...Object.keys(ADM1_COUNTS_IND).map((n) => [n, 'IND']), ...Object.keys(ADM1_COUNTS_CHN).map((n) => [n, 'CHN']), +]); // ── (2) ADM0 per-country counts (iso3 → # records in admin-membership.json) ── // Covers ALL 161 ADM0 countries rendered in world-adm0.geojson; every one has a @@ -159,7 +165,7 @@ export function resolveTerritory(props, opts = {}) { const count = Object.prototype.hasOwnProperty.call(ADM1_COUNTS, name) ? ADM1_COUNTS[name] : null; // country: which ADM1 set it belongs to (IND / CHN), because data/apply-grouping.mjs regroups one kind at a time. - return { key: 'adm1:' + name, name, count, kind: 'adm1', country: props.shapeGroup || props.iso3 || null }; + return { key: 'adm1:' + name, name, count, kind: 'adm1', country: props.shapeGroup || props.iso3 || ADM1_COUNTRY[name] || null }; } // (2) ADM0 — country (only iso3 on the feature)