Skip to content

Optimize cartodiagram WKB/WKT polygon feature handling#41

Open
pierrejego wants to merge 2 commits intoterrestris:5.0.0-customfrom
geo2france:issue-37843
Open

Optimize cartodiagram WKB/WKT polygon feature handling#41
pierrejego wants to merge 2 commits intoterrestris:5.0.0-customfrom
geo2france:issue-37843

Conversation

@pierrejego
Copy link

@pierrejego pierrejego commented Feb 10, 2026

  • Reuse parsed OpenLayers features to avoid repeated geometry parsing
  • Fit map from existing features instead of re-parsing records
  • Simplify feature construction in dataRecordsToOlFeatures

fix(cartodiagram): avoid repeated geometry parsing

SUMMARY

Reuse parsed OpenLayers features for WKB/WKT geometries to avoid re-parsing on render and fit operations. This reduces repeated geometry parsing when polygon layers are large.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A (performance-only change)
Before
Slow-superset
After
faster-superset

TESTING INSTRUCTIONS

  1. Open a Thematic Map (Cartodiagram) chart using a large polygon layer (WKB/WKT).
  2. Interact with the chart (load, zoom, apply time filter if used).
  3. Observe improved responsiveness and no regressions in rendering.

Using

ADDITIONAL INFORMATION

  • Has associated issue: TODO (add if applicable, e.g., Fixes #NNNNN)
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Funding: This work was funded by the Région Hauts-de-France (France).

link to apache#37843

- Reuse parsed OpenLayers features to avoid repeated geometry parsing
- Fit map from existing features instead of re-parsing records
- Simplify feature construction in dataRecordsToOlFeatures
@Doctor-Who
Copy link

Thanks for the improvement; it meets our needs and will help load larger amounts of data.

@jansule
Copy link
Member

jansule commented Feb 19, 2026

Thanks @pierrejego. I will try to take a look at it this week.

Copy link
Member

@jansule jansule left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @pierrejego ! This looks mainly good. Just a few remarks that should be easy to solve.

Please also run the linter as there are some parts that do not follow the current linting rules.

dataFeatures,
getMapExtentPadding(mapExtentPadding),
);
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the else branch ever be reached, or is this obsolete?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was obsolete

return data;
}, [data, geomColumn, geomFormat]);

const dataFeatures = useMemo(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment on where/when to use this instead of another data related variable, e.g. processedData, so future devs can more easily decide which to use when.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments added

getMapExtentPadding(mapExtentPadding),
);
} else {
fitMapToDataRecords(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment above

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

source?.addFeatures(features);
});
}, [currentDataLayers, filteredData, geomColumn, geomFormat]);
}, [currentDataLayers, filteredData, filteredFeatures, geomColumn, geomFormat]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like geomColumn can be removed from the list of dependencies

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch yes

*/
import { DataRecord } from '@superset-ui/core';
import { useEffect, useMemo, useState } from 'react';
import { useEffect, useMemo, useRef, useState } from 'react';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove unused useRef.

@jansule
Copy link
Member

jansule commented Feb 24, 2026

Also, do you have an indicator/metric on how much the performance was improved due to your changes?

clarify dataFeatures usage and clean up OlChartMap
@pierrejego
Copy link
Author

Also, do you have an indicator/metric on how much the performance was improved due to your changes?

During development, I added some temporary indicators to get a rough measure of the impact.
On my test dataset, the changes in this PR, mainly optimizing feature creation and avoiding unnecessary data reloads, reduced the rendering time from roughly 9 seconds to about 4 seconds.

In addition, for large and complex geometries, using ST_SimplifyPreserveTopology(geom, 50) AS geom in the query improves performance even further. In that case, rendering drops to under 1 second on my dataset, and the map appears before the tables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants