summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2026-10-28 09:25:36 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2026-10-28 10:34:53 +0100
commit8b87a9d31c966b431e9547bcc411f9da7f3c527a (patch)
treefa01e8e323f4dcd26baf20d1ef9fd16a197e224a
parentf0cf0c3e95ca0518de754f7915458bd90e8abf32 (diff)
web: load an alternative hill database from the UI
Secondary button under the database status line: picks a .dat (or gzipped) peak list at runtime — e.g. a regional file like everest.dat instead of the full 21k gipfel.dat. Markers and track reference hill indices, so they are dropped when the database is swapped.
-rw-r--r--crates/wipfel/src/app.rs71
-rw-r--r--crates/wipfel/www/style.css9
-rw-r--r--dist/wipfel/style.css9
-rw-r--r--dist/wipfel/wipfel.js4
-rw-r--r--dist/wipfel/wipfel_bg.wasmbin519240 -> 523068 bytes
5 files changed, 91 insertions, 2 deletions
diff --git a/crates/wipfel/src/app.rs b/crates/wipfel/src/app.rs
index a7af089..fbe49c4 100644
--- a/crates/wipfel/src/app.rs
+++ b/crates/wipfel/src/app.rs
@@ -190,6 +190,8 @@ pub fn app() -> Html {
let track = use_state(Vec::<usize>::new);
let track_width = use_state(|| 200.0f64);
let track_file_ref = use_node_ref();
+ // optional alternative hill database (e.g. a regional list)
+ let db_file_ref = use_node_ref();
// set once the user pans or zooms by hand; auto-fit is then suppressed
// until the next image load
let user_moved = use_mut_ref(|| false);
@@ -492,6 +494,65 @@ pub fn app() -> Html {
})
};
+ let open_db_picker = {
+ let db_file_ref = db_file_ref.clone();
+ Callback::from(move |_: MouseEvent| {
+ if let Some(input) = db_file_ref.cast::<HtmlInputElement>() {
+ input.click();
+ }
+ })
+ };
+
+ // replace the hill database at runtime (e.g. everest.dat for the
+ // Khumbu); markers and track reference hill indices and are dropped
+ let on_db_file_change = {
+ let pan = pan.clone();
+ let db_status = db_status.clone();
+ let markers = markers.clone();
+ let track = track.clone();
+ Callback::from(move |e: Event| {
+ let input: HtmlInputElement = e.target_unchecked_into();
+ let Some(file) = input.files().and_then(|f| f.item(0)) else {
+ return;
+ };
+ let (pan, db_status, markers, track) = (
+ pan.clone(),
+ db_status.clone(),
+ markers.clone(),
+ track.clone(),
+ );
+ let name = file.name();
+ spawn_local(async move {
+ match bridge::read_blob(&file).await {
+ Ok(bytes) => {
+ // accept plain .dat and gzipped variants
+ let raw = match bytes.first() {
+ Some(0x1f) if bytes.get(1) == Some(&0x8b) => match gunzip(&bytes) {
+ Ok(r) => r,
+ Err(err) => {
+ db_status.set(format!("gunzip failed: {err}"));
+ return;
+ }
+ },
+ _ => bytes,
+ };
+ match pan.borrow_mut().load_data_from_bytes(&raw) {
+ Ok(()) => {
+ markers.set(Vec::new());
+ track.set(Vec::new());
+ let n = pan.borrow().hills.len();
+ db_status.set(format!("Hill database {name}: {n} peaks"));
+ }
+ Err(err) => db_status.set(format!("Database failed: {err}")),
+ }
+ }
+ Err(err) => db_status.set(format!("Failed to read {name}: {err}")),
+ }
+ });
+ input.set_value(""); // allow re-selecting the same file
+ })
+ };
+
// parse a GPX file and swap it into the panorama as track-point hills
// (always appended last, so marker hill indices never shift)
let on_track_file_change = {
@@ -960,6 +1021,16 @@ pub fn app() -> Html {
/>
<p class="status">{ (*status).clone() }</p>
<p class="hint">{ (*db_status).clone() }</p>
+ <button class="secondary" onclick={open_db_picker}>
+ { "Load hill database…" }
+ </button>
+ <input
+ type="file"
+ class="hidden-file"
+ accept=".dat,.gz,.gzip,application/gzip"
+ ref={db_file_ref}
+ onchange={on_db_file_change}
+ />
if bitmap.is_some() {
<>
<div class="section">{ "Viewpoint" }</div>
diff --git a/crates/wipfel/www/style.css b/crates/wipfel/www/style.css
index 80c4d15..9ed7bd8 100644
--- a/crates/wipfel/www/style.css
+++ b/crates/wipfel/www/style.css
@@ -163,6 +163,15 @@ body {
.sidebar button:hover {
background: var(--btn-hover);
}
+.sidebar button.secondary {
+ background: var(--chip-bg);
+ color: var(--text);
+ font-size: 13px;
+ padding: 6px 10px;
+}
+.sidebar button.secondary:hover {
+ background: var(--chip-hover);
+}
.status {
font-size: 13px;
color: var(--text-dim);
diff --git a/dist/wipfel/style.css b/dist/wipfel/style.css
index 80c4d15..9ed7bd8 100644
--- a/dist/wipfel/style.css
+++ b/dist/wipfel/style.css
@@ -163,6 +163,15 @@ body {
.sidebar button:hover {
background: var(--btn-hover);
}
+.sidebar button.secondary {
+ background: var(--chip-bg);
+ color: var(--text);
+ font-size: 13px;
+ padding: 6px 10px;
+}
+.sidebar button.secondary:hover {
+ background: var(--chip-hover);
+}
.status {
font-size: 13px;
color: var(--text-dim);
diff --git a/dist/wipfel/wipfel.js b/dist/wipfel/wipfel.js
index b27047b..f3c4b1b 100644
--- a/dist/wipfel/wipfel.js
+++ b/dist/wipfel/wipfel.js
@@ -623,7 +623,7 @@ function __wbg_get_imports() {
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: 72, 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: 74, 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_fd3e5a073eeae266___features__gen_ResizeObserver__ResizeObserver______true_);
return ret;
},
@@ -633,7 +633,7 @@ function __wbg_get_imports() {
return ret;
},
__wbindgen_generic_0000000000000004: function(arg0, arg1) {
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 74, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 76, 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/wipfel/wipfel_bg.wasm b/dist/wipfel/wipfel_bg.wasm
index d35f0ae..83fe2ec 100644
--- a/dist/wipfel/wipfel_bg.wasm
+++ b/dist/wipfel/wipfel_bg.wasm
Binary files differ