Skip to content

Commit

Permalink
upgrade GDAL to 3.8.2 (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmomtchev authored Jan 8, 2024
1 parent 8af6ed4 commit a183d38
Show file tree
Hide file tree
Showing 35 changed files with 866 additions and 480 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.8.2] 2024-01-08

### Added
- GDAL 3.8.2

## [3.8.1] 2023-12-12

### Added
Expand Down
2 changes: 1 addition & 1 deletion deps/libgdal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -eu
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$DIR/libgdal"

GDAL_VERSION=3.8.1
GDAL_VERSION=3.8.2
GDAL_VERSION_SUFFIX=
dir_gdal=./gdal
dir_formats_gyp=./gyp-formats
Expand Down
4 changes: 2 additions & 2 deletions deps/libgdal/gdal/CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cff-version: 1.2.0
message: Please cite this software using these metadata or in the CITATION file.
type: software
title: GDAL
version: 3.8.1
date-released: 2023-11-23
version: 3.8.2
date-released: 2023-12-16
doi: 10.5281/zenodo.5884351
abstract: GDAL is a translator library for raster and vector geospatial data
formats that is released under an MIT style Open Source License by the Open
Expand Down
2 changes: 1 addition & 1 deletion deps/libgdal/gdal/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.8.1
3.8.2
6 changes: 4 additions & 2 deletions deps/libgdal/gdal/alg/llrasterize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,8 @@ void GDALdllImageLineAllTouched(int nRasterXSize, int nRasterYSize,

const int iX = static_cast<int>(floor(dfXEnd));
int iY = static_cast<int>(floor(dfY));
int iYEnd = static_cast<int>(floor(dfYEnd));
int iYEnd =
static_cast<int>(floor(dfYEnd - EPSILON_INTERSECT_ONLY));

if (iX < 0 || iX >= nRasterXSize)
continue;
Expand Down Expand Up @@ -556,7 +557,8 @@ void GDALdllImageLineAllTouched(int nRasterXSize, int nRasterYSize,

int iX = static_cast<int>(floor(dfX));
const int iY = static_cast<int>(floor(dfY));
int iXEnd = static_cast<int>(floor(dfXEnd));
int iXEnd =
static_cast<int>(floor(dfXEnd - EPSILON_INTERSECT_ONLY));

if (iY < 0 || iY >= nRasterYSize)
continue;
Expand Down
6 changes: 6 additions & 0 deletions deps/libgdal/gdal/apps/gdal_footprint_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,12 @@ GetOutputLayerAndUpdateDstDS(const char *pszDest, GDALDatasetH &hDstDS,
if (!psOptions->osDestLayerName.empty())
{
poLayer = poDstDS->GetLayerByName(psOptions->osDestLayerName.c_str());
if (!poLayer)
{
CPLError(CE_Failure, CPLE_AppDefined, "Cannot find layer %s",
psOptions->osDestLayerName.c_str());
return nullptr;
}
}
else if (poDstDS->GetLayerCount() == 1 && poDstDS->GetDriver() &&
EQUAL(poDstDS->GetDriver()->GetDescription(), "ESRI Shapefile"))
Expand Down
98 changes: 7 additions & 91 deletions deps/libgdal/gdal/apps/gdal_translate_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1110,100 +1110,16 @@ GDALDatasetH GDALTranslate(const char *pszDest, GDALDatasetH hSrcDataset,
/* -------------------------------------------------------------------- */
if (!psOptions->aosCreateOptions.FetchBool("APPEND_SUBDATASET", false))
{
// Someone issuing Create("foo.tif") on a
// memory driver doesn't expect files with those names to be deleted
// on a file system...
// This is somewhat messy. Ideally there should be a way for the
// driver to overload the default behavior
if (!EQUAL(psOptions->osFormat.c_str(), "MEM") &&
!EQUAL(psOptions->osFormat.c_str(), "Memory"))
if (!EQUAL(psOptions->osFormat.c_str(), "VRT"))
{
/* --------------------------------------------------------------------
*/
/* Establish list of files of output dataset if it already
* exists. */
/* --------------------------------------------------------------------
*/
std::set<std::string> oSetExistingDestFiles;
{
CPLPushErrorHandler(CPLQuietErrorHandler);
const char *const apszAllowedDrivers[] = {
psOptions->osFormat.c_str(), nullptr};
auto poExistingOutputDS =
std::unique_ptr<GDALDataset>(GDALDataset::Open(
pszDest, GDAL_OF_RASTER, apszAllowedDrivers));
if (poExistingOutputDS)
{
char **papszFileList = poExistingOutputDS->GetFileList();
for (char **papszIter = papszFileList;
papszIter && *papszIter; ++papszIter)
{
oSetExistingDestFiles.insert(
CPLString(*papszIter).replaceAll('\\', '/'));
}
CSLDestroy(papszFileList);
}
CPLPopErrorHandler();
}

/* --------------------------------------------------------------------
*/
/* Check if the source dataset shares some files with the dest
* one.*/
/* --------------------------------------------------------------------
*/
std::set<std::string> oSetExistingDestFilesFoundInSource;
if (!oSetExistingDestFiles.empty())
{
CPLPushErrorHandler(CPLQuietErrorHandler);
// We need to reopen in a temporary dataset for the particular
// case of overwritten a .tif.ovr file from a .tif
// If we probe the file list of the .tif, it will then open the
// .tif.ovr !
const char *const apszAllowedDrivers[] = {
poSrcDS->GetDriver()
? poSrcDS->GetDriver()->GetDescription()
: nullptr,
nullptr};
auto poSrcDSTmp = std::unique_ptr<GDALDataset>(
GDALDataset::Open(poSrcDS->GetDescription(), GDAL_OF_RASTER,
apszAllowedDrivers));
if (poSrcDSTmp)
{
char **papszFileList = poSrcDSTmp->GetFileList();
for (char **papszIter = papszFileList;
papszIter && *papszIter; ++papszIter)
{
CPLString osFilename(*papszIter);
osFilename.replaceAll('\\', '/');
if (oSetExistingDestFiles.find(osFilename) !=
oSetExistingDestFiles.end())
{
oSetExistingDestFilesFoundInSource.insert(
osFilename);
}
}
CSLDestroy(papszFileList);
}
CPLPopErrorHandler();
}
// Prevent GDALDriver::CreateCopy() from doing that again.
psOptions->aosCreateOptions.SetNameValue(
"@QUIET_DELETE_ON_CREATE_COPY", "NO");
}

// If the source file(s) and the dest one share some files in
// common, only remove the files that are *not* in common
if (!oSetExistingDestFilesFoundInSource.empty())
{
for (const std::string &osFilename : oSetExistingDestFiles)
{
if (oSetExistingDestFilesFoundInSource.find(osFilename) ==
oSetExistingDestFilesFoundInSource.end())
{
VSIUnlink(osFilename.c_str());
}
}
}
GDALDriver::FromHandle(hDriver)->QuietDeleteForCreateCopy(pszDest,
poSrcDS);

GDALDriver::FromHandle(hDriver)->QuietDelete(pszDest);
}
// Make sure to load early overviews, so that on the GTiff driver
// external .ovr is looked for before it might be created as the
// output dataset !
Expand Down
44 changes: 24 additions & 20 deletions deps/libgdal/gdal/apps/gdal_utils_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,6 @@ struct GDALWarpAppOptionsForBinary
char **papszAllowInputDrivers;
};

/* Access modes */
typedef enum
{
ACCESS_CREATION,
ACCESS_UPDATE, /* open existing output datasource in update mode rather than
trying to create a new one */
ACCESS_APPEND, /* append to existing layer instead of creating new */
ACCESS_OVERWRITE /* delete the output layer and recreate it empty */
} GDALVectorTranslateAccessMode;

struct GDALVectorTranslateOptionsForBinary
{
char *pszDataSource;
char *pszDestDataSource;
int bQuiet;
char **papszOpenOptions;
char *pszFormat;
GDALVectorTranslateAccessMode eAccessMode;
};

struct GDALDEMProcessingOptionsForBinary
{
char *pszProcessing;
Expand Down Expand Up @@ -135,6 +115,30 @@ struct GDALBuildVRTOptionsForBinary

CPL_C_END

/* Access modes */
typedef enum
{
ACCESS_CREATION,
ACCESS_UPDATE, /* open existing output datasource in update mode rather than
trying to create a new one */
ACCESS_APPEND, /* append to existing layer instead of creating new */
ACCESS_OVERWRITE /* delete the output layer and recreate it empty */
} GDALVectorTranslateAccessMode;

struct GDALVectorTranslateOptionsForBinary
{
std::string osDataSource{};
bool bDestSpecified = false;
std::string osDestDataSource{};
bool bQuiet = false;
CPLStringList aosOpenOptions{};
std::string osFormat;
GDALVectorTranslateAccessMode eAccessMode = ACCESS_CREATION;

/* Allowed input drivers. */
CPLStringList aosAllowInputDrivers{};
};

struct GDALMultiDimInfoOptionsForBinary
{
/* Filename to open. */
Expand Down
61 changes: 29 additions & 32 deletions deps/libgdal/gdal/apps/ogr2ogr_bin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ static void Usage(bool bIsError, const char *pszAdditionalMsg = nullptr,
" [-a_srs <srs_def>] [-t_srs <srs_def>] [-s_srs "
"<srs_def>] "
"[-ct <string>]\n"
" [-f <format_name>] [-overwrite] "
" [-if <input_drv_name>] [-f <output_drv_name>] "
"[-overwrite] "
"[-dsco <NAME>=<VALUE>]...\n"
" [-lco <NAME>=<VALUE>]... [-nln <name>] \n"
" [-nlt "
Expand Down Expand Up @@ -233,8 +234,7 @@ static void Usage(bool bIsError, const char *pszAdditionalMsg = nullptr,
static GDALVectorTranslateOptionsForBinary *
GDALVectorTranslateOptionsForBinaryNew()
{
return static_cast<GDALVectorTranslateOptionsForBinary *>(
CPLCalloc(1, sizeof(GDALVectorTranslateOptionsForBinary)));
return new GDALVectorTranslateOptionsForBinary;
}

/************************************************************************/
Expand All @@ -244,14 +244,7 @@ GDALVectorTranslateOptionsForBinaryNew()
static void GDALVectorTranslateOptionsForBinaryFree(
GDALVectorTranslateOptionsForBinary *psOptionsForBinary)
{
if (psOptionsForBinary)
{
CPLFree(psOptionsForBinary->pszDataSource);
CPLFree(psOptionsForBinary->pszDestDataSource);
CSLDestroy(psOptionsForBinary->papszOpenOptions);
CPLFree(psOptionsForBinary->pszFormat);
CPLFree(psOptionsForBinary);
}
delete psOptionsForBinary;
}

/************************************************************************/
Expand Down Expand Up @@ -327,10 +320,10 @@ MAIN_START(nArgc, papszArgv)
goto exit;
}

if (psOptionsForBinary->pszDataSource == nullptr ||
psOptionsForBinary->pszDestDataSource == nullptr)
if (psOptionsForBinary->osDataSource.empty() ||
!psOptionsForBinary->bDestSpecified)
{
if (psOptionsForBinary->pszDestDataSource == nullptr)
if (!psOptionsForBinary->bDestSpecified)
Usage(true, "no target datasource provided");
else
Usage(true, "no source datasource provided");
Expand All @@ -339,8 +332,8 @@ MAIN_START(nArgc, papszArgv)
goto exit;
}

if (strcmp(psOptionsForBinary->pszDestDataSource, "/vsistdout/") == 0)
psOptionsForBinary->bQuiet = TRUE;
if (psOptionsForBinary->osDestDataSource == "/vsistdout/")
psOptionsForBinary->bQuiet = true;

/* -------------------------------------------------------------------- */
/* Open data source. */
Expand All @@ -350,12 +343,13 @@ MAIN_START(nArgc, papszArgv)
// output Known to cause problems with at least FGdb, SQlite and GPKG
// drivers. See #4270
if (psOptionsForBinary->eAccessMode != ACCESS_CREATION &&
strcmp(psOptionsForBinary->pszDestDataSource,
psOptionsForBinary->pszDataSource) == 0)
psOptionsForBinary->osDestDataSource ==
psOptionsForBinary->osDataSource)
{
hODS = GDALOpenEx(psOptionsForBinary->pszDataSource,
GDAL_OF_UPDATE | GDAL_OF_VECTOR, nullptr,
psOptionsForBinary->papszOpenOptions, nullptr);
hODS = GDALOpenEx(psOptionsForBinary->osDataSource.c_str(),
GDAL_OF_UPDATE | GDAL_OF_VECTOR,
psOptionsForBinary->aosAllowInputDrivers.List(),
psOptionsForBinary->aosOpenOptions.List(), nullptr);

GDALDriverH hDriver =
hODS != nullptr ? GDALGetDatasetDriver(hODS) : nullptr;
Expand All @@ -366,9 +360,10 @@ MAIN_START(nArgc, papszArgv)
EQUAL(GDALGetDescription(hDriver), "SQLite") ||
EQUAL(GDALGetDescription(hDriver), "GPKG")))
{
hDS = GDALOpenEx(psOptionsForBinary->pszDataSource, GDAL_OF_VECTOR,
nullptr, psOptionsForBinary->papszOpenOptions,
nullptr);
hDS = GDALOpenEx(
psOptionsForBinary->osDataSource.c_str(), GDAL_OF_VECTOR,
psOptionsForBinary->aosAllowInputDrivers.List(),
psOptionsForBinary->aosOpenOptions.List(), nullptr);
}
else
{
Expand All @@ -379,8 +374,9 @@ MAIN_START(nArgc, papszArgv)
else
{
hDS =
GDALOpenEx(psOptionsForBinary->pszDataSource, GDAL_OF_VECTOR,
nullptr, psOptionsForBinary->papszOpenOptions, nullptr);
GDALOpenEx(psOptionsForBinary->osDataSource.c_str(), GDAL_OF_VECTOR,
psOptionsForBinary->aosAllowInputDrivers.List(),
psOptionsForBinary->aosOpenOptions.List(), nullptr);
}

/* -------------------------------------------------------------------- */
Expand All @@ -393,7 +389,7 @@ MAIN_START(nArgc, papszArgv)
fprintf(stderr,
"FAILURE:\n"
"Unable to open datasource `%s' with the following drivers.\n",
psOptionsForBinary->pszDataSource);
psOptionsForBinary->osDataSource.c_str());

for (int iDriver = 0; iDriver < poDM->GetDriverCount(); iDriver++)
{
Expand All @@ -411,16 +407,16 @@ MAIN_START(nArgc, papszArgv)
goto exit;
}

if (hODS != nullptr && psOptionsForBinary->pszFormat != nullptr)
if (hODS != nullptr && !psOptionsForBinary->osFormat.empty())
{
GDALDriverManager *poDM = GetGDALDriverManager();

GDALDriver *poDriver =
poDM->GetDriverByName(psOptionsForBinary->pszFormat);
poDM->GetDriverByName(psOptionsForBinary->osFormat.c_str());
if (poDriver == nullptr)
{
fprintf(stderr, "Unable to find driver `%s'.\n",
psOptionsForBinary->pszFormat);
psOptionsForBinary->osFormat.c_str());
fprintf(stderr, "The following drivers are available:\n");

for (int iDriver = 0; iDriver < poDM->GetDriverCount(); iDriver++)
Expand Down Expand Up @@ -452,8 +448,9 @@ MAIN_START(nArgc, papszArgv)
{
// TODO(schwehr): Remove scope after removing gotos
int bUsageError = FALSE;
hDstDS = GDALVectorTranslate(psOptionsForBinary->pszDestDataSource,
hODS, 1, &hDS, psOptions, &bUsageError);
hDstDS =
GDALVectorTranslate(psOptionsForBinary->osDestDataSource.c_str(),
hODS, 1, &hDS, psOptions, &bUsageError);
if (bUsageError)
Usage(true);
else
Expand Down
Loading

0 comments on commit a183d38

Please sign in to comment.