Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b30c184
feat(mobile): the capture form marks required fields, follows conting…
giswqs Nov 14, 2026
08798c8
feat(mobile): edit a shape's vertices by touch, and snap the capture …
giswqs Nov 14, 2026
6b24332
feat(mobile): average the device's positions, and record a track (#1902)
giswqs Nov 14, 2026
0917e82
fix(mobile): contingent values match numbers by value, calculated and…
giswqs Nov 14, 2026
1c7e035
Merge branch 'feat/mobile-form-rules' into feat/mobile-vertex-edit
giswqs Nov 14, 2026
bdbcb54
fix(mobile): Delete Feature works with nothing selected, and leaves o…
giswqs Nov 14, 2026
03d1299
test(mobile): drop an unused count
giswqs Nov 14, 2026
79fa7db
Merge branch 'feat/mobile-vertex-edit' into feat/mobile-track
giswqs Nov 14, 2026
d47bfcd
fix(mobile): an average stops with the position, a refused track stil…
giswqs Nov 14, 2026
7a5fadc
fix(mobile): typing ends only when Android says the keyboard went, an…
giswqs Nov 14, 2026
2a5f9cc
Merge branch 'feat/mobile-form-rules' into feat/mobile-vertex-edit
giswqs Nov 14, 2026
1853e56
fix(mobile): a picked vertex an undo moved or took away is let go
giswqs Nov 14, 2026
efd858f
Merge branch 'feat/mobile-vertex-edit' into feat/mobile-track
giswqs Nov 14, 2026
3016f5f
fix(mobile): a track goes to a Tracks layer with its fields, is added…
giswqs Nov 14, 2026
c4fc886
fix(mobile): a calendar closes when its field is narrowed to chips, a…
giswqs Nov 14, 2026
b94a0d8
Merge branch 'feat/mobile-form-rules' into feat/mobile-vertex-edit
giswqs Nov 14, 2026
53603e8
fix(mobile): Move Point Here refuses a multipoint, which it would mov…
giswqs Nov 14, 2026
c40e715
fix(mobile): import VertexId where it is used
giswqs Nov 14, 2026
72eb09b
Merge branch 'feat/mobile-vertex-edit' into feat/mobile-track
giswqs Nov 14, 2026
8a2c778
fix(mobile): a Tracks layer needs its fields by their exact names, an…
giswqs Nov 14, 2026
3b1ed75
Merge remote-tracking branch 'origin/main' into feat/mobile-vertex-edit
giswqs Nov 14, 2026
b8053e3
Address Claude review feedback
giswqs Nov 14, 2026
1e22688
Merge commit 'b8053e37' into feat/mobile-track
giswqs Nov 14, 2026
cf963fa
Merge remote-tracking branch 'origin/main' into feat/mobile-track
giswqs Nov 14, 2026
94e25ce
Address review feedback
giswqs Nov 14, 2026
5f14be5
Address review feedback
giswqs Nov 14, 2026
80d91cd
Address review feedback
giswqs Nov 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion apps/rustgis-mobile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ RustGIS on Android ([#1902](https://github.com/opengeos/RustGIS/issues/1902)). I
front end (`rustgis-ui-egui`) in a `NativeActivity`, with the system's file picker for opening and
saving, and the touch interface (`rustgis-ui-touch`) around its map, which can capture points,
lines and polygons with their attributes, edit their shapes, snap, and show where the device is.
It is not a field app yet: positions aren't averaged or logged as a track, and there are no photos.
It averages positions and records tracks. It is not a field app yet: there are no photos, and a
track stops while the app is out of sight.

## Build

Expand Down Expand Up @@ -111,6 +112,19 @@ sheet and at the top of the Capture sheet, moves the map so the capture cross is
or a vertex added then is at the device's position. **Hide My Position** stops asking, which
spares the battery.

**Average Position**, beside Go to My Position in the Capture sheet, averages the positions that
come while it runs: each weighted by how exact Android says it is (one over its accuracy squared),
and the sheet says how many and how far they lie from their average. **Use Average** puts the
cross there, for a point or a vertex more exact than one position.

**Record a Track**, in the More sheet with the position shown, draws where the device goes as it
goes, with a bar over the buttons that counts its positions and has **Stop**. Stopping (or Hide My
Position) adds the track as one line to the map's **Tracks** layer, made when the map has none,
named for when it started, with its count and length in minutes. A position less exact than 50 m
is left out, and the notice says how many were. Every position Android reports reaches the track,
not only the last one each frame (`RustGisApp::fixes`). The track is kept in memory until it is
stopped: an app the system ends loses it.

**Edit**, beside **Add** at the top of the Capture sheet, changes the shapes already on the
map, the same way: the map is moved under the cross. **Pick Feature at Cross** picks the layer's
feature drawn on top under it (within half a finger) and draws its vertices. For a line or polygon,
Expand Down
5 changes: 3 additions & 2 deletions apps/rustgis-mobile/java/org/rustgis/mobile/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
* picked purpose name path a chosen file, copied to the app's storage
* cancelled a picker closed without a choice
* saved name a file written where the user chose
* position lon lat accuracy where the device is (accuracy in metres, or empty)
* position lon lat accuracy time where the device is (accuracy in metres, or empty;
* time in milliseconds since 1970)
* stopped positioning ended without being asked to
* failed text what went wrong, to show the user
*/
Expand Down Expand Up @@ -182,7 +183,7 @@ private void startLocating() {
@Override
public void onLocationChanged(android.location.Location fix) {
add("position\t" + fix.getLongitude() + "\t" + fix.getLatitude() + "\t"
+ (fix.hasAccuracy() ? Float.toString(fix.getAccuracy()) : ""));
+ (fix.hasAccuracy() ? Float.toString(fix.getAccuracy()) : "") + "\t" + fix.getTime());
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion apps/rustgis-mobile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ mod android {
Event::Picked { purpose, name, path } => self.waiting.push((purpose, name, path)),
Event::Cancelled => {}
Event::Saved { name } => self.app.session.notify(i18n::fmt("Saved {name}.", &[("name", &name)]), false),
Event::Position(fix) if self.locating => self.app.position = Some(fix),
Event::Position(fix) if self.locating => self.app.report_position(fix),
// A fix that was on its way when positioning was turned off.
Event::Position(_) => {}
// Android ended positioning itself (its reason is a failure beside this): the
Expand Down
55 changes: 41 additions & 14 deletions crates/engine/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ pub struct Fix {
/// The radius the system gives the position to (about two times in three), in metres, when
/// it says.
pub accuracy: Option<f64>,
/// When the system found it, in milliseconds since 1970 (UTC), when it says.
pub time: Option<i64>,
}

/// What the system did since the front end last asked.
Expand Down Expand Up @@ -50,7 +52,8 @@ pub enum Event {
impl Event {
/// Reads an event a shell passed as one line of tab-separated fields (`picked`, `cancelled`,
/// `saved`, `position`, `stopped`, `failed`). A line that is none of these is a failure that quotes it: nothing a
/// shell reports is dropped.
/// shell reports is dropped. A position is `position`, longitude, latitude, accuracy (empty
/// when unknown) and, optionally, its time in milliseconds since 1970.
pub fn parse(line: &str) -> Event {
let fields: Vec<&str> = line.split('\t').collect();
match fields.as_slice() {
Expand All @@ -61,19 +64,32 @@ impl Event {
["stopped"] => Event::Stopped,
// A name is the user's own text and may hold a tab: the rest of the line is the name.
["saved", name @ ..] if !name.is_empty() => Event::Saved { name: name.join("\t") },
["position", lon, lat, accuracy] => match (lon.parse::<f64>(), lat.parse::<f64>()) {
// A place on the Earth, or it is no position: a failure that quotes the line.
(Ok(lon), Ok(lat)) if (-180.0..=180.0).contains(&lon) && (-90.0..=90.0).contains(&lat) => {
// No accuracy given is no accuracy; one given that isn't a distance is a line
// RustGIS doesn't know, not a position quietly taken without it.
match accuracy.parse::<f64>() {
_ if accuracy.is_empty() => Event::Position(Fix { lon, lat, accuracy: None }),
Ok(metres) if metres.is_finite() && metres >= 0.0 => Event::Position(Fix { lon, lat, accuracy: Some(metres) }),
_ => Event::Failed(format!("The system reported something RustGIS doesn't know: {line}")),
["position", lon, lat, accuracy, rest @ ..] if rest.len() <= 1 => {
let unknown = || Event::Failed(format!("The system reported something RustGIS doesn't know: {line}"));
// A time given that isn't one is a line RustGIS doesn't know, as below.
let time = match rest.first() {
None => None,
Some(ms) => match ms.parse::<i64>() {
Ok(ms) if ms >= 0 => Some(ms),
_ => return unknown(),
},
};
match (lon.parse::<f64>(), lat.parse::<f64>()) {
// A place on the Earth, or it is no position: a failure that quotes the line.
(Ok(lon), Ok(lat)) if (-180.0..=180.0).contains(&lon) && (-90.0..=90.0).contains(&lat) => {
// No accuracy given is no accuracy; one given that isn't a distance is a
// line RustGIS doesn't know, not a position quietly taken without it.
match accuracy.parse::<f64>() {
_ if accuracy.is_empty() => Event::Position(Fix { lon, lat, accuracy: None, time }),
Ok(metres) if metres.is_finite() && metres >= 0.0 => {
Event::Position(Fix { lon, lat, accuracy: Some(metres), time })
}
_ => unknown(),
}
}
_ => unknown(),
}
_ => Event::Failed(format!("The system reported something RustGIS doesn't know: {line}")),
},
}
["failed", text @ ..] => Event::Failed(text.join("\t")),
_ => Event::Failed(format!("The system reported something RustGIS doesn't know: {line}")),
}
Expand Down Expand Up @@ -115,9 +131,17 @@ mod tests {
);
assert_eq!(Event::parse("cancelled"), Event::Cancelled);
assert_eq!(Event::parse("stopped"), Event::Stopped);
assert_eq!(Event::parse("position\t-83.92\t35.96\t4.5"), Event::Position(Fix { lon: -83.92, lat: 35.96, accuracy: Some(4.5) }));
assert_eq!(
Event::parse("position\t-83.92\t35.96\t4.5"),
Event::Position(Fix { lon: -83.92, lat: 35.96, accuracy: Some(4.5), time: None })
);
// No accuracy given: the position stands without it.
assert_eq!(Event::parse("position\t10\t20\t"), Event::Position(Fix { lon: 10.0, lat: 20.0, accuracy: None }));
assert_eq!(Event::parse("position\t10\t20\t"), Event::Position(Fix { lon: 10.0, lat: 20.0, accuracy: None, time: None }));
// With its time.
assert_eq!(
Event::parse("position\t10\t20\t3\t1794787200000"),
Event::Position(Fix { lon: 10.0, lat: 20.0, accuracy: Some(3.0), time: Some(1_794_787_200_000) })
);
assert_eq!(Event::parse("saved\tmap.png"), Event::Saved { name: "map.png".into() });
assert_eq!(Event::parse("saved\tmy\tmap.png"), Event::Saved { name: "my\tmap.png".into() });
// A failure's text is kept whole, tabs and all.
Expand All @@ -137,6 +161,9 @@ mod tests {
"position\t10\t20\t-1",
"position\t10\t20\tabc",
"position\t10\t20\tinf",
"position\t10\t20\t3\tsoon",
"position\t10\t20\t3\t-5",
"position\t10\t20\t3\t1\t2",
] {
match Event::parse(line) {
Event::Failed(text) => assert!(text.ends_with(line), "{text}"),
Expand Down
27 changes: 27 additions & 0 deletions crates/ui-egui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,23 @@ const CAPTURE_PIXELS: f64 = 16_000_000.0;
/// The lowest dpi a layout is copied at: a page that would need less is an error.
const CAPTURE_MIN_DPI: f64 = 36.0;

/// The most positions [`RustGisApp::fixes`] keeps for an interface to take: a day of one a second.
pub const FIXES_KEPT: usize = 86_400;

impl RustGisApp {
/// Keeps a position the shell reported: the last one in [`RustGisApp::position`], and each in
/// [`RustGisApp::fixes`] until an interface takes them (the oldest dropped past
/// [`FIXES_KEPT`]).
pub fn report_position(&mut self, fix: rustgis_engine::platform::Fix) {
self.position = Some(fix);
if self.fixes.len() >= FIXES_KEPT {
Comment thread
giswqs marked this conversation as resolved.
Resolved
self.fixes.pop_front();
self.fixes_dropped += 1;
}
self.fixes.push_back(fix);
}
}

pub struct RustGisApp {
pub session: Session,
pub ui: UiState,
Expand Down Expand Up @@ -1145,6 +1162,14 @@ pub struct RustGisApp {
/// Where the device is, as the shell last reported it; `None` until it has, and again once
/// positioning is off. An interface draws it on the map and can capture at it.
pub position: Option<rustgis_engine::platform::Fix>,
/// Every position the shell reported since an interface last took them, oldest first (at most
/// [`FIXES_KEPT`]: the oldest go first). [`RustGisApp::position`] is only the last: a track
/// or an average needs each, including those that arrived together after the app was out of
/// sight.
pub fixes: std::collections::VecDeque<rustgis_engine::platform::Fix>,
/// How many positions were dropped from [`RustGisApp::fixes`] past [`FIXES_KEPT`] since an
/// interface last took them: the interface says so when a track or an average missed them.
pub fixes_dropped: usize,
/// Watches linked local files for changes made outside RustGIS and offers Reload Data
/// (the desktop app; see [`diskwatch`]). Off for tests, unless one turns it on (as `ui_shot`'s
/// `watchFiles` does).
Expand Down Expand Up @@ -1414,6 +1439,8 @@ impl RustGisApp {
chrome: None,
locate: false,
position: None,
fixes: std::collections::VecDeque::new(),
fixes_dropped: 0,
#[cfg(not(target_arch = "wasm32"))]
watch_files: false,
#[cfg(not(target_arch = "wasm32"))]
Expand Down
Loading
Loading