// hover.js — status-bar text for the cell under the resting pointer (pure) import { distanceKm } from './geo.js'; export const canReuse = (cell, p, detail) => // same cell for sure: no need to ask the server again !detail && !!cell?.center && distanceKm(p, { lat: cell.center[0], lon: cell.center[1] }) < cell.inner_km; const int = v => Math.round(v).toLocaleString('en-US'); export function hoverText(cell, detail = false) { // detail: procedural tiles are showing, so show their height const f = Object.fromEntries(cell.fields.map(x => [x.key, x])); const z = ((detail && f.z_detail_m) || f.z_surface_m)?.value ?? 0; if (f.ocean?.value) return `sea, ${int(Math.max(0, -z))} m deep`; const parts = [`${int(z)} m`]; if (f.lake?.value) parts.push('lake'); if (f.holdridge?.text) parts.push(f.holdridge.text); return parts.join(' · '); }