jiayuasu opened a new pull request, #2663: URL: https://github.com/apache/sedona/pull/2663
## Did you read the Contributor Guide? - Yes, I have read the [Contributor Rules](https://sedona.apache.org/latest/community/rule/) and [Contributor Developer Guide](https://sedona.apache.org/latest/community/develop/) ## Is this PR related to a ticket? - Yes, and the PR name follows the format `[GH-XXX] my subject`. Closes #2662 ## What changes were proposed in this PR? This PR adds a pure Java, single-threaded Cloud Optimized GeoTIFF (COG) writer to Apache Sedona. The implementation generates COG files by: 1. Computing overview decimation factors (powers of 2), ported from GeoTrellis 2. Generating downsampled overview images via GeoTools resample 3. Writing each level as a tiled GeoTIFF via GeoTools GeoTiffWriter 4. Parsing the TIFF IFD structure of each level (TiffIfdParser) 5. Reassembling all levels into COG byte order with IFDs at file start and image data in reverse size order (CogAssembler) ### New files - **CogOptions.java** - Immutable builder-pattern options class with 5 configurable parameters: - `compression` (default: Deflate) - compression algorithm - `compressionQuality` (default: 0.2) - quality from 0.0 to 1.0 - `tileSize` (default: 256) - tile dimensions, must be power of 2 - `resampling` (default: Nearest) - overview resampling: Nearest, Bilinear, or Bicubic - `overviewCount` (default: -1/auto) - number of overview levels, 0 for none - **CogWriter.java** - Main orchestrator with `write(GridCoverage2D, CogOptions)` primary method - **CogAssembler.java** - Reassembles parsed TIFFs into COG-compliant byte layout, injects NewSubfileType tag for overviews - **TiffIfdParser.java** - Parses TIFF byte arrays to extract IFD entries, image data, and overflow areas ### Modified files - **RasterOutputs.java** - New public API methods: - `asCloudOptimizedGeoTiff(GridCoverage2D raster)` - `asCloudOptimizedGeoTiff(GridCoverage2D raster, String compressionType, double compressionQuality)` - `asCloudOptimizedGeoTiff(GridCoverage2D raster, CogOptions options)` ## How was this patch tested? - 25 unit tests in CogWriterTest.java covering: - Overview decimation computation - Overview generation with all resampling modes (Nearest, Bilinear, Bicubic) - Small raster (no overviews), medium raster (with overviews), multiband raster - LZW compression, existing GeoTIFF conversion - TIFF IFD parsing, NewSubfileType tag presence in overview IFDs - Input validation (compressionQuality, tileSize, malformed TIFF) - COG tile offsets are forward-pointing - CogOptions builder defaults, validation, and resampling normalization - overviewCount=0 (no overviews), overviewCount=1 (specific count) - tileSize=512, RasterOutputs CogOptions API path - External validation: generated COGs confirmed valid by `rio cogeo validate` and `gdalinfo` ## Did this PR include necessary documentation updates? - No, this PR does not affect any public API so no need to change the documentation. The Spark SQL API surface will be added in a follow-up PR. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
