trackme share: include POI near the ride (bbox of route+track), shown on the viewer
This commit is contained in:
parent
ab1259eb20
commit
06ffab66a1
1 changed files with 15 additions and 2 deletions
|
|
@ -4897,13 +4897,26 @@ async function shareRideContext() {
|
||||||
let segs = buildRoadSegments(await DB.getRoadPoints());
|
let segs = buildRoadSegments(await DB.getRoadPoints());
|
||||||
roads = segs.map(s => ({ p: s.pts.map(q => [r5(q.lat), r5(q.lon)]), t: s.atype || "b" }));
|
roads = segs.map(s => ({ p: s.pts.map(q => [r5(q.lat), r5(q.lon)]), t: s.atype || "b" }));
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
// POI near the ride only (bbox of route+track + margin) — the full set is too big to send.
|
||||||
|
let pois = [];
|
||||||
|
try {
|
||||||
|
let all = await POI.load();
|
||||||
|
let bpts = track.concat(route);
|
||||||
|
if (all && all.length && bpts.length) {
|
||||||
|
let minLa = 1e9, maxLa = -1e9, minLo = 1e9, maxLo = -1e9;
|
||||||
|
for (let p of bpts) { if (p[0] < minLa) minLa = p[0]; if (p[0] > maxLa) maxLa = p[0]; if (p[1] < minLo) minLo = p[1]; if (p[1] > maxLo) maxLo = p[1]; }
|
||||||
|
minLa -= 0.05; maxLa += 0.05; minLo -= 0.07; maxLo += 0.07; // ~5 km margin
|
||||||
|
pois = all.filter(p => p.la >= minLa && p.la <= maxLa && p.lo >= minLo && p.lo <= maxLo)
|
||||||
|
.map(p => ({ la: r5(p.la), lo: r5(p.lo), c: p.c, n: p.n }));
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
showToast("Отдаю смотрящему...");
|
showToast("Отдаю смотрящему...");
|
||||||
try {
|
try {
|
||||||
let raw = await window.__TAURI__.core.invoke("http_request", {
|
let raw = await window.__TAURI__.core.invoke("http_request", {
|
||||||
url: shareUrl, method: "POST", body: JSON.stringify({ token, route, roads, track })
|
url: shareUrl, method: "POST", body: JSON.stringify({ token, route, roads, track, pois })
|
||||||
});
|
});
|
||||||
let res = JSON.parse(raw || "{}");
|
let res = JSON.parse(raw || "{}");
|
||||||
if (res.ok) showToast(`Отдано: маршрут ${route.length}, дороги ${roads.length}, трек ${track.length}`);
|
if (res.ok) showToast(`Отдано: маршрут ${route.length}, дороги ${roads.length}, трек ${track.length}, POI ${pois.length}`);
|
||||||
else appAlert("Не отдалось: " + (res.error || "ошибка"));
|
else appAlert("Не отдалось: " + (res.error || "ошибка"));
|
||||||
} catch (e) { appAlert("Не отдалось: " + (e.message || e)); }
|
} catch (e) { appAlert("Не отдалось: " + (e.message || e)); }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue