Repository navigation
feat(layout): raster profiles beside a map frame (#2863 part 2) - #3256
elpidioassinaturas wants to merge 1 commit into
Conversation
A Profile element draws, beside a map frame, a raster's profile along one of the frame's section lines: under or over it for a horizontal line, right or left of it for a vertical one. Each sample is read at its point of the line on the page, taken back through the frame's projection, so the curve is straight across from the place it comes from. Its box is the frame's side, which it follows when the frame is moved or resized; dragged or resized, it changes its gap and thickness. It reads any band of a raster held whole, bilinearly, a sample a cell up to 10,000 (Raster::bilinear, moved into rustgis-data from analysis' elevation_at, which now calls it), and draws a line filled under it or not, a value axis (round or given min and max), a distance axis along the ground, guides, a unit, a title and the section's names. One that can't be drawn (a tilted or globe frame, a raster read in place, a band it lacks, no data) draws its placeholder and says why, in its commands, the layout view, exports and reports. A layout with one requires layout-profile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
| self.line_width = finite_or(self.line_width, PROFILE_LINE_WIDTH).clamp(PROFILE_LINE_WIDTHS.0, PROFILE_LINE_WIDTHS.1); | ||
| self.band = self.band.clamp(1, MAX_PROFILE_BAND); | ||
| self.min = self.min.filter(|v| v.is_finite()); | ||
| self.max = self.max.filter(|v| v.is_finite()); |
There was a problem hiding this comment.
A hand-edited file with min at or above max loads unchanged, and given_range then drops both ends at draw time. The value axis silently reverts to the samples' own range, and clamp counts no repair. The command path refuses such a pair on entry (profile_params), so only a hand-edited file reaches this. AGENTS.md's "Never silent" rule asks that a reader which drops or changes a value says so. Repairing the pair on load fixes it, and because Layout::clamp compares the element's kind, the repair counts as an adjusted element with no further change:
| self.max = self.max.filter(|v| v.is_finite()); | |
| self.max = self.max.filter(|v| v.is_finite()); | |
| if matches!((self.min, self.max), (Some(lo), Some(hi)) if lo >= hi) { | |
| (self.min, self.max) = (None, None); | |
| } |
Confidence: high that the value is ignored without a notice. Medium on the fix: the doc says "read only when below the other end", so the maintainers may prefer a notice over a repair.
Category: bug
| out.metres.push(metres); | ||
| out.values.push(at.and_then(|c| r.bilinear(band, c))); | ||
| } | ||
| if out.values.iter().all(Option::is_none) { |
There was a problem hiding this comment.
This fails only when no sample has a value. A line that leaves the raster partway (the raster covers part of the frame's section, or it has a no-data stretch along it) draws a broken curve with no notice. profiles_not_drawn reports only the whole-line failure and the cell count, so the missing part is dropped silently. AGENTS.md's "Never silent" rule asks that a reader or tool that drops data says what, how much and where. A fix would count the samples without a value in ProfileSamples and carry that count in ProfileNote next to cells, then say it in profiles_notice.
Confidence: about 50%. The PR body says "No data breaks the curve", so the gap may be a deliberate choice that still needs a notice.
Category: bug
Code reviewI read the full diff, the base-branch AGENTS.md, and the surrounding code: Bugs
Security
Performance
Quality
AGENTS.md
Change sizeCompared: the whole PR against main (merge base 65e1068 to PR head 9b56f3c).
The table lists the 20 largest changes from |
📖 Docs preview
GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the |
|
Closing in favour of #3277: this part is now split into six PRs of about 400 lines each (2a to 2f), opened one at a time, so each gets a full review. The two open review threads here are carried to the part they belong to. |
…#2863 part 2c) (opengeos#3310) * feat(layout): what keeps a profile from being drawn is said (opengeos#2863 part 2c) A profile that can't be drawn says why, once, with the profile named: a tilted frame or one on the globe, a section line running the other way or one its frame lacks or doesn't draw, a layer that isn't a raster of the frame's map, a band it lacks, a raster read in place (whose overview changes with the scale), no pixels read, no data along the whole line. One read at 10,000 samples along a line crossing more cells says so too. The layout view, PNG, PDF and SVG exports and reports say it, for a map series' PDF on how many pages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(layout): a profile drawn with gaps says how many samples have no value A line that runs off its raster or over no data draws a broken curve; the review of opengeos#3256 (thread r4728204609) asked that it be said. A ProfileNote now carries a drawn profile's samples without a value, and profiles_notice says those profiles in one notice, with how many of all. The test was written first and failed. Part of opengeos#2863 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(layout): a report says a profile it doesn't draw, its layout named Part of opengeos#2863 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(layout): a thinned or gapped profile says on how many pages Review round 1 of opengeos#3310. Over several pages, the thinned and gaps notices dropped the pages a profile is on, which the not-drawn notice gives; they now keep the count and say "on N of M pages". On one page they are unchanged. The test was written first and failed. Also the two wording points on the notice's doc and the layout view's comment. Part of opengeos#2863 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: elpidioassinaturas <elpidiofilho@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Part of #2863 (part 2 of 5: profiles along a side,
layout-profile). Part 1, the section lines, is in main (#2872, #3140).What it does
A new layout element, Profile (Publish › Map Surrounds, and
layout.addElementwith"kind": "profile"), draws the profile of a raster along one of its frame's section lines, beside the frame:profile.createfollows.Profile::rect): under or over the frame for a horizontal section line, right or left of it for a vertical one, with a gap and a thickness of its own. Moving or resizing the frame takes the profile with it (Layout::fit_profiles, run bylayout.update,layout.duplicateElementand when a layout is read). Dragging the profile changes its gap, resizing it its thickness; along the frame it keeps the frame's.layerandband(1-based); not always band 1 called elevation. It has atitle(default: the layer's name), aunitafter the value axis' numbers, and the value axis from the samples out to round numbers, orminandmaxgiven, so two profiles can share a scale. The distance axis counts along the ground (WGS 84) from the line's A end, in the units a scale bar takes. Guide lines, the section's names at the ends (in its colour), an ink (color), a background, the layout's decimal comma.lineColor,lineWidth), filled under it in one colour (fill,nullfor none). No data breaks the curve.profile.*commands' limit), bilinear, nothing smoothed. The bilinear read moves torustgis-data(Raster::bilinear), whichrustgis-rendercan reach;rustgis_analysis::rasterops::elevation_atnow calls it, soprofile.*keep their results.Never silent
A profile that can't be drawn draws its placeholder, and says why, once, with the profile named: when it is added or changed, in the layout view, and in PNG, PDF and SVG exports and reports (for a map series' PDF, on how many pages):
A profile read at 10,000 samples along a line crossing more cells says so, with the cells.
Checks against
profile.create(the issue's Mantiqueira)On the Copernicus DEM GLO-30 of the issue (UTM 23S, 1:200,000, frame 186 × 112 mm), with this branch:
profile.createbetween the ends, as many samplesThe vertical line of a UTM frame strays little from the straight line of longitude and latitude between its ends, so the two agree within 0.12 m, as the issue found (0.11 m over 1,600 samples). The horizontal one strays:
profile.createreads up to 14.7 m off the page's line there, which is what the profile is for. The tests repeat both on a synthetic relief of the same frame (the DEM isn't committed):the_mantiqueira_profile_agrees_with_profile_create(within 0.5 m), anda_profile_is_read_along_the_line_on_the_page/the_page_line_is_not_a_straight_line_of_longitude_and_latitude, on grids whose value is their own northing or easting, where a page line reads one value end to end and the chord between its ends doesn't.a_profiles_peak_is_drawn_straight_across_from_its_placerenders the page and finds a peak's top within 3 pixels of where the frame shows it, on all four sides, with the frame turned. Lengths are on the ellipsoid;profile.createmeasures on the sphere, 0.4 % longer here.Screenshot
The Mantiqueira page drawn by this branch (Copernicus DEM GLO-30, © DLR e.V. 2010-2014 and © Airbus Defence and Space GmbH 2014-2018, provided under COPERNICUS by the European Union and ESA): two dashed section lines, profile A under the frame and B at its right, sharing a scale from 400 to 2,900 m.
Saved files
A layout with a profile requires
layout-profile(projects, layout files, saved commands:layout.addElementof a profile,layout.updatewith a key only a profile reads,layout.importandreport.existingTemplateof a layout file with one). A layout without one keeps its bytes. Schema regenerated; new fixtureschema/fixtures/layout_profile.rgis, read back byte for byte by the layout-file test. A hand-edited file is brought into range (gap, thickness, line width, band, one-line title and unit), and a profile saved away from its frame's side is put back beside it, counted as adjusted.Reach
layout.updatesets everything.layout.addElement/layout.update, whose help lists the new keys; command surface updated.layout.removeElement, removing the frame, saved and reopened.Memory and threads
No copy of the raster: a profile holds at most 10,000 samples (three numbers each, 240 KB), worked out when its page is drawn. Sampling runs on the thread that draws the page, as the rest of the page; its work is bounded by the 10,000 samples, so it adds no background command.
Tests
cargo test -j 4forrustgis-data,rustgis-analysis,rustgis-map,rustgis-render,rustgis-engineandrustgis-ui-egui;cargo fmt,cargo clippy -D warningson those crates (all targets),cargo xtask schema --check, and the command-surface snapshot. Locally (Windows): map 515, render 919, analysis all, data 1,914 + 70, ui-egui all (1,683 + the rest), engine lib 2,749 and integration 244 pass; two engine tests fail here as they do on main on this machine (layout_report_text::a_report_measures_each_layout_page_with_its_own_page_number, which measures text with this machine's fonts, andportable_projects::reload::wrong_geometry…, which matches an English OS error).New tests:
a_profile_keeps_to_its_frames_side(map);a_profile_is_read_along_the_line_on_the_page,the_page_line_is_not_a_straight_line_of_longitude_and_latitude,a_profiles_peak_is_drawn_straight_across_from_its_place,a_profile_not_drawn_says_why,a_profiles_value_axis_is_round_or_given(render);a_profile_is_added_follows_its_frame_and_is_undone,a_profile_not_drawn_is_said,the_mantiqueira_profile_agrees_with_profile_create(engine); thelayout-profilesample in the capability tests and the fixture in the layout-file test.No i18n catalogs touched; the icon is drawn in code.
🤖 Generated with Claude Code