Skip to content

Commit

Permalink
Merge branch 'OSGeo:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
a0x8o authored Aug 26, 2024
2 parents acb0366 + 449d5f0 commit 59bef2e
Show file tree
Hide file tree
Showing 68 changed files with 4,097 additions and 271 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/doc_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ jobs:
run: |
make latexpdf
working-directory: ./doc
#- name: Spelling
# shell: bash -l {0}
# run: |
# make spelling
# working-directory: ./doc
- name: Spelling
shell: bash -l {0}
run: |
make spelling
working-directory: ./doc
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: PDF
Expand Down
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# This is the config file for building GDAL and running its autotest suite
# with Travis-ci.org

# FIXME: Travis-CI builds are disabled
branches:
except:
- /^(cherry-pick-)?backport-\d+-to-/
only:
- disabled_disabled
#branches:
# except:
# - /^(cherry-pick-)?backport-\d+-to-/

matrix:
fast_finish: true
Expand Down
2 changes: 1 addition & 1 deletion alg/gdalproximity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ the proximity output.
FIXED_BUF_VAL=n
If this option is set, all pixels within the MAXDIST threadhold are
If this option is set, all pixels within the MAXDIST threshold are
set to this fixed value instead of to a proximity distance.
*/

Expand Down
12 changes: 6 additions & 6 deletions alg/gdaltransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1765,13 +1765,13 @@ static void GDALGCPAntimeridianUnwrap(int nGCPCount, GDAL_GCP *pasGCPList,
* a PROJ or WKT string, used as an override over the normally computed
* pipeline. The pipeline must take into account the axis order of the source
* and target SRS. <li> COORDINATE_EPOCH: (GDAL &gt;= 3.0) Coordinate epoch,
* expressed as a decimal year. Useful for time-dependant coordinate operations.
* expressed as a decimal year. Useful for time-dependent coordinate operations.
* </li>
* <li> SRC_COORDINATE_EPOCH: (GDAL &gt;= 3.4) Coordinate epoch of source CRS,
* expressed as a decimal year. Useful for time-dependant coordinate operations.
* expressed as a decimal year. Useful for time-dependent coordinate operations.
* </li>
* <li> DST_COORDINATE_EPOCH: (GDAL &gt;= 3.4) Coordinate epoch of target CRS,
* expressed as a decimal year. Useful for time-dependant coordinate operations.
* expressed as a decimal year. Useful for time-dependent coordinate operations.
* </li>
* <li> GCPS_OK: If false, GCPs will not be used, default is TRUE.
* </li>
Expand Down Expand Up @@ -3366,11 +3366,11 @@ void *GDALCreateReprojectionTransformer(const char *pszSrcWKT,
* <li>COORDINATE_OPERATION=string: PROJ or WKT string representing a
* coordinate operation, overriding the default computed transformation.</li>
* <li>COORDINATE_EPOCH=decimal_year: Coordinate epoch, expressed as a
* decimal year. Useful for time-dependant coordinate operations.</li>
* decimal year. Useful for time-dependent coordinate operations.</li>
* <li> SRC_COORDINATE_EPOCH: (GDAL &gt;= 3.4) Coordinate epoch of source CRS,
* expressed as a decimal year. Useful for time-dependant coordinate
* expressed as a decimal year. Useful for time-dependent coordinate
*operations.</li> <li> DST_COORDINATE_EPOCH: (GDAL &gt;= 3.4) Coordinate epoch
*of target CRS, expressed as a decimal year. Useful for time-dependant
*of target CRS, expressed as a decimal year. Useful for time-dependent
*coordinate operations.</li>
* </ul>
*
Expand Down
2 changes: 1 addition & 1 deletion alg/gdalwarper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ CPLErr GDALWarpDstAlphaMasker(void *pMaskFuncArg, int nBandCount,
* is sufficient. Depending on the transformation in effect, the source
* window may be a bit too small, or even missing large areas. Problem
* situations are those where the transformation is very non-linear or
* "inside out". Examples are transforming from WGS84 to Polar Steregraphic
* "inside out". Examples are transforming from WGS84 to Polar Stereographic
* for areas around the pole, or transformations where some of the image is
* untransformable. The following options provide some additional control
* to deal with errors in computing the source window:
Expand Down
22 changes: 18 additions & 4 deletions apps/gdal_translate_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1826,10 +1826,24 @@ GDALDatasetH GDALTranslate(const char *pszDest, GDALDatasetH hSrcDataset,

const double df2 = adfSrcWinOri[2];
const double df3 = adfSrcWinOri[3];
dfSAMP_OFF *= nOXSize / df2;
dfLINE_OFF *= nOYSize / df3;
dfSAMP_SCALE *= nOXSize / df2;
dfLINE_SCALE *= nOYSize / df3;
const double dfXRatio = nOXSize / df2;
const double dfYRatio = nOYSize / df3;

// For line offset and pixel offset, we need to convert from RPC
// pixel center registration convention to GDAL pixel top-left corner
// registration convention by adding an initial 0.5 shift, and un-apply
// it after scaling.

dfSAMP_OFF += 0.5;
dfSAMP_OFF *= dfXRatio;
dfSAMP_OFF -= 0.5;

dfLINE_OFF += 0.5;
dfLINE_OFF *= dfYRatio;
dfLINE_OFF -= 0.5;

dfSAMP_SCALE *= dfXRatio;
dfLINE_SCALE *= dfYRatio;

CPLString osField;
osField.Printf("%.15g", dfLINE_OFF);
Expand Down
13 changes: 6 additions & 7 deletions autotest/gcore/overviewds.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,12 @@ def test_overviewds_4(tmp_path):

for key in rpc_md:
assert ds.GetMetadataItem(key, "RPC") == got_md[key]
if (
key == "LINE_SCALE"
or key == "SAMP_SCALE"
or key == "LINE_OFF"
or key == "SAMP_OFF"
):
assert float(got_md[key]) == myfloat(rpc_md[key]) / 2
if key == "LINE_SCALE" or key == "SAMP_SCALE":
assert float(got_md[key]) == pytest.approx(myfloat(rpc_md[key]) / 2)
elif key == "LINE_OFF" or key == "SAMP_OFF":
assert float(got_md[key]) == pytest.approx(
(myfloat(rpc_md[key]) + 0.5) / 2 - 0.5
)
elif got_md[key] != rpc_md[key]:
print(got_md[key])
print(rpc_md[key])
Expand Down
45 changes: 45 additions & 0 deletions autotest/gdrivers/jp2kak.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,51 @@ def test_jp2kak_lossless_uint32_nbits_20():
gdal.GetDriverByName("JP2KAK").Delete(tmpfilename)


###############################################################################
# Test lossless copying of multi band with tiling (to cause a stripe_height != 1)


@pytest.mark.parametrize("use_stripe_compressor", ["YES", "NO"])
def test_jp2kak_lossless_multiband(tmp_vsimem, use_stripe_compressor):

src_ds = gdal.Open("data/rgbsmall.tif")
out_filename = str(tmp_vsimem / "out.jp2")
with gdaltest.config_option("JP2KAK_USE_STRIPE_COMPRESSOR", use_stripe_compressor):
gdal.GetDriverByName("JP2KAK").CreateCopy(
out_filename,
src_ds,
options=["QUALITY=100", "BLOCKXSIZE=32", "BLOCKYSIZE=24"],
)
ds = gdal.Open(out_filename)
assert [ds.GetRasterBand(i + 1).Checksum() for i in range(3)] == [
src_ds.GetRasterBand(i + 1).Checksum() for i in range(3)
]


###############################################################################
# Test lossless copying of multi band with tiling (to cause a stripe_height != 1)


@pytest.mark.parametrize("use_stripe_compressor", ["YES", "NO"])
def test_jp2kak_lossless_multiband_non_byte(tmp_vsimem, use_stripe_compressor):

src_ds = gdal.Open("data/rgbsmall.tif")
src_ds = gdal.Translate(
"", src_ds, options="-f MEM -ot UInt16 -scale 0 255 0 65535"
)
out_filename = str(tmp_vsimem / "out.jp2")
with gdaltest.config_option("JP2KAK_USE_STRIPE_COMPRESSOR", use_stripe_compressor):
gdal.GetDriverByName("JP2KAK").CreateCopy(
out_filename,
src_ds,
options=["QUALITY=100", "BLOCKXSIZE=32", "BLOCKYSIZE=24"],
)
ds = gdal.Open(out_filename)
assert [ds.GetRasterBand(i + 1).Checksum() for i in range(3)] == [
src_ds.GetRasterBand(i + 1).Checksum() for i in range(3)
]


###############################################################################
# Test lossy copying of Int32

Expand Down
26 changes: 26 additions & 0 deletions autotest/gdrivers/netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6510,6 +6510,32 @@ def test_band_names_creation_option(tmp_path):
assert gdal.GetSubdatasetInfo(sds_names[1]).GetSubdatasetComponent() == "prate"


@gdaltest.enable_exceptions()
def test_band_names_creation_option_createcopy(tmp_path):

fname = tmp_path / "out.nc"

# 1 band, 2 names
with pytest.raises(Exception, match="but 2 names provided"):
src_ds = gdal.GetDriverByName("MEM").Create("", 1, 1)
gdal.GetDriverByName("NetCDF").CreateCopy(
fname, src_ds, options={"BAND_NAMES": "t2m,prate"}
)

# 2 bands, 2 names
src_ds = gdal.GetDriverByName("MEM").Create("", 1, 1, 2)
with gdal.GetDriverByName("NetCDF").CreateCopy(
fname, src_ds, options={"BAND_NAMES": "t2m,prate"}
):
pass

with gdal.Open(fname) as ds:
sds_names = [sds[0] for sds in ds.GetSubDatasets()]

assert gdal.GetSubdatasetInfo(sds_names[0]).GetSubdatasetComponent() == "t2m"
assert gdal.GetSubdatasetInfo(sds_names[1]).GetSubdatasetComponent() == "prate"


@gdaltest.enable_exceptions()
def test_netcdf_create_metadata_with_equal_sign(tmp_path):

Expand Down
28 changes: 22 additions & 6 deletions autotest/utilities/test_gdal_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,16 +872,32 @@ def test_gdal_translate_32(gdal_translate_path, tmp_path):

dst_tif = str(tmp_path / "out.tif")

src_ds = gdal.Open("../gcore/data/byte_rpc.tif")
src_md = src_ds.GetMetadata("RPC")
srcxoff = 1
srcyoff = 2
srcwidth = 13
srcheight = 14
widthratio = 200
heightratio = 300
gdaltest.runexternal(
f"{gdal_translate_path} ../gcore/data/byte_rpc.tif {dst_tif} -srcwin 1 2 13 14 -outsize 150% 300%"
f"{gdal_translate_path} ../gcore/data/byte_rpc.tif {dst_tif} -srcwin {srcxoff} {srcyoff} {srcwidth} {srcheight} -outsize {widthratio}% {heightratio}%"
)
widthratio /= 100.0
heightratio /= 100.0
ds = gdal.Open(dst_tif)
md = ds.GetMetadata("RPC")
assert (
float(md["LINE_OFF"]) == pytest.approx(47496, abs=1e-5)
and float(md["LINE_SCALE"]) == pytest.approx(47502, abs=1e-5)
and float(md["SAMP_OFF"]) == pytest.approx(19676.6923076923, abs=1e-5)
and float(md["SAMP_SCALE"]) == pytest.approx(19678.1538461538, abs=1e-5)
assert float(md["LINE_OFF"]) == pytest.approx(
(float(src_md["LINE_OFF"]) - srcyoff + 0.5) * heightratio - 0.5, abs=1e-5
)
assert float(md["LINE_SCALE"]) == pytest.approx(
float(src_md["LINE_SCALE"]) * heightratio, abs=1e-5
)
assert float(md["SAMP_OFF"]) == pytest.approx(
(float(src_md["SAMP_OFF"]) - srcxoff + 0.5) * widthratio - 0.5, abs=1e-5
)
assert float(md["SAMP_SCALE"]) == pytest.approx(
float(src_md["SAMP_SCALE"]) * widthratio, abs=1e-5
)


Expand Down
8 changes: 6 additions & 2 deletions autotest/utilities/test_gdal_translate_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1281,11 +1281,15 @@ def test_gdal_translate_ovr_rpc():
src_rpc = src_ds.GetMetadata("RPC")
ovr_rpc = ds.GetMetadata("RPC")
assert ovr_rpc
assert float(ovr_rpc["LINE_OFF"]) == pytest.approx(0.5 * float(src_rpc["LINE_OFF"]))
assert float(ovr_rpc["LINE_OFF"]) == pytest.approx(
0.5 * (float(src_rpc["LINE_OFF"]) + 0.5) - 0.5
)
assert float(ovr_rpc["LINE_SCALE"]) == pytest.approx(
0.5 * float(src_rpc["LINE_SCALE"])
)
assert float(ovr_rpc["SAMP_OFF"]) == pytest.approx(0.5 * float(src_rpc["SAMP_OFF"]))
assert float(ovr_rpc["SAMP_OFF"]) == pytest.approx(
0.5 * (float(src_rpc["SAMP_OFF"]) + 0.5) - 0.5
)
assert float(ovr_rpc["SAMP_SCALE"]) == pytest.approx(
0.5 * float(src_rpc["SAMP_SCALE"])
)
Expand Down
7 changes: 6 additions & 1 deletion doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if (UNIX
else()
set(BUILD_DOCS_DEFAULT OFF)
endif()
option(BUILD_DOCS "Set to ON to define documentation targets: 'html', 'latexpdf', 'man', 'doxygen', 'doxygen_check_warnings', 'clean_doc'" ${BUILD_DOCS_DEFAULT})
option(BUILD_DOCS "Set to ON to define documentation targets: 'html', 'latexpdf', 'man', 'doxygen', 'doxygen_check_warnings', 'spelling', 'clean_doc'" ${BUILD_DOCS_DEFAULT})

if (BUILD_DOCS)
if (NOT UNIX)
Expand Down Expand Up @@ -59,6 +59,11 @@ if (BUILD_DOCS)
COMMAND ${MAKE_EXECUTABLE} man BUILDDIR=${DOC_BUILDDIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

add_custom_target(
spelling
COMMAND ${MAKE_EXECUTABLE} spelling BUILDDIR=${DOC_BUILDDIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

add_custom_target(
clean_doc
COMMAND ${MAKE_EXECUTABLE} clean BUILDDIR=${DOC_BUILDDIR}
Expand Down
9 changes: 6 additions & 3 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ generated_rst_files: $(BUILDDIR)/.doxygen_up_to_date

.PHONY: html latexpdf
html: generated_rst_files
$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
BUILDDIR="${BUILDDIR}" $(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
# Hack to hide the TOC
sed 's/<div class="toctree-wrapper compound">/<div class="toctree-wrapper compound" style="display: none;">/' < "$(BUILDDIR)/html/drivers/raster/index.html" > "$(BUILDDIR)/html/drivers/raster/index.html.mod"
mv "$(BUILDDIR)/html/drivers/raster/index.html.mod" "$(BUILDDIR)/html/drivers/raster/index.html"
Expand All @@ -89,10 +89,13 @@ html: generated_rst_files
cp -f "source/sponsors/Sustainable GDAL Sponsorship Prospectus.pdf" $(BUILDDIR)/html/sponsors

man: generated_rst_files
$(SPHINXBUILD) -M man "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
BUILDDIR="${BUILDDIR}" $(SPHINXBUILD) -M man "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

latexpdf: generated_rst_files
$(SPHINXBUILD) -M latexpdf "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
BUILDDIR="${BUILDDIR}" $(SPHINXBUILD) -M latexpdf "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

spelling: generated_rst_files
BUILDDIR="${BUILDDIR}" $(SPHINXBUILD) -b spelling "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

clean:
rm -rf "$(BUILDDIR)/xml"
Expand Down
14 changes: 13 additions & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"source_file",
"sphinx.ext.napoleon",
"sphinxcontrib.jquery",
"sphinxcontrib.spelling",
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -516,7 +517,11 @@
# -- Breathe -------------------------------------------------

# Setup the breathe extension
breathe_projects = {"api": "../build/xml"}

build_dir = os.environ.get("BUILDDIR", "../build")
if build_dir == "build":
build_dir = "../build"
breathe_projects = {"api": os.path.join(build_dir, "xml")}
breathe_default_project = "api"

# Tell sphinx what the primary language being documented is.
Expand All @@ -533,3 +538,10 @@
# -- Redirects --------------------------------------------------

enable_redirects = False

# -- Spelling --------------------------------------------------

# Avoid running git
spelling_ignore_contributor_names = False

spelling_word_list_filename = ["spelling_wordlist.txt"]
5 changes: 5 additions & 0 deletions doc/source/development/dev_documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ The following targets are available:
verifies that there are no Doxygen warnings.
Requires Doxygen >= 1.9.3 to be warning free.

* ``spelling``: runs spell checking on the documentation, covering as well as
documentation generated from C/C++ API (Doxygen) and Python API. Words unknown
to the spell checker but still considered valid should be added to the allow
list in :file:`doc/source/spelling_wordlist.txt`

* ``clean``: clean the ``doc/build`` directory.

It is also possible to run those targets as CMake targets. In that case, the
Expand Down
2 changes: 1 addition & 1 deletion doc/source/development/rfc/rfc19_safememalloc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ scanlines, whole image buffers, etc.. Currently no overflow checking is
done, thus leading to potential allocation of not large enough buffers.
Overflow can occur when raster dimensions are very large (this can be
the case with a WMS raster source for example) or when a dataset is
corrupted, intentionnaly or unintentionnaly. This can lead to latter
corrupted, intentionally or unintentionally. This can lead to latter
crash.

This RFC introduces new API to allocate memory when the computation of
Expand Down
2 changes: 1 addition & 1 deletion doc/source/development/rfc/rfc39_ogr_layer_algebra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ for commonly needed overlay analysis methods.
The basic functionality for spatial analysis with GDAL is provided by
GEOS. However, GEOS operates on geometries and typically people work
with geospatial data layers. Vector data layers are represented in GDAL
by OGRLayer objects. Thus, there is a need for spatial analaysis
by OGRLayer objects. Thus, there is a need for spatial analysis
operations that work on layers.

Unfortunately there is no standard for spatial analysis operations API,
Expand Down
Loading

0 comments on commit 59bef2e

Please sign in to comment.