Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

carto: Fix caching in ClusterTileLayer #9167

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
improve typings
  • Loading branch information
zbigg committed Sep 20, 2024
commit 12ee0f8e5327ed83ba2b002138cf04d9de1a7e6f
4 changes: 2 additions & 2 deletions modules/carto/src/layers/cluster-tile-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class ClusterGeoJsonLayer<
clusterIds: bigint[];
hoveredFeatureId: bigint | number | null;
highlightColor: number[];
aggregationCache: WeakMap<any, Map<number, any>>; // tile.content => Record<number, aggregationResultWhateverItIs>
aggregationCache: WeakMap<any, Map<number, ClusteredFeaturePropertiesT<FeaturePropertiesT>[]>>;
};

initializeState() {
Expand Down Expand Up @@ -148,7 +148,7 @@ class ClusterGeoJsonLayer<
getWeight
);
needsUpdate ||= didAggregate;
data.push(...tileAggregationCache.get(aggregationLevels));
data.push(...tileAggregationCache.get(aggregationLevels)!);
}

data.sort((a, b) => Number(b.count - a.count));
Expand Down
4 changes: 2 additions & 2 deletions modules/carto/src/layers/cluster-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type ParsedQuadbinTile<FeaturePropertiesT> = ParsedQuadbinCell<FeaturePro
*/
export function aggregateTile<FeaturePropertiesT>(
tile: Tile2DHeader<ParsedQuadbinTile<FeaturePropertiesT>>,
tileAggregationCache: Map<number, any>,
tileAggregationCache: Map<number, ClusteredFeaturePropertiesT<FeaturePropertiesT>[]>,
aggregationLevels: number,
properties: AggregationProperties<FeaturePropertiesT> = [],
getPosition: Accessor<ParsedQuadbinCell<FeaturePropertiesT>, [number, number]>,
Expand All @@ -42,7 +42,7 @@ export function aggregateTile<FeaturePropertiesT>(
}

// Aggregated properties have changed, re-aggregate
tileAggregationCache.clear()
tileAggregationCache.clear();
}

const out: Record<number, any> = {};
Expand Down
Loading