mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-16 00:05:45 -04:00
This class implements an optimised method for generating a profile from a raster layer in a thread-safe way: On the main thread: - The data provider is cloned during preparation, and all other required properties from the raster layer are copied and stored for later thread-safe use on a background thread On the background thread: - The profile line is transformed to the raster's native CRS - We then iterate over the portion of the raster which intersects the profile line's bounding box in small tiles. We use small tiles here as we will shortcut by skipping straight over any tiles which don't intersect the profile line at all, without requesting their raster data at all. Since the profile line will only cover a very small portion of an overall raster extent, by using small tiles we end up shortcutting and avoiding the costly tile pixel iteration for most of the raster's coverage. - For any tiles which DO intersect the profile curve, we fetch the tile data and then iterate over the pixels, keeping only those which actually intersect the profile curve. These pixel centroids are then transformed back to the original CRS of the profile line. - After collecting the filtered pixels centroids and their raster (height) values, we then convert the pixel x/y locations to a distance/chainage along the profile line, giving us an array of distance vs height values for all pixels which intersect the profile line.