Repository navigation
fix(raster): a large local tiled GeoTIFF is read in place, drawn at the level the view needs (#2761) #2772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(raster): a large local tiled GeoTIFF is read in place, drawn at the level the view needs (#2761) #2772
Changes from 1 commit
3089345
117eda9
5719e77
dc10b31
d0fee2f
cf9aaf4
8fa9312
cb2550b
61948da
d3042fc
2455625
8437e3b
c4278f3
d110c71
6927237
76a7672
2c1d10f
628fb51
ad7a034
3b4f70c
36a1f06
037f7d7
019fd96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -395,7 +395,7 @@ pub fn external_start(s: &mut Session, tool: &str, params: &Value) -> Result<Ext | ||||||||||
| return Err(format!("no GeoLibre tool '{tool}'")); | |||||||||||
| } | |||||||||||
| let params = params.clone(); | |||||||||||
| let job = preparing(&continuation, || pin.prepare_suite(&map_inputs(s, Some(spec), ¶ms)?, ¶ms))?; | |||||||||||
| let job = preparing(&continuation, || pin.prepare_suite(&map_inputs(s, Some(spec), ¶ms, false)?, ¶ms))?; | |||||||||||
| s.next_pending = s.next_pending.wrapping_add(1); | |||||||||||
| let id = s.next_pending; | |||||||||||
| let run = ExternalRun { | |||||||||||
|
|
@@ -535,7 +535,7 @@ pub fn plugin_start(s: &mut Session, tool: &str, params: &Value) -> Result<Plugi | ||||||||||
| let plugin = pin.plugin().ok_or_else(|| format!("no plugin tool '{tool}'"))?; | |||||||||||
| let (_, tid) = rustgis_plugins::split_id(spec.id).ok_or("invalid plugin tool id")?; | |||||||||||
| let (job, full_ids) = preparing(&continuation, || { | |||||||||||
| let inputs = map_inputs(s, Some(spec), resolved)?; | |||||||||||
| let inputs = map_inputs(s, Some(spec), resolved, false)?; | |||||||||||
| let job = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { | |||||||||||
| rustgis_plugins::tools::prepare_pinned(plugin.plugin(), tid, &inputs, resolved) | |||||||||||
| })) | |||||||||||
|
|
@@ -710,7 +710,7 @@ impl ToolRun { | ||||||||||
| // A bug in reading the inputs, like one in a tool, must not take the app down. | |||||||||||
| let mut done = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { | |||||||||||
| crate::render::rustgis_tiles::cache::with_still(still, || { | |||||||||||
| let inputs = match inputs_of(snap, Some(spec), ¶ms) { | |||||||||||
| let inputs = match inputs_of(snap, Some(spec), ¶ms, true) { | |||||||||||
| Ok(inputs) => inputs, | |||||||||||
| // A Cancel while the inputs are read names the tool, as one while it runs does. | |||||||||||
| Err(_) if control.is_cancelled() => { | |||||||||||
|
|
@@ -1309,6 +1309,9 @@ struct MapInputs<'a> { | ||||||||||
| /// Import warnings from local file inputs, kept in the tool result and history. | |||||||||||
| messages: Vec<String>, | |||||||||||
| losses: Vec<LossMessage>, | |||||||||||
| /// Raster layers read in place from a file on this computer, read again from it for the run | |||||||||||
| /// ([`tiled_inputs`]), by lowercase name. | |||||||||||
| rasters: std::collections::HashMap<String, std::sync::Arc<rustgis_data::raster::Raster>>, | |||||||||||
| /// The flat map's projection (its name, the projection and its unit in metres), built the | |||||||||||
| /// first time a tool asks for it (Tissot's indicatrix does), once for the run; `None` on the | |||||||||||
| /// globe. | |||||||||||
|
|
@@ -1363,14 +1366,28 @@ impl MapInputs<'_> { | ||||||||||
| } | |||||||||||
| } | |||||||||||
|
|
|||||||||||
| fn map_inputs<'a>(s: &'a Session, spec: Option<&rustgis_analysis::ToolSpec>, params: &Value) -> Result<MapInputs<'a>, String> { | |||||||||||
| inputs_of(Snapshot::of(s), spec, params) | |||||||||||
| /// [`inputs_of`] from the session as it is; `read_tiled` as there. | |||||||||||
| fn map_inputs<'a>( | |||||||||||
| s: &'a Session, | |||||||||||
| spec: Option<&rustgis_analysis::ToolSpec>, | |||||||||||
| params: &Value, | |||||||||||
| read_tiled: bool, | |||||||||||
| ) -> Result<MapInputs<'a>, String> { | |||||||||||
| inputs_of(Snapshot::of(s), spec, params, read_tiled) | |||||||||||
| } | |||||||||||
|
|
|||||||||||
| /// A tool's inputs from what it read of the session: the streamed layers and files it names read | |||||||||||
| /// whole, and the rows of each layer it runs on. It reads, so a background run does this on its | |||||||||||
| /// thread. | |||||||||||
| fn inputs_of<'a>(snap: Snapshot<'a>, spec: Option<&rustgis_analysis::ToolSpec>, params: &Value) -> Result<MapInputs<'a>, String> { | |||||||||||
| /// thread. With `read_tiled`, the raster layers it reads that are read in place from a file on | |||||||||||
| /// this computer are read from the file ([`tiled_inputs`]): only where the read may take long (a | |||||||||||
| /// built-in tool's run), never for a plugin's run or a suite tool's preparation on the app's | |||||||||||
| /// thread, which read the overview the layer holds, or the file by its path. | |||||||||||
| fn inputs_of<'a>( | |||||||||||
| snap: Snapshot<'a>, | |||||||||||
| spec: Option<&rustgis_analysis::ToolSpec>, | |||||||||||
| params: &Value, | |||||||||||
| read_tiled: bool, | |||||||||||
| ) -> Result<MapInputs<'a>, String> { | |||||||||||
| let (full, said) = streamed_inputs(&snap.map, spec, params)?; | |||||||||||
| let (mut messages, mut losses) = (Vec::new(), Vec::new()); | |||||||||||
| for m in said { | |||||||||||
|
|
@@ -1401,6 +1418,13 @@ fn inputs_of<'a>(snap: Snapshot<'a>, spec: Option<&rustgis_analysis::ToolSpec>, | ||||||||||
| let mut rows = env_inputs(&snap.map, &full, &snap.env, params)?; | |||||||||||
| narrow_to_queries(&snap.map, spec, params, &full, &mut rows, &mut messages)?; | |||||||||||
| let unread = if work == Crs::LonLat { std::collections::HashSet::new() } else { attributes_only(spec, params) }; | |||||||||||
| #[cfg(not(target_arch = "wasm32"))] | |||||||||||
| let rasters = if read_tiled { tiled_inputs(&snap.map, spec, params, &mut messages)? } else { std::collections::HashMap::new() }; | |||||||||||
| #[cfg(target_arch = "wasm32")] | |||||||||||
| let rasters = { | |||||||||||
| let _ = read_tiled; | |||||||||||
| std::collections::HashMap::new() | |||||||||||
| }; | |||||||||||
| Ok(MapInputs { | |||||||||||
| snap, | |||||||||||
| rows, | |||||||||||
|
|
@@ -1409,11 +1433,54 @@ fn inputs_of<'a>(snap: Snapshot<'a>, spec: Option<&rustgis_analysis::ToolSpec>, | ||||||||||
| unread, | |||||||||||
| messages, | |||||||||||
| losses, | |||||||||||
| rasters, | |||||||||||
| flat: std::cell::OnceCell::new(), | |||||||||||
| view: std::cell::OnceCell::new(), | |||||||||||
| }) | |||||||||||
| } | |||||||||||
|
|
|||||||||||
| /// The raster layers `spec`'s parameters name that are read in place from a file on this | |||||||||||
| /// computer ([`rustgis_map::raster::RasterLayer::tiled`]), each read again from the file for the | |||||||||||
| /// run, by lowercase name: such a layer holds only the small overview the map draws from zoomed | |||||||||||
| /// out, and a tool reads the finest level of the file it can hold, the full image when it fits | |||||||||||
| /// (#2761). Read on the run's thread, stopping on its Cancel; one read from an overview is said. | |||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doc comment says the read stops on Cancel, but it doesn't. Category: agents-md
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The read does look at Cancel. The GeoTIFF reader calls |
|||||||||||
| #[cfg(not(target_arch = "wasm32"))] | |||||||||||
| fn tiled_inputs( | |||||||||||
| map: &rustgis_map::Map, | |||||||||||
| spec: Option<&rustgis_analysis::ToolSpec>, | |||||||||||
| params: &Value, | |||||||||||
| messages: &mut Vec<String>, | |||||||||||
| ) -> Result<std::collections::HashMap<String, std::sync::Arc<rustgis_data::raster::Raster>>, String> { | |||||||||||
| use rustgis_analysis::ParamKind; | |||||||||||
| let mut read = std::collections::HashMap::new(); | |||||||||||
| let Some(spec) = spec else { return Ok(read) }; | |||||||||||
| for parameter in spec.params { | |||||||||||
| let value = params.get(parameter.name).unwrap_or(&Value::Null); | |||||||||||
| let names: Vec<&str> = match parameter.kind { | |||||||||||
| ParamKind::RasterLayer => value.as_str().into_iter().collect(), | |||||||||||
| ParamKind::RasterLayers => rustgis_analysis::layer_list(value).unwrap_or_default(), | |||||||||||
| _ => continue, | |||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ByPath refusal only covers raster-kinded parameters, so a GeoLibre file/other-kinded parameter can still stage the held overview silently.
Failure: a tiled layer whose file was moved, named in a GeoLibre tool parameter declared as a file. The tool runs on the overview and reports success. Fix: in Category: bug
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 019fd96. In |
|||||||||||
| }; | |||||||||||
| for name in names { | |||||||||||
| let Some(l) = map.layer_by_name(name) else { continue }; | |||||||||||
| let key = l.name.to_ascii_lowercase(); | |||||||||||
| let Some(path) = l.raster.as_ref().filter(|rl| rl.tiled).and_then(|rl| rl.path.as_deref()) else { continue }; | |||||||||||
| if read.contains_key(&key) { | |||||||||||
| continue; | |||||||||||
| } | |||||||||||
| let r = rustgis_data::raster::read_path_with(std::path::Path::new(path), None, None).map_err(|e| format!("{}: {e}", l.name))?; | |||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Every built-in tool run that names a tiled layer now decodes the file again, whole-file reader up to The PR measures only open and export, not tool runs. Please measure a tool run on the reporter's file (wall time and peak memory) and either keep the decoded raster for the layer's current Category: performance
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Measured on the reporter's file: open it, then run Zonal Statistics twice over one small polygon (release CLI, Linux, one run each).
Repetition: 5719e77 keeps a batch's reads for as long as the batch runs, so its items read each file once ( Narrowing to the extent: the environment's extent doesn't clip raster inputs today. A read clipped to the extent or to a zone's box would need that first, so it is follow-up work. The PR description now gives these numbers and the run's memory as a multiple of the layer. |
|||||||||||
| if let Some((fw, fh)) = r.overview { | |||||||||||
| messages.push(format!( | |||||||||||
| "{}: read at its {} × {} overview of the {fw} × {fh} raster, the finest it can hold", | |||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Built-in tool runs add one overview note per tiled input, while plugin runs now join theirs into one notice. With two or more tiled raster inputs, this pushes one message for each layer (the same kind of overview read each time). The plugin path was changed to one joined notice (d0fee2f) for the same reason. Joining these messages here as well would keep the names and counts while saying it once per run. This is a nit; I'm leaving it for the release quality pass if the maintainers prefer, but it is the same pattern as the earlier plugin thread. Category: quality
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 61948da: a built-in run now gives one note naming every tiled input read at an overview, as the plugin path does. |
|||||||||||
| l.name, r.width, r.height | |||||||||||
| )); | |||||||||||
| } | |||||||||||
| read.insert(key, std::sync::Arc::new(r)); | |||||||||||
| } | |||||||||||
| } | |||||||||||
| Ok(read) | |||||||||||
| } | |||||||||||
|
|
|||||||||||
| /// Narrows the rows a tool reads of each layer to the features its definition query keeps, as the | |||||||||||
| /// map draws them (#1995): a selection is cut to its drawn features, and a layer without one (or | |||||||||||
| /// with only the environment's extent) reads the kept features instead of every one. A layer whose | |||||||||||
|
|
@@ -1990,9 +2057,11 @@ impl Inputs for MapInputs<'_> { | ||||||||||
| *self.view.get_or_init(|| view_extent(&self.snap)) | |||||||||||
| } | |||||||||||
| fn raster(&self, layer: &str) -> Option<RasterInput<'_>> { | |||||||||||
| let rl = self.snap.map.layer_by_name(layer)?.raster.as_ref()?; | |||||||||||
| let l = self.snap.map.layer_by_name(layer)?; | |||||||||||
| let rl = l.raster.as_ref()?; | |||||||||||
| let read = self.rasters.get(&l.name.to_ascii_lowercase()).map(std::sync::Arc::as_ref); | |||||||||||
| Some(RasterInput { | |||||||||||
| raster: rl.data.as_deref()?, | |||||||||||
| raster: read.or(rl.data.as_deref())?, | |||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GeoLibre runs can silently stage the held overview of a tiled layer whose file has gone. Failure: add a 1 GB tiled GeoTIFF, move it, run a GeoLibre raster tool on the layer. The tool runs on a 326 × 307 image and reports success. Fix: for Confidence: medium-high on the code path; I did not run it. Category: bug
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in cf9aaf4. In |
|||||||||||
| path: rl.path.as_deref(), | |||||||||||
| embedded: rl.embedded.as_deref().map(|b| (rl.file_name.as_deref().unwrap_or("raster.tif"), b.as_slice())), | |||||||||||
| }) | |||||||||||
|
|
@@ -3100,7 +3169,9 @@ pub(crate) fn execute( | ||||||||||
| } | |||||||||||
| #[cfg(not(target_arch = "wasm32"))] | |||||||||||
| let read = recording.then(|| Snapshot::owned(s)); | |||||||||||
| let inputs = match map_inputs(s, Some(spec), params) { | |||||||||||
| // A built-in tool run here (the command line, a script on its own thread) reads a | |||||||||||
| // raster file read in place, as one the app starts on a thread does. | |||||||||||
| let inputs = match map_inputs(s, Some(spec), params, pin.plugin().is_none()) { | |||||||||||
| Ok(inputs) => inputs, | |||||||||||
| // A batch item that can't read its input is kept in the history as a failed run. | |||||||||||
| Err(e) if opts.record.is_some() => return apply_with(s, run_of(t0), kept(), Err(e), now_ms().saturating_sub(t0), opts), | |||||||||||
|
|
|||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -402,15 +402,15 @@ pub(super) fn read_notices(s: &mut Session, name: &str, layer: &mut RasterLayer) | |
| let lost = layer.lost_unsaid(); | ||
| let pixels = layer.pixels_unsaid(); | ||
| if let Some(r) = pixels.as_deref() | ||
| && let Some((fw, fh)) = r.overview.filter(|_| !layer.in_place) | ||
| && let Some((fw, fh)) = r.overview.filter(|_| !layer.reads_in_place()) | ||
| { | ||
| s.notify(format!("{name}: showing a {} × {} overview of the {fw} × {fh} raster", r.width, r.height), false); | ||
| } | ||
| for loss in lost { | ||
| s.notify(format!("{name}: {loss}"), false); | ||
| } | ||
| if let Some(r) = pixels.as_deref() { | ||
| if let Some(held) = layer.in_place.then(|| crate::in_place_overview(r)).flatten() { | ||
| if let Some(held) = layer.reads_in_place().then(|| crate::in_place_overview(r, layer.tiled)).flatten() { | ||
| s.notify(format!("{name}: {held}"), false); | ||
| } | ||
| if let Some(count) = rounded_count(r) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For a tiled layer read in place, Category: agents-md
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 3b4f70c. For a raster read in place, the notice now says the count is of its W × H overview as it was read, and that the map and an export read finer levels and so show rounded values in more places. A raster held whole keeps the old wording. |
||
|
|
@@ -567,7 +567,7 @@ pub(crate) fn say_losses(s: &mut Session, losses: Vec<(String, String)>) { | |
| /// Opens a raster file by path; `ignored` is said with what reading it lost (options given that | ||
| /// don't apply to it). | ||
| pub fn add_path(s: &mut Session, path: &str, name: Option<&str>, page: Option<&str>, scan: bool, ignored: Option<String>) -> CmdResult { | ||
| let mut r = match super::reads::take(s, &read_key(path, page, scan)) { | ||
| let (mut r, tiled) = match super::reads::take::<RasterRead>(s, &read_key(path, page, scan)) { | ||
| Some(r) => r, | ||
| None => read_raster_as(path, page, scan), | ||
| }?; | ||
|
|
@@ -580,7 +580,7 @@ pub fn add_path(s: &mut Session, path: &str, name: Option<&str>, page: Option<&s | |
| // gives plain paths on Windows rather than `\\?\` ones). | ||
| let full = std::path::absolute(path).map(|p| p.display().to_string()).unwrap_or_else(|_| path.to_string()); | ||
| // A scan is laid over the view as it is added, and that placement makes it reopen as one. | ||
| let mut rl = RasterLayer::from_path(r, full); | ||
| let mut rl = if tiled { RasterLayer::tiled_file(r, full) } else { RasterLayer::from_path(r, full) }; | ||
| // A PDF's page, kept so the project opens the same page again. | ||
| rl.subdataset = page.map(str::to_string); | ||
| add_raster(s, &name, rl) | ||
|
|
@@ -639,10 +639,76 @@ pub fn read_download_shared_page(name: &str, bytes: std::sync::Arc<Vec<u8>>, pag | |
|
|
||
| /// The raster at `path` (a PDF's `page`), read whole; for a `scan`, as the file holds it, without | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doc nit: this comment still says the raster is "read whole", but Left for the release quality pass. Category: quality
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 2c1d10f along with the probe change. |
||
| /// the world file beside it (#2075). | ||
| pub(crate) fn read_raster_as(path: &str, page: Option<&str>, scan: bool) -> Result<Raster, String> { | ||
| pub(crate) fn read_raster_as(path: &str, page: Option<&str>, scan: bool) -> RasterRead { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possible AGENTS.md gap: a project is now read differently, with no fixture. A project's local tiled GeoTIFF layer is now read in place when it opens (through Category: agents-md
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I checked this and don't think the fixture rule applies, so no fixture is added.
|
||
| // A large tiled GeoTIFF: its overview, the part in view read as the map draws. Read whole | ||
| // as before when its overview can't be read after all. | ||
| #[cfg(not(target_arch = "wasm32"))] | ||
| if !scan && page.is_none() { | ||
| let full = std::path::absolute(path).map(|p| p.display().to_string()).unwrap_or_else(|_| path.to_string()); | ||
| if tiled_in_place(&full) | ||
| && let Ok(mut r) = crate::render::rustgis_tiles::cog::raster::overview_blocking(&full) | ||
| { | ||
| r.name = Path::new(path).file_stem().and_then(|s| s.to_str()).unwrap_or("raster").to_string(); | ||
| return Ok((r, true)); | ||
| } | ||
| } | ||
| let p = Path::new(path); | ||
| let read = if scan { raster::read_path_unplaced(p, page, None) } else { raster::read_path_with(p, page, None) }; | ||
| read.map_err(|e| format!("{path}: {e}")) | ||
| read.map(|r| (r, false)).map_err(|e| format!("{path}: {e}")) | ||
| } | ||
|
|
||
| /// The most samples a raster file is held whole with: [`raster::max_samples`], or under test what | ||
| /// [`HELD_WHOLE`] sets on this thread, as no small fixture reaches the real limit. | ||
| #[cfg(not(target_arch = "wasm32"))] | ||
| fn held_whole() -> usize { | ||
| #[cfg(test)] | ||
| if let Some(max) = HELD_WHOLE.with(std::cell::Cell::get) { | ||
| return max; | ||
| } | ||
| raster::max_samples() | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| thread_local! { | ||
| /// [`held_whole`]'s limit on this thread, under test. | ||
| pub(crate) static HELD_WHOLE: std::cell::Cell<Option<usize>> = const { std::cell::Cell::new(None) }; | ||
| } | ||
|
|
||
| /// A raster file read for [`add_path`]: its pixels, and whether they are the overview of a large | ||
| /// tiled GeoTIFF read in place ([`tiled_in_place`]). | ||
| pub(crate) type RasterRead = Result<(Raster, bool), String>; | ||
|
|
||
| /// Whether the GeoTIFF at `path` (a full path on this computer) is read in place rather than | ||
| /// held, as a cloud-optimised GeoTIFF's web address is (#2761): the map then reads the part in | ||
| /// view at the level the view needs, where holding it means one overview at every zoom. It is | ||
| /// when the file is tiled with overviews, too large to hold whole ([`raster::max_samples`]), and | ||
| /// reading it in place loses nothing reading it whole keeps: its header reports no loss (a | ||
| /// transparency mask, metadata that can't be read) and no `.aux.xml` or world file is beside it. | ||
| /// Reads the file's header (a few reads of the file, on the fetch workers), afresh each time, as | ||
| /// the file may have been written again; forgotten when it isn't read in place. | ||
| #[cfg(not(target_arch = "wasm32"))] | ||
| pub(crate) fn tiled_in_place(path: &str) -> bool { | ||
| use crate::render::rustgis_tiles::cog; | ||
| // A `#` would be taken for a look's start by the in-place reader. | ||
| if !cog::is_local_file(path) || path.contains('#') { | ||
| return false; | ||
| } | ||
| let p = Path::new(path); | ||
| if !p.is_file() || raster::pam::read(p).is_some() || raster::world::beside(p).is_some() { | ||
| return false; | ||
| } | ||
| cog::forget_local_file(path); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The probe reads the header of each local Cheaper alternatives: check the file's byte length (or a cheap size bound) before the header read, and forget only when the revision changed, using the Confidence: medium. Cost is inferred from the code, not measured. Category: performance
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 2c1d10f. The probe no longer forgets the file before reading its header. A kept header and its tiles are reused while the file is unchanged, and they are read again only once its revision differs ( |
||
| let tiled = cog::info_blocking(path).is_ok_and(|info| { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Category: agents-md
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in 76a7672 by documenting it, the second option: |
||
| let l = &info.layout; | ||
| let full = l.levels.first().map_or(0, |f| u64::from(f.width) * u64::from(f.height)); | ||
| let samples = full.saturating_mul(l.bands.max(1) as u64); | ||
| let lossless = l.lost.is_empty() && l.described.as_ref().is_none_or(|d| d.lost.is_empty()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For a geographic GeoTIFF with no EPSG code, Fix: have Confidence: high on the code path (read, not run). Category: agents-md
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 037f7d7, as suggested.
|
||
| samples > held_whole() as u64 && lossless && cog::raster::overview_level(&info).is_some() | ||
| }); | ||
| if !tiled { | ||
| cog::forget_local_file(path); | ||
| } | ||
| tiled | ||
| } | ||
|
|
||
| /// The key [`add_path`]'s read of `path` (a PDF's `page`) is taken by (see [`super::reads`]): a | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,7 +87,7 @@ pub(crate) fn read(r: &RasterLayer) -> Result<Frame, String> { | |
| return Err("Original image grids require a GeoTIFF source. Export this image as a GeoTIFF and add that file.".into()); | ||
| } | ||
| placed()?; | ||
| if r.in_place { | ||
| if r.reads_in_place() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Original image grids on a large local tiled GeoTIFF now refuse, which looks like a regression the PR doesn't mention. Before this change such a layer was held whole at the overview level with Either keep the command working by checking the revision against the held overview, or name the refusal as a deliberate change in the PR description. Confidence: medium; I have not run the old behaviour to confirm the check passed. Category: bug
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a regression, fixed in d3042fc so the command keeps working.
|
||
| return Err("Original image grids need the image's pixels loaded whole, and this image is read in place a view at a time. Choose map metres, or add a clipped copy that opens whole.".into()); | ||
| } | ||
| let input = rustgis_data::provenance::open(path).map_err(|e| e.to_string())?; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A plugin's run reads a tiled local GeoTIFF's overview, and nothing says so.
falsehere meanstiled_inputsnever runs, soInputs::raster(gp.rs:2059) returnsrl.data, the 1:8 overview, and no message is pushed. The notice the layer gets (in_place_overview, crates/engine/src/lib.rs:431) says "geoprocessing tools read the file at the finest level they can hold". For plugin runs that is false. The same applies toexternal_start(gp.rs:398), andexecute(gp.rs:3172) for plugin tools.Failure: a user adds an 83517 × 78739 tiled GeoTIFF, runs a WASM plugin tool on it, and gets results computed from a 326 × 307 overview. Nothing in the result or the notices says the input was approximated. AGENTS.md's "Never silent" rule covers this: an approximated input needs a notice.
Fix options: (a) read the file for plugin runs too, on the app thread or in the prepare step, with a Cancel check; or (b) keep plugins on the overview and say so in the plugin's result messages, and make the layer notice name the tools that read the file.
Category: bug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 117eda9 (option b). A plugin's inputs are read on the app's thread, so it keeps the held overview, and
plugin_startnow says so for each such input as a notice ("read at the 326 × 307 overview of the … raster the layer holds, as plugin tools don't read a raster read in place from its file"). Its input messages were dropped before, so this also covers streamed-input notes. A synchronous plugin run gets the same message in its result. GeoLibre's preparation stages the file by its path, so it reads the full file and says nothing. The layer notice now says "built-in geoprocessing tools" and lists plugin tools with the commands that read the overview.tiled_files::each_kind_of_run_reads_a_tiled_file_as_it_sayscovers each mode, and a layer held whole for the clean case.