You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/09/22 01:25:35 UTC

(superset) branch master updated: fix(country-map): correct Karelia boundary (#44273)

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

rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 3e39ba13e34 fix(country-map): correct Karelia boundary (#44273)
3e39ba13e34 is described below

commit 3e39ba13e347f68521acd2148a135cd57b9c6765
Author: Deepak Jain (DJ) <de...@users.noreply.github.com>
AuthorDate: Mon Sep 21 18:25:27 2026 -0700

    fix(country-map): correct Karelia boundary (#44273)
    
    Signed-off-by: Deepak Jain <de...@gmail.com>
---
 .../scripts/Country Map GeoJSON Generator.ipynb    | Bin 226846 -> 227629 bytes
 .../src/countries/russia.geojson                   | Bin 747442 -> 678517 bytes
 .../test/russia.geojson.test.ts                    |  87 +++++++++++++++++++++
 3 files changed, 87 insertions(+)

diff --git a/superset-frontend/plugins/plugin-chart-country-map/scripts/Country Map GeoJSON Generator.ipynb b/superset-frontend/plugins/plugin-chart-country-map/scripts/Country Map GeoJSON Generator.ipynb
index 7b6941ee307..1b40e100cd3 100644
Binary files a/superset-frontend/plugins/plugin-chart-country-map/scripts/Country Map GeoJSON Generator.ipynb and b/superset-frontend/plugins/plugin-chart-country-map/scripts/Country Map GeoJSON Generator.ipynb differ
diff --git a/superset-frontend/plugins/plugin-chart-country-map/src/countries/russia.geojson b/superset-frontend/plugins/plugin-chart-country-map/src/countries/russia.geojson
index 33df3402655..919524c55d5 100644
Binary files a/superset-frontend/plugins/plugin-chart-country-map/src/countries/russia.geojson and b/superset-frontend/plugins/plugin-chart-country-map/src/countries/russia.geojson differ
diff --git a/superset-frontend/plugins/plugin-chart-country-map/test/russia.geojson.test.ts b/superset-frontend/plugins/plugin-chart-country-map/test/russia.geojson.test.ts
new file mode 100644
index 00000000000..7518fc70d76
--- /dev/null
+++ b/superset-frontend/plugins/plugin-chart-country-map/test/russia.geojson.test.ts
@@ -0,0 +1,87 @@
+/**
+ * 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 Position = [number, number];
+type Coordinates = number | Coordinates[];
+type Feature = {
+  properties: { ISO: string; NAME_1: string };
+  geometry: { coordinates: Coordinates };
+};
+
+function positions(coordinates: Coordinates): Position[] {
+  if (
+    Array.isArray(coordinates) &&
+    typeof coordinates[0] === 'number' &&
+    typeof coordinates[1] === 'number'
+  ) {
+    return [coordinates as Position];
+  }
+  return (coordinates as Coordinates[]).flatMap(positions);
+}
+
+function bounds(feature: Feature) {
+  const points = positions(feature.geometry.coordinates);
+  return points.reduce(
+    ([minX, minY, maxX, maxY], [x, y]) => [
+      Math.min(minX, x),
+      Math.min(minY, y),
+      Math.max(maxX, x),
+      Math.max(maxY, y),
+    ],
+    [Infinity, Infinity, -Infinity, -Infinity],
+  );
+}
+
+test('Karelia and Murmansk have distinct full-size boundaries', () => {
+  const filePath = path.join(__dirname, '../src/countries/russia.geojson');
+  // The 1:50m map is about 747 kB. Replacing only the two incorrect regions
+  // keeps the payload close to that baseline instead of shipping all 1:10m data.
+  expect(fs.statSync(filePath).size).toBeLessThan(760_000);
+  const { features }: { features: Feature[] } = JSON.parse(
+    fs.readFileSync(filePath, 'utf-8'),
+  );
+  const byIso = new Map(
+    features.map(feature => [feature.properties.ISO, feature]),
+  );
+
+  expect(features).toHaveLength(85);
+  expect(byIso.size).toBe(85);
+
+  const karelia = byIso.get('RU-KR');
+  const murmansk = byIso.get('RU-MUR');
+  expect(karelia?.properties.NAME_1).toBe('Karelia');
+  expect(murmansk?.properties.NAME_1).toBe('Murmansk');
+
+  const [kareliaMinX, kareliaMinY, kareliaMaxX, kareliaMaxY] = bounds(karelia!);
+  expect(kareliaMinX).toBeLessThan(30);
+  expect(kareliaMinY).toBeLessThan(61);
+  expect(kareliaMaxX).toBeGreaterThan(37);
+  expect(kareliaMaxY).toBeGreaterThan(66);
+
+  const [murmanskMinX, murmanskMinY, murmanskMaxX, murmanskMaxY] = bounds(
+    murmansk!,
+  );
+  expect(murmanskMinX).toBeLessThan(30);
+  expect(murmanskMinY).toBeGreaterThan(65);
+  expect(murmanskMaxX).toBeGreaterThan(40);
+  expect(murmanskMaxY).toBeGreaterThan(69);
+});