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

[pull] master from OSGeo:master #206

Merged
merged 10 commits into from
Mar 4, 2025
10 changes: 5 additions & 5 deletions .github/workflows/cmake_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ jobs:

- name: Install pdfium
run: |
wget -q https://github.com/rouault/pdfium_build_gdal_3_10/releases/download/pdfium_6677_v1/install-ubuntu2004-rev6677.tar.gz \
&& tar -xzf install-ubuntu2004-rev6677.tar.gz \
wget -q https://github.com/rouault/pdfium_build_gdal_3_11/releases/download/pdfium_7047_v1/install-ubuntu2004-rev7047.tar.gz \
&& tar -xzf install-ubuntu2004-rev7047.tar.gz \
&& sudo chown -R root:root install \
&& sudo mv install/lib/* /usr/lib/ \
&& sudo mv install/include/* /usr/include/ \
&& sudo rm -rf install-ubuntu2004-rev6677.tar.gz install \
&& sudo rm -rf install-ubuntu2004-rev7047.tar.gz install \
&& sudo apt-get update -y \
&& sudo apt-get install -y --fix-missing --no-install-recommends liblcms2-dev
- name: Configure ccache
Expand Down Expand Up @@ -441,8 +441,8 @@ jobs:
- name: Install pdfium
shell: bash -l {0}
run: |
curl -LOs https://github.com/rouault/pdfium_build_gdal_3_10/releases/download/pdfium_6677_v1/install-win10-vs2019-x64-rev6677.zip
unzip install-win10-vs2019-x64-rev6677.zip
curl -LOs https://github.com/rouault/pdfium_build_gdal_3_11/releases/download/pdfium_7047_v1/install-win10-vs2019-x64-rev7047.zip
unzip install-win10-vs2019-x64-rev7047.zip
mv install install-pdfium

- name: Remove conflicting libraries
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ubuntu_20.04/Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,12 @@ RUN mkdir geos \
&& rm -rf geos

# Install pdfium
RUN wget -q https://github.com/rouault/pdfium_build_gdal_3_10/releases/download/pdfium_6677_v1/install-ubuntu2004-rev6677.tar.gz \
&& tar -xzf install-ubuntu2004-rev6677.tar.gz \
RUN wget -q https://github.com/rouault/pdfium_build_gdal_3_11/releases/download/pdfium_7047_v1/install-ubuntu2004-rev7047.tar.gz \
&& tar -xzf install-ubuntu2004-rev7047.tar.gz \
&& chown -R root:root install \
&& mv install/lib/* /usr/lib/ \
&& mv install/include/* /usr/include/ \
&& rm -rf install-ubuntu2004-rev6677.tar.gz install
&& rm -rf install-ubuntu2004-rev7047.tar.gz install

# HANA: client side
# Install hdbsql tool
Expand Down
1 change: 1 addition & 0 deletions autotest/cpp/testfloat16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ TEST(TestFloat16, math)
if (x >= 0)
{
using std::sqrt;
// coverity[negative_returns]
EXPECT_NEAR(sqrt(GFloat16(x)), sqrt(x), fabs(sqrt(x) / 1024));
}
}
Expand Down
31 changes: 11 additions & 20 deletions autotest/gdrivers/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ def test_pdf_online_1(poppler_or_pdfium):
if pdf_is_pdfium():
expected_gt = (
-77.11232757568358,
9.1663393281356228e-06,
9.166339328135623e-06,
0.0,
38.897842406247477,
38.89784240741306,
0.0,
-9.1665025563464202e-06,
-9.166503628631888e-06,
)
elif pdf_is_poppler():
expected_gt = (
Expand Down Expand Up @@ -220,11 +220,11 @@ def test_pdf_online_2(poppler_or_pdfium):
if pdf_is_pdfium():
expected_gt = (
-77.11232757568358,
9.1663393281356228e-06,
9.166339328135623e-06,
0.0,
38.897842406247477,
38.89784240741306,
0.0,
-9.1665025563464202e-06,
-9.166503628631888e-06,
)
elif pdf_is_poppler():
expected_gt = (
Expand Down Expand Up @@ -278,12 +278,12 @@ def test_pdf_1(poppler_or_pdfium):

if pdf_is_pdfium():
expected_gt = (
333275.12406585668,
31.764450118407499,
333274.5701626293,
31.765012397640078,
0.0,
4940392.1233656602,
4940391.755002656,
0.0,
-31.794983670894396,
-31.794694104865194,
)
else:
expected_gt = (
Expand All @@ -310,7 +310,7 @@ def test_pdf_1(poppler_or_pdfium):
got_geom = ogr.CreateGeometryFromWkt(neatline)
if pdf_is_pdfium():
expected_geom = ogr.CreateGeometryFromWkt(
"POLYGON ((338304.28536533244187 4896674.10591614805162,338304.812550922040828 4933414.853961281478405,382774.246895745047368 4933414.855149634182453,382774.983309225703124 4896673.95723026804626,338304.28536533244187 4896674.10591614805162))"
"POLYGON ((338304.274926337 4896673.68220244,338304.206397453 4933414.86906802,382774.239238623 4933414.4314159,382774.990878249 4896674.38093959,338304.274926337 4896673.68220244))"
)
else:
expected_geom = ogr.CreateGeometryFromWkt(
Expand Down Expand Up @@ -959,15 +959,6 @@ def _pdf_set_neatline(pdf_backend, geo_encoding, dpi=300):
got_neatline = ds.GetMetadataItem("NEATLINE")

if pdf_is_pdfium():
if geo_encoding == "ISO32000":
expected_gt = (
440722.21886505646,
59.894520395349709,
0.020450745157516229,
3751318.6133243339,
0.077268565258743135,
-60.009312694035692,
)
max_error = 1
else:
max_error = 0.0001
Expand Down
8 changes: 7 additions & 1 deletion doc/source/drivers/raster/pdf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -727,9 +727,15 @@ Only GDAL builds against static builds of PDFium have been tested.
Building PDFium can be challenging, and particular builds must be used to
work properly with GDAL.

With GDAL >= 3.10
With GDAL >= 3.11
+++++++++++++++++

The scripts in the `<https://github.com/rouault/pdfium_build_gdal_3_11>`__
repository must be used to build a patched version of PDFium.

With GDAL = 3.10
++++++++++++++++

The scripts in the `<https://github.com/rouault/pdfium_build_gdal_3_10>`__
repository must be used to build a patched version of PDFium.

Expand Down
6 changes: 3 additions & 3 deletions docker/ubuntu-full/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,12 @@ ARG WITH_PDFIUM=yes
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
if echo "$WITH_PDFIUM" | grep -Eiq "^(y(es)?|1|true)$" ; then ( \
wget -q https://github.com/rouault/pdfium_build_gdal_3_10/releases/download/pdfium_6677_v1/install-ubuntu2004-rev6677.tar.gz \
&& tar -xzf install-ubuntu2004-rev6677.tar.gz \
wget -q https://github.com/rouault/pdfium_build_gdal_3_11/releases/download/pdfium_7047_v1/install-ubuntu2004-rev7047.tar.gz \
&& tar -xzf install-ubuntu2004-rev7047.tar.gz \
&& chown -R root:root install \
&& mv install/lib/* /usr/lib/ \
&& mv install/include/* /usr/include/ \
&& rm -rf install-ubuntu2004-rev6677.tar.gz install \
&& rm -rf install-ubuntu2004-rev7047.tar.gz install \
&& apt-get update -y \
&& apt-get install -y --fix-missing --no-install-recommends liblcms2-dev${APT_ARCH_SUFFIX} \
) ; fi
Expand Down
2 changes: 1 addition & 1 deletion frmts/avif/avifdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ GDALAVIFIO::GDALAVIFIO(VSIVirtualHandleUniquePtr fpIn) : fp(std::move(fpIn))
nFileSize = fp->Tell();
fp->Seek(0, SEEK_SET);

io.sizeHint = std::min<uint64_t>(10 * 1024 * 1024, nFileSize);
io.sizeHint = nFileSize;
}

/************************************************************************/
Expand Down
24 changes: 14 additions & 10 deletions frmts/msg/xritheaderparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,20 @@ XRITHeaderParser::XRITHeaderParser(std::ifstream &ifile)
{
unsigned char *buf =
(unsigned char *)std::malloc(totalHeaderLength);
std::memcpy(
buf, probeBuf,
probeSize); // save what we have already read when probing
ifile.read((char *)buf + probeSize,
totalHeaderLength -
probeSize); // read the rest of the header section
parseHeader(buf, totalHeaderLength);
std::free(buf);

m_isValid = true;
if (buf)
{
std::memcpy(
buf, probeBuf,
probeSize); // save what we have already read when probing
ifile.read(
(char *)buf + probeSize,
totalHeaderLength -
probeSize); // read the rest of the header section
parseHeader(buf, totalHeaderLength);
std::free(buf);

m_isValid = true;
}
}
}

Expand Down
18 changes: 7 additions & 11 deletions frmts/pdf/pdfdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1527,30 +1527,26 @@ class GDALPDFiumRenderDeviceDriver : public RenderDeviceDriverIface
const CFX_Matrix *pObject2Device,
const CFX_GraphStateData *pGraphState,
uint32_t fill_color, uint32_t stroke_color,
const CFX_FillRenderOptions &fill_options,
BlendMode blend_type) override
const CFX_FillRenderOptions &fill_options) override
{
if (!bEnableVector && !bTemporaryEnableVectorForTextStroking)
return true;
return m_poParent->DrawPath(path, pObject2Device, pGraphState,
fill_color, stroke_color, fill_options,
blend_type);
fill_color, stroke_color, fill_options);
}

virtual bool FillRectWithBlend(const FX_RECT &rect, uint32_t fill_color,
BlendMode blend_type) override
virtual bool FillRect(const FX_RECT &rect, uint32_t fill_color) override
{
return m_poParent->FillRectWithBlend(rect, fill_color, blend_type);
return m_poParent->FillRect(rect, fill_color);
}

virtual bool DrawCosmeticLine(const CFX_PointF &ptMoveTo,
const CFX_PointF &ptLineTo, uint32_t color,
BlendMode blend_typeL) override
const CFX_PointF &ptLineTo,
uint32_t color) override
{
if (!bEnableVector && !bTemporaryEnableVectorForTextStroking)
return TRUE;
return m_poParent->DrawCosmeticLine(ptMoveTo, ptLineTo, color,
blend_typeL);
return m_poParent->DrawCosmeticLine(ptMoveTo, ptLineTo, color);
}

virtual FX_RECT GetClipBox() const override
Expand Down
16 changes: 16 additions & 0 deletions frmts/pdf/pdfsdk_headers_pdfium.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@
#pragma warning(push)
// include/pdfium\core/fxcrt/fx_memcpy_wrappers.h(48,30): warning C4244: 'argument': conversion from 'int' to 'wchar_t', possible loss of data
#pragma warning(disable : 4244)

// Nasty hack to avoid build issues with asm volatile in include/pdfium\core/fxcrt/immediate_crash.h(138,3)
#define CORE_FXCRT_IMMEDIATE_CRASH_H_
#include "cpl_error.h"

namespace pdfium
{

[[noreturn]] inline void ImmediateCrash()
{
// Private joke: GDAL crashing !!!! Are you satisfied Martin ;-)
CPLError(CE_Fatal, CPLE_AppDefined, "ImmediateCrash()");
}

} // namespace pdfium

#endif

#include <cstring>
Expand Down
14 changes: 9 additions & 5 deletions gcore/gdal_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2837,7 +2837,7 @@ int CPL_STDCALL GDALWriteWorldFile(const char *pszBaseFilename,
* string. i.e. "20230312".</li>
* <li> "RELEASE_NAME": Returns the GDAL_RELEASE_NAME. ie. "3.6.3"</li>
* <li> "RELEASE_NICKNAME": (>= 3.11) Returns the GDAL_RELEASE_NICKNAME.
* i.e. "Trans rights are human rights"</li>
* (may be empty)</li>
* <li> "--version": Returns one line version message suitable for
* use in response to --version requests. i.e. "GDAL 3.6.3, released
* 2023/03/12"</li>
Expand Down Expand Up @@ -3002,12 +3002,16 @@ const char *CPL_STDCALL GDALVersionInfo(const char *pszRequest)
else if (EQUAL(pszRequest, "RELEASE_NAME"))
osVersionInfo.Printf(GDAL_RELEASE_NAME);
else if (EQUAL(pszRequest, "RELEASE_NICKNAME"))
osVersionInfo.Printf(GDAL_RELEASE_NICKNAME);
osVersionInfo.Printf("%s", GDAL_RELEASE_NICKNAME);
else // --version
{
osVersionInfo.Printf(
"GDAL %s \"%s\", released %d/%02d/%02d", GDAL_RELEASE_NAME,
GDAL_RELEASE_NICKNAME, GDAL_RELEASE_DATE / 10000,
osVersionInfo = "GDAL " GDAL_RELEASE_NAME;
if (GDAL_RELEASE_NICKNAME[0])
{
osVersionInfo += " \"" GDAL_RELEASE_NICKNAME "\"";
}
osVersionInfo += CPLString().Printf(
", released %d/%02d/%02d", GDAL_RELEASE_DATE / 10000,
(GDAL_RELEASE_DATE % 10000) / 100, GDAL_RELEASE_DATE % 100);
#if defined(__GNUC__) && !defined(__OPTIMIZE__)
// Cf https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
Expand Down
4 changes: 3 additions & 1 deletion gcore/gdal_version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
# define GDAL_RELEASE_NAME "3.11.0dev"
#endif

#define GDAL_RELEASE_NICKNAME "Trans rights are human rights"
#ifndef GDAL_RELEASE_NICKNAME
#define GDAL_RELEASE_NICKNAME ""
#endif

#endif
16 changes: 15 additions & 1 deletion gcore/gdalalgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,21 @@ class CPL_DLL GDALAlgorithmArg /* non-final */
!std::is_same_v<T, std::vector<GDALArgDatasetValue>>)
{
if (decl.HasDefaultValue())
*std::get<T *>(m_value) = decl.GetDefault<T>();
{
try
{
*std::get<T *>(m_value) = decl.GetDefault<T>();
}
catch (const std::bad_variant_access &e)
{
// I don't think that can happen, but Coverity Scan thinks
// so
CPLError(CE_Failure, CPLE_AppDefined,
"*std::get<T *>(m_value) = decl.GetDefault<T>() "
"failed: %s",
e.what());
}
}
}
}

Expand Down
12 changes: 8 additions & 4 deletions gcore/overview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3142,7 +3142,10 @@ static CPLErr GDALResampleChunk_ConvolutionT(
: dfNoDataValue;
// cppcheck-suppress unreadVariable
const int isIntegerDT = GDALDataTypeIsInteger(dstDataType);
const auto nNodataValueInt64 = static_cast<GInt64>(dfNoDataValue);
const bool bNoDataValueInt64Valid =
isIntegerDT && GDALIsValueExactAs<GInt64>(dfNoDataValue);
const auto nNodataValueInt64 =
bNoDataValueInt64Valid ? static_cast<GInt64>(dfNoDataValue) : 0;
constexpr int nWrkDataTypeSize = static_cast<int>(sizeof(Twork));

// TODO: we should have some generic function to do this.
Expand Down Expand Up @@ -3196,8 +3199,8 @@ static CPLErr GDALResampleChunk_ConvolutionT(
}

auto replaceValIfNodata = [bHasNoData, isIntegerDT, fDstMin, fDstMax,
nNodataValueInt64, dfNoDataValue,
dfReplacementVal](Twork fVal)
bNoDataValueInt64Valid, nNodataValueInt64,
dfNoDataValue, dfReplacementVal](Twork fVal)
{
if (!bHasNoData)
return fVal;
Expand All @@ -3211,7 +3214,8 @@ static CPLErr GDALResampleChunk_ConvolutionT(
fClamped = fDstMax;
if (isIntegerDT)
{
if (nNodataValueInt64 == static_cast<GInt64>(std::round(fClamped)))
if (bNoDataValueInt64Valid &&
nNodataValueInt64 == static_cast<GInt64>(std::round(fClamped)))
{
// Do not use the nodata value
return static_cast<Twork>(dfReplacementVal);
Expand Down
6 changes: 3 additions & 3 deletions ogr/ogrsf_frmts/ngw/gdalngwdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1738,7 +1738,7 @@ bool OGRNGWDataset::AddFieldDomain(std::unique_ptr<OGRFieldDomain> &&domain,
}

auto osPalyload = CreateNGWLookupTableJson(
dynamic_cast<OGRCodedFieldDomain *>(domain.get()),
static_cast<OGRCodedFieldDomain *>(domain.get()),
static_cast<GIntBig>(std::stol(osResourceId)));

std::string osResourceIdInt =
Expand Down Expand Up @@ -1801,7 +1801,7 @@ bool OGRNGWDataset::UpdateFieldDomain(std::unique_ptr<OGRFieldDomain> &&domain,
}

auto osPayload = CreateNGWLookupTableJson(
dynamic_cast<const OGRCodedFieldDomain *>(domain.get()),
static_cast<const OGRCodedFieldDomain *>(domain.get()),
static_cast<GIntBig>(std::stol(osResourceId)));

if (!NGWAPI::UpdateResource(osUrl, osResourceId, osPayload, GetHeaders()))
Expand Down Expand Up @@ -1859,4 +1859,4 @@ GIntBig OGRNGWDataset::GetDomainIdByName(const std::string &osDomainName) const
}
}
return 0L;
}
}
1 change: 1 addition & 0 deletions scripts/cppcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ for dirname in alg port gcore ogr frmts gnm apps fuzzers; do
-DPCIDSK_FRMT_UINT64="\"%llu\"" \
-DGNMGFIDFormat="\"%lld\"" \
-DGDAL_RELEASE_NAME="\"dummy\"" \
-DGDAL_RELEASE_NICKNAME="\"dummy\"" \
"-DBANDMAP_TYPE=int*" \
-DSQLITE_UTF8=1 \
-DSQLITE_DETERMINISTIC=0x000000800 \
Expand Down