Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update GDAL to 3.9.2 #174

Merged
merged 4 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.9.2]

### Added
- GDAL 3.9.2

## [3.9.0] 2024-06-24

### 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.9.0
GDAL_VERSION=3.9.2
GDAL_VERSION_SUFFIX=
dir_gdal=./gdal
dir_formats_gyp=./gyp-formats
Expand Down
36 changes: 18 additions & 18 deletions deps/libgdal/gdal/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ matrix:
- BUILD_NAME=s390x
- DETAILS=""

- os: linux
arch: arm64-graviton2
virt: lxd
group: edge
compiler: gcc
language: cpp
sudo: false
dist: jammy
cache:
apt: true
directories:
- $HOME/.ccache
apt:
packages:
- ccache
env:
- BUILD_NAME=graviton2
- DETAILS=
#- os: linux
# arch: arm64-graviton2
# virt: lxd
# group: edge
# compiler: gcc
# language: cpp
# sudo: false
# dist: jammy
# cache:
# apt: true
# directories:
# - $HOME/.ccache
# apt:
# packages:
# - ccache
# env:
# - BUILD_NAME=graviton2
# - DETAILS=

before_install:
- if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(.rst)$'; then travis_terminate 0; fi
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.9.0
date-released: 2024-05-06
version: 3.9.2
date-released: 2024-08-13
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.9.0
3.9.2
8 changes: 8 additions & 0 deletions deps/libgdal/gdal/alg/contour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,14 @@ CPLErr GDALContourGenerateEx(GDALRasterBandH hBand, void *hLayer,
if (opt)
{
contourInterval = CPLAtof(opt);
// Written this way to catch NaN as well.
if (!(contourInterval > 0))
{
CPLError(CE_Failure, CPLE_AppDefined,
"Invalid value for LEVEL_INTERVAL. Should be strictly "
"positive.");
return CE_Failure;
}
}

double contourBase = 0.0;
Expand Down
16 changes: 16 additions & 0 deletions deps/libgdal/gdal/alg/gdal_crs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,22 @@ static void *GDALCreateGCPTransformerEx(int nGCPCount,
psInfo->nRefCount = 1;

psInfo->asGCPs = gdal::GCP::fromC(pasGCPList, nGCPCount);
if (nGCPCount == 2 && nReqOrder == 1 &&
psInfo->asGCPs[0].X() != psInfo->asGCPs[1].X() &&
psInfo->asGCPs[0].Y() != psInfo->asGCPs[1].Y())
{
// Assumes that the 2 GCPs form opposite corners of a rectangle,
// and synthetize a 3rd corner
gdal::GCP newGCP;
newGCP.X() = psInfo->asGCPs[1].X();
newGCP.Y() = psInfo->asGCPs[0].Y();
newGCP.Pixel() = psInfo->asGCPs[1].Pixel();
newGCP.Line() = psInfo->asGCPs[0].Line();
psInfo->asGCPs.emplace_back(std::move(newGCP));

nGCPCount = 3;
pasGCPList = gdal::GCP::c_ptr(psInfo->asGCPs);
}

memcpy(psInfo->sTI.abySignature, GDAL_GTI2_SIGNATURE,
strlen(GDAL_GTI2_SIGNATURE));
Expand Down
93 changes: 54 additions & 39 deletions deps/libgdal/gdal/alg/gdalsievefilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <cstring>

#include <algorithm>
#include <cassert>
#include <set>
#include <vector>
#include <utility>
Expand Down Expand Up @@ -211,30 +210,36 @@ CPLErr CPL_STDCALL GDALSieveFilter(GDALRasterBandH hSrcBand,
/* -------------------------------------------------------------------- */
int nXSize = GDALGetRasterBandXSize(hSrcBand);
int nYSize = GDALGetRasterBandYSize(hSrcBand);
auto *panLastLineVal = static_cast<std::int64_t *>(
VSI_MALLOC2_VERBOSE(sizeof(std::int64_t), nXSize));
auto *panThisLineVal = static_cast<std::int64_t *>(
VSI_MALLOC2_VERBOSE(sizeof(std::int64_t), nXSize));
auto *panLastLineId =
static_cast<GInt32 *>(VSI_MALLOC2_VERBOSE(sizeof(GInt32), nXSize));
auto *panThisLineId =
static_cast<GInt32 *>(VSI_MALLOC2_VERBOSE(sizeof(GInt32), nXSize));
auto *panThisLineWriteVal = static_cast<std::int64_t *>(
VSI_MALLOC2_VERBOSE(sizeof(std::int64_t), nXSize));
GByte *pabyMaskLine = hMaskBand != nullptr
? static_cast<GByte *>(VSI_MALLOC_VERBOSE(nXSize))
: nullptr;
auto panLastLineValKeeper = std::unique_ptr<std::int64_t, VSIFreeReleaser>(
static_cast<std::int64_t *>(
VSI_MALLOC2_VERBOSE(sizeof(std::int64_t), nXSize)));
auto panThisLineValKeeper = std::unique_ptr<std::int64_t, VSIFreeReleaser>(
static_cast<std::int64_t *>(
VSI_MALLOC2_VERBOSE(sizeof(std::int64_t), nXSize)));
auto panLastLineIdKeeper = std::unique_ptr<GInt32, VSIFreeReleaser>(
static_cast<GInt32 *>(VSI_MALLOC2_VERBOSE(sizeof(GInt32), nXSize)));
auto panThisLineIdKeeper = std::unique_ptr<GInt32, VSIFreeReleaser>(
static_cast<GInt32 *>(VSI_MALLOC2_VERBOSE(sizeof(GInt32), nXSize)));
auto panThisLineWriteValKeeper =
std::unique_ptr<std::int64_t, VSIFreeReleaser>(
static_cast<std::int64_t *>(
VSI_MALLOC2_VERBOSE(sizeof(std::int64_t), nXSize)));
auto pabyMaskLineKeeper = std::unique_ptr<GByte, VSIFreeReleaser>(
hMaskBand != nullptr ? static_cast<GByte *>(VSI_MALLOC_VERBOSE(nXSize))
: nullptr);

auto panLastLineVal = panLastLineValKeeper.get();
auto panThisLineVal = panThisLineValKeeper.get();
auto panLastLineId = panLastLineIdKeeper.get();
auto panThisLineId = panThisLineIdKeeper.get();
auto panThisLineWriteVal = panThisLineWriteValKeeper.get();
auto pabyMaskLine = pabyMaskLineKeeper.get();

if (panLastLineVal == nullptr || panThisLineVal == nullptr ||
panLastLineId == nullptr || panThisLineId == nullptr ||
panThisLineWriteVal == nullptr ||
(hMaskBand != nullptr && pabyMaskLine == nullptr))
{
CPLFree(panThisLineId);
CPLFree(panLastLineId);
CPLFree(panThisLineVal);
CPLFree(panLastLineVal);
CPLFree(panThisLineWriteVal);
CPLFree(pabyMaskLine);
return CE_Failure;
}

Expand Down Expand Up @@ -316,12 +321,28 @@ CPLErr CPL_STDCALL GDALSieveFilter(GDALRasterBandH hSrcBand,
if (eErr == CE_None)
oFirstEnum.CompleteMerges();

/* -------------------------------------------------------------------- */
/* Check if there are polygons */
/* -------------------------------------------------------------------- */
if (!oFirstEnum.panPolyIdMap || !oFirstEnum.panPolyValue)
{
// Can happen if all pixels are masked
if (hSrcBand == hDstBand)
{
pfnProgress(1.0, "", pProgressArg);
return CE_None;
}
else
{
return GDALRasterBandCopyWholeRaster(hSrcBand, hDstBand, nullptr,
pfnProgress, pProgressArg);
}
}

/* -------------------------------------------------------------------- */
/* Push the sizes of merged polygon fragments into the */
/* merged polygon id's count. */
/* -------------------------------------------------------------------- */
assert(oFirstEnum.panPolyIdMap != nullptr); // for Coverity
assert(oFirstEnum.panPolyValue != nullptr); // for Coverity
for (int iPoly = 0; iPoly < oFirstEnum.nNextPolygonId; iPoly++)
{
if (oFirstEnum.panPolyIdMap[iPoly] != iPoly)
Expand All @@ -346,10 +367,16 @@ CPLErr CPL_STDCALL GDALSieveFilter(GDALRasterBandH hSrcBand,
GDALRasterPolygonEnumerator oSecondEnum(nConnectedness);

std::vector<int> anBigNeighbour;
anBigNeighbour.resize(anPolySizes.size());

for (int iPoly = 0; iPoly < static_cast<int>(anPolySizes.size()); iPoly++)
anBigNeighbour[iPoly] = -1;
try
{
anBigNeighbour.resize(anPolySizes.size(), -1);
}
catch (const std::exception &)
{
CPLError(CE_Failure, CPLE_OutOfMemory, "%s: Out of memory",
__FUNCTION__);
return CE_Failure;
}

/* ==================================================================== */
/* Second pass ... identify the largest neighbour for each */
Expand Down Expand Up @@ -540,9 +567,7 @@ CPLErr CPL_STDCALL GDALSieveFilter(GDALRasterBandH hSrcBand,
/* ==================================================================== */
oSecondEnum.Clear();

for (int iY = 0; oFirstEnum.panPolyIdMap != nullptr && // for Coverity
eErr == CE_None && iY < nYSize;
iY++)
for (int iY = 0; eErr == CE_None && iY < nYSize; iY++)
{
/* --------------------------------------------------------------------
*/
Expand Down Expand Up @@ -627,15 +652,5 @@ CPLErr CPL_STDCALL GDALSieveFilter(GDALRasterBandH hSrcBand,
}
}

/* -------------------------------------------------------------------- */
/* Cleanup */
/* -------------------------------------------------------------------- */
CPLFree(panThisLineId);
CPLFree(panLastLineId);
CPLFree(panThisLineVal);
CPLFree(panLastLineVal);
CPLFree(panThisLineWriteVal);
CPLFree(pabyMaskLine);

return eErr;
}
7 changes: 6 additions & 1 deletion deps/libgdal/gdal/alg/gdaltransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,12 @@ static void InsertCenterLong(GDALDatasetH hDS, OGRSpatialReference *poSRS,
adfGeoTransform[0] + nXSize * adfGeoTransform[1] +
nYSize * adfGeoTransform[2]));

if (dfMaxLong - dfMinLong > 360.0)
const double dfEpsilon =
std::max(std::fabs(adfGeoTransform[1]), std::fabs(adfGeoTransform[2]));
// If the raster covers more than 360 degree (allow an extra pixel),
// give up
constexpr double RELATIVE_EPSILON = 0.05; // for numeric precision issues
if (dfMaxLong - dfMinLong > 360.0 + dfEpsilon * (1 + RELATIVE_EPSILON))
return;

/* -------------------------------------------------------------------- */
Expand Down
7 changes: 6 additions & 1 deletion deps/libgdal/gdal/apps/argparse/argparse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,8 @@ class Argument {
std::bind(is_optional, std::placeholders::_1, m_prefix_chars));
dist = static_cast<std::size_t>(std::distance(start, end));
if (dist < num_args_min) {
throw std::runtime_error("Too few arguments");
throw std::runtime_error("Too few arguments for '" +
std::string(m_used_name) + "'.");
}
}

Expand Down Expand Up @@ -1357,6 +1358,10 @@ class Argument {
* '+' '-'
*/
static bool is_decimal_literal(std::string_view s) {
if (s == "inf") {
return true;
}

auto is_digit = [](auto c) constexpr {
switch (c) {
case '0':
Expand Down
6 changes: 3 additions & 3 deletions deps/libgdal/gdal/apps/data/gdalinfo_output.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
},

"stac": {
"$comment": "Derived from https://raw.githubusercontent.com/stac-extensions/projection/main/json-schema/schema.json#/definitions/fields, https://raw.githubusercontent.com/stac-extensions/eo/main/json-schema/schema.json#/definitions/bands and https://raw.githubusercontent.com/stac-extensions/eo/main/json-schema/schema.json#/definitions/bands",
"$comment": "Derived from https://raw.githubusercontent.com/stac-extensions/projection/main/json-schema/schema.json#/definitions/fields, https://raw.githubusercontent.com/stac-extensions/eo/v1.1.0/json-schema/schema.json#/definitions/bands and https://raw.githubusercontent.com/stac-extensions/eo/v1.1.0/json-schema/schema.json#/definitions/bands",
"type": "object",
"properties": {
"proj:epsg": {
Expand Down Expand Up @@ -334,10 +334,10 @@
}
},
"eo:bands": {
"$ref": "https://raw.githubusercontent.com/stac-extensions/eo/main/json-schema/schema.json#/definitions/bands"
"$ref": "https://raw.githubusercontent.com/stac-extensions/eo/v1.1.0/json-schema/schema.json#/definitions/bands"
},
"raster:bands": {
"$ref": "https://raw.githubusercontent.com/stac-extensions/eo/main/json-schema/schema.json#/definitions/bands"
"$ref": "https://raw.githubusercontent.com/stac-extensions/eo/v1.1.0/json-schema/schema.json#/definitions/bands"
}
},
"additionalProperties": false
Expand Down
Loading