summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2026-11-09 10:21:03 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2026-11-09 10:21:03 +0100
commit31a47fc4393856a0a0380b2fdcf79f9dac72ad56 (patch)
tree6db58e01329bc0331fc7e4b8b2db09d7c8b3b6fc
parentd5967c1b91b14b3b4e5b0d9663e8a4d2a5e80533 (diff)
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
-rw-r--r--README.md23
-rw-r--r--crates/gipfel-core/src/metadata.rs24
-rw-r--r--crates/gipfel/Cargo.toml1
-rwxr-xr-xcrates/gipfel/build-release.sh3
-rwxr-xr-xcrates/gipfel/serve-here.sh3
-rw-r--r--crates/gipfel/src/app.rs129
-rw-r--r--crates/gipfel/www/style.css29
-rw-r--r--dist/gipfel/gipfel.js11
-rw-r--r--dist/gipfel/gipfel_bg.wasmbin551505 -> 555370 bytes
-rw-r--r--dist/gipfel/style.css29
10 files changed, 235 insertions, 17 deletions
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<String> {
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::<Marker>::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::<String>::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<u8>, 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=<same-origin path> 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=<path or http(s) URL> 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<usize> = 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::<HtmlCanvasElement>()
+ .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 {
<SliderItem label="Roll" display={format!("{:.1}°", vp.roll)}
value={vp.roll} min={-10.0} max={10.0} step={0.01} onchange={on_roll} />
<div class="section">{ "Projection" }</div>
+ <select class="textinput" onchange={on_projection}>
+ <option value="0" selected={*projection == 0}>{ "Rectilinear projection" }</option>
+ <option value="1" selected={*projection == 1}>{ "Cylindrical (panoramic)" }</option>
+ </select>
<label class="row">
<input type="checkbox" checked={*fit_distortion} onchange={on_distortion_toggle} />
{ "Fit distortion (needs ≥ 4 markers)" }
@@ -1422,6 +1522,7 @@ pub fn app() -> Html {
</>
}
<div class="infofoot">
+ <p class="hint dim">{ format!("gipfel {} · build {}", env!("CARGO_PKG_VERSION"), BUILD_STAMP) }</p>
<p class="hint">
{ "Hover a dot to see the peak · click to mark it (or pick from the list) · drag to adjust · right-click to remove." }
</p>
@@ -1450,6 +1551,12 @@ pub fn app() -> Html {
label_font={vp.label_font}
/>
{ findpeak_popup.clone() }
+ if bitmap.is_some() {
+ <div class="zoomctrl">
+ <button onclick={zoom_in} title="Zoom in" aria-label="Zoom in">{"+"}</button>
+ <button onclick={zoom_out} title="Zoom out" aria-label="Zoom out">{"\u{2212}"}</button>
+ </div>
+ }
</div>
if bitmap.is_some() {
<Compass data={compass_data} tick={*tick} on_change={compass_change} />
diff --git a/crates/gipfel/www/style.css b/crates/gipfel/www/style.css
index 1a0173c..942c569 100644
--- a/crates/gipfel/www/style.css
+++ b/crates/gipfel/www/style.css
@@ -376,3 +376,32 @@ select.textinput {
.row.gap {
margin-top: 6px;
}
+/* Google-Maps-style zoom control, bottom right above the status line */
+.zoomctrl {
+ position: absolute;
+ right: 12px;
+ bottom: 34px;
+ display: flex;
+ flex-direction: column;
+ border-radius: 8px;
+ overflow: hidden;
+ box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
+ z-index: 6;
+}
+.zoomctrl button {
+ width: 38px;
+ height: 38px;
+ padding: 0;
+ font-size: 21px;
+ line-height: 1;
+ background: rgba(26, 26, 32, 0.85);
+ color: #fff;
+ border: 0;
+ cursor: pointer;
+}
+.zoomctrl button:hover {
+ background: rgba(59, 111, 212, 0.9);
+}
+.zoomctrl button + button {
+ border-top: 1px solid rgba(255, 255, 255, 0.15);
+}
diff --git a/dist/gipfel/gipfel.js b/dist/gipfel/gipfel.js
index f570bef..7265351 100644
--- a/dist/gipfel/gipfel.js
+++ b/dist/gipfel/gipfel.js
@@ -370,6 +370,9 @@ function __wbg_get_imports() {
const ret = arg0.location;
return ret;
},
+ __wbg_log_17c30ef363c61cf4: function(arg0) {
+ console.log(arg0);
+ },
__wbg_measureText_1035b288be51876c: function() { return handleError(function (arg0, arg1, arg2) {
const ret = arg0.measureText(getStringFromWasm0(arg1, arg2));
return ret;
@@ -688,22 +691,22 @@ function __wbg_get_imports() {
return ret;
},
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 72, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 73, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_f1f668f83a5f514b___convert__closures_____invoke___wasm_bindgen_f1f668f83a5f514b___JsValue__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_f1f668f83a5f514b___JsError___true_);
return ret;
},
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Array<any>"), NamedExternref("ResizeObserver")], shim_idx: 32, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Array<any>"), NamedExternref("ResizeObserver")], shim_idx: 33, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
const ret = makeClosure(arg0, arg1, wasm_bindgen_f1f668f83a5f514b___convert__closures_____invoke___js_sys_351dd7d36d5f7033___Array__web_sys_ce8fadd6eea37a81___features__gen_ResizeObserver__ResizeObserver______true_);
return ret;
},
__wbindgen_generic_0000000000000003: function(arg0, arg1) {
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Ref(NamedExternref("Event"))], shim_idx: 96, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Ref(NamedExternref("Event"))], shim_idx: 97, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
const ret = makeClosure(arg0, arg1, wasm_bindgen_f1f668f83a5f514b___convert__closures________invoke___web_sys_ce8fadd6eea37a81___features__gen_Event__Event______true_);
return ret;
},
__wbindgen_generic_0000000000000004: function(arg0, arg1) {
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 34, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 35, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
const ret = makeClosure(arg0, arg1, wasm_bindgen_f1f668f83a5f514b___convert__closures_____invoke_______true_);
return ret;
},
diff --git a/dist/gipfel/gipfel_bg.wasm b/dist/gipfel/gipfel_bg.wasm
index 417b81e..c12ae41 100644
--- a/dist/gipfel/gipfel_bg.wasm
+++ b/dist/gipfel/gipfel_bg.wasm
Binary files differ
diff --git a/dist/gipfel/style.css b/dist/gipfel/style.css
index 1a0173c..942c569 100644
--- a/dist/gipfel/style.css
+++ b/dist/gipfel/style.css
@@ -376,3 +376,32 @@ select.textinput {
.row.gap {
margin-top: 6px;
}
+/* Google-Maps-style zoom control, bottom right above the status line */
+.zoomctrl {
+ position: absolute;
+ right: 12px;
+ bottom: 34px;
+ display: flex;
+ flex-direction: column;
+ border-radius: 8px;
+ overflow: hidden;
+ box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
+ z-index: 6;
+}
+.zoomctrl button {
+ width: 38px;
+ height: 38px;
+ padding: 0;
+ font-size: 21px;
+ line-height: 1;
+ background: rgba(26, 26, 32, 0.85);
+ color: #fff;
+ border: 0;
+ cursor: pointer;
+}
+.zoomctrl button:hover {
+ background: rgba(59, 111, 212, 0.9);
+}
+.zoomctrl button + button {
+ border-top: 1px solid rgba(255, 255, 255, 0.15);
+}