Repository navigation
feat(engine): map.convertPosition gives a place in every form RustGIS writes (#1042) - #2312
Conversation
… writes (opengeos#1042) A read-only command for scripts, Python and the AI Assistant (opengeos#1042, piece 6). It reads the place as map.goToXY does (lon and lat, or a position in any form the search box reads) and answers with longitude and latitude, decimal degrees and DMS as the status bar writes them, UTM (UPS in the polar areas) with its zone, band, hemisphere, easting and northing, and MGRS spaced and in one word, to 0 to 5 digits. What the reading assumed is said as goToXY says it; the map doesn't move; on another body's map the grids are null and a note says why. map.goToXY and map.convertPosition share one reader of the place.
…on every body, and says a missing MGRS UPS goes in its own ups key (grid says which), note is always present, a missing MGRS reference is said in note, and degrees read from degrees, minutes and seconds come back without float noise.
…ers -0, and is among the Assistant's common commands
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
| C::new("map.goToXY", "By Coordinates…", "Home › Navigate › Locate", go_to_xy).roles(&[]).effects(crate::policy::Effects::NONE) | ||
| .view() | ||
| .params(r#"{"lon" | "x": degrees (-74.006, or text such as 74°0′22″W), "lat" | "y": degrees (40.7128, or text such as 40°42′46″N), "position"?: text in place of lon and lat, as the search box reads it, latitude first (40.7128, -74.006; 18north 583959 4507351; 18TWL8395907350), "scale"?: number, "bearing"?: degrees clockwise from north, "pitch"?: degrees of tilt (0 to 85)}"#), | ||
| C::new("map.convertPosition", "Convert Position", "Home › Navigate › Locate", convert_position).roles(&[]).effects(crate::policy::Effects::NONE) |
There was a problem hiding this comment.
Reach (AGENTS.md "Reach every surface"). map.goToXY has a dialog on the desktop (chrome.rs search_action, "map.goToXY" => Dialog("goToXY")). map.convertPosition has no entry there, so the desktop has no form to take its input and no place that shows its answer, since the returned JSON is only visible to scripts, Python and the Assistant. The PR description covers those surfaces but says nothing about the desktop ribbon and command search, the browser, the phone (ui-touch), MCP or plugins, or why each doesn't apply. Please either state that in the PR or show how the desktop reaches the result. Confidence: medium (about 55%). I did not verify how command search treats a command with required parameters that has no dialog route.
There was a problem hiding this comment.
Added a Surfaces section to the description. Short version: CLI, Python, MCP, the Assistant, the web app and plugins all reach it as a command. On the desktop and phone there's no dialog on purpose, since the status-bar readout and the right-click menu already show and copy each form. It's read-only, so there's nothing to undo.
| } else { | ||
| if let Some(u) = rustgis_geom::to_utm(c) { | ||
| out["grid"] = json!("utm"); | ||
| out["utm"] = json!(u.to_string()); |
There was a problem hiding this comment.
Possible inconsistency within one answer. The utm string comes from Utm's Display, which rounds easting and northing to whole meters (utm.rs:265, .round()). The mgrs field comes from to_mgrs, which floors them (utm.rs:404, .floor()). A point with easting 583959.7 therefore returns easting: 583959.7, utm: "18north 583960 …" and mgrs: "18T WL 83959 …" in the same object. The existing test point (New York) has a fractional part under 0.5, so it hides this. Confidence: low to medium (about 40%). The Display rounding predates this PR, but this command now puts both forms side by side. Either format utm from the floored values, or say in the doc that the two can differ by one meter. I did not check whether the coordinate readout relies on the rounded form.
There was a problem hiding this comment.
Right, that's how the readouts behave too: the UTM text rounds to the meter as GeoConvert writes it, and MGRS truncates by definition. I kept both and said so in the user guide in 9784702, with easting and northing there for the exact place. That commit also makes every field come from the same rounded place, so they agree on the hemisphere right at the equator.
Code reviewBugs
Security
Performance
Quality
AGENTS.md
Already raised in earlier threads: none. Checked: Change sizeCompared: the whole PR against main (merge base e65ee78 to PR head 0fe4615).
|
📖 Docs preview
GitHub Pages takes a minute or two to publish a new commit. |
…they agree at the equator Every field is made from the rounded place, so a tiny negative latitude no longer gives lat 0 with a southern hemisphere, and easting and northing are truncated to the millimeter as MGRS truncates, so a northing just south of the equator stays short of 10,000,000 m. The note on another body names UPS too, and the user guide says the UTM text rounds to the meter while MGRS truncates.
Code reviewNo confirmed defects. I read the diff against the surrounding code, the UTM/UPS/MGRS helpers, and the existing Bugs
Security
Performance
Quality
AGENTS.md
Earlier concerns: 2 existing threads reviewed and left alone (desktop reach, still unanswered; utm/MGRS rounding, which the new Change sizeCompared with the base branch: the whole PR, merge base e65ee78 to head 9784702.
|
Summary
Piece 6 of #1042:
map.convertPosition, a command that gives a place in every form RustGIS writes one, for scripts, Python and the AI Assistant. It doesn't move the map.It reads the place the way
map.goToXYdoes:lonandlat(numbers, or degrees, minutes and seconds), or apositionin any form the search box reads (decimal or DMS, UTM, UPS, MGRS).It answers with:
lonandlat, plusdecimalanddmsas the status bar writes them;grid(utm, orupsfrom 84° N and south of 80° S), and the reference inutmorups;zoneandband,hemisphere,eastingandnorthingin meters;mgrs(spaced, as the readout writes it) andmgrsCompact.digits(0 to 5) sets the MGRS precision. Every key is always present,nullwhere it has no value.What the reading assumed is said, as
goToXYsays it: two bare numbers read latitude first, or an MGRS square taken at its center.On another body's map the Earth's grids are
null, andnotesays why.map.goToXYandmap.convertPositionnow share one reader of the place, so they can't drift apart.It's in the Assistant's list of common commands, and the Coordinate readouts section of
docs/user-guide/maps.mddocuments it with a CLI and a Python example.returns, among the rest,
"grid": "utm","zone": 18,"band": "T","easting": 583959.5,"northing": 4507350.5(the center of that 1 m square), and"mgrs": "18T WL 83959 07350".No new dependency; nothing changes in
map.goToXY's behavior.Surfaces
rustgis-cli run --cmd,Session.run,run_commandand the Assistant all reach it. Its parameters come from the registry, and it's in the Assistant's common commands, so the Assistant sees it without a search.Effects::NONE), so it needs no permission.map.zoomToExtent.Testing
cargo xtask cipasses.convert_position_gives_every_formcovers:GeoConvertvalues thatgoToXY's test already uses;2.0), the two notices and their absence, refusals, the map not moving, and a map of Mars;go_to_xy_reads_a_position_as_the_search_box_doespasses unchanged.UI evidence
No visible UI change.
Related issue
Part of #1042 (piece 6).