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

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

commit 85a4903fccf7e39e6ccf4261a81d032d69ef8acc
Author: rusackas <[email protected]>
AuthorDate: Sun Jul 26 06:44:19 2026 -0700

    fix(viz): correct duplicate/incorrect ISO codes in Iran country map
    
    Tehran and Alborz provinces both used IR-07 in the Iran GeoJSON, and
    Razavi Khorasan was assigned IR-30 (Alborz's actual code), leaving
    IR-09 unused. This made it impossible to color Tehran and Alborz
    independently on the country map viz and mapped Razavi Khorasan data
    to the wrong region. Alborz now uses IR-30 and Razavi Khorasan uses
    IR-09, matching ISO 3166-2:IR, with a test pinning uniqueness of the
    ISO codes.
    
    Fixes #31991
---
 .../src/countries/iran.geojson                     | Bin 134245 -> 134245 bytes
 .../test/countries/iran.test.ts                    |  59 +++++++++++++++++++++
 2 files changed, 59 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..41cf91bfe0c 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/countries/iran.test.ts
 
b/superset-frontend/plugins/legacy-plugin-chart-country-map/test/countries/iran.test.ts
new file mode 100644
index 00000000000..c44ee0770dc
--- /dev/null
+++ 
b/superset-frontend/plugins/legacy-plugin-chart-country-map/test/countries/iran.test.ts
@@ -0,0 +1,59 @@
+/**
+ * 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';
+
+// The geojson is loaded via fs rather than a normal import because the
+// webpack/jest loaders treat *.geojson as an opaque asset (a URL string in
+// the browser build, an empty mock object under jest), so neither exposes
+// the actual feature data to a unit test.
+const iranGeojsonPath = path.join(
+  __dirname,
+  '..',
+  '..',
+  'src',
+  'countries',
+  'iran.geojson',
+);
+
+type IranFeature = {
+  properties: { ISO: string; NAME_1: string };
+};
+
+const getIranFeatures = (): IranFeature[] =>
+  JSON.parse(fs.readFileSync(iranGeojsonPath, 'utf-8')).features;
+
+test('every province in the Iran map has a unique ISO code', () => {
+  const isoCodes = getIranFeatures().map(feature => feature.properties.ISO);
+  const uniqueIsoCodes = new Set(isoCodes);
+  expect(uniqueIsoCodes.size).toBe(isoCodes.length);
+});
+
+test('Tehran, Alborz and Razavi Khorasan have their correct, distinct ISO 
codes', () => {
+  const provincesByIso = Object.fromEntries(
+    getIranFeatures().map(feature => [
+      feature.properties.NAME_1,
+      feature.properties.ISO,
+    ]),
+  );
+
+  expect(provincesByIso.Tehran).toBe('IR-07');
+  expect(provincesByIso.Alborz).toBe('IR-30');
+  expect(provincesByIso['Razavi Khorasan']).toBe('IR-09');
+});

Reply via email to