Skip to content

Commit

Permalink
upgrade GDAL to 3.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mmomtchev committed Nov 28, 2023
1 parent 13e517d commit 9b3dcc5
Show file tree
Hide file tree
Showing 643 changed files with 98,986 additions and 47,892 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.0]

### Added
- GDAL 3.8.0

## [3.7.3]

### 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.7.3
GDAL_VERSION=3.8.0
GDAL_VERSION_SUFFIX=
dir_gdal=./gdal
dir_formats_gyp=./gyp-formats
Expand Down
6 changes: 4 additions & 2 deletions deps/libgdal/gdal/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repos:
autotest/ogr/data/
)
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: 'v15.0.4'
rev: 'v15.0.7'
hooks:
- id: clang-format
exclude: >
Expand All @@ -53,5 +53,7 @@ repos:
frmts/grib/degrib/g2clib|
ogr/ogrsf_frmts/cad/libopencad/|
ogr/ogrsf_frmts/geojson/libjson/|
ogr/ogrsf_frmts/flatgeobuf/flatbuffers/
ogr/ogrsf_frmts/flatgeobuf/flatbuffers/|
ogr/ogrsf_frmts/pmtiles/pmtiles/|
ogr/ogrsf_frmts/sqlite/sqlite_rtree_bulk_load
)
4 changes: 2 additions & 2 deletions deps/libgdal/gdal/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ matrix:
compiler: gcc
language: cpp
sudo: false
dist: bionic
dist: jammy
cache:
apt: true
directories:
Expand All @@ -33,7 +33,7 @@ matrix:
compiler: gcc
language: cpp
sudo: false
dist: bionic
dist: jammy
cache:
apt: true
directories:
Expand Down
2 changes: 1 addition & 1 deletion deps/libgdal/gdal/CITATION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
To cite GDAL/OGR in publications use:

GDAL/OGR contributors (2022). GDAL/OGR Geospatial Data Abstraction
GDAL/OGR contributors (2023). GDAL/OGR Geospatial Data Abstraction
software Library. Open Source Geospatial Foundation. URL https://gdal.org
DOI: 10.5281/zenodo.5884351

Expand Down
15 changes: 13 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.7.3
date-released: 2023-10-30
version: 3.8.0
date-released: 2023-11-06
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 Expand Up @@ -59,6 +59,17 @@ authors:
family-names: Dawson
affiliation: North Road
orcid: https://orcid.org/0000-0001-9812-7584
- given-names: Daniel
family-names: Baston
affiliation: ISciences, L.L.C.
orcid: https://orcid.org/0000-0002-2195-1716
- given-names: Craig
family-names: de Stigter
affiliation: Koordinates
- given-names: Hiroshi
family-names: Miura
orcid: https://orcid.org/0000-0001-7754-0433

keywords:
- GDAL
- geospatial
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.7.3
3.8.0
4 changes: 3 additions & 1 deletion deps/libgdal/gdal/alg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ add_library(
rasterfill.cpp
thinplatespline.cpp
gdal_simplesurf.cpp
viewshed.cpp)
viewshed.cpp
gdalgenericinverse.cpp
)

add_dependencies(alg generate_gdal_version_h)

Expand Down
21 changes: 11 additions & 10 deletions deps/libgdal/gdal/alg/gdal_crs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,18 @@ static void *GDALCreateSimilarGCPTransformer(void *hTransformArg,

static void *GDALCreateGCPTransformerEx(int nGCPCount,
const GDAL_GCP *pasGCPList,
int nReqOrder, int bReversed,
int bRefine, double dfTolerance,
int nReqOrder, bool bReversed,
bool bRefine, double dfTolerance,
int nMinimumGcps)

{
// If no minimumGcp parameter was passed, we use the default value
// according to the model
if (bRefine && nMinimumGcps == -1)
{
nMinimumGcps = ((nReqOrder + 1) * (nReqOrder + 2)) / 2 + 1;
}

GCPTransformInfo *psInfo = nullptr;
double *padfGeoX = nullptr;
double *padfGeoY = nullptr;
Expand Down Expand Up @@ -341,7 +348,7 @@ void *GDALCreateGCPTransformer(int nGCPCount, const GDAL_GCP *pasGCPList,

{
return GDALCreateGCPTransformerEx(nGCPCount, pasGCPList, nReqOrder,
bReversed, FALSE, -1, -1);
CPL_TO_BOOL(bReversed), false, -1, -1);
}

/** Create GCP based polynomial transformer, with a tolerance threshold to
Expand All @@ -352,14 +359,8 @@ void *GDALCreateGCPRefineTransformer(int nGCPCount, const GDAL_GCP *pasGCPList,
double dfTolerance, int nMinimumGcps)

{
// If no minimumGcp parameter was passed, we use the default value
// according to the model
if (nMinimumGcps == -1)
{
nMinimumGcps = ((nReqOrder + 1) * (nReqOrder + 2)) / 2 + 1;
}
return GDALCreateGCPTransformerEx(nGCPCount, pasGCPList, nReqOrder,
bReversed, TRUE, dfTolerance,
CPL_TO_BOOL(bReversed), true, dfTolerance,
nMinimumGcps);
}

Expand Down
20 changes: 20 additions & 0 deletions deps/libgdal/gdal/alg/gdal_tps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "gdal_alg.h"
#include "gdal_alg_priv.h"
#include "gdal_priv.h"
#include "gdalgenericinverse.h"

CPL_CVSID("$Id$")

Expand Down Expand Up @@ -363,7 +364,26 @@ int GDALTPSTransform(void *pTransformArg, int bDstToSrc, int nPointCount,

if (bDstToSrc)
{
// Compute initial guess
psInfo->poReverse->get_point(x[i], y[i], xy_out);

const auto ForwardTransformer = [](double xIn, double yIn,
double &xOut, double &yOut,
void *pUserData)
{
double xyOut[2] = {0.0, 0.0};
TPSTransformInfo *l_psInfo =
static_cast<TPSTransformInfo *>(pUserData);
l_psInfo->poForward->get_point(xIn, yIn, xyOut);
xOut = xyOut[0];
yOut = xyOut[1];
return true;
};

// Refine the initial guess
GDALGenericInverse2D(x[i], y[i], xy_out[0], xy_out[1],
ForwardTransformer, psInfo, xy_out[0],
xy_out[1]);
x[i] = xy_out[0];
y[i] = xy_out[1];
}
Expand Down
117 changes: 117 additions & 0 deletions deps/libgdal/gdal/alg/gdalgenericinverse.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/******************************************************************************
*
* Project: GDAL
* Purpose: Generic method to compute inverse coordinate transformation from
* forward method
* Author: Even Rouault <even dot rouault at spatialys dot com>
*
******************************************************************************
* Copyright (c) 2023, Even Rouault <even dot rouault at spatialys dot com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/

#include <algorithm>
#include <cmath>

#include "gdalgenericinverse.h"
#include <cstdio>

/** Compute (xOut, yOut) corresponding to input (xIn, yIn) using
* the provided forward transformation to emulate the reverse direction.
*
* Uses Newton-Raphson method, extended to 2D variables, that is using
* inversion of the Jacobian 2D matrix of partial derivatives. The derivatives
* are estimated numerically from the forward method evaluated at close points.
*
* Starts with initial guess provided by user in (guessedXOut, guessedYOut)
*
* It iterates at most for 15 iterations or as soon as we get below the specified
* tolerance (on input coordinates)
*/
bool GDALGenericInverse2D(double xIn, double yIn, double guessedXOut,
double guessedYOut,
GDALForwardCoordTransformer pfnForwardTranformer,
void *pfnForwardTranformerUserData, double &xOut,
double &yOut, double toleranceOnInputCoordinates)
{
const double dfAbsValOut = std::max(fabs(guessedXOut), fabs(guessedYOut));
const double dfEps = dfAbsValOut > 0 ? dfAbsValOut * 1e-6 : 1e-6;
if (toleranceOnInputCoordinates == 0)
{
const double dfAbsValIn = std::max(fabs(xIn), fabs(yIn));
toleranceOnInputCoordinates =
dfAbsValIn > 0 ? dfAbsValIn * 1e-12 : 1e-12;
}
xOut = guessedXOut;
yOut = guessedYOut;
double deriv_lam_X = 0;
double deriv_lam_Y = 0;
double deriv_phi_X = 0;
double deriv_phi_Y = 0;
for (int i = 0; i < 15; i++)
{
double xApprox;
double yApprox;
if (!pfnForwardTranformer(xOut, yOut, xApprox, yApprox,
pfnForwardTranformerUserData))
return false;
const double deltaX = xApprox - xIn;
const double deltaY = yApprox - yIn;
if (fabs(deltaX) < toleranceOnInputCoordinates &&
fabs(deltaY) < toleranceOnInputCoordinates)
{
return true;
}

// Compute Jacobian matrix
double xTmp = xOut + dfEps;
double yTmp = yOut;
double xTmpOut;
double yTmpOut;
if (!pfnForwardTranformer(xTmp, yTmp, xTmpOut, yTmpOut,
pfnForwardTranformerUserData))
return false;
const double deriv_X_lam = (xTmpOut - xApprox) / dfEps;
const double deriv_Y_lam = (yTmpOut - yApprox) / dfEps;

xTmp = xOut;
yTmp = yOut + dfEps;
if (!pfnForwardTranformer(xTmp, yTmp, xTmpOut, yTmpOut,
pfnForwardTranformerUserData))
return false;
const double deriv_X_phi = (xTmpOut - xApprox) / dfEps;
const double deriv_Y_phi = (yTmpOut - yApprox) / dfEps;

// Inverse of Jacobian matrix
const double det =
deriv_X_lam * deriv_Y_phi - deriv_X_phi * deriv_Y_lam;
if (det != 0)
{
deriv_lam_X = deriv_Y_phi / det;
deriv_lam_Y = -deriv_X_phi / det;
deriv_phi_X = -deriv_Y_lam / det;
deriv_phi_Y = deriv_X_lam / det;
}

xOut -= deltaX * deriv_lam_X + deltaY * deriv_lam_Y;
yOut -= deltaX * deriv_phi_X + deltaY * deriv_phi_Y;
}
return false;
}
44 changes: 44 additions & 0 deletions deps/libgdal/gdal/alg/gdalgenericinverse.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/******************************************************************************
*
* Project: GDAL
* Purpose: Generic method to compute inverse coordinate transformation from
* forward method
* Author: Even Rouault <even dot rouault at spatialys dot com>
*
******************************************************************************
* Copyright (c) 2023, Even Rouault <even dot rouault at spatialys dot com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/

#ifndef GDALGENERICINVERSE_H
#define GDALGENERICINVERSE_H
#include <stdbool.h>

typedef bool (*GDALForwardCoordTransformer)(double xIn, double yIn,
double &xOut, double &yOt,
void *pUserData);

bool GDALGenericInverse2D(double xIn, double yIn, double guessedXOut,
double guessedYOut,
GDALForwardCoordTransformer pfnForwardTranformer,
void *pfnForwardTranformerUserData, double &xOut,
double &yOut, double toleranceOnInputCoordinates = 0);

#endif // GDALGENERICINVERSE_H
20 changes: 17 additions & 3 deletions deps/libgdal/gdal/alg/gdalgeoloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ inline double Clamp(double v, double minV, double maxV)
/*! @cond Doxygen_Suppress */

template <class Accessors>
bool GDALGeoLoc<Accessors>::LoadGeolocFinish(
void GDALGeoLoc<Accessors>::LoadGeolocFinish(
GDALGeoLocTransformInfo *psTransform)
{
auto pAccessors = static_cast<Accessors *>(psTransform->pAccessors);
Expand Down Expand Up @@ -377,8 +377,6 @@ bool GDALGeoLoc<Accessors>::LoadGeolocFinish(
UpdateMinMax(psTransform, dfGeoLocX, dfGeoLocY);
}
}

return true;
}

/************************************************************************/
Expand Down Expand Up @@ -1973,6 +1971,22 @@ void *GDALCreateGeoLocTransformerEx(GDALDatasetH hBaseDS,
psTransform->nGeoLocXSize = nXSize;
psTransform->nGeoLocYSize = nYSize;

if (hBaseDS && psTransform->dfPIXEL_OFFSET == 0 &&
psTransform->dfLINE_OFFSET == 0 && psTransform->dfPIXEL_STEP == 1 &&
psTransform->dfLINE_STEP == 1)
{
if (GDALGetRasterXSize(hBaseDS) > nXSize ||
GDALGetRasterYSize(hBaseDS) > nYSize)
{
CPLError(CE_Warning, CPLE_AppDefined,
"Geolocation array is %d x %d large, "
"whereas dataset is %d x %d large. Result might be "
"incorrect due to lack of values in geolocation array.",
nXSize, nYSize, GDALGetRasterXSize(hBaseDS),
GDALGetRasterYSize(hBaseDS));
}
}

/* -------------------------------------------------------------------- */
/* Load the geolocation array. */
/* -------------------------------------------------------------------- */
Expand Down
Loading

0 comments on commit 9b3dcc5

Please sign in to comment.