This is an automated email from the ASF dual-hosted git repository.
jli 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 b99fc582e4 fix(chart): implement geohash decoding (#37027)
b99fc582e4 is described below
commit b99fc582e4e5809f97ba5a54d65f2f74055c6f18
Author: Reynold Morel <[email protected]>
AuthorDate: Fri Jan 23 18:15:29 2026 -0400
fix(chart): implement geohash decoding (#37027)
---
.../src/layers/Polygon/transformProps.test.ts | 50 ++++++++++++++++++++++
.../src/layers/Polygon/transformProps.ts | 11 +++++
2 files changed, 61 insertions(+)
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 50725fefe6..a7b7be3ab9 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
@@ -69,6 +69,37 @@ describe('Polygon transformProps', () => {
emitCrossFilters: false,
};
+ const mockedChartPropsWithGeoHash: Partial<ChartProps> = {
+ ...mockChartProps,
+ rawFormData: {
+ line_column: 'geohash',
+ line_type: 'geohash',
+ viewport: {},
+ },
+ queriesData: [
+ {
+ data: [
+ {
+ geohash: '9q8yt',
+ 'sum(population)': 9800,
+ },
+ {
+ geohash: '9q8yk',
+ 'sum(population)': 13100,
+ },
+ {
+ geohash: '9q8yv',
+ 'sum(population)': 15600,
+ },
+ {
+ geohash: '9q8yq',
+ 'sum(population)': 7500,
+ },
+ ],
+ },
+ ],
+ };
+
test('should use constant elevation value when point_radius_fixed type is
"fix"', () => {
const fixProps = {
...mockChartProps,
@@ -257,4 +288,23 @@ describe('Polygon transformProps', () => {
expect(features).toHaveLength(1);
expect(features[0]?.elevation).toBeUndefined();
});
+
+ test('should handle geohash decoding successfully', () => {
+ const props = {
+ ...mockedChartPropsWithGeoHash,
+ rawFormData: {
+ ...mockedChartPropsWithGeoHash.rawFormData,
+ point_radius_fixed: {
+ type: 'fix',
+ value: '1000',
+ },
+ },
+ };
+
+ const result = transformProps(props as ChartProps);
+
+ const features = result.payload.data.features as PolygonFeature[];
+ expect(features.flatMap(p => p?.polygon || [])).toHaveLength(20); // 4
geohashes x 5 corners each
+ expect(features[0]?.elevation).toBe(1000);
+ });
});
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 3c55142d39..bb070d92e3 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
@@ -26,6 +26,7 @@ import {
addPropertiesToFeature,
} from '../transformUtils';
import { DeckPolygonFormData } from './buildQuery';
+import { decode_bbox } from 'ngeohash';
function parseElevationValue(value: string): number | undefined {
const parsed = parseFloat(value);
@@ -122,6 +123,16 @@ function processPolygonData(
break;
}
case 'geohash':
+ polygonCoords = [];
+ const decoded = decode_bbox(String(rawPolygonData));
+ if (decoded) {
+ polygonCoords.push([decoded[1], decoded[0]]); // SW (minLon,
minLat)
+ polygonCoords.push([decoded[1], decoded[2]]); // NW (minLon,
maxLat)
+ polygonCoords.push([decoded[3], decoded[2]]); // NE (maxLon,
maxLat)
+ polygonCoords.push([decoded[3], decoded[0]]); // SE (maxLon,
minLat)
+ polygonCoords.push([decoded[1], decoded[0]]); // SW (close
polygon)
+ }
+ break;
case 'zipcode':
default: {
polygonCoords = Array.isArray(rawPolygonData) ? rawPolygonData :
[];