This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch fix/issue-31991-iran-alborz-duplicate-iso
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 21cd451a9d43c6ca624a090956acca338440c7c6
Author: rusackas <[email protected]>
AuthorDate: Sat Jul 25 19:47:34 2026 -0700

    fix(country-map): give Alborz its own ISO code instead of reusing Tehran's
    
    Tehran and Alborz were split into separate Iranian provinces in 2010,
    but iran.geojson still tagged both with ISO IR-07, so the Country Map
    chart couldn't distinguish or individually color/tooltip them. Assign
    Alborz IR-32, its own pre-2020 ISO 3166-2:IR code, matching the scheme
    already used by every other province in this file.
    
    Fixes #31991
---
 .../src/countries/iran.geojson                     | Bin 134245 -> 134245 bytes
 .../test/iran.geojson.test.ts                      |  63 +++++++++++++++++++++
 2 files changed, 63 insertions(+)

diff --git 
a/superset-frontend/plugins/legacy-plugin-chart-country-map/src/countries/iran.geojson
 
b/superset-frontend/plugins/legacy-plugin-chart-country-map/src/countries/iran.geojson
index 19c9ec51025..9a7f0fd828f 100644
Binary files 
a/superset-frontend/plugins/legacy-plugin-chart-country-map/src/countries/iran.geojson
 and 
b/superset-frontend/plugins/legacy-plugin-chart-country-map/src/countries/iran.geojson
 differ
diff --git 
a/superset-frontend/plugins/legacy-plugin-chart-country-map/test/iran.geojson.test.ts
 
b/superset-frontend/plugins/legacy-plugin-chart-country-map/test/iran.geojson.test.ts
new file mode 100644
index 00000000000..e9136b089a7
--- /dev/null
+++ 
b/superset-frontend/plugins/legacy-plugin-chart-country-map/test/iran.geojson.test.ts
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import fs from 'fs';
+import path from 'path';
+
+type Feature = {
+  properties: {
+    ISO: string;
+    NAME_1: string;
+  };
+};
+
+// `.geojson` imports are mocked out to an empty object by the Jest module
+// mapper (see jest.config.js), so the file is read from disk directly to
+// exercise the real, committed data.
+function loadIranGeoJson(): { features: Feature[] } {
+  const filePath = path.join(__dirname, '../src/countries/iran.geojson');
+  return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
+}
+
+test('every Iranian province has its own distinct ISO 3166-2 code', () => {
+  const { features } = loadIranGeoJson();
+
+  // Sanity check: every province name in this file is unique, so a
+  // duplicate ISO code below can only mean two different provinces were
+  // mistakenly assigned the same code (as opposed to one province being
+  // split across multiple polygon features).
+  const names = features.map(feature => feature.properties.NAME_1);
+  expect(new Set(names).size).toBe(names.length);
+
+  const isoByName = new Map(
+    features.map(feature => [
+      feature.properties.NAME_1,
+      feature.properties.ISO,
+    ]),
+  );
+  const isoCodes = features.map(feature => feature.properties.ISO);
+
+  expect(new Set(isoCodes).size).toBe(isoCodes.length);
+
+  // Tehran and Alborz were split into separate provinces in 2010, but the
+  // GeoJSON still assigned both the same ISO code (IR-07), which used to
+  // make it impossible to distinguish them on the Country Map chart.
+  expect(isoByName.get('Tehran')).toBe('IR-07');
+  expect(isoByName.get('Alborz')).not.toBe(isoByName.get('Tehran'));
+});

Reply via email to