summaryrefslogtreecommitdiff
path: root/crates/wipfel
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2026-10-27 20:02:23 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2026-10-27 20:03:12 +0100
commit4cdfae6ad5d5f9808ebf3078fb4630298051f464 (patch)
tree9b982284a809831b812797ed8876d211c4c70ae3 /crates/wipfel
parentb084d94e484aa057cc839892c6e49df3caf8a0e6 (diff)
web: GPS paste field in Viewpoint section
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.
Diffstat (limited to 'crates/wipfel')
-rw-r--r--crates/wipfel/src/app.rs31
-rw-r--r--crates/wipfel/src/widgets.rs29
-rw-r--r--crates/wipfel/www/style.css3
3 files changed, 62 insertions, 1 deletions
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<f64> = text
+ .replace([';', ' '], ",")
+ .split(',')
+ .filter(|p| !p.trim().is_empty())
+ .filter_map(|p| p.trim().parse::<f64>().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} />
<NumItem label="Height (m)" value={vp.height} step={1.0} decimals={0}
onchange={on_height} />
+ <TextItem label="GPS paste" placeholder="47.676,13.32042"
+ onchange={on_gps} />
<div class="section">{ "Orientation" }</div>
<SliderItem label="Azimuth" display={format!("{:.1}°", vp.az)}
value={vp.az} min={0.0} max={360.0} step={0.01} onchange={on_az} />
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<String>,
+}
+
+#[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! {
+ <label class="numrow">
+ <span>{ p.label.as_ref().to_string() }</span>
+ <input
+ type="text"
+ placeholder={p.placeholder.as_ref().to_string()}
+ {onchange}
+ />
+ </label>
+ }
+}
+
#[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;