Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
fix(export): scale point radius correctly for 2x resolution image export (#2592) (#3340)
pierreeurope76ee803400b0
diff --git a/src/components/src/plot-container.tsx b/src/components/src/plot-container.tsxindex e6033e5c1..773d85ecc 100644--- a/src/components/src/plot-container.tsx+++ b/src/components/src/plot-container.tsx@@ -312,11 +312,13 @@ export default function PlotContainerFactory(// Memoize map stateconst newMapState = useMemo(() => {+ const zoomOffset = Math.log2(scale) || 0;const baseMapState = {...mapState,width,height,- zoom: mapState.zoom + (Math.log2(scale) || 0)+ zoom: mapState.zoom + zoomOffset,+ zoomOffset};if (center) {diff --git a/src/reducers/src/ui-state-updaters.ts b/src/reducers/src/ui-state-updaters.tsindex e2aa577ed..3325fbede 100644--- a/src/reducers/src/ui-state-updaters.ts+++ b/src/reducers/src/ui-state-updaters.ts@@ -548,9 +548,6 @@ export const setExportImageSettingUpdater = (...state,exportImage: {...updated,- // @ts-expect-error- // TODO: calculateExportImageSize does not return imageSize.zoomOffset,- // do we need take this value from current state, or return defaul value = 0imageSize}};diff --git a/src/utils/src/export-utils.ts b/src/utils/src/export-utils.tsindex 7843c9aaf..77b226917 100644--- a/src/utils/src/export-utils.ts+++ b/src/utils/src/export-utils.ts@@ -63,9 +63,11 @@ export function calculateExportImageSize({const {width: imageW, height: imageH} = ratioItem.getSize(scaledWidth, scaledHeight);const {scale} = ratioItem.id === EXPORT_IMG_RATIOS.CUSTOM ? {scale: undefined} : resolutionItem;+ const resolvedScale = scale ?? 1;return {- scale,+ zoomOffset: Math.log2(resolvedScale) || 0,+ scale: resolvedScale,imageW,imageH};diff --git a/test/node/utils/export-utils-test.js b/test/node/utils/export-utils-test.jsindex aeb7a95a9..a5c40af6d 100644--- a/test/node/utils/export-utils-test.js+++ b/test/node/utils/export-utils-test.js@@ -55,7 +55,7 @@ test('exportUtils -> calculateExportImageSize', t => {ratio: EXPORT_IMG_RATIOS.SCREEN,resolution: RESOLUTIONS.ONE_X}),- {scale: 1, imageW: 1400, imageH: 990},+ {zoomOffset: 0, scale: 1, imageW: 1400, imageH: 990},'Should calculate the correct export image size');@@ -88,8 +88,8 @@ test('exportUtils -> calculateExportImageSize', t => {ratio: EXPORT_IMG_RATIOS.CUSTOM,resolution: RESOLUTIONS.ONE_X}),- {scale: undefined, imageW: 1440, imageH: 990},- 'Should return scale null because of custom ratio'+ {zoomOffset: 0, scale: 1, imageW: 1440, imageH: 990},+ 'Should return scale 1 for custom ratio (defaults to 1)');t.deepEqual(@@ -99,7 +99,7 @@ test('exportUtils -> calculateExportImageSize', t => {ratio: 'not-valid',resolution: RESOLUTIONS.ONE_X}),- {scale: 1, imageW: 1440, imageH: 1080},+ {zoomOffset: 0, scale: 1, imageW: 1440, imageH: 1080},'Should return a correct valid with a non valid ratio param');@@ -110,7 +110,7 @@ test('exportUtils -> calculateExportImageSize', t => {ratio: EXPORT_IMG_RATIOS.SCREEN,resolution: 'not-valid'}),- {scale: 1, imageW: 1440, imageH: 990},+ {zoomOffset: 0, scale: 1, imageW: 1440, imageH: 990},'Should return a correct valid with a non valid resolution param');