From 53bc27faa39201f5d09a9ea786f9738e802965af Mon Sep 17 00:00:00 2001 From: rene Date: Sat, 6 Jun 2026 12:46:12 +0200 Subject: [PATCH] Offline-Karten Runde 4: Minimal-Speicher-Modell (Modell Rene) Funkloch-Gedaechtnis = Quelle der Wahrheit, Kacheln = ableitbarer Cache: - Ephemeres Vorausladen: Prefetch-Kacheln werden bei Aufzeichnungsende geloescht, wenn die Runde kein Funkloch hatte (nur neue Keys) - Netz-Probe bei Aufzeichnung (~2min, 6s-Timeout): erkennt Funkloecher auch in bereits gespeicherten Gebieten (dort kein Remote-Miss als Signal) - clear() behaelt Zonen (filled=false) -> naechster Online-Start laedt Funkloch-Gebiete automatisch neu, auch nach 'Alles loeschen' - Start-Check mit Position: nur Zonen im 50-km-Umkreis, naechste zuerst, Coverage-Verify (faengt Eviction ab); Pfote Segment 5 = alle Zonen gefuellt - Coverage-Layer zweifarbig: Funkloch orange, manuell blau + Modal-Legende - Stub-Tests Runde 4 (Prune/Probe/clear/Naehe/Verify/Faerbung) bestanden Bump v1230 --- VERSION | 2 +- backend/static/index.html | 24 ++-- backend/static/js/app.js | 2 +- backend/static/js/map-offline.js | 168 +++++++++++++++++++------ backend/static/js/offline-indicator.js | 63 +++++++--- backend/static/js/pages/map.js | 12 +- backend/static/js/pages/routes.js | 3 +- backend/static/landing.html | 2 +- backend/static/sw.js | 2 +- docs/OFFLINE_MAPS_PLAN.md | 17 +++ 10 files changed, 221 insertions(+), 74 deletions(-) diff --git a/VERSION b/VERSION index c31e0ca..dd09130 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1229 \ No newline at end of file +1230 \ No newline at end of file diff --git a/backend/static/index.html b/backend/static/index.html index 1e0e49a..9dc36be 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -86,14 +86,14 @@ Ban Yaro - + - - - - - + + + + + @@ -612,11 +612,11 @@ - - - - - + + + + + @@ -626,7 +626,7 @@ - + diff --git a/backend/static/js/app.js b/backend/static/js/app.js index 41835b0..e5c3ef7 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,7 +3,7 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '1229'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '1230'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt window.APP_VER = APP_VER; // global verfügbar für andere Module (z.B. offline-indicator) window.APP_VERSION = APP_VERSION; diff --git a/backend/static/js/map-offline.js b/backend/static/js/map-offline.js index 92d6e88..1a322a4 100644 --- a/backend/static/js/map-offline.js +++ b/backend/static/js/map-offline.js @@ -37,6 +37,7 @@ window.MapOffline = (function () { } var _get = function (k) { return _req(STORE, 'readonly', function (os) { return os.get(k); }); }; var _put = function (k, v) { return _req(STORE, 'readwrite', function (os) { os.put(v, k); }); }; + var _del = function (k) { return _req(STORE, 'readwrite', function (os) { os.delete(k); }); }; var _count = function () { return _req(STORE, 'readonly', function (os) { return os.count(); }); }; var _metaGet = function (k) { return _req(META, 'readonly', function (os) { return os.get(k); }); }; var _metaPut = function (k, v) { return _req(META, 'readwrite', function (os) { os.put(v, k); }); }; @@ -291,8 +292,8 @@ window.MapOffline = (function () { .then(function (gb) { state.bytes += gb; return _cachePois(_bboxAround(lat, lon, radiusKm)); }) .then(function (pc) { poiCount = pc; - return _addRegion({ lat: lat, lon: lon, radiusKm: radiusKm, tiles: state.stored, - bytes: state.bytes, pois: poiCount, savedAt: Date.now() }); + return _addRegion({ type: opts.type || 'gebiet', lat: lat, lon: lon, radiusKm: radiusKm, + tiles: state.stored, bytes: state.bytes, pois: poiCount, savedAt: Date.now() }); }) .then(function () { return _bumpTotal(state.bytes); }) .then(function () { return { tiles: state.stored, bytes: state.bytes, pois: poiCount, radiusKm: radiusKm }; }); @@ -311,7 +312,7 @@ window.MapOffline = (function () { function _bumpTotal(bytes) { if (!bytes) return Promise.resolve(); return _metaGet('totalBytes') - .then(function (t) { return _metaPut('totalBytes', (t || 0) + bytes); }) + .then(function (t) { return _metaPut('totalBytes', Math.max(0, (t || 0) + bytes)); }) .catch(function () {}); } function _overCap() { @@ -330,14 +331,23 @@ window.MapOffline = (function () { } catch (e) {} } - // {lat,lon} während aktiver Aufzeichnung, sonst null. Nebeneffekt (Runde 3): - // ROLLENDES VORAUSLADEN — solange Empfang da ist, alle ~400 m die fehlenden Kacheln - // um die aktuelle Position still mitnehmen. Deckt den Weg + die Anfahrt ab, BEVOR - // man ins Funkloch läuft (greift schon beim ersten Besuch, anders als das Gedächtnis). + // {lat,lon} während aktiver Aufzeichnung, sonst null. Nebeneffekte (Runde 3): + // 1. ROLLENDES VORAUSLADEN — solange Empfang da ist, alle ~400 m die fehlenden Kacheln + // um die aktuelle Position still mitnehmen. EPHEMER: Hatte die Runde KEIN Funkloch, + // wird das Vorausgeladene am Ende wieder gelöscht — gespeichert bleibt nur, was + // wegen fehlenden Netzes nötig ist + manuell Hinzugefügtes (Modell René 2026-06-08). + // 2. NETZ-PROBE — erkennt Funklöcher auch in BEREITS GESPEICHERTEN Gebieten (dort + // kommen Kacheln aus IndexedDB → kein Remote-Miss als Signal). var _lastPre = null, _preActive = false; + var _preKeys = [], _preBytes = 0, _recHadDeadzone = false; function setGps(pos) { + if (!pos) { // Aufzeichnung beendet + _gps = null; _lastPre = null; + _prunePrefetch(); + return; + } _gps = pos; - if (!pos) { _lastPre = null; return; } + _probeNet(pos); if (_preActive || !navigator.onLine) return; if (_lastPre && _distKm(_lastPre.lat, _lastPre.lon, pos.lat, pos.lon) < 0.4) return; _preActive = true; @@ -349,6 +359,36 @@ window.MapOffline = (function () { .then(function () { _preActive = false; }); } + // Aktive Netz-Probe (alle ~2 Min bei Aufzeichnung): kleiner Request mit Timeout. + // Fehlschlag = Funkloch an dieser Position — unabhängig davon, ob die Kacheln + // hier längst lokal liegen. (navigator.onLine lügt bei Schwachempfang.) + var _lastProbe = 0; + function _probeNet(pos) { + var now = Date.now(); + if (now - _lastProbe < 120000) return; + _lastProbe = now; + var p = { lat: pos.lat, lon: pos.lon }; + var ctrl = (typeof AbortController !== 'undefined') ? new AbortController() : null; + var timer = ctrl && setTimeout(function () { try { ctrl.abort(); } catch (e) {} }, 6000); + fetch('/api/version', { cache: 'no-store', signal: ctrl ? ctrl.signal : undefined }) + .then(function (r) { if (!r.ok) throw new Error('probe ' + r.status); }) + .catch(function () { + _recHadDeadzone = true; + markDeadZone(p.lat, p.lon); + }) + .then(function () { if (timer) clearTimeout(timer); }); + } + + // Vorausgeladenes wieder entfernen, wenn die Runde KEIN Funkloch hatte. + function _prunePrefetch() { + var keys = _preKeys, bytes = _preBytes, had = _recHadDeadzone; + _preKeys = []; _preBytes = 0; _recHadDeadzone = false; + if (had || !keys.length) return Promise.resolve(); + var chain = Promise.resolve(); + keys.forEach(function (k) { chain = chain.then(function () { return _del(k).catch(function () {}); }); }); + return chain.then(function () { return _bumpTotal(-bytes); }); + } + // z14-Kacheln ±n um lat/lon (+ Eltern z10–13) — NUR fehlende, still, ohne Region-Eintrag. function _prefetchRing(lat, lon, n) { var cx = _x(lon, MAXZOOM), cy = _y(lat, MAXZOOM), seen = {}, list = []; @@ -368,7 +408,12 @@ window.MapOffline = (function () { var state = { done: 0, bytes: 0, stored: 0 }; return chain .then(function () { return missing.length ? _fetchTiles(missing, state, null) : null; }) - .then(function () { return _bumpTotal(state.bytes); }); + .then(function () { + // Nur NEU gespeicherte Keys fürs Prune merken — Bestand bleibt unangetastet. + missing.forEach(function (t) { _preKeys.push(t[0] + '/' + t[1] + '/' + t[2]); }); + _preBytes += state.bytes; + return _bumpTotal(state.bytes); + }); } function _distKm(aLat, aLon, bLat, bLon) { @@ -378,6 +423,7 @@ window.MapOffline = (function () { function _noteRemoteMiss() { if (!_gps) return; + _recHadDeadzone = true; // Vorausgeladenes dieser Runde behalten var now = Date.now(); if (now - _lastZoneNote < 120000) return; // max. 1 Eintrag / 2 Min _lastZoneNote = now; @@ -395,32 +441,55 @@ window.MapOffline = (function () { }).catch(function () {}); } - // Offene Funkloch-Zonen budget-getrieben nachladen (nur online sinnvoll). - // Dort wo Netz verfügbar ist, braucht man keine Offline-Karten — gespeichert - // wird gezielt da, wo es ausfiel. Liefert die Anzahl gefüllter Zonen. + // Funkloch-Zonen nachladen (nur online sinnvoll). Dort wo Netz verfügbar ist, braucht + // man keine Offline-Karten — gespeichert wird gezielt da, wo es ausfiel. + // opts {lat, lon, maxKm:50}: mit Position werden nur Zonen im Umkreis betrachtet + // (Speicher minimal halten) und nächstgelegene zuerst geladen. Gefüllte Zonen werden + // VERIFIZIERT (Zentrums-Kachel noch da?) — fängt „Alles löschen" und iOS-Eviction ab: + // die Gebiete kommen beim nächsten Start automatisch wieder (Modell René 2026-06-08). + // Liefert die Anzahl (neu) gefüllter Zonen. var _autofillActive = false; - function autoFillDeadZones() { + function autoFillDeadZones(opts) { + opts = opts || {}; + var maxKm = opts.maxKm || 50; if (_autofillActive || !navigator.onLine) return Promise.resolve(0); _autofillActive = true; - var filled = 0; + var filled = 0, all = null; return _overCap().then(function (over) { if (over) return null; // Speicher-Cap erreicht → kein automatisches Nachladen mehr return _metaGet('deadzones'); }).then(function (zones) { - if (zones === null) return 0; - zones = zones || []; - var open = zones.filter(function (z) { return !z.filled; }); - if (!open.length) return 0; - var chain = Promise.resolve(); - open.forEach(function (z) { - chain = chain.then(function () { - return downloadAround(z.lat, z.lon, { budgetMB: 5 }).then(function (res) { - if (res.bytes > 0) { z.filled = true; filled++; } - }).catch(function () {}); + if (zones === null || zones === undefined) return 0; + all = zones; + var cand = opts.lat == null ? zones.slice() : zones.filter(function (z) { + return _distKm(z.lat, z.lon, opts.lat, opts.lon) <= maxKm; + }); + if (!cand.length) return 0; + // Verify: als gefüllt markierte Zonen ohne lokale Zentrums-Kachel wieder öffnen. + var verify = Promise.resolve(); + cand.forEach(function (z) { + verify = verify.then(function () { + if (!z.filled) return; + return _get(MAXZOOM + '/' + _x(z.lon, MAXZOOM) + '/' + _y(z.lat, MAXZOOM)) + .then(function (hit) { if (!hit) z.filled = false; }); }); }); - return chain.then(function () { return _metaPut('deadzones', zones); }) - .then(function () { return filled; }); + return verify.then(function () { + var open = cand.filter(function (z) { return !z.filled; }); + if (opts.lat != null) open.sort(function (a, b) { + return _distKm(a.lat, a.lon, opts.lat, opts.lon) - _distKm(b.lat, b.lon, opts.lat, opts.lon); + }); + var chain = Promise.resolve(); + open.forEach(function (z) { + chain = chain.then(function () { + return downloadAround(z.lat, z.lon, { budgetMB: 5, type: 'funkloch' }).then(function (res) { + if (res.bytes > 0) { z.filled = true; filled++; } + }).catch(function () {}); + }); + }); + return chain.then(function () { return _metaPut('deadzones', all); }) + .then(function () { return filled; }); + }); }).then(function (n) { _autofillActive = false; return n; }, function () { _autofillActive = false; return 0; }); } @@ -521,25 +590,35 @@ window.MapOffline = (function () { } // ---- Coverage-Layer ---------------------------------------------------------- - // GeoJSON der gespeicherten z14-Kacheln — zeigt auf der Karte, welche Bereiche offline da sind. + // GeoJSON der gespeicherten z14-Kacheln — zeigt auf der Karte, welche Bereiche offline + // da sind. properties.kind: 'funkloch' (Kachel liegt in einer Funkloch-Region, wird + // anders eingefärbt — Wunsch René 2026-06-08) oder 'manuell'. function _tile2lat(y, z) { var m = Math.PI - 2 * Math.PI * y / Math.pow(2, z); return 180 / Math.PI * Math.atan(0.5 * (Math.exp(m) - Math.exp(-m))); } function coverage() { var re = new RegExp('^' + MAXZOOM + '/(\\d+)/(\\d+)$'); - return _req(STORE, 'readonly', function (os) { return os.getAllKeys(); }).then(function (keys) { - var feats = []; - (keys || []).forEach(function (k) { - var m = re.exec(k); - if (!m) return; - var x = +m[1], y = +m[2], n2 = Math.pow(2, MAXZOOM); - var west = x / n2 * 360 - 180, east = (x + 1) / n2 * 360 - 180; - var north = _tile2lat(y, MAXZOOM), south = _tile2lat(y + 1, MAXZOOM); - feats.push({ type: 'Feature', properties: {}, geometry: { type: 'Polygon', - coordinates: [[[west, south], [east, south], [east, north], [west, north], [west, south]]] } }); + return _metaGet('regions').then(function (regions) { + var fz = (regions || []).filter(function (r) { return r.type === 'funkloch'; }); + return _req(STORE, 'readonly', function (os) { return os.getAllKeys(); }).then(function (keys) { + var feats = []; + (keys || []).forEach(function (k) { + var m = re.exec(k); + if (!m) return; + var x = +m[1], y = +m[2], n2 = Math.pow(2, MAXZOOM); + var west = x / n2 * 360 - 180, east = (x + 1) / n2 * 360 - 180; + var north = _tile2lat(y, MAXZOOM), south = _tile2lat(y + 1, MAXZOOM); + var cLat = (north + south) / 2, cLon = (west + east) / 2; + var isFz = fz.some(function (r) { + return _distKm(r.lat, r.lon, cLat, cLon) <= (r.radiusKm || 5) + 0.8; + }); + feats.push({ type: 'Feature', properties: { kind: isFz ? 'funkloch' : 'manuell' }, + geometry: { type: 'Polygon', + coordinates: [[[west, south], [east, south], [east, north], [west, north], [west, south]]] } }); + }); + return { type: 'FeatureCollection', features: feats }; }); - return { type: 'FeatureCollection', features: feats }; }); } @@ -555,9 +634,20 @@ window.MapOffline = (function () { }); } function hasRegion() { return stats().then(function (s) { return s.count > 0; }).catch(function () { return false; }); } + // „Alles löschen" entfernt Kacheln/Marker/Regionen — das FUNKLOCH-GEDÄCHTNIS bleibt + // (Quelle der Wahrheit, Modell René 2026-06-08): Zonen werden auf filled:false gesetzt + // und beim nächsten Online-Start in Positionsnähe automatisch neu geladen. function clear() { return _req(STORE, 'readwrite', function (os) { os.clear(); }) - .then(function () { return _req(META, 'readwrite', function (os) { os.clear(); }); }); + .then(function () { return _metaGet('deadzones'); }) + .then(function (zones) { + return _req(META, 'readwrite', function (os) { os.clear(); }).then(function () { + if (zones && zones.length) { + zones.forEach(function (z) { z.filled = false; }); + return _metaPut('deadzones', zones); + } + }); + }); } return { diff --git a/backend/static/js/offline-indicator.js b/backend/static/js/offline-indicator.js index 54a06be..88ccc00 100644 --- a/backend/static/js/offline-indicator.js +++ b/backend/static/js/offline-indicator.js @@ -25,9 +25,11 @@ window.OfflineIndicator = (() => { function _offlineTilesMode() { try { return !!(window.BY && BY.offlineTiles()); } catch (e) { return false; } } - // Ist eine Offline-Region (Vektorkacheln) in IndexedDB gespeichert? (ohne MapOffline zu laden) - // WICHTIG: dasselbe Schema/Version wie map-offline.js anlegen — sonst legt ein versionsloses open() - // die DB leer an und MapOffline kann seine Stores nicht mehr erstellen. + // Offline-Ready (Pfote Segment 5) — ohne MapOffline/GL-Stack zu laden. + // Semantik (Modell René 2026-06-08): Gibt es bekannte FUNKLOCH-Zonen, zählt deren + // Füllstand (alle gefüllt = grün); ohne bekannte Zonen wie bisher: irgendein Gebiet da. + // WICHTIG: dasselbe Schema/Version wie map-offline.js anlegen — sonst legt ein versionsloses + // open() die DB leer an und MapOffline kann seine Stores nicht mehr erstellen. function _offlineRegionStored() { return new Promise(res => { try { @@ -39,10 +41,18 @@ window.OfflineIndicator = (() => { }; r.onsuccess = () => { const db = r.result; - if (!db.objectStoreNames.contains('tiles')) { db.close(); return res(false); } - const cnt = db.transaction('tiles', 'readonly').objectStore('tiles').count(); - cnt.onsuccess = () => { res(cnt.result > 0); db.close(); }; - cnt.onerror = () => { res(false); db.close(); }; + if (!db.objectStoreNames.contains('tiles') || !db.objectStoreNames.contains('meta')) { + db.close(); return res(false); + } + const mz = db.transaction('meta', 'readonly').objectStore('meta').get('deadzones'); + mz.onsuccess = () => { + const zones = mz.result || []; + if (zones.length) { res(zones.every(z => z.filled)); db.close(); return; } + const cnt = db.transaction('tiles', 'readonly').objectStore('tiles').count(); + cnt.onsuccess = () => { res(cnt.result > 0); db.close(); }; + cnt.onerror = () => { res(false); db.close(); }; + }; + mz.onerror = () => { res(false); db.close(); }; }; r.onerror = () => res(false); } catch (e) { res(false); } @@ -224,9 +234,10 @@ window.OfflineIndicator = (() => { } catch (e) { console.warn('Offline-Region-Download fehlgeschlagen:', e); } } - // Gibt es offene (ungefüllte) Funkloch-Zonen? — direkt aus IndexedDB, OHNE den - // GL-Stack zu laden (gleiches Schema/Version wie map-offline.js, s. Warnung oben). - function _openDeadZonesStored() { + // Gibt es überhaupt Funkloch-Zonen? — direkt aus IndexedDB, OHNE den GL-Stack zu + // laden. Auch GEFÜLLTE zählen: der Start-Check verifiziert deren Kacheln (nach + // „Alles löschen"/Eviction werden sie automatisch neu geladen, Modell René 2026-06-08). + function _anyDeadZonesStored() { return new Promise(res => { try { const r = indexedDB.open('by-offline-tiles', 1); @@ -239,7 +250,7 @@ window.OfflineIndicator = (() => { const db = r.result; if (!db.objectStoreNames.contains('meta')) { db.close(); return res(false); } const rq = db.transaction('meta', 'readonly').objectStore('meta').get('deadzones'); - rq.onsuccess = () => { res((rq.result || []).some(z => !z.filled)); db.close(); }; + rq.onsuccess = () => { res((rq.result || []).length > 0); db.close(); }; rq.onerror = () => { res(false); db.close(); }; }; r.onerror = () => res(false); @@ -247,8 +258,29 @@ window.OfflineIndicator = (() => { }); } - // Funkloch-Zonen automatisch füllen, sobald Netz da ist — das Gerät lernt selbst, - // wo Offline-Karten nötig sind (dort wo Netz ist, braucht es keine). + // Letzte bekannte Position: GPS nur wenn Permission schon erteilt (kein Popup), + // sonst localStorage-Stand (gesetzt von wetter.js u.a.). + async function _lastKnownPos() { + try { + if (navigator.permissions && navigator.geolocation) { + const perm = await navigator.permissions.query({ name: 'geolocation' }); + if (perm.state === 'granted') { + const pos = await new Promise(res => + navigator.geolocation.getCurrentPosition(p => res(p), () => res(null), { timeout: 5000 })); + if (pos) return { lat: pos.coords.latitude, lon: pos.coords.longitude }; + } + } + } catch {} + try { + const raw = localStorage.getItem(LS_LAST_POS); + if (raw) { const p = JSON.parse(raw); if (p?.lat != null) return { lat: p.lat, lon: p.lon }; } + } catch {} + return null; + } + + // Funkloch-Zonen automatisch füllen/verifizieren, sobald Netz da ist — das Gerät lernt + // selbst, wo Offline-Karten nötig sind. Mit Position werden nur Zonen im Umkreis + // (50 km) geladen → Speicher bleibt minimal, ferne Zonen kommen, wenn man dort ist. let _autoFillTimer = null; function _scheduleAutoFill(delayMs) { if (!_offlineTilesMode()) return; @@ -256,9 +288,10 @@ window.OfflineIndicator = (() => { _autoFillTimer = setTimeout(async () => { if (!navigator.onLine) return; try { - if (!(await _openDeadZonesStored())) return; // nichts zu tun → GL-Stack nicht laden + if (!(await _anyDeadZonesStored())) return; // nichts zu tun → GL-Stack nicht laden + const pos = await _lastKnownPos(); await UI.loadMapLibreUI(); - const n = await window.MapOffline?.autoFillDeadZones?.(); + const n = await window.MapOffline?.autoFillDeadZones?.(pos ? { lat: pos.lat, lon: pos.lon } : {}); if (n) { UI.toast?.info(`${n} Funkloch-${n === 1 ? 'Gebiet' : 'Gebiete'} automatisch offline gespeichert.`); refresh(); diff --git a/backend/static/js/pages/map.js b/backend/static/js/pages/map.js index e179322..7a436ee 100644 --- a/backend/static/js/pages/map.js +++ b/backend/static/js/pages/map.js @@ -2235,14 +2235,16 @@ window.Page_map = (() => { } const gj = await MapOffline.coverage().catch(() => null); if (!gj || !gj.features.length) { UI.toast.info('Noch keine Offline-Bereiche gespeichert.'); return false; } + // Funkloch-Gebiete orange, manuell gespeicherte blau (Wunsch René 2026-06-08). + const covColor = ['match', ['get', 'kind'], 'funkloch', '#f59e0b', '#3b82f6']; if (_map.getSource('by-off-cov')) { _map.getSource('by-off-cov').setData(gj); } else { _map.addSource('by-off-cov', { type: 'geojson', data: gj }); _map.addLayer({ id: 'by-off-cov', type: 'fill', source: 'by-off-cov', - paint: { 'fill-color': '#3b82f6', 'fill-opacity': 0.15 } }); + paint: { 'fill-color': covColor, 'fill-opacity': 0.15 } }); _map.addLayer({ id: 'by-off-cov-line', type: 'line', source: 'by-off-cov', - paint: { 'line-color': '#3b82f6', 'line-opacity': 0.35, 'line-width': 0.5 } }); + paint: { 'line-color': covColor, 'line-opacity': 0.35, 'line-width': 0.5 } }); } _covOn = true; return true; @@ -2268,6 +2270,10 @@ window.Page_map = (() => { +

+ manuell gespeichert  ·  + Funkloch (automatisch) +

${regions.length ? `` : ''} `, @@ -2286,7 +2292,7 @@ window.Page_map = (() => { await MapOffline.clear().catch(() => {}); _setCoverage(false); UI.modal.close(); - UI.toast.success('Offline-Karten gelöscht.'); + UI.toast.success('Offline-Karten gelöscht. Bekannte Funkloch-Gebiete werden beim nächsten Start automatisch neu geladen.'); window.OfflineIndicator?.refresh(); }); } diff --git a/backend/static/js/pages/routes.js b/backend/static/js/pages/routes.js index 68729c7..220496d 100644 --- a/backend/static/js/pages/routes.js +++ b/backend/static/js/pages/routes.js @@ -2488,7 +2488,8 @@ window.Page_routes = (() => { else { gl.addSource('rd-off-cov', { type: 'geojson', data: gj }); gl.addLayer({ id: 'rd-off-cov', type: 'fill', source: 'rd-off-cov', - paint: { 'fill-color': '#3b82f6', 'fill-opacity': 0.15 } }); + paint: { 'fill-color': ['match', ['get', 'kind'], 'funkloch', '#f59e0b', '#3b82f6'], + 'fill-opacity': 0.15 } }); } } } catch (e) {} diff --git a/backend/static/landing.html b/backend/static/landing.html index d2f572d..8b96abb 100644 --- a/backend/static/landing.html +++ b/backend/static/landing.html @@ -4,7 +4,7 @@ - + Ban Yaro — Die Hunde-App für Deutschland, Österreich & Schweiz diff --git a/backend/static/sw.js b/backend/static/sw.js index 27b8baf..fd03d36 100644 --- a/backend/static/sw.js +++ b/backend/static/sw.js @@ -4,7 +4,7 @@ ============================================================ */ // ← EINZIGE Stelle für die Version — STATIC_ASSETS und CACHE_VERSION leiten sich ab -const VER = '1229'; +const VER = '1230'; const CACHE_VERSION = `by-v${VER}`; const CACHE_STATIC = `${CACHE_VERSION}-static`; const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten diff --git a/docs/OFFLINE_MAPS_PLAN.md b/docs/OFFLINE_MAPS_PLAN.md index d7e7af1..bbafc36 100644 --- a/docs/OFFLINE_MAPS_PLAN.md +++ b/docs/OFFLINE_MAPS_PLAN.md @@ -86,6 +86,23 @@ nach bestandenen Gerätetests Runde 1+2). localhost = Leaflet/AUS. Achtung Node 21+: eingebautes `navigator`-Global schluckt `global.navigator=`-Stubs — `Object.defineProperty(globalThis, 'navigator', …)` verwenden. +**✅ Runde 4 — Minimal-Speicher-Modell (2026-06-08, Modell René):** +Prinzip: Gespeichert bleibt NUR, was wegen Funklöchern nötig ist + manuell Hinzugefügtes +(jeweils mit allen Markern + Warnungen). Das Funkloch-Gedächtnis ist die QUELLE DER WAHRHEIT, +die Kacheln sind jederzeit neu ableitbarer Cache. +- **Ephemeres Vorausladen:** Rolling-Prefetch-Kacheln werden bei Aufzeichnungsende GELÖSCHT, + wenn die Runde kein Funkloch hatte (nur neu gespeicherte Keys; Bestand unangetastet). +- **Netz-Probe bei Aufzeichnung** (alle ~2 Min, /api/version, 6-s-Timeout): erkennt Funklöcher + auch in BEREITS GESPEICHERTEN Gebieten — dort kommen Kacheln aus IndexedDB, es gibt keinen + Remote-Miss als Signal (Lücke von René gefunden). +- **clear() behält das Funkloch-Gedächtnis** (Zonen → filled:false): Beim nächsten Online-Start + werden Funkloch-Gebiete automatisch neu geladen, auch wenn man alles gelöscht hat. +- **Start-Check mit Position:** autoFillDeadZones({lat,lon,maxKm:50}) — nur Zonen im Umkreis + (Speicher minimal), nächstgelegene zuerst; VERIFIZIERT gefüllte Zonen (Zentrums-Kachel da?) + → fängt Löschen + iOS-Eviction ab. Pfote-Segment 5 = „alle bekannten Funkloch-Zonen gefüllt". +- **Coverage-Layer zweifarbig:** Funkloch-Gebiete ORANGE (#f59e0b), manuelle BLAU (#3b82f6); + Legende im Offline-Modal; Regionen tragen type 'funkloch'/'gebiet'/'korridor'/'ausschnitt'. + **🔲 Offen (Backlog):** - Echte LRU-Eviction (Refcounting/Region-Zuordnung der Kacheln), wenn Nutzer real ans Cap kommen. - Rechteck-Zeichnen als präzisere Bereichsauswahl (Viewport-Variante deckt den Hauptfall ab).