More FE changes

This commit is contained in:
Andras Schmelczer 2026-05-09 09:43:41 +01:00
parent f114ada255
commit a48eb945e0
48 changed files with 4127 additions and 1751 deletions

View file

@ -17,14 +17,12 @@ export class ScreenshotCache {
/**
* Build a cache key by quantizing view params and hashing.
* - lat/lon quantized to 2 decimal places
* - zoom quantized to integer
* - filters, configurable filters, and POI categories sorted alphabetically
* lat/lon are rounded to 2 decimals and zoom to an integer so nearby views
* share a cache entry; all other params are sorted for order-independence.
*/
buildKey(params: URLSearchParams): string {
const normalized: Record<string, string> = {};
// Quantize lat/lon/zoom
const lat = params.get('lat');
const lon = params.get('lon');
const zoom = params.get('zoom');
@ -34,44 +32,10 @@ export class ScreenshotCache {
normalized.zoom = Math.round(parseFloat(zoom)).toString();
}
// Sort filters
const filters = params.getAll('filter').sort();
if (filters.length > 0) {
normalized.filters = filters.join(',');
}
const schools = params.getAll('school').sort();
if (schools.length > 0) {
normalized.school = schools.join(',');
}
const crimes = params.getAll('crime').sort();
if (crimes.length > 0) {
normalized.crime = crimes.join(',');
}
// Sort POI categories
const pois = params.getAll('poi').sort();
if (pois.length > 0) {
normalized.poi = pois.join(',');
}
// Sort travel time entries
const tt = params.getAll('tt').sort();
if (tt.length > 0) {
normalized.tt = tt.join(',');
}
if (params.get('tab')) {
normalized.tab = params.get('tab')!;
}
if (params.get('og')) {
normalized.og = params.get('og')!;
}
if (params.get('path')) {
normalized.path = params.get('path')!;
const quantized = new Set(['lat', 'lon', 'zoom']);
const keys = [...new Set(params.keys())].filter((k) => !quantized.has(k)).sort();
for (const key of keys) {
normalized[key] = params.getAll(key).sort().join(',');
}
const input = JSON.stringify(normalized);