Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
0d23862
fix(engine): a COG tile layer says what its header leaves out once th…
deniial00 Nov 12, 2026
a190e5d
fix(engine): an undo doesn't say a COG tile layer's header losses aga…
deniial00 Nov 12, 2026
3421e15
fix(engine): COG tile layers' header losses are said one notice a kin…
deniial00 Nov 12, 2026
97e9b13
chore(engine): #1331 review nits: the landing comment, a wasm guard o…
deniial00 Nov 12, 2026
612f590
feat(engine): the landing check reads no header itself, so a COG tile…
deniial00 Nov 12, 2026
b6b413f
chore(engine): #1331 round 4 nits: the test helper asks only for laye…
deniial00 Nov 12, 2026
58c6a74
fix(engine): a dated COG series names the date's file in what it says…
deniial00 Nov 12, 2026
e8aa911
fix(engine): #1331 pre-push review: a dated file is named by its path…
deniial00 Nov 12, 2026
a85db20
test(engine): #1331 pre-push review: the rename is undone, the token …
deniial00 Nov 12, 2026
b46974d
test(engine): #1331 the dated test's doc says when each date is said
deniial00 Nov 12, 2026
4675878
fix(engine): a dated COG series says a date whose header lands after …
deniial00 Nov 13, 2026
8f45857
fix(engine): #1331 a dated series keeps only the dates' reads under w…
deniial00 Nov 13, 2026
495b041
fix(engine): #1331 the date shown now stays among the reads under way…
deniial00 Nov 13, 2026
3697605
fix(engine): #1331 a dated series keeps the date it leaves; undo and …
deniial00 Nov 13, 2026
d936188
fix(map): #1331 only a COG tile layer keeps the dates it has shown
deniial00 Nov 13, 2026
43af761
test(map): #1331 the dates a COG keeps as shown, by address, from a l…
deniial00 Nov 13, 2026
ce0a5c3
fix(map): #1331 a COG tile layer keeps only the dates still to say, s…
deniial00 Nov 13, 2026
0d2a01a
docs(engine): #1331 which shown dates the landing check lets go, and …
deniial00 Nov 13, 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
65 changes: 49 additions & 16 deletions crates/engine/src/cmd/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4255,22 +4255,18 @@ pub(crate) fn add_cog_with(s: &mut Session, p: &Value, url: &str, strict: bool,
s.zoom_to(&rustgis_geom::Extent::new(w, so, e, n));
}
r["bounds"] = json!(info.bounds);
// Drawn in place, the tiles are drawn as values (a palette image's by its colour table):
// what the header holds beside them (band and class names, wavelengths) comes only with a
// window, and is said.
let l = &info.layout;
let named = l
.described
.as_ref()
.is_some_and(|d| d.bands.iter().any(|b| b.description.is_some() || !b.categories.is_empty() || b.wavelength.is_some()));
let mut said: Vec<String> = l.lost.clone();
said.extend(l.described.iter().flat_map(|d| d.lost.iter().map(|x| format!("{}: {x}", rustgis_data::raster::pam::GDAL_METADATA))));
if named {
said.push("drawn in place without its band names, class names or wavelengths: a window (\"bbox\") reads them".into());
}
// A tile layer's own name, as added.
let shown = r.get("name").and_then(Value::as_str).unwrap_or(name).to_string();
for line in said {
// A tile layer's own name, as added (and a dated series' file); its header's losses said
// now, and not again as the map draws (see `Session::notice_landed_rasters`).
let index = r.get("index").and_then(Value::as_u64).and_then(|i| usize::try_from(i).ok());
let mut shown = r.get("name").and_then(Value::as_str).unwrap_or(name).to_string();
if let Some(t) = index.and_then(|i| s.map_mut().tiles.get_mut(i)) {
shown = cog_tile_where(t, &t.url);
let file = crate::render::rustgis_tiles::cog::split(&t.url).0.to_string();
if !t.headers_said.contains(&file) {
t.headers_said.push(file);
}
}
for line in cog_tile_losses(&info) {
s.notify(format!("{shown}: {line}"), false);
}
} else if probed || why.is_some() || r.get("dated").is_some() {
Expand All @@ -4284,6 +4280,43 @@ pub(crate) fn add_cog_with(s: &mut Session, p: &Value, url: &str, strict: bool,
Ok(r)
}

/// Where a cloud-optimised GeoTIFF tile layer's header losses are said: its name, and for a dated
/// series the file of `address`, one of its dates' (the last part of its path: the host, a login
/// wrapper, the query and the fragment stay out of what is said).
pub(crate) fn cog_tile_where(t: &rustgis_map::tiles::TileLayer, address: &str) -> String {
if t.time_url.is_none() && t.time_urls.is_empty() {
return t.name.clone();
}
let inner = rustgis_data::login_address::inner(rustgis_data::s3_address::inner(address));
let address = inner.split(['?', '#']).next().unwrap_or(inner);
// The path after the host (an address without a scheme is a path already); one without a
// path names no file.
let path = match address.split_once("://") {
Some((_, rest)) => rest.split_once('/').map_or("", |(_, path)| path),
None => address,
};
let file: String = path.rsplit(['/', '\\']).next().unwrap_or_default().chars().take(80).collect();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A cut file name is shown without saying it was cut (AGENTS.md › Never silent, medium confidence)

This is a re-raise of the earlier thread on this line. The reply that it is "left for the release quality pass" doesn't fit this rule. AGENTS.md lists "field names cut" among the losses a reader or command must report, and that is what this take(80) does: a long file name in a notice is shortened with no sign of it. It is a rule point, not a style point, so it belongs in this PR. The fix is small and marks the cut:

Suggested change
let file: String = path.rsplit(['/', '\\']).next().unwrap_or_default().chars().take(80).collect();
let name = path.rsplit(['/', '\\']).next().unwrap_or_default();
let cut = name.chars().count() > 80;
let file: String = name.chars().take(80).chain(cut.then_some('…')).collect();

A test for a long file name (notice ends in …) would cover it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left for the release quality pass: marking a cut file name with an ellipsis, with a long-name test, as suggested. (reviewed at 0d2a01a)

if file.is_empty() { t.name.clone() } else { format!("{} ({file})", t.name) }
Comment thread
deniial00 marked this conversation as resolved.
Resolved
}

/// What a cloud-optimised GeoTIFF drawn as a tile layer leaves out of its header, a line each:
/// drawn in place, its tiles are drawn as values (a palette image's by its colour table), so what
/// the header holds beside them (band and class names, wavelengths) comes only with a window. Said
/// as the layer is added, or once its header lands ([`Session::notice_landed_rasters`]).
pub(crate) fn cog_tile_losses(info: &crate::render::rustgis_tiles::cog::Info) -> Vec<String> {
let l = &info.layout;
let named = l
.described
.as_ref()
.is_some_and(|d| d.bands.iter().any(|b| b.description.is_some() || !b.categories.is_empty() || b.wavelength.is_some()));
let mut said: Vec<String> = l.lost.clone();
said.extend(l.described.iter().flat_map(|d| d.lost.iter().map(|x| format!("{}: {x}", rustgis_data::raster::pam::GDAL_METADATA))));
if named {
said.push("drawn in place without its band names, class names or wavelengths: a window (\"bbox\") reads them".into());
}
said
}

/// Adds a cloud-optimised GeoTIFF as a raster layer read in place: its overview held (read now
/// where the session waits for reads in place, failing the command when it can't be; landing as
/// the map draws on the desktop and in the browser, see [`Session::in_place_wait`]), the part in
Expand Down
4 changes: 4 additions & 0 deletions crates/engine/src/cmd/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ fn frames(s: &mut Session, steps: &[f64], w: f64, h: f64, gif: Option<u32>) -> R
// rustgis_render::render_complete) fetches the tiles it lacks and waits for them
// before it draws, so each frame shows its own date's imagery.
let png = super::share::map_png(s, Some(w), Some(h), Some(96.0))?;
// What this date's file left out, said while its header is surely in (a cleared tile
// cache could drop it before the export ends): the slider moves on before the
// command's own landing check.
s.notice_landed_rasters();
match (&mut enc, gif) {
(Some(e), Some(ms)) => {
let img = image::load_from_memory_with_format(&png, image::ImageFormat::Png).map_err(|e| e.to_string())?.to_rgba8();
Expand Down
92 changes: 90 additions & 2 deletions crates/engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,9 @@ pub struct Session {
/// Notices given in this session, including ones no longer kept (see [`Session::notices_since`]),
/// less those a failed command withdrew.
notices_given: u64,
/// The count of cloud-optimised GeoTIFF headers landed when [`Session::notice_landed_rasters`]
/// last looked back at the dates a dated series has shown (`cog::landed_count`).
cog_headers_seen: u64,
/// Layer whose attribute table is open.
pub table_layer: Option<u32>,
/// The standalone table shown in the attribute table instead of a layer, by its id.
Expand Down Expand Up @@ -1159,6 +1162,7 @@ impl Session {
bundled_roots_said: false,
diagnostics: rustgis_data::diagnostics::History::default(),
notices_given: 0,
cog_headers_seen: 0,
table_layer: None,
table_standalone: None,
clipboard: None,
Expand Down Expand Up @@ -2021,8 +2025,10 @@ impl Session {
/// read in place land later: in the browser, a project, an import): what the file's header
/// left out (`Raster::lost`: a colour table missing or short, GDAL metadata that doesn't
/// decode), an overview statistics and tools read, a layer read in place that couldn't be
/// read, and why. Once for each layer's pixels or failure, one notice of each kind; the app
/// calls it each frame.
/// read, and why; and what the header of a cloud-optimised GeoTIFF drawn as a tile layer
/// leaves out, once that header lands (each date's file of a dated series as it is shown).
/// Once for each layer's pixels, failure or file, one notice of each kind; the app calls it
/// each frame.
pub fn notice_landed_rasters(&mut self) {
// Streamed vector windows land after project opening too. Check each installed read
// once, keeping the same counted notice channel as retained resident expressions.
Expand Down Expand Up @@ -2056,6 +2062,53 @@ impl Session {
}
}
}
// A cloud-optimised GeoTIFF drawn as a tile layer (a dated series, a data cube's file,
// AlphaEarth) whose header wasn't in as it was added (the browser, a project opened):
// what its header leaves out, as adding it says it, once its header lands. Its header is
// asked for by the map drawing or exporting it, or by adding it, not here: a layer the map
// doesn't draw starts no read. A dated series' other dates' files it has shown (the slider
// moved on before a header landed, an export of the time steps) are looked at again only
// when a header has landed since the last look; those then neither said nor being read
// (not asked for yet: the slider passed over them, or their tiles still wait their turn)
// are let go, so the list holds only reads under way. A date let go draws nothing until it
// is shown again, and is said then, as the date shown.
use render::rustgis_tiles::cog;
let landed = cog::landed_count();
let look_back = landed != self.cog_headers_seen;
self.cog_headers_seen = landed;
for m in &mut self.project.maps {
for t in m.tiles.iter_mut().filter(|t| t.kind == rustgis_map::tiles::TileKind::Cog) {
// The address shown now, while its header is being read, is kept among those shown,
// whatever showed it (a dated series added, its project opened).
let dated = t.time_url.is_some() || !t.time_urls.is_empty();
if dated && cog::info_loading(&t.url) {
t.note_shown();
}
let back = look_back.then_some(t.headers_shown.iter().filter(|u| **u != t.url)).into_iter().flatten();
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
// By its file: a look changed at the address's end (`#bands=…`) reads no new header.
let mut hits = Vec::new();
for address in std::iter::once(&t.url).chain(back) {
let file = cog::split(address).0;
if t.headers_said.iter().any(|f| f == file) || hits.iter().any(|(f, _, _): &(String, _, _)| f == file) {
continue;
}
let Some(info) = cog::info_landed(address) else { continue };
hits.push((file.to_string(), cmd::layer::cog_tile_where(t, address), info));
}
for (file, shown, info) in hits {
t.headers_said.push(file);
lost.extend(cmd::layer::cog_tile_losses(&info).into_iter().map(|line| (shown.clone(), line)));
}
if look_back {
// Kept while unsaid and shown now (its read may start as it is drawn), being
// read, or landed since this look (said on the next).
let (said, now) = (&t.headers_said, &t.url);
t.headers_shown.retain(|u| {
!said.iter().any(|f| f == cog::split(u).0) && (u == now || cog::info_loading(u) || cog::info_landed(u).is_some())
});
}
}
}
// What a header left out, as adding the layer says it (one notice a kind, with counts).
cmd::raster::say_losses(self, lost);
// The browser uses its own trust; only native clients can fall back.
Expand Down Expand Up @@ -2422,6 +2475,7 @@ impl Session {
self.reopen_layout(open, saved);
self.keep_time_position(&cur);
self.keep_tile_pick(&cur);
self.keep_headers_said(&cur);
self.redo.push((cur, was, label, actor, std::mem::replace(&mut self.state, state), files, old_trust));
self.touch_all_geometry();
true
Expand All @@ -2446,6 +2500,7 @@ impl Session {
self.reopen_layout(open, saved);
self.keep_time_position(&cur);
self.keep_tile_pick(&cur);
self.keep_headers_said(&cur);
self.undo.push((cur, was, label, actor, std::mem::replace(&mut self.state, state), files, old_trust));
self.touch_all_geometry();
true
Expand Down Expand Up @@ -2491,6 +2546,39 @@ impl Session {
}
}

/// After undo or redo swaps the project: a cloud-optimised GeoTIFF tile layer keeps the files
/// whose header losses were said and the dates' addresses it has shown (neither is an undo
/// step), found again on the map of its name by its kind and its name or file (a rename
/// undone), so a file said since the restored copy was made isn't said again, and one shown
/// since is still said once its header lands. The restored addresses are looked at again on
/// the next landing check, a header having landed meanwhile or not.
fn keep_headers_said(&mut self, before: &Project) {
use render::rustgis_tiles::cog::split;
self.cog_headers_seen = u64::MAX;
let names: Vec<String> = self.project.maps.iter().map(|m| m.name.clone()).collect();
for (i, m) in self.project.maps.iter_mut().enumerate() {
// By its name, else (a map rename undone) the map in the same place, when no map of
// the restored project has that one's name.
let renamed = || before.maps.get(i).filter(|o| !names.contains(&o.name));
let Some(old) = before.maps.iter().find(|o| o.name == m.name).or_else(renamed) else { continue };
for t in m.tiles.iter_mut().filter(|t| t.kind == rustgis_map::tiles::TileKind::Cog) {
let same =
|o: &&rustgis_map::tiles::TileLayer| o.kind == t.kind && (o.name == t.name || split(&o.url).0 == split(&t.url).0);
let old: Vec<&rustgis_map::tiles::TileLayer> = old.tiles.iter().filter(same).collect();
for file in old.iter().flat_map(|o| &o.headers_said) {
if !t.headers_said.contains(file) {
t.headers_said.push(file.clone());
}
}
for address in old.iter().flat_map(|o| &o.headers_shown) {
if t.headers_shown.len() < rustgis_map::time::MAX_STEPS && !t.headers_shown.contains(address) {
t.headers_shown.push(address.clone());
}
}
}
}
}

fn open_layout_name(&self) -> Option<String> {
self.active_layout.and_then(|i| self.project.layouts.get(i)).map(|l| l.name.clone())
}
Expand Down
Loading
Loading