You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by en...@apache.org on 2026/03/12 10:20:59 UTC
(superset) 01/01: fix(deckgl): render polygon chart when boundary column contains nested geometry JSON
This is an automated email from the ASF dual-hosted git repository.
enzomartellucci pushed a commit to branch enxdev/fix/deck-gl-chart
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 8a37dbff3c62b6a5b463d55354eb333b6ab413dc
Author: Enzo Martellucci <en...@gmail.com>
AuthorDate: Thu Mar 12 11:20:38 2026 +0100
fix(deckgl): render polygon chart when boundary column contains nested geometry JSON
---
.../src/layers/Polygon/transformProps.test.ts | 138 ++++++++++++++++++++-
.../src/layers/Polygon/transformProps.ts | 4 +
2 files changed, 136 insertions(+), 6 deletions(-)
diff --git a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Polygon/transformProps.test.ts b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Polygon/transformProps.test.ts
index a7b7be3ab9a..8e2e762fe98 100644
--- a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Polygon/transformProps.test.ts
+++ b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Polygon/transformProps.test.ts
@@ -43,12 +43,18 @@ describe('Polygon transformProps', () => {
{
data: [
{
- geom: JSON.stringify([
- [-122.4, 37.8],
- [-122.3, 37.8],
- [-122.3, 37.9],
- [-122.4, 37.9],
- ]),
+ geom: JSON.stringify({
+ type: 'Polygon',
+ coordinates: [
+ [
+ [-122.4, 37.8],
+ [-122.3, 37.8],
+ [-122.3, 37.9],
+ [-122.4, 37.9],
+ [-122.4, 37.8],
+ ],
+ ],
+ }),
'AVG(elevation)': 150.5,
population: 50000,
},
@@ -289,6 +295,126 @@ describe('Polygon transformProps', () => {
expect(features[0]?.elevation).toBeUndefined();
});
+ test('should render polygons when boundary column contains GeoJSON Feature format', () => {
+ const geojsonFeatureProps = {
+ ...mockChartProps,
+ queriesData: [
+ {
+ data: [
+ {
+ geom: JSON.stringify({
+ type: 'Feature',
+ geometry: {
+ type: 'Polygon',
+ coordinates: [
+ [
+ [-122.4, 37.8],
+ [-122.3, 37.8],
+ [-122.3, 37.9],
+ [-122.4, 37.9],
+ [-122.4, 37.8],
+ ],
+ ],
+ },
+ properties: { name: 'test' },
+ }),
+ },
+ ],
+ },
+ ],
+ };
+
+ const result = transformProps(geojsonFeatureProps as ChartProps);
+
+ const features = result.payload.data.features as PolygonFeature[];
+ expect(features).toHaveLength(1);
+ expect(features[0]?.polygon).toEqual([
+ [-122.4, 37.8],
+ [-122.3, 37.8],
+ [-122.3, 37.9],
+ [-122.4, 37.9],
+ [-122.4, 37.8],
+ ]);
+ });
+
+ test('should render polygons when boundary column contains GeoJSON Geometry format', () => {
+ const geojsonGeometryProps = {
+ ...mockChartProps,
+ queriesData: [
+ {
+ data: [
+ {
+ geom: JSON.stringify({
+ type: 'Polygon',
+ coordinates: [
+ [
+ [-122.4, 37.8],
+ [-122.3, 37.8],
+ [-122.3, 37.9],
+ [-122.4, 37.9],
+ [-122.4, 37.8],
+ ],
+ ],
+ }),
+ },
+ ],
+ },
+ ],
+ };
+
+ const result = transformProps(geojsonGeometryProps as ChartProps);
+
+ const features = result.payload.data.features as PolygonFeature[];
+ expect(features).toHaveLength(1);
+ expect(features[0]?.polygon).toEqual([
+ [-122.4, 37.8],
+ [-122.3, 37.8],
+ [-122.3, 37.9],
+ [-122.4, 37.9],
+ [-122.4, 37.8],
+ ]);
+ });
+
+ test('should render polygons when boundary column contains JSON with nested geometry', () => {
+ // Real-world format: {"type":"Polygon","geometry":{"type":"Polygon","coordinates":[...]}}
+ const nonStandardProps = {
+ ...mockChartProps,
+ queriesData: [
+ {
+ data: [
+ {
+ geom: JSON.stringify({
+ type: 'Polygon',
+ geometry: {
+ type: 'Polygon',
+ coordinates: [
+ [
+ [79.7912, 8.4641],
+ [79.7959, 8.4629],
+ [79.7994, 8.4535],
+ [79.7912, 8.4641],
+ ],
+ ],
+ },
+ }),
+ },
+ ],
+ },
+ ],
+ };
+
+ const result = transformProps(nonStandardProps as ChartProps);
+
+ const features = result.payload.data.features as PolygonFeature[];
+ expect(features).toHaveLength(1);
+ expect(features[0]?.polygon).toEqual([
+ [79.7912, 8.4641],
+ [79.7959, 8.4629],
+ [79.7994, 8.4535],
+ [79.7912, 8.4641],
+ ]);
+ });
+
test('should handle geohash decoding successfully', () => {
const props = {
...mockedChartPropsWithGeoHash,
diff --git a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Polygon/transformProps.ts b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Polygon/transformProps.ts
index bb070d92e36..5a9f71b2a53 100644
--- a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Polygon/transformProps.ts
+++ b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Polygon/transformProps.ts
@@ -115,6 +115,10 @@ function processPolygonData(
if (parsed.coordinates) {
polygonCoords = parsed.coordinates[0] || parsed.coordinates;
+ } else if (parsed.geometry?.coordinates) {
+ // Non-standard format with nested geometry
+ polygonCoords =
+ parsed.geometry.coordinates[0] || parsed.geometry.coordinates;
} else if (Array.isArray(parsed)) {
polygonCoords = parsed;
} else {