From 37e4be70c90357634ad5664415b380260e410e31 Mon Sep 17 00:00:00 2001 From: Jacqueline Ryan Date: Wed, 16 Oct 2024 15:02:52 -0700 Subject: [PATCH 1/3] WIP commit for testing on an onearth-tools container instance, added start and stop levels back in --- mrf_apps/mrf_insert.cpp | 50 +++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/mrf_apps/mrf_insert.cpp b/mrf_apps/mrf_insert.cpp index 66b610c..a971407 100644 --- a/mrf_apps/mrf_insert.cpp +++ b/mrf_apps/mrf_insert.cpp @@ -369,28 +369,50 @@ bool state::patch() GDALClose(hPatch); GDALFlushCache(hDataset); - // Call the patchOverview for the MRF + // Call the PatchOverview for the MRF if (overlays) { - auto BlockXOut = static_cast(blocks_bbox.lx); - auto BlockYOut = static_cast(blocks_bbox.uy); - // correct off-by-one error when generating overlays - auto WidthOut = static_cast(blocks_bbox.ux - blocks_bbox.lx + 1); - auto HeightOut = static_cast(blocks_bbox.ly - blocks_bbox.uy + 1); + // Initialize BlockX, BlockY, Width, and Height based on the bounding box + auto BlockX = static_cast(blocks_bbox.lx); + auto BlockY = static_cast(blocks_bbox.uy); + auto Width = static_cast(blocks_bbox.ux - blocks_bbox.lx); + auto Height = static_cast(blocks_bbox.ly - blocks_bbox.uy); - // If stop level is not set, do all levels + // If stop_level is not set, process all levels if (stop_level == -1) - { stop_level = overview_count; - } - // convert level limits to source levels + // Convert level limits to source levels start_level--; - // Use recursive mode to have the MRF driver handle overviews automatically - pTarg->PatchOverview(BlockXOut, BlockYOut, WidthOut, HeightOut, - 0, true, Resampling); - GDALFlushCache(hDataset); + // Loop through each source level + for (int sl = 0; sl < overview_count; sl++) + { + if (sl >= start_level && sl < stop_level) + { + pTarg->PatchOverview(BlockX, BlockY, Width, Height, + sl, false, Resampling); + GDALFlushCache(hDataset); + } + + // Update BlockX and BlockY for the next level (round down) + int BlockXOut = BlockX / 2; + int BlockYOut = BlockY / 2; + + // Adjust Width and Height before division + Width += (BlockX & 1); // Increment width if BlockX was rounded down + Height += (BlockY & 1); // Increment height if BlockY was rounded down + + // Compute WidthOut and HeightOut for the next level (round up) + int WidthOut = Width / 2 + (Width & 1); + int HeightOut = Height / 2 + (Height & 1); + + // Prepare for the next iteration + BlockX = BlockXOut; + BlockY = BlockYOut; + Width = WidthOut; + Height = HeightOut; + } } // Now for the upper levels From 9209386a590bc7a1b0f8ded239b43f522c56808d Mon Sep 17 00:00:00 2001 From: Jacqueline Ryan Date: Wed, 6 Nov 2024 11:52:45 -0800 Subject: [PATCH 2/3] Added some debug output for functional testing --- mrf_apps/mrf_insert.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mrf_apps/mrf_insert.cpp b/mrf_apps/mrf_insert.cpp index a971407..92d07a7 100644 --- a/mrf_apps/mrf_insert.cpp +++ b/mrf_apps/mrf_insert.cpp @@ -385,7 +385,6 @@ bool state::patch() // Convert level limits to source levels start_level--; - // Loop through each source level for (int sl = 0; sl < overview_count; sl++) { if (sl >= start_level && sl < stop_level) @@ -393,13 +392,18 @@ bool state::patch() pTarg->PatchOverview(BlockX, BlockY, Width, Height, sl, false, Resampling); GDALFlushCache(hDataset); + + if (verbose != 0) + { + cerr << "Overview Level: " << sl << endl; + cerr << "WidthOut = " << WidthOut << " HeightOut = " << HeightOut << endl; + } } // Update BlockX and BlockY for the next level (round down) int BlockXOut = BlockX / 2; int BlockYOut = BlockY / 2; - // Adjust Width and Height before division Width += (BlockX & 1); // Increment width if BlockX was rounded down Height += (BlockY & 1); // Increment height if BlockY was rounded down From d3d8ca90f348268fb0ac068991a4afabe669aa71 Mon Sep 17 00:00:00 2001 From: Jacqueline Ryan Date: Wed, 6 Nov 2024 11:53:46 -0800 Subject: [PATCH 3/3] fixed typo --- mrf_apps/mrf_insert.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mrf_apps/mrf_insert.cpp b/mrf_apps/mrf_insert.cpp index 92d07a7..be38e1e 100644 --- a/mrf_apps/mrf_insert.cpp +++ b/mrf_apps/mrf_insert.cpp @@ -396,7 +396,7 @@ bool state::patch() if (verbose != 0) { cerr << "Overview Level: " << sl << endl; - cerr << "WidthOut = " << WidthOut << " HeightOut = " << HeightOut << endl; + cerr << "WidthOut = " << Width << " HeightOut = " << Height << endl; } }