Skip to content

Commit

Permalink
upgrade GDAL to 3.7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
mmomtchev committed Nov 8, 2023
1 parent f1eb75c commit 0128846
Show file tree
Hide file tree
Showing 69 changed files with 1,897 additions and 810 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ 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.7.3]

### Added
- GDAL 3.7.3

## [3.7.2] 2023-09-21

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.2
GDAL_VERSION=3.7.3
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.7.2
date-released: 2023-09-05
version: 3.7.3
date-released: 2023-10-30
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.7.2
3.7.3
9 changes: 7 additions & 2 deletions deps/libgdal/gdal/alg/gdal_alg_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

#include <cstdint>

#include <set>

#include "gdal_alg.h"
#include "ogr_spatialref.h"

Expand Down Expand Up @@ -73,6 +75,8 @@ typedef struct
} burnValues;
GDALBurnValueSrc eBurnValueSource;
GDALRasterMergeAlg eMergeAlg;
bool bFillSetVisitedPoints;
std::set<uint64_t> *poSetVisitedPoints;
} GDALRasterizeInfo;

typedef enum
Expand Down Expand Up @@ -104,14 +108,15 @@ void GDALdllImageLineAllTouched(int nRasterXSize, int nRasterYSize,
const double *padfX, const double *padfY,
const double *padfVariant,
llPointFunc pfnPointFunc, void *pCBData,
int bAvoidBurningSamePoints,
bool bAvoidBurningSamePoints,
bool bIntersectOnly);

void GDALdllImageFilledPolygon(int nRasterXSize, int nRasterYSize,
int nPartCount, const int *panPartSize,
const double *padfX, const double *padfY,
const double *padfVariant,
llScanlineFunc pfnScanlineFunc, void *pCBData);
llScanlineFunc pfnScanlineFunc, void *pCBData,
bool bAvoidBurningSamePoints);

CPL_C_END

Expand Down
123 changes: 101 additions & 22 deletions deps/libgdal/gdal/alg/gdalrasterize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ template <typename T> static inline T SaturatedAddSigned(T a, T b)
}
}

/************************************************************************/
/* MakeKey() */
/************************************************************************/

inline uint64_t MakeKey(int y, int x)
{
return (static_cast<uint64_t>(y) << 32) | static_cast<uint64_t>(x);
}

/************************************************************************/
/* gvBurnScanlineBasic() */
/************************************************************************/
Expand All @@ -90,23 +99,43 @@ static inline void gvBurnScanlineBasic(GDALRasterizeInfo *psInfo, int nY,
unsigned char *pabyInsert =
psInfo->pabyChunkBuf + iBand * psInfo->nBandSpace +
nY * psInfo->nLineSpace + nXStart * psInfo->nPixelSpace;
int nPixels = nXEnd - nXStart + 1;
if (psInfo->eMergeAlg == GRMA_Add)
{
while (nPixels-- > 0)
if (psInfo->poSetVisitedPoints)
{
double dfVal =
static_cast<double>(*reinterpret_cast<T *>(pabyInsert)) +
burnValue;
GDALCopyWord(dfVal, *reinterpret_cast<T *>(pabyInsert));
pabyInsert += psInfo->nPixelSpace;
CPLAssert(!psInfo->bFillSetVisitedPoints);
uint64_t nKey = MakeKey(nY, nXStart);
auto &oSetVisitedPoints = *(psInfo->poSetVisitedPoints);
for (int nX = nXStart; nX <= nXEnd; ++nX)
{
if (oSetVisitedPoints.find(nKey) == oSetVisitedPoints.end())
{
double dfVal = static_cast<double>(
*reinterpret_cast<T *>(pabyInsert)) +
burnValue;
GDALCopyWord(dfVal, *reinterpret_cast<T *>(pabyInsert));
}
pabyInsert += psInfo->nPixelSpace;
++nKey;
}
}
else
{
for (int nX = nXStart; nX <= nXEnd; ++nX)
{
double dfVal = static_cast<double>(
*reinterpret_cast<T *>(pabyInsert)) +
burnValue;
GDALCopyWord(dfVal, *reinterpret_cast<T *>(pabyInsert));
pabyInsert += psInfo->nPixelSpace;
}
}
}
else
{
T nVal;
GDALCopyWord(burnValue, nVal);
while (nPixels-- > 0)
for (int nX = nXStart; nX <= nXEnd; ++nX)
{
*reinterpret_cast<T *>(pabyInsert) = nVal;
pabyInsert += psInfo->nPixelSpace;
Expand All @@ -127,21 +156,41 @@ static inline void gvBurnScanlineInt64UserBurnValue(GDALRasterizeInfo *psInfo,
unsigned char *pabyInsert =
psInfo->pabyChunkBuf + iBand * psInfo->nBandSpace +
nY * psInfo->nLineSpace + nXStart * psInfo->nPixelSpace;
int nPixels = nXEnd - nXStart + 1;
if (psInfo->eMergeAlg == GRMA_Add)
{
while (nPixels-- > 0)
if (psInfo->poSetVisitedPoints)
{
*reinterpret_cast<std::int64_t *>(pabyInsert) =
SaturatedAddSigned(
*reinterpret_cast<std::int64_t *>(pabyInsert),
burnValue);
pabyInsert += psInfo->nPixelSpace;
CPLAssert(!psInfo->bFillSetVisitedPoints);
uint64_t nKey = MakeKey(nY, nXStart);
auto &oSetVisitedPoints = *(psInfo->poSetVisitedPoints);
for (int nX = nXStart; nX <= nXEnd; ++nX)
{
if (oSetVisitedPoints.find(nKey) == oSetVisitedPoints.end())
{
*reinterpret_cast<std::int64_t *>(pabyInsert) =
SaturatedAddSigned(
*reinterpret_cast<std::int64_t *>(pabyInsert),
burnValue);
}
pabyInsert += psInfo->nPixelSpace;
++nKey;
}
}
else
{
for (int nX = nXStart; nX <= nXEnd; ++nX)
{
*reinterpret_cast<std::int64_t *>(pabyInsert) =
SaturatedAddSigned(
*reinterpret_cast<std::int64_t *>(pabyInsert),
burnValue);
pabyInsert += psInfo->nPixelSpace;
}
}
}
else
{
while (nPixels-- > 0)
for (int nX = nXStart; nX <= nXEnd; ++nX)
{
*reinterpret_cast<std::int64_t *>(pabyInsert) = burnValue;
pabyInsert += psInfo->nPixelSpace;
Expand Down Expand Up @@ -285,6 +334,21 @@ static void gvBurnPoint(void *pCBData, int nY, int nX, double dfVariant)
CPLAssert(nY >= 0 && nY < psInfo->nYSize);
CPLAssert(nX >= 0 && nX < psInfo->nXSize);

if (psInfo->poSetVisitedPoints)
{
const uint64_t nKey = MakeKey(nY, nX);
if (psInfo->poSetVisitedPoints->find(nKey) ==
psInfo->poSetVisitedPoints->end())
{
if (psInfo->bFillSetVisitedPoints)
psInfo->poSetVisitedPoints->insert(nKey);
}
else
{
return;
}
}

if (psInfo->eBurnValueType == GDT_Int64)
{
if (psInfo->eType == GDT_Int64 &&
Expand Down Expand Up @@ -552,6 +616,8 @@ static void gv_rasterize_one_shape(
}
sInfo.eBurnValueSource = eBurnValueSrc;
sInfo.eMergeAlg = eMergeAlg;
sInfo.bFillSetVisitedPoints = false;
sInfo.poSetVisitedPoints = nullptr;

/* -------------------------------------------------------------------- */
/* Transform polygon geometries into a set of rings and a part */
Expand Down Expand Up @@ -607,6 +673,11 @@ static void gv_rasterize_one_shape(
case wkbLineString:
case wkbMultiLineString:
{
if (eMergeAlg == GRMA_Add)
{
sInfo.bFillSetVisitedPoints = true;
sInfo.poSetVisitedPoints = new std::set<uint64_t>();
}
if (bAllTouched)
GDALdllImageLineAllTouched(
sInfo.nXSize, nYSize, static_cast<int>(aPartSize.size()),
Expand All @@ -626,12 +697,11 @@ static void gv_rasterize_one_shape(

default:
{
GDALdllImageFilledPolygon(
sInfo.nXSize, nYSize, static_cast<int>(aPartSize.size()),
aPartSize.data(), aPointX.data(), aPointY.data(),
(eBurnValueSrc == GBV_UserBurnValue) ? nullptr
: aPointVariant.data(),
gvBurnScanline, &sInfo);
if (eMergeAlg == GRMA_Add)
{
sInfo.bFillSetVisitedPoints = true;
sInfo.poSetVisitedPoints = new std::set<uint64_t>();
}
if (bAllTouched)
{
// Reverting the variants to the first value because the
Expand Down Expand Up @@ -662,9 +732,18 @@ static void gv_rasterize_one_shape(
gvBurnPoint, &sInfo, eMergeAlg == GRMA_Add, true);
}
}
sInfo.bFillSetVisitedPoints = false;
GDALdllImageFilledPolygon(
sInfo.nXSize, nYSize, static_cast<int>(aPartSize.size()),
aPartSize.data(), aPointX.data(), aPointY.data(),
(eBurnValueSrc == GBV_UserBurnValue) ? nullptr
: aPointVariant.data(),
gvBurnScanline, &sInfo, eMergeAlg == GRMA_Add);
}
break;
}

delete sInfo.poSetVisitedPoints;
}

/************************************************************************/
Expand Down
39 changes: 32 additions & 7 deletions deps/libgdal/gdal/alg/gdaltransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3372,14 +3372,40 @@ static CPLXMLNode *GDALSerializeReprojectionTransformer(void *pTransformArg)
/* -------------------------------------------------------------------- */
/* Handle SourceCS. */
/* -------------------------------------------------------------------- */
char *pszWKT = nullptr;
const auto ExportToWkt = [](const OGRSpatialReference *poSRS)
{
// Try first in WKT1 for backward compat
{
char *pszWKT = nullptr;
const char *const apszOptions[] = {"FORMAT=WKT1", nullptr};
CPLErrorHandlerPusher oHandler(CPLQuietErrorHandler);
CPLErrorStateBackuper oBackuper;
if (poSRS->exportToWkt(&pszWKT, apszOptions) == OGRERR_NONE)
{
std::string osRet(pszWKT);
CPLFree(pszWKT);
return osRet;
}
CPLFree(pszWKT);
}

char *pszWKT = nullptr;
const char *const apszOptions[] = {"FORMAT=WKT2_2019", nullptr};
if (poSRS->exportToWkt(&pszWKT, apszOptions) == OGRERR_NONE)
{
std::string osRet(pszWKT);
CPLFree(pszWKT);
return osRet;
}
CPLFree(pszWKT);
return std::string();
};

auto poSRS = psInfo->poForwardTransform->GetSourceCS();
if (poSRS)
{
poSRS->exportToWkt(&pszWKT);
CPLCreateXMLElementAndValue(psTree, "SourceSRS", pszWKT);
CPLFree(pszWKT);
const auto osWKT = ExportToWkt(poSRS);
CPLCreateXMLElementAndValue(psTree, "SourceSRS", osWKT.c_str());
}

/* -------------------------------------------------------------------- */
Expand All @@ -3388,9 +3414,8 @@ static CPLXMLNode *GDALSerializeReprojectionTransformer(void *pTransformArg)
poSRS = psInfo->poForwardTransform->GetTargetCS();
if (poSRS)
{
poSRS->exportToWkt(&pszWKT);
CPLCreateXMLElementAndValue(psTree, "TargetSRS", pszWKT);
CPLFree(pszWKT);
const auto osWKT = ExportToWkt(poSRS);
CPLCreateXMLElementAndValue(psTree, "TargetSRS", osWKT.c_str());
}

/* -------------------------------------------------------------------- */
Expand Down
Loading

0 comments on commit 0128846

Please sign in to comment.