From d5967c1b91b14b3b4e5b0d9663e8a4d2a5e80533 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 6 Nov 2026 09:52:26 +0100 Subject: wasm front end becomes the main gipfel; add desktop installers - rename crates/wipfel -> crates/gipfel (crate, wasm artifact, dist, scripts, page titles); slogan back to "Photogrammetry for Mountain Images"; crates/wipfel-tauri -> crates/gipfel-desktop - new features in the wasm app: Save image (gipfel JPEG comment, same format as before, via browser download) and lens distortion profiles stored in localStorage in FLTK prefs format with camera auto-match on image load; profile name field, save/load and dropdown - gipfel-core: read GPSImgDirection from EXIF (magnetic -> true) as azimuth fallback; expose parse_prefs/serialize_prefs for the wasm build; ?file=/?az=/?pitch=/?roll=/?focal=/?vis= URL parameters - Tauri v2 wrapper crate building .deb, AppImage and (cross-compiled) Windows NSIS installers; safe stage-and-swap build-release.sh - README: web-centric Installation, concise Build section for the official targets (Web, Windows, Linux); drop native/Android mentions - release site moved dist/wipfel -> dist/gipfel --- README.md | 78 ++++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 23 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 55aac31..3ecf7a0 100644 --- a/README.md +++ b/README.md @@ -33,27 +33,59 @@ Requirements Installation ------------ -COSMIC desktop application: `cargo build --release -p gipfel-app`. -Then run it with `target/release/gipfel [image.jpg] [--data gipfel.dat]`. +Build the web site (see Build below), serve the resulting `dist/gipfel/` +directory with any static webserver and open it in a browser. Ready-made +desktop installers (.deb, AppImage, Windows installer) are built with the +commands in the Build section. + +Build +----- +All targets share the platform-free library `crates/gipfel-core`; the +browser/WASM front end lives in `crates/gipfel`, the desktop installer +wrapper in `crates/gipfel-desktop`. + +Prerequisites (all targets): + + rustup target add wasm32-unknown-unknown + cargo install wasm-bindgen-cli + +Web (static site, any webserver): + + ./crates/gipfel/build-release.sh # assembles dist/gipfel/ + +dev loop: `./crates/gipfel/serve-here.sh` (refreshes /tmp/gipfel-dist). + +Desktop installers (Tauri, `crates/gipfel-desktop`; needs node/npm once: +`npm i -D @tauri-apps/cli`): + + # Linux .deb + AppImage + sudo apt-get install libwebkit2gtk-4.1-dev libgtk-3-dev librsvg2-dev libxdo-dev + cd crates/gipfel-desktop && npx tauri build --bundles deb,appimage + + # Windows NSIS installer (cross-compiled from Linux) + sudo apt-get install mingw-w64 nsis + rustup target add x86_64-pc-windows-gnu + npx tauri build --target x86_64-pc-windows-gnu --bundles nsis + +Artifacts appear under `target/[x86_64-pc-windows-gnu/]release/bundle/`. +Installers are unsigned. The official targets are Web, Windows and Linux. Running ------- -You should now see a window with controls on the left and the actual picture. -Depending on whether gipfel could find localization data in the image metadata, -you need to set the viewpoint from which the picture was taken. -Alternatively, you can enter the GPS coordinate of the viewpoint directly in -the control window (hit `` for every data field). -You can now use the controls in the control window to modify the view -parameters. - -Play around with these parameters, until you see the names of -mountains, which you already recognize on the picture. -Now middle-click on the small cross at the left of the name to mark it. -It should turn red. Now you can drag it with the left mouse button pressed -to the position of the mountain on the picture. -If you have positioned at least two mountains all other mountains should -move to their correct positions in the picture. -You can try to set more than two mountains to ge a more accurate result. +Open a picture (Open image… or drag & drop it onto the page). Depending +on whether gipfel could find localization data in the image metadata, +you need to set the viewpoint from which the picture was taken, either +in the Latitude/Longitude/Height fields or by pasting GPS coordinates +("47.676,13.32042"). + +Play around with the view parameters (Azimuth, Pitch, Roll, Focal) +until the projected dots roughly match the ridges in the picture. +Hover a dot to see which peak it represents; click a dot to mark it (or +click anywhere in the picture and pick the peak from the searchable +list). Drag a marker onto the position of the mountain in the picture; +right-click removes it. Once at least two mountains are positioned, +gipfel fits the view parameters automatically and moves the remaining +peaks to their correct positions. More markers improve the fit. You may also want to have a look at the (outdated) [screen video](http://www.flpsed.org/images/gipfel.avi) @@ -96,7 +128,7 @@ GPS Tracks ---------- Once you have determined the right parameters using the procedure described above, you can load GPS tracks and display them on the picture. Use the -File->Load Track menu item. GPS tracks should be in GPX format. +"Load GPX Track…" button. GPS tracks should be in GPX format. GPS tracks are displayed with variable width depending on the distance of the way points from the current view point and the scale value. You can also modify the width using the "Track Width" slider. @@ -104,7 +136,7 @@ You can also modify the width using the "Track Width" slider. Loading and Saving Images ------------------------- gipfel allows to save the image parameters in the comment section of -the JPEG image. Use the File->Save Image menu item. +the JPEG image. Use the "Save image…" button. Note, that in the saved image all previous JPEG comments are removed. If you open an image containing gipfel image parameters, they are automatcally set. @@ -115,8 +147,8 @@ gipfel tries to identify objects in its database, that are hidden by others. This is done by assuming that every object/peak has the form of a cone with a fixed steepness. If such imaginary cone would hide the view to a point in the database, gipfel marks it as hidden. Hidden objects are -not shown by default, but you can enable the display of hidden objects using -the Option->Show Hidden menu entry. Hidden objects and hidden GPS way points +not shown by default, but you can enable their display using the +"Show hidden peaks" checkbox. Hidden objects and hidden GPS way points are displayed in blue. Refraction @@ -147,7 +179,7 @@ x0 is the main point offset in X direction. If you mark and position more than 3 mountains on an image and enable distortion fitting, gipfel tries to correct lens distortion. Once you have reasonable values for k0 and k1 for a special camera and -focal length you can save the distortion profile (Distortion/Save Profile). +focal length you can save the distortion profile (Distortion profiles → Save). Whenever you now open an image taken with this camera model and focal length, gipfel will use this distortion profile. Independent of the distortion profiles one can also modify the -- cgit v1.2.3 From 31a47fc4393856a0a0380b2fdcf79f9dac72ad56 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 9 Nov 2026 10:21:03 +0100 Subject: web: projection switch, external image URLs, zoom buttons - ?file= now also accepts absolute http(s) image URLs (CORS applies); README documents all URL parameters - Projection dropdown (rectilinear / cylindrical-panoramic), synced from the gipfel comment on load; cylindrical lifts the lens-FOV visibility limit (unlimited view angle) so 360 deg panoramas show peaks in every direction - force visibility rebuild on every image load (the change detection alone could keep a stale list when the limit value was unchanged) - Google-Maps-style +/- zoom buttons at the lower right of the canvas - save/load roundtrip test for the projection type in the gipfel comment; build stamp in the sidebar footer and ?debug=1 console diagnostics to spot stale cached bundles and inspect the effective visibility state --- README.md | 23 +++++++ crates/gipfel-core/src/metadata.rs | 24 +++++++ crates/gipfel/Cargo.toml | 1 + crates/gipfel/build-release.sh | 3 +- crates/gipfel/serve-here.sh | 3 +- crates/gipfel/src/app.rs | 129 +++++++++++++++++++++++++++++++++---- crates/gipfel/www/style.css | 29 +++++++++ dist/gipfel/gipfel.js | 11 ++-- dist/gipfel/gipfel_bg.wasm | Bin 551505 -> 555370 bytes dist/gipfel/style.css | 29 +++++++++ 10 files changed, 235 insertions(+), 17 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 3ecf7a0..85d49ef 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,29 @@ right-click removes it. Once at least two mountains are positioned, gipfel fits the view parameters automatically and moves the remaining peaks to their correct positions. More markers improve the fit. +URL Parameters +-------------- +The web app can be fully linked to: image and view parameters are +passed as URL query parameters, e.g. + + https://example.org/gipfel/?file=photo.jpg + https://example.org/gipfel/?file=https://host/pano.jpg&az=57.4&pitch=-20 + +* `file` — image to open: a path on the same host, or an absolute + `http(s)` URL (the remote host must allow CORS) +* `az` — azimuth in degrees (true north) +* `pitch` — pitch in degrees +* `roll` — roll in degrees +* `focal` — focal length in mm (35 mm equivalent) +* `vis` — visibility override (0.01–0.1, same scale as the Visibility + slider; higher shows more distant peaks) + +The parameters are applied *after* the image's own EXIF/gipfel +metadata, so they override values recorded in the photo. A `gipfel:` +comment saved by "Save image…" is read back when the saved file is +opened again, so annotated images carry their view without any URL +parameters. + You may also want to have a look at the (outdated) [screen video](http://www.flpsed.org/images/gipfel.avi) for an example session. diff --git a/crates/gipfel-core/src/metadata.rs b/crates/gipfel-core/src/metadata.rs index 428cf79..d9c98f9 100644 --- a/crates/gipfel-core/src/metadata.rs +++ b/crates/gipfel-core/src/metadata.rs @@ -768,3 +768,27 @@ mod tests { assert!((pan.get_scale() - 50.0 * 1000.0 / 35.0).abs() < 1e-9); } } + +#[cfg(test)] +mod save_tests { + use super::*; + + #[test] + fn comment_roundtrip_preserves_projection_type() { + let mut md = ImageMetaData::new(); + md.longitude = 10.5; + md.latitude = 47.0; + md.height = 2993.0; + md.direction = 57.4; + md.pitch = -20.0; + md.roll = 0.3; + md.focal_length_35mm = 27.0; + md.projection_type = 1; // cylindrical + // minimal valid JPEG (SOI, empty COM, EOI) + let jpg = b"\xff\xd8\xff\xfe\x00\x02\xff\xd9"; + let out = md.save_image_to_bytes(jpg).unwrap(); + let mut md2 = ImageMetaData::new(); + md2.load_image_from_bytes(&out); + assert_eq!(md2.projection_type, 1, "projection type lost in comment roundtrip"); + } +} diff --git a/crates/gipfel/Cargo.toml b/crates/gipfel/Cargo.toml index 55b4e05..35df39b 100644 --- a/crates/gipfel/Cargo.toml +++ b/crates/gipfel/Cargo.toml @@ -16,6 +16,7 @@ yew = { version = "0.21", features = ["csr"] } [dependencies.web-sys] version = "0.3" features = [ + "console", "Blob", "BlobPropertyBag", "CanvasRenderingContext2d", diff --git a/crates/gipfel/build-release.sh b/crates/gipfel/build-release.sh index 1e429ca..d118b59 100755 --- a/crates/gipfel/build-release.sh +++ b/crates/gipfel/build-release.sh @@ -21,7 +21,8 @@ esac # size-optimized build for the web (the workspace default profile # targets native binaries); --remove-name-section drops the debug # symbol names wasm-bindgen adds for devtools -CARGO_PROFILE_RELEASE_OPT_LEVEL=z cargo build -p gipfel --target wasm32-unknown-unknown --release +touch crates/gipfel/src/app.rs # re-stamp every build (option_env! does not track STAMP) +STAMP=$(date -u +%Y-%m-%d_%H:%M) CARGO_PROFILE_RELEASE_OPT_LEVEL=z cargo build -p gipfel --target wasm32-unknown-unknown --release # stage into a fresh temp dir and swap it in only on success, so a # failing build never destroys the previous site and the old site is diff --git a/crates/gipfel/serve-here.sh b/crates/gipfel/serve-here.sh index 2eaaf4d..1fd3a46 100755 --- a/crates/gipfel/serve-here.sh +++ b/crates/gipfel/serve-here.sh @@ -3,7 +3,8 @@ # /tmp/gipfel-dist (python http.server on :8090). Dev-only helper. set -e cd "$(dirname "$0")/../.." -cargo build -p gipfel --target wasm32-unknown-unknown --release +touch crates/gipfel/src/app.rs # re-stamp every build (option_env! does not track STAMP) +STAMP=$(date -u +%Y-%m-%d_%H:%M) cargo build -p gipfel --target wasm32-unknown-unknown --release DIST=/tmp/gipfel-dist mkdir -p "$DIST" wasm-bindgen --target web --out-dir "$DIST" target/wasm32-unknown-unknown/release/gipfel.wasm diff --git a/crates/gipfel/src/app.rs b/crates/gipfel/src/app.rs index 7479b8e..9fff27a 100644 --- a/crates/gipfel/src/app.rs +++ b/crates/gipfel/src/app.rs @@ -9,6 +9,7 @@ use gipfel_core::hill::{FLAG_DUPLIC, FLAG_HIDDEN, FLAG_TRACK_POINT, FLAG_VISIBLE use gipfel_core::track as gpx; use gipfel_core::metadata::{apply_image_metadata, ImageMetaData}; use gipfel_core::panorama::Panorama; +use gipfel_core::projection::ProjectionType; use wasm_bindgen::closure::Closure; use wasm_bindgen::JsCast; use wasm_bindgen_futures::spawn_local; @@ -73,6 +74,14 @@ struct FindPeak { query: String, } +/// Build stamp injected by serve-here.sh / build-release.sh so a +/// quick glance at the sidebar reveals whether the browser is running +/// a cached old bundle. +const BUILD_STAMP: &str = match option_env!("STAMP") { + Some(s) => s, + None => "dev", +}; + /// Read a query parameter from the page URL (e.g. `/?file=test.jpg`). fn url_param(name: &str) -> Option { let search = bridge::window().location().search().ok()?; @@ -209,6 +218,9 @@ pub fn app() -> Html { let pan = use_mut_ref(Panorama::new); let markers = use_state(Vec::::new); let fit_distortion = use_state(|| false); + // 0 = rectilinear, 1 = cylindrical (panoramic); mirrors + // Panorama::projection_type, synced from the image comment on load + let projection = use_state(|| 0u32); let hover = use_state(|| Option::::None); let vp = use_state(UiParams::default); let img_size = use_state(|| (0u32, 0u32)); @@ -440,6 +452,7 @@ pub fn app() -> Html { let img_md = img_md.clone(); let profile_name = profile_name.clone(); let profiles = profiles.clone(); + let projection = projection.clone(); Callback::from(move |(bytes, name): (Vec, String)| { let (bitmap, status, fit, pan, markers, fit_info) = (bitmap.clone(), status.clone(), fit.clone(), pan.clone(), markers.clone(), fit_info.clone()); @@ -453,6 +466,7 @@ pub fn app() -> Html { let img_md = img_md.clone(); let profile_name = profile_name.clone(); let profiles = profiles.clone(); + let projection = projection.clone(); spawn_local(async move { match bridge::decode_bitmap(&bytes).await { Ok(bmp) => { @@ -528,6 +542,15 @@ pub fn app() -> Html { } }; vp.set(u); + // a saved gipfel comment may request the panoramic + // projection; sync the dropdown with the result + projection.set(pan.borrow().projection_type as u32); + // force the per-render limit block to re-evaluate: + // its change detection compares against the old + // value, and a metadata-driven switch to cylindrical + // (limit 0) would otherwise look "unchanged" and + // keep the stale visibility list + pan.borrow_mut().max_view_angle = -1.0; img_size.set((w, h)); let vp = if have { format!("viewpoint from image · {vis} peaks visible") @@ -561,18 +584,21 @@ pub fn app() -> Html { }) }; - // Auto-load an image given as ?file= so a photo can - // be opened by URL alone, e.g. /?file=test.jpg. It goes through the + // Auto-load an image given as ?file= so a photo + // can be opened by link alone, e.g. /?file=test.jpg or + // /?file=https://example.org/pano.jpg&az=57.4. It goes through the // normal load pipeline, so EXIF viewpoint/focal metadata is applied - // exactly as for a picked file. + // exactly as for a picked file. External URLs need CORS on their + // host; the status line reports failures. { let load_bytes = load_bytes.clone(); let status = status.clone(); let overrides = overrides.clone(); use_effect_with((), move |_| { let Some(path) = url_param("file") else { return }; - if path.is_empty() || path.starts_with("http") || path.contains(":/") { - status.set("?file= must be a same-origin path".to_string()); + let external = path.starts_with("https://") || path.starts_with("http://"); + if path.is_empty() || (!external && path.contains(":/")) { + status.set("?file= must be a path on this host or an http(s) URL".to_string()); return; } let name = path.rsplit('/').next().unwrap_or(&path).to_string(); @@ -895,6 +921,21 @@ pub fn app() -> Html { }) }; + let on_projection = { + let pan = pan.clone(); + let projection = projection.clone(); + Callback::from(move |e: Event| { + let sel: web_sys::HtmlSelectElement = e.target_unchecked_into(); + let cyl = sel.value() == "1"; + projection.set(if cyl { 1 } else { 0 }); + pan.borrow_mut().set_projection(if cyl { + ProjectionType::Cylindrical + } else { + ProjectionType::Rectilinear + }); + }) + }; + let on_distortion_toggle = { let fit_distortion = fit_distortion.clone(); let markers = markers.clone(); @@ -1218,24 +1259,43 @@ pub fn app() -> Html { // Lens FOV visibility limit, port of the desktop bump(): the angle at // which the (possibly distorted) projection reaches the image edge. // Peaks beyond it cannot be inside the photo even if the fitted - // distortion folds their projection back into the image. Running this - // every render is idempotent and cheap; visibility is only rebuilt - // when the limit actually changed. + // distortion folds their projection back into the image. Cylindrical + // (panoramic) images are exempt: they may cover the full 360°, so the + // limit is set to 0 = unlimited. Running this every render is + // idempotent and cheap; visibility is only rebuilt when the limit + // actually changed. { let mut p = pan.borrow_mut(); - let limit = if img_size.0 > 0 { + let limit = if img_size.0 == 0 || p.projection_type == ProjectionType::Cylindrical { + // 0 = unlimited: no image loaded, or panoramic projection, + // whose image may wrap all the way around the viewpoint + 0.0 + } else { let c = p.parms.a_center; let proj = gipfel_core::projection::projection_from_type(p.projection_type); let a_edge = alph_at_img_x(p.projection_type, &*proj, &p.parms, img_size.0 as f64 / 2.0, c); (a_edge - c).abs() - } else { - 0.0 }; if (limit - p.max_view_angle).abs() > 1e-9 { p.max_view_angle = limit; let known: Vec = markers.iter().map(|m| m.hill).collect(); p.update_visible_mountains(Some(&known)); } + // ?debug=1 dumps the effective visibility state to the browser + // console on every render (DevTools → Console) + if url_param("debug").is_some() { + web_sys::console::log_1( + &format!( + "gipfel dbg: proj={:?} max_view_angle={:.4} visible={} img={}x{}", + p.projection_type, + p.max_view_angle, + p.visible.len(), + img_size.0, + img_size.1 + ) + .into(), + ); + } } // overlay data for the canvas @@ -1292,6 +1352,42 @@ pub fn app() -> Html { let nav_open = nav_open.clone(); Callback::from(move |_: MouseEvent| nav_open.set(false)) }; + + // Google-Maps-style +/- buttons: zoom about the canvas center using + // the same math as wheel/pinch zoom; counts as manual navigation so + // the auto-fit stays out of the way afterwards + let zoom_step = { + let apply = apply_view.clone(); + let user_moved = user_moved.clone(); + let canvas_ref = canvas_ref.clone(); + Rc::new(move |factor: f64| { + let (cx, cy) = canvas_ref + .cast::() + .map(|c| { + ( + c.client_width() as f64 / 2.0, + c.client_height() as f64 / 2.0, + ) + }) + .unwrap_or((400.0, 300.0)); + *user_moved.borrow_mut() = true; + apply(&move |v| { + let ns = (v.scale * factor).clamp(0.02, 64.0); + let k = ns / v.scale; + v.ox = cx - (cx - v.ox) * k; + v.oy = cy - (cy - v.oy) * k; + v.scale = ns; + }); + }) + }; + let zoom_in = { + let zoom = zoom_step.clone(); + Callback::from(move |_: MouseEvent| zoom(1.4)) + }; + let zoom_out = { + let zoom = zoom_step.clone(); + Callback::from(move |_: MouseEvent| zoom(1.0 / 1.4)) + }; let expand_cb = { let nav_open = nav_open.clone(); Callback::from(move |_: MouseEvent| nav_open.set(true)) @@ -1350,6 +1446,10 @@ pub fn app() -> Html {
{ "Projection" }
+