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

Clientside data optimization #269

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
paint by county
  • Loading branch information
nofurtherinformation committed Feb 5, 2025
commit d6ffb5772051c3dc370311933e6a8aa96ae98469
7 changes: 7 additions & 0 deletions app/src/app/utils/featureCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ class FeatureCache {
return results
}

searchIds(
prefix:string
): [string, Data][] {
const ids = Object.keys(this.features).filter((id) => id.startsWith(prefix));
return ids.map((id) => [id, this.features[id].properties]);
}

clear(){
this.tree.clear();
this.features = {};
Expand Down
6 changes: 3 additions & 3 deletions app/src/app/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ export const getFeaturesIntersectingCounties = (
const fips = countyFeatures[0].properties.STATEFP + countyFeatures[0].properties.COUNTYFP;
const {mapDocument, shatterIds, checkParentsToHeal} = useMapStore.getState();
const filterPrefix = mapDocument?.parent_layer.includes('vtd') ? 'vtd:' : '';
const cachedParentFeatures = idCache
.getFiltered(`${filterPrefix}${fips}`)
const cachedParentFeatures = featureCache
.searchIds(`${filterPrefix}${fips}`)
.map(([id, properties]) => ({
source: BLOCK_SOURCE_ID,
sourceLayer: mapDocument?.parent_layer,
id,
...properties,
properties,
}));

const childFeatures = shatterIds.children.size
Expand Down
Loading