From 4cdfae6ad5d5f9808ebf3078fb4630298051f464 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 27 Oct 2026 20:02:23 +0100 Subject: web: GPS paste field in Viewpoint section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One text field accepting '47.676,13.32042' (optionally ',alt' as a third component; commas, semicolons or spaces as separators) — the format gallery apps show, so the coordinates can simply be copied and pasted. This replaces the PWA/share-target detour for getting a viewpoint onto mobile: EXIF GPS may be redacted by the OS, but the gallery displays the true coordinates for manual transfer. --- crates/wipfel/src/app.rs | 31 ++++++++++++++++++++++++++++++- crates/wipfel/src/widgets.rs | 29 +++++++++++++++++++++++++++++ crates/wipfel/www/style.css | 3 +++ 3 files changed, 62 insertions(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/wipfel/src/app.rs b/crates/wipfel/src/app.rs index 78961fc..137e121 100644 --- a/crates/wipfel/src/app.rs +++ b/crates/wipfel/src/app.rs @@ -19,7 +19,7 @@ use crate::bridge; use crate::canvas_view::{CanvasView, DotView, MarkerView, TrackView, ViewCallbacks, ViewState}; use crate::compass::{alph_at_img_x, Compass, CompassData}; use crate::markers::{self, Marker}; -use crate::widgets::{NumItem, SliderItem}; +use crate::widgets::{NumItem, SliderItem, TextItem}; /// sidebar-editable view parameters (degrees / meters / mm) #[derive(Clone, Copy, PartialEq)] @@ -548,6 +548,33 @@ pub fn app() -> Html { let on_lat = param_cb!(lat, |p: &mut Panorama, v| p.set_view_lat(v)); let on_lon = param_cb!(lon, |p, v| p.set_view_long(v)); let on_height = param_cb!(height, |p, v| p.set_view_height(v)); + // GPS paste field: "47.676,13.32042" — the format gallery apps show + // for coordinates; height stays a separate field + let on_gps = { + let vp = vp.clone(); + let pan = pan.clone(); + let status = status.clone(); + Callback::from(move |text: String| { + let parts: Vec = text + .replace([';', ' '], ",") + .split(',') + .filter(|p| !p.trim().is_empty()) + .filter_map(|p| p.trim().parse::().ok()) + .collect(); + if parts.len() < 2 || parts[0].abs() > 90.0 || parts[1].abs() > 180.0 { + status.set("GPS: expected \"lat,lon\" like 47.676,13.32042".to_string()); + return; + } + let mut u = *vp; + u.lat = parts[0]; + u.lon = parts[1]; + let mut p = pan.borrow_mut(); + p.set_view_lat(parts[0]); + p.set_view_long(parts[1]); + vp.set(u); + status.set(format!("Viewpoint: {:.5}, {:.5}", parts[0], parts[1])); + }) + }; let on_az = param_cb!(az, |p, v| p.set_center_angle(v)); let on_pitch = param_cb!(pitch, |p, v| p.set_pitch_angle(v)); let on_roll = param_cb!(roll, |p, v| p.set_roll_angle(v)); @@ -929,6 +956,8 @@ pub fn app() -> Html { onchange={on_lon} /> +
{ "Orientation" }
diff --git a/crates/wipfel/src/widgets.rs b/crates/wipfel/src/widgets.rs index 1d22bac..93e2cdc 100644 --- a/crates/wipfel/src/widgets.rs +++ b/crates/wipfel/src/widgets.rs @@ -46,6 +46,35 @@ pub fn slider_item(p: &SliderProps) -> Html { } } +/// single-line text row (e.g. paste a GPS string) +#[derive(Properties, PartialEq)] +pub struct TextProps { + pub label: AttrValue, + pub placeholder: AttrValue, + pub onchange: Callback, +} + +#[function_component(TextItem)] +pub fn text_item(p: &TextProps) -> Html { + let onchange = { + let onchange = p.onchange.clone(); + Callback::from(move |e: Event| { + let input: HtmlInputElement = e.target_unchecked_into(); + onchange.emit(input.value()); + }) + }; + html! { + + } +} + #[derive(Properties, PartialEq)] pub struct NumProps { pub label: AttrValue, diff --git a/crates/wipfel/www/style.css b/crates/wipfel/www/style.css index 646444d..79e2dee 100644 --- a/crates/wipfel/www/style.css +++ b/crates/wipfel/www/style.css @@ -216,6 +216,9 @@ canvas.compass { border: 1px solid #34343e; border-radius: 4px; } +.numrow input[type="text"] { + width: 150px; +} .fpbackdrop { position: absolute; inset: 0; -- cgit v1.2.3