summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock9
-rw-r--r--Cargo.toml2
-rw-r--r--crates/gipfel-wasm/Cargo.toml14
-rw-r--r--crates/gipfel-wasm/README.md36
-rwxr-xr-xcrates/gipfel-wasm/build.sh22
-rw-r--r--crates/gipfel-wasm/demo/index.html39
-rw-r--r--crates/gipfel-wasm/src/lib.rs147
7 files changed, 1 insertions, 268 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 0be6ad5..b9b8a97 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1807,15 +1807,6 @@ dependencies = [
]
[[package]]
-name = "gipfel-wasm"
-version = "0.5.5"
-dependencies = [
- "gipfel-core",
- "image",
- "wasm-bindgen",
-]
-
-[[package]]
name = "gl_generator"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 196bcda..ab0a71f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
-members = ["crates/gipfel-core", "crates/gipfel-cli", "crates/gipfel-app", "crates/gipfel-wasm", "crates/wipfel"]
+members = ["crates/gipfel-core", "crates/gipfel-cli", "crates/gipfel-app", "crates/wipfel"]
# Single source of truth for metadata inherited by every crate via
# `version.workspace = true` etc. Bump `version` here on release; the
diff --git a/crates/gipfel-wasm/Cargo.toml b/crates/gipfel-wasm/Cargo.toml
deleted file mode 100644
index 34cbbbd..0000000
--- a/crates/gipfel-wasm/Cargo.toml
+++ /dev/null
@@ -1,14 +0,0 @@
-[package]
-name = "gipfel-wasm"
-version.workspace = true
-edition.workspace = true
-license.workspace = true
-description = "EXPERIMENT: WebAssembly bindings for gipfel-core (browser spike, not part of the app)"
-
-[lib]
-crate-type = ["cdylib", "rlib"]
-
-[dependencies]
-gipfel-core = { path = "../gipfel-core" }
-image.workspace = true
-wasm-bindgen = "0.2"
diff --git a/crates/gipfel-wasm/README.md b/crates/gipfel-wasm/README.md
deleted file mode 100644
index 20d7dc7..0000000
--- a/crates/gipfel-wasm/README.md
+++ /dev/null
@@ -1,36 +0,0 @@
-# gipfel-wasm (EXPERIMENT)
-
-Browser spike proving the gipfel core runs as WebAssembly. Enabled by the
-GSL removal — the core is pure Rust end to end.
-
-## Status: spike verified (2026-10-26)
-
-`fit_demo()` ran the full pipeline in a real browser on a 4080×3072
-gipfel-annotated photo (21324 hills, gipfel JPEG comment found):
-
-```json
-{"ok":true,"hills_in_db":21324,"image":"4080x3072","had_gipfel_info":true,
- "observations":5,"viewpoint":{"lat":47.65526,"lon":11.61856,"height_m":1319},
- "perturbed":{"center_deg":245.8905,"scale":2558.0},
- "refitted":{"center_deg":245.390505,"pitch_deg":-7.763227,"roll_deg":1.245000,"scale":2692.61},
- "max_reproj_err_px":0.0000}
-```
-
-Wall time 50 ms. The refit exactly undid the synthetic perturbation
-(center to 5e-6 deg, scale to 7e-6 rel) — identical convergence to the
-native golden tests.
-
-## Build & run (requires rustup)
-
-```sh
-cd crates/gipfel-wasm
-./build.sh # wasm-pack build --target web
-python3 -m http.server 8080 # then open /demo/
-```
-
-## What is proven / what is not
-- Proven: hill DB parsing, JPEG comment + EXIF I/O, geodesy, projections,
- Levenberg-Marquardt fit — all in wasm at native speed.
-- Not built: the UI shell (libcosmic has no browser story). Next step if
- pursued: Yew (or Leptos) + canvas 2D reusing the viewport/compass logic
- and the pixel-based dump renderer.
diff --git a/crates/gipfel-wasm/build.sh b/crates/gipfel-wasm/build.sh
deleted file mode 100755
index 8d1d812..0000000
--- a/crates/gipfel-wasm/build.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-# Build the gipfel WASM spike and serve the demo page.
-# Requires: rustup (for the wasm target) and wasm-pack.
-set -e
-cd "$(dirname "$0")"
-
-if ! rustup target list --installed 2>/dev/null | grep -q wasm32-unknown-unknown; then
- echo "adding wasm32-unknown-unknown target ..."
- rustup target add wasm32-unknown-unknown
-fi
-command -v wasm-pack >/dev/null 2>&1 || {
- echo "wasm-pack not found. Install it once with:"
- echo " cargo install wasm-pack (or: cargo binstall wasm-pack)"
- exit 1
-}
-
-wasm-pack build --target web
-
-echo
-echo "built. serve the demo with:"
-echo " (cd crates/gipfel-wasm && python3 -m http.server 8080)"
-echo "then open http://localhost:8080/demo/"
diff --git a/crates/gipfel-wasm/demo/index.html b/crates/gipfel-wasm/demo/index.html
deleted file mode 100644
index f8e764d..0000000
--- a/crates/gipfel-wasm/demo/index.html
+++ /dev/null
@@ -1,39 +0,0 @@
-<!doctype html>
-<html lang="en">
-<head>
- <meta charset="utf-8" />
- <title>gipfel WASM spike</title>
- <style>
- body { font-family: system-ui, sans-serif; max-width: 720px; margin: 3em auto; line-height: 1.5; }
- pre { background: #f4f4f4; padding: 1em; overflow-x: auto; }
- label { display: block; margin: 0.6em 0; }
- button { margin-top: 1em; padding: 0.5em 1.2em; }
- </style>
-</head>
-<body>
- <h1>gipfel WASM spike</h1>
- <p>core version: <code id="ver">loading…</code></p>
- <p>Pick a hill database and a JPEG (ideally one saved by gipfel, or with EXIF GPS data):</p>
- <label>gipfel.dat: <input type="file" id="db" /></label>
- <label>image.jpg: <input type="file" id="jpg" /></label>
- <button id="go" disabled>Run fit pipeline</button>
- <pre id="out">pick both files, then run</pre>
-
- <script type="module">
- import init, { fit_demo, version } from '../pkg/gipfel_wasm.js';
- const $ = (id) => document.getElementById(id);
- await init();
- $('ver').textContent = version();
- $('go').disabled = false;
- $('go').onclick = async () => {
- const f = (id) => $(id).files[0];
- if (!f('db') || !f('jpg')) { $('out').textContent = 'pick both files first'; return; }
- const db = new Uint8Array(await f('db').arrayBuffer());
- const jpg = new Uint8Array(await f('jpg').arrayBuffer());
- const t0 = performance.now();
- const res = fit_demo(db, jpg);
- $('out').textContent = res + `\n\n(wall time: ${(performance.now() - t0).toFixed(1)} ms)`;
- };
- </script>
-</body>
-</html>
diff --git a/crates/gipfel-wasm/src/lib.rs b/crates/gipfel-wasm/src/lib.rs
deleted file mode 100644
index b521829..0000000
--- a/crates/gipfel-wasm/src/lib.rs
+++ /dev/null
@@ -1,147 +0,0 @@
-//! EXPERIMENT: browser spike exposing the gipfel core pipeline to JavaScript.
-//!
-//! The whole computational core (hill DB, geodesy, projections, LM fit,
-//! JPEG comment + EXIF I/O) is pure Rust and WASM-friendly — the GSL
-//! removal made this possible. This crate proves the pipeline end-to-end
-//! in the browser: bytes in (hill DB + JPEG), fit report out.
-//!
-//! Build (requires rustup):
-//! rustup target add wasm32-unknown-unknown
-//! cargo install wasm-pack # once
-//! cd crates/gipfel-wasm && wasm-pack build --target web
-//! python3 -m http.server 8080 # then open /demo/
-
-use wasm_bindgen::prelude::*;
-
-/// Crate version (from Cargo.toml, via the workspace).
-#[wasm_bindgen]
-pub fn version() -> String {
- env!("CARGO_PKG_VERSION").to_string()
-}
-
-/// End-to-end pipeline smoke test, all in memory:
-///
-/// 1. parse the hill database (`db` = gipfel.dat bytes, Latin-1 CSV)
-/// 2. read gipfel metadata from the JPEG bytes (comment, else EXIF)
-/// 3. build the panorama, take up to 5 visible hills as synthetic
-/// "user-marked" observations, perturb the view parameters, refit
-/// 4. return a JSON report (recovered parameters + max reprojection error)
-///
-/// This mirrors the native golden fit test; a correct WASM build reports
-/// a reprojection error well below one pixel.
-#[wasm_bindgen]
-pub fn fit_demo(db: &[u8], jpg: &[u8]) -> String {
- match fit_inner(db, jpg) {
- Ok(json) => json,
- Err(e) => format!(r#"{{"ok":false,"error":"{}"}}"#, e.replace('\\', "\\\\").replace('"', "\\\"")),
- }
-}
-
-fn fit_inner(db: &[u8], jpg: &[u8]) -> Result<String, String> {
- use gipfel_core::metadata::{apply_image_metadata, ImageMetaData};
- use gipfel_core::panorama::Panorama;
- use gipfel_core::projection::projection_from_type;
-
- let mut pan = Panorama::new();
- pan.load_data_from_bytes(db).map_err(|e| format!("hill db: {e}"))?;
-
- let mut md = ImageMetaData::new();
- md.load_image_from_bytes(jpg);
-
- let (w, h) = image::ImageReader::new(std::io::Cursor::new(jpg))
- .with_guessed_format()
- .map_err(|e| format!("image: {e}"))?
- .into_dimensions()
- .map_err(|e| format!("image: {e}"))?;
- if w == 0 || h == 0 {
- return Err("image has zero dimensions".into());
- }
-
- let have = apply_image_metadata(&mut pan, &md, w, h);
- if !have {
- // demo fallback: a fixed Alpine viewpoint so the pipeline always runs
- pan.set_view_lat(47.36);
- pan.set_view_long(11.15);
- pan.set_view_height(2100.0);
- pan.set_center_angle(20.0);
- pan.set_pitch_angle(0.0);
- pan.set_roll_angle(1.0);
- pan.set_scale(3000.0);
- }
-
- let n = pan.visible.len().min(5);
- if n < 2 {
- return Err("fewer than 2 hills visible from this viewpoint".into());
- }
- // snapshot the "observations" (what a user would have marked)
- let obs: Vec<_> = pan.visible[..n].iter().map(|&i| pan.hills[i].clone()).collect();
- let known: Vec<usize> = (0..n).collect();
-
- // perturb, then refit (distortion stays locked for the spike)
- let center0 = pan.get_center_angle();
- let scale0 = pan.get_scale();
- pan.set_center_angle(center0 + 0.5);
- pan.set_scale(scale0 * 0.95);
- pan.comp_params_with(&obs, &known, false)?;
-
- // reprojection error of the recovered parameters against the snapshot
- let proj = projection_from_type(pan.projection_type);
- let mut max_err = 0.0f64;
- for ob in &obs {
- let (x, y) = proj.get_coordinates(ob.alph, ob.a_elev, &pan.parms);
- max_err = max_err.max((x - ob.x).hypot(y - ob.y));
- }
-
- Ok(format!(
- concat!(
- "{{\"ok\":true,\"hills_in_db\":{},\"image\":\"{}x{}\",\"had_gipfel_info\":{},",
- "\"observations\":{},\"viewpoint\":{{\"lat\":{:.5},\"lon\":{:.5},\"height_m\":{:.0}}},",
- "\"perturbed\":{{\"center_deg\":{:.4},\"scale\":{:.1}}},",
- "\"refitted\":{{\"center_deg\":{:.6},\"pitch_deg\":{:.6},\"roll_deg\":{:.6},\"scale\":{:.2}}},",
- "\"max_reproj_err_px\":{:.4}}}"
- ),
- pan.hills.len(),
- w,
- h,
- have,
- n,
- pan.get_view_lat(),
- pan.get_view_long(),
- pan.get_view_height(),
- center0 + 0.5,
- scale0 * 0.95,
- pan.get_center_angle(),
- pan.get_pitch_angle(),
- pan.get_roll_angle(),
- pan.get_scale(),
- max_err,
- ))
-}
-
-#[cfg(test)]
-mod tests {
- use crate::fit_demo;
-
- /// The spike must also work natively (the wasm-bindgen attribute is a
- /// no-op off-wasm), so CI here covers the whole byte-oriented pipeline.
- /// Skips when the repo data files are not present (e.g. stripped checkouts).
- #[test]
- fn fit_demo_native_pipeline() {
- let (Ok(db), Ok(jpg)) = (
- std::fs::read("../../gipfel.dat"),
- std::fs::read("../../tests/golden/test.jpg"),
- ) else {
- eprintln!("gipfel.dat / test.jpg not found, skipping");
- return;
- };
- let out = fit_demo(&db, &jpg);
- assert!(out.contains(r#""ok":true"#), "fit_demo failed: {out}");
- // recovered parameters must reproduce the observations sub-pixel
- let err = out
- .split("max_reproj_err_px\":")
- .nth(1)
- .and_then(|s| s.trim_end_matches('}').parse::<f64>().ok())
- .expect("error value present");
- assert!(err < 0.01, "reprojection error too large: {out}");
- }
-}