// vents.js — hydrothermal vents as map markers (pure): clusters on a lat/lon grid sized to ≈ px screen pixels import { R_KM } from './geo.js'; const FLOW = ['weak flow', 'steady flow', 'strong flow']; export const zoomBucket = kmPerPx => Math.floor(Math.log(kmPerPx) / Math.log(1.5)); export function clusterVents(vents, kmPerPx, px = 40) { const deg = Math.max(1e-6, (kmPerPx * px * 180) / (Math.PI * R_KM)); const cells = new Map(); for (const v of vents) { const key = `${Math.floor(v.lat / deg)}:${Math.floor(v.lon / deg)}`; const c = cells.get(key); if (c) { c.lat += v.lat; c.lon += v.lon; c.n++; } else cells.set(key, { lat: v.lat, lon: v.lon, n: 1, v }); } return [...cells.values()].map(c => (c.n === 1 ? c : { lat: c.lat / c.n, lon: c.lon / c.n, n: c.n, v: null })); } export function ventText(v, types, minerals) { return `${types[v.type] ?? 'vent'} · ${Math.round(v.temp_c)} °C · ${minerals[v.mineral] ?? '?'} · ${FLOW[v.flow] ?? ''}`; }