Skip to content

Commit

Permalink
docs: update outdated comment in GeoRaster.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
kb173 committed Aug 9, 2023
1 parent d702a23 commit ec778ae
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/raster-tile-extractor/GeoRaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
#include <algorithm> // For std::clamp etc
#include <cstring>


RasterIOHelper GeoRaster::get_raster_io_helper() {
RasterIOHelper result;
// Restrict the offset and extent to the available data
// TODO: Handle properly:
// 1. Create array using size destination_window_size_pixels
// 2. Extract into other array as usual, but with clamped extent
// 3. Insert other array into 1. array line-by-line using the part which was clamped as the
// offset. This has the disadvantage of potentially allocating twice as much data, but it seems
// to be the only option with GDAL's RasterIO.

int min_raster_size = std::min(data->GetRasterXSize(), data->GetRasterYSize());

double source_destination_ratio = static_cast<double>(destination_window_size_pixels) /
Expand All @@ -31,6 +26,12 @@ RasterIOHelper GeoRaster::get_raster_io_helper() {

int target_width, target_height;

// Calculate clamped_pixel_offset and usable_[width|height] which can be used for retrieving data
// without getting outside of the raster data's extent (which would cause RasterIO errors)
// How this should be used:
// 1. Create array using size destination_window_size_pixels
// 2. Extract into that array clamped offset and usable width/height, offset by x and y remainder

if (pixel_offset_x < 0) {
usable_width += pixel_offset_x;
remainder_x_left = (-pixel_offset_x) * source_destination_ratio;
Expand Down

0 comments on commit ec778ae

Please sign in to comment.