fix(map): geofence delete, vessel snapshots, sentinel cache, news briefs
Geofences could be drawn but not removed. VesselAPI Hormuz dots vanished
on restart and DVR skipped between the 5 daily polls. Sentinel-1 re-hit
STAC on every pan and often painted a neighbouring swath. Executive
briefs truncated; ticker stayed empty unless something was critical.
- Layer-panel list + polygon popup DELETE /api/geofences/{id}
- Persist VesselAPI polls to vessels (UTC-day purge, DVR as-of, boot hydrate)
- Cache Sentinel-1 by 2° cell; pick covering scene; clip Leaflet tiles
- Retry truncated LLM JSON; ticker falls back to medium/low; 3-min HUD poll
This commit is contained in:
parent
fdf5969e27
commit
c48788d4b6
20 changed files with 669 additions and 57 deletions
|
|
@ -358,6 +358,11 @@
|
|||
.lp-future .lp-name { cursor: not-allowed; }
|
||||
.lp-error { color: var(--red); font-size: 0.66rem; }
|
||||
.lp-note { font-size: 0.6rem; color: var(--muted); opacity: 0.85; line-height: 1.35; }
|
||||
.gf-list { display: flex; flex-direction: column; gap: 0.22rem; max-height: 8rem; overflow-y: auto; }
|
||||
.gf-item { display: flex; justify-content: space-between; align-items: center; gap: 0.4rem; font-size: 0.64rem; }
|
||||
.gf-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
|
||||
.gf-del { background: transparent; border: 1px solid var(--magenta); color: var(--magenta); font-family: 'Share Tech Mono', monospace; font-size: 0.58rem; letter-spacing: 0.08em; text-transform: uppercase; padding: 0.12rem 0.35rem; border-radius: 3px; cursor: pointer; }
|
||||
.gf-del:hover { background: rgba(255,46,151,0.16); }
|
||||
|
||||
/* ── Camera / blip popup thumbnails ── */
|
||||
.cam-pop { min-width: 210px; max-width: 260px; }
|
||||
|
|
@ -583,6 +588,8 @@
|
|||
.tick-item .b-tag { font-family: 'Share Tech Mono', monospace; font-size: 0.6rem; color: #1c0311; background: var(--magenta); border-radius: 2px; padding: 0.08rem 0.4rem; letter-spacing: 0.1em; }
|
||||
.tick-item .b-tag.critical { background: var(--red); }
|
||||
.tick-item .b-tag.high { background: var(--amber); }
|
||||
.tick-item .b-tag.medium { background: var(--cyan); color: #041018; }
|
||||
.tick-item .b-tag.low { background: var(--muted); color: #041018; }
|
||||
.tick-item.brief:hover { color: var(--magenta); }
|
||||
.tick-item.standby { color: var(--muted); opacity: 0.75; }
|
||||
.tick-item.standby .price { color: var(--muted); }
|
||||
|
|
@ -906,7 +913,8 @@
|
|||
<div class="lp-row">
|
||||
<button class="btn" id="gf-draw" type="button" onclick="toggleGeofenceDraw()">Draw geofence</button>
|
||||
</div>
|
||||
<div class="lp-note">No Leaflet.Draw — click vertices, double-click to close. Saved to POST /api/geofences.</div>
|
||||
<div id="gf-list" class="gf-list"></div>
|
||||
<div class="lp-note">Click vertices, double-click to close. Delete a saved fence from the list or its popup.</div>
|
||||
</div>
|
||||
<div class="lp-layer">
|
||||
<div class="lp-row">
|
||||
|
|
@ -1420,7 +1428,7 @@ function initMarketTicker() {
|
|||
|
||||
/* ═══════════════ NEWS FEED + TICKER ═══════════════ */
|
||||
let newsInterval = null;
|
||||
const NEWS_REFRESH_MS = 900000; // 15-min cycle
|
||||
const NEWS_REFRESH_MS = 180000; // 3-min ticker/brief poll
|
||||
let newsTickerBuilt = false;
|
||||
|
||||
function newsEsc(s) {
|
||||
|
|
@ -1527,10 +1535,11 @@ function renderNewsTicker(articles, summaries, tickerItems) {
|
|||
if (ticks.length) {
|
||||
ticks.forEach(t => {
|
||||
const imp = String(t.importance || '').toLowerCase();
|
||||
const tag = imp === 'critical' ? 'CRITICAL' : 'HIGH';
|
||||
const tag = imp === 'critical' ? 'CRITICAL' : imp === 'high' ? 'HIGH' : imp === 'medium' ? 'MED' : 'LOW';
|
||||
const tagClass = (imp === 'critical' || imp === 'high' || imp === 'medium' || imp === 'low') ? imp : 'high';
|
||||
const loc = (t.location_name || '').trim();
|
||||
const inner =
|
||||
`<span class="b-tag ${imp === 'critical' ? 'critical' : 'high'}">${tag}</span>` +
|
||||
`<span class="b-tag ${tagClass}">${tag}</span>` +
|
||||
`<span>${newsEsc((t.headline || '').trim())}</span>` +
|
||||
(loc ? `<span class="dom">${newsEsc(loc)}</span>` : '') +
|
||||
`<span class="tt">${newsTimeAgo(t.created_at)}</span><span class="sep">▸</span>`;
|
||||
|
|
@ -1906,6 +1915,7 @@ let extraAttribs = new Set();
|
|||
let radarLayer = null, radarOn = true, radarOpacity = 0.7, radarMeta = null, radarTimer = null;
|
||||
let thermalLayer = null, thermalOn = false;
|
||||
let sentinelLayer = null, sentinelOn = false, sentinelOpacity = 0.8;
|
||||
let sentinelItemId = null, sentinelBounds = null;
|
||||
let wxAlertsGroup = null, wxAlertsOn = true;
|
||||
let perimGroup = null, perimOn = true;
|
||||
let incidentsGroup = null, incidentsOn = false;
|
||||
|
|
@ -3071,6 +3081,8 @@ async function toggleSentinel1() {
|
|||
if (sentinelOn) await loadSentinel1();
|
||||
else {
|
||||
sentinelLayer = dropLayer(sentinelLayer);
|
||||
sentinelItemId = null;
|
||||
sentinelBounds = null;
|
||||
const n = document.getElementById('lp-sentinel-count');
|
||||
if (n) n.textContent = '7d';
|
||||
}
|
||||
|
|
@ -3080,8 +3092,15 @@ function setSentinelOpacity(v) {
|
|||
document.getElementById('lp-sentinel-val').textContent = `${Math.round(v)}%`;
|
||||
if (sentinelLayer) sentinelLayer.setOpacity(sentinelOpacity);
|
||||
}
|
||||
function sentinelStillCovers() {
|
||||
if (!map || !sentinelBounds || sentinelBounds.length < 4) return false;
|
||||
const c = map.getCenter();
|
||||
return c.lng >= sentinelBounds[0] && c.lng <= sentinelBounds[2]
|
||||
&& c.lat >= sentinelBounds[1] && c.lat <= sentinelBounds[3];
|
||||
}
|
||||
async function loadSentinel1() {
|
||||
if (!map || !sentinelOn) return;
|
||||
if (sentinelLayer && sentinelStillCovers()) return;
|
||||
const req = ++overlayReq.sar;
|
||||
const countEl = document.getElementById('lp-sentinel-count');
|
||||
const hint = document.getElementById('map-hint');
|
||||
|
|
@ -3093,6 +3112,8 @@ async function loadSentinel1() {
|
|||
if (req !== overlayReq.sar) return;
|
||||
if (r.status === 404 && body && body.error === 'no_imagery') {
|
||||
sentinelLayer = dropLayer(sentinelLayer);
|
||||
sentinelItemId = null;
|
||||
sentinelBounds = null;
|
||||
if (hint) hint.textContent = 'No Sentinel-1 imagery for this view in the last 7 days.';
|
||||
if (countEl) countEl.textContent = 'none';
|
||||
return;
|
||||
|
|
@ -3109,13 +3130,31 @@ async function loadSentinel1() {
|
|||
if (countEl) countEl.textContent = 'err';
|
||||
return;
|
||||
}
|
||||
if (body.itemId && body.itemId === sentinelItemId && sentinelLayer) {
|
||||
if (Array.isArray(body.bbox) && body.bbox.length >= 4) sentinelBounds = body.bbox;
|
||||
sentinelLayer.setOpacity(sentinelOpacity);
|
||||
if (countEl) countEl.textContent = String(body.polarization || 'SAR').toUpperCase();
|
||||
return;
|
||||
}
|
||||
const attrib = body.attribution || '';
|
||||
sentinelLayer = dropLayer(sentinelLayer);
|
||||
sentinelLayer = L.tileLayer(body.tileUrl, {
|
||||
const layerOpts = {
|
||||
opacity: sentinelOpacity,
|
||||
maxZoom: 18,
|
||||
attribution: attrib,
|
||||
}).addTo(map);
|
||||
noWrap: true,
|
||||
};
|
||||
if (Array.isArray(body.bbox) && body.bbox.length >= 4) {
|
||||
sentinelBounds = body.bbox;
|
||||
layerOpts.bounds = L.latLngBounds(
|
||||
[body.bbox[1], body.bbox[0]],
|
||||
[body.bbox[3], body.bbox[2]],
|
||||
);
|
||||
} else {
|
||||
sentinelBounds = null;
|
||||
}
|
||||
sentinelLayer = dropLayer(sentinelLayer);
|
||||
sentinelLayer = L.tileLayer(body.tileUrl, layerOpts).addTo(map);
|
||||
sentinelItemId = body.itemId || null;
|
||||
if (countEl) countEl.textContent = String(body.polarization || 'SAR').toUpperCase();
|
||||
if (hint) {
|
||||
const when = body.datetime ? ` · ${body.datetime}` : '';
|
||||
|
|
@ -3477,17 +3516,44 @@ async function onGfClose(e) {
|
|||
toggleGeofenceDraw();
|
||||
loadGeofences();
|
||||
}
|
||||
async function deleteGeofence(id) {
|
||||
if (!id) return;
|
||||
try {
|
||||
const r = await fetch(`${API}/api/geofences/${encodeURIComponent(id)}`, { method: 'DELETE' });
|
||||
if (!r.ok && r.status !== 204) throw new Error('delete failed');
|
||||
} catch (err) { console.error('geofence delete failed', err); }
|
||||
loadGeofences();
|
||||
}
|
||||
async function loadGeofences() {
|
||||
if (!map) return;
|
||||
try {
|
||||
const r = await overlayFetch(`${API}/api/geofences`);
|
||||
const rows = await r.json();
|
||||
const list = Array.isArray(rows) ? rows : [];
|
||||
const box = document.getElementById('gf-list');
|
||||
if (box) {
|
||||
box.innerHTML = list.map(f => {
|
||||
const id = newsEsc(f.id || '');
|
||||
const name = newsEsc(f.name || 'Fence');
|
||||
return `<div class="gf-item"><span title="${name}">${name}</span>` +
|
||||
`<button class="gf-del" type="button" onclick="deleteGeofence('${id}')">Delete</button></div>`;
|
||||
}).join('');
|
||||
}
|
||||
if (gfSaved && map.hasLayer(gfSaved)) map.removeLayer(gfSaved);
|
||||
const feats = (Array.isArray(rows) ? rows : []).map(f => ({
|
||||
const feats = list.map(f => ({
|
||||
type: 'Feature', properties: { name: f.name, id: f.id }, geometry: f.geojson,
|
||||
}));
|
||||
gfSaved = L.geoJSON({ type: 'FeatureCollection', features: feats }, {
|
||||
style: { color: '#ff2e97', weight: 2, fillOpacity: 0.08 },
|
||||
onEachFeature: (feat, layer) => {
|
||||
const id = feat.properties && feat.properties.id;
|
||||
const name = newsEsc((feat.properties && feat.properties.name) || 'Fence');
|
||||
if (!id) return;
|
||||
layer.bindPopup(
|
||||
`<div class="gf-pop"><b>${name}</b><br>` +
|
||||
`<button class="gf-del" type="button" onclick="deleteGeofence('${newsEsc(id)}')">Delete</button></div>`
|
||||
);
|
||||
},
|
||||
}).addTo(map);
|
||||
} catch (e) { if (!isAbort(e)) console.error('geofences load failed', e); }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue