Skip to content

Commit

Permalink
dont query the entire damn globe at once
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed Feb 19, 2025
1 parent 6e5a880 commit 0b7d76c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
16 changes: 9 additions & 7 deletions src/components/addLayers/addLiveDots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ export async function makeCircleLayers(map: Map, darkMode: boolean, layerspercat
['literal', [0, -60]]
];

const pointing_shell_light_image = await map.loadImage('/icons/pointing-shell-light.png');
map.addImage('pointingshelllight', pointing_shell_light_image.data);
const [pointing_shell_light_image, pointing_filled_image, pointing_shell_image] =
await Promise.all([
map.loadImage('/icons/pointing-shell-light.png'),
map.loadImage('/icons/pointing-filled.png'),
map.loadImage('/icons/pointing-shell.png')
]);

const pointing_filled_image = await map.loadImage('/icons/pointing-filled.png');
map.addImage('pointingshelllight', pointing_shell_light_image.data);
map.addImage('pointingcoloured', pointing_filled_image.data, { sdf: true });

const pointing_shell_image = await map.loadImage('/icons/pointing-shell.png');
map.addImage('pointingshell', pointing_shell_image.data);

console.log('shells loaded');
Expand All @@ -80,7 +82,7 @@ export async function makeCircleLayers(map: Map, darkMode: boolean, layerspercat
//'circle-emissive-strength': 1,
'circle-opacity': 0.5
},
minzoom: 8.5
minzoom: 6
});

map.addLayer({
Expand Down Expand Up @@ -294,7 +296,7 @@ export async function makeCircleLayers(map: Map, darkMode: boolean, layerspercat
'icon-color': ['get', 'contrastdarkmodebearing'],
'icon-opacity': 1
},
minZoom: 2,
minZoom: 4.5,
layout: {
'icon-image': 'pointingcoloured',
'icon-allow-overlap': true,
Expand Down
17 changes: 15 additions & 2 deletions src/components/fetch_realtime_vehicle_locations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,33 @@ export function fetch_realtime_vehicle_locations(
const categories_to_request: string[] = [];

if (layersettings.bus.visible) {
if (map.getZoom() > 6) {

categories_to_request.push('bus');
}


}

if (map.getZoom() > 3) {
if (layersettings.intercityrail.visible) {
categories_to_request.push('rail');
}
}

if (layersettings.localrail.visible) {
categories_to_request.push('metro');
if (map.getZoom() > 4) {
if (layersettings.localrail.visible) {
categories_to_request.push('metro');
}
}

if (map.getZoom() > 3) {


if (layersettings.other.visible) {
categories_to_request.push('other');
}
}

const realtime_chateaus_in_frame = get(chateaus_in_frame).filter((chateau_id: string) => {
return chateau_to_realtime_feed_lookup[chateau_id].length > 0;
Expand Down

0 comments on commit 0b7d76c

Please sign in to comment.