fix(map): remove coordinate swap, properly format basePath filter with quoting

Revert coordinate transformation (PhotoPrism already returns correct [lng,lat] format).
Fix basePath filter query string to properly quote paths with special characters
and add wildcard suffix using same quoteIfNeeded logic as filters store.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-06-30 21:08:04 +02:00
parent 400b215036
commit 52ab3b6840
2 changed files with 9 additions and 18 deletions

View File

@@ -590,23 +590,6 @@ export async function listGeo(q = ''): Promise<PpGeoCollection> {
params: { count: 50000, q: q || undefined }
});
// PhotoPrism's geo endpoint returns coordinates as [lat, lng] but GeoJSON
// (and MapLibre) expect [lng, lat]. Swap the coordinates in each feature.
if (data.features) {
for (const feature of data.features) {
if (feature.geometry.type === 'Point' && Array.isArray(feature.geometry.coordinates)) {
const [lat, lng] = feature.geometry.coordinates;
feature.geometry.coordinates = [lng, lat];
}
}
}
// Also swap bbox if present: [minLat, minLng, maxLat, maxLng] → [minLng, minLat, maxLng, maxLat]
if (data.bbox && data.bbox.length === 4) {
const [minLat, minLng, maxLat, maxLng] = data.bbox;
data.bbox = [minLng, minLat, maxLng, maxLat];
}
return data;
}

View File

@@ -13,9 +13,17 @@
import { setAnchor, setFocused, setOrder } from '$lib/stores/selection.svelte';
import Toolbar from '$lib/components/layout/Toolbar.svelte';
// Helper to quote if needed (matches filters.svelte.ts logic)
function quoteIfNeeded(v: string): string {
if (!v) return '';
if (/^[A-Za-z0-9_\-./]+$/.test(v)) return v;
return `"${v.replace(/"/g, '\\"')}"`;
}
const geoQuery = createQuery<PpGeoCollection>(() => {
const bp = userBasePath();
const q = bp ? `path:${bp}*` : '';
// Build path filter: add wildcard first, then quote if needed
const q = bp ? `path:${quoteIfNeeded(bp + '*')}` : '';
return {
queryKey: ['geo', bp],
queryFn: () => listGeo(q),