aboutsummaryrefslogtreecommitdiffziptar.gz
path: root/viewer/js/vents.js
diff options
context:
space:
mode:
authorgodosa <godosa@godosa.eu>2026-10-07 00:14:38 +0200
committergodosa <godosa@godosa.eu>2026-10-07 00:14:38 +0200
commit3443c1c65e9f1753e1e656b35d08416c1fa298f2 (patch)
tree4e43236f460145a4d75d1b4616dcb7aa6ef08f51 /viewer/js/vents.js
downloadworldmap-viewer-3443c1c65e9f1753e1e656b35d08416c1fa298f2.tar.gz
worldmap-viewer-3443c1c65e9f1753e1e656b35d08416c1fa298f2.zip
worldmap-viewer: initial public history
Diffstat (limited to 'viewer/js/vents.js')
-rw-r--r--viewer/js/vents.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/viewer/js/vents.js b/viewer/js/vents.js
new file mode 100644
index 0000000..34eedfc
--- /dev/null
+++ b/viewer/js/vents.js
@@ -0,0 +1,25 @@
+// 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] ?? ''}`;
+}