From 47d1b9c3ad59d98e7f0923c01f1852a505f16e7d Mon Sep 17 00:00:00 2001 From: hawahee <38278825+hawahee@users.noreply.github.com> Date: Tue, 15 Oct 2024 20:06:13 +0200 Subject: [PATCH] Warn when providing unrecognized creation options to stringlist --- src/utils.jl | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index da13c33..df02014 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -80,10 +80,50 @@ function setmetadata(ds::ArchGDAL.AbstractDataset, d::Dict{String}) end end -function stringlist(dict::Dict{String}) +const gtiffcreationoptions = [ + "TFW", + "RPB", + "RPCTXT", + "INTERLEAVE", + "TILED", + "BLOCKXSIZE", + "BLOCKYSIZE", + "NBITS", + "COMPRESS", + "NUM_THREADS", + "PREDICTOR", + "DISCARD_LSB", + "SPARSE_OK", + "JPEG_QUALITY", + "JPEGTABLESMODE", + "ZLEVEL", + "ZSTD_LEVEL", + "MAX_Z_ERROR", + "MAX_Z_ERROR_OVERVIEW", + "WEBP_LEVEL", + "WEBP_LOSSLESS", + "JXL_LOSSLESS", + "JXL_EFFORT", + "JXL_DISTANCE", + "JXL_ALPHA_DISTANCE", + "PHOTOMETRIC", + "ALPHA", + "PROFILE", + "BIGTIFF", + "PIXELTYPE", + "COPY_SRC_OVERVIEWS", + "STREAMABLE_OUTPUT", + "GEOTIFF_KEYS_FLAVOR", + "GEOTIFF_VERSION", + "COLOR_TABLE_MULTIPLIER" +] + +function stringlist(dict::Dict{String}; validate = true, validatelist = gtiffcreationoptions) sv = Vector{String}() for (k, v) in pairs(dict) - push!(sv, uppercase(string(k)) * "=" * string(v)) + nk = uppercase(string(k)) + validate && !(nk in validatelist) && @warn "Unrecognized key $nk. Should be one of $validatelist" + push!(sv, nk * "=" * string(v)) end return sv end