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 Jul 10, 2024
2 parents 5b641ea + 064ce89 commit c87b3a5
Show file tree
Hide file tree
Showing 178 changed files with 4,624 additions and 2,188 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ubuntu_20.04/Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ RUN apt-get update -y \
libfreexl-dev \
libfyba-dev \
libgeos-dev \
libgeotiff-dev \
libgif-dev \
libhdf4-alt-dev \
libhdf5-serial-dev \
Expand Down Expand Up @@ -75,7 +76,7 @@ RUN apt-get update -y \
numactl \
ocl-icd-opencl-dev \
opencl-c-headers \
openjdk-8-jdk \
openjdk-8-jdk-headless \
pkg-config \
python3-dev \
python3-numpy \
Expand Down
32 changes: 26 additions & 6 deletions .github/workflows/ubuntu_20.04/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ set -eu
export CXXFLAGS="-march=native -O2 -Wodr -flto-odr-type-merging -Werror"
export CFLAGS="-O2 -march=native -Werror"

cmake ${GDAL_SOURCE_DIR:=..} \
cmake "${GDAL_SOURCE_DIR:=..}" \
-DUSE_CCACHE=ON \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
-DCMAKE_INSTALL_PREFIX=/usr \
-DGDAL_USE_TIFF_INTERNAL=ON \
-DGDAL_USE_GEOTIFF_INTERNAL=ON \
-DCMAKE_INSTALL_PREFIX=/tmp/install-gdal \
-DGDAL_USE_TIFF_INTERNAL=OFF \
-DGDAL_USE_GEOTIFF_INTERNAL=OFF \
-DECW_ROOT=/opt/libecwj2-3.3 \
-DMRSID_ROOT=/usr/local \
-DFileGDB_ROOT=/usr/local/FileGDB_API \
Expand All @@ -20,5 +20,25 @@ cmake ${GDAL_SOURCE_DIR:=..} \
unset CXXFLAGS
unset CFLAGS

make -j$(nproc)
make -j$(nproc) install DESTDIR=/tmp/install-gdal
make "-j$(nproc)"
make "-j$(nproc)" install

# Test building MrSID driver in standalone mode
mkdir build_mrsid
cd build_mrsid
cmake -S ${GDAL_SOURCE_DIR:=..}/frmts/mrsid -DMRSID_ROOT=/usr/local -DCMAKE_PREFIX_PATH=/tmp/install-gdal
cmake --build . "-j$(nproc)"
test -f gdal_MrSID.so
cd ..

# Test building OCI driver in standalone mode
mkdir build_oci
cd build_oci
wget https://download.oracle.com/otn_software/linux/instantclient/1923000/instantclient-basic-linux.x64-19.23.0.0.0dbru.zip
wget https://download.oracle.com/otn_software/linux/instantclient/1923000/instantclient-sdk-linux.x64-19.23.0.0.0dbru.zip
unzip -o instantclient-basic-linux.x64-19.23.0.0.0dbru.zip
unzip -o instantclient-sdk-linux.x64-19.23.0.0.0dbru.zip
cmake -S "${GDAL_SOURCE_DIR:=..}/ogr/ogrsf_frmts/oci" "-DOracle_ROOT=$PWD/instantclient_19_23" -DCMAKE_PREFIX_PATH=/tmp/install-gdal
cmake --build . "-j$(nproc)"
test -f ogr_OCI.so
cd ..
4 changes: 2 additions & 2 deletions .github/workflows/ubuntu_22.04/Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ RUN apt-get update && \
locales \
mysql-client-core-8.0 \
netcdf-bin \
openjdk-8-jdk \
openjdk-8-jdk-headless \
poppler-utils \
postgis \
postgresql-client \
Expand Down Expand Up @@ -104,7 +104,7 @@ RUN mkdir mongocxx \
&& make install \
&& cd ../.. \
&& rm -rf mongocxx

# Build libOpenDRIVE
ARG OPENDRIVE_VERSION=0.5.0-gdal
RUN if test "${OPENDRIVE_VERSION}" != ""; then ( \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu_24.04/Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ RUN apt-get update && \
locales \
mysql-client-core-8.0 \
netcdf-bin \
openjdk-8-jdk \
openjdk-8-jdk-headless \
poppler-utils \
postgis \
postgresql-client \
Expand Down
18 changes: 1 addition & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,8 @@ define_property(
PROPERTY PLUGIN_OUTPUT_DIR
BRIEF_DOCS "Plugin modules build directories"
FULL_DOCS "Plugin modules build directories")
#
# check compiler and set preferences.
if (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

if (NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
endif()

#
if (MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(-DNOMINMAX)
endif ()
#
include(GdalCAndCXXStandards)
include(CheckCompilerMachineOption)
include(CheckCompilerSIMDFeature)
include(Ccache)
Expand Down
1 change: 1 addition & 0 deletions alg/gdalchecksum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,5 +368,6 @@ int CPL_STDCALL GDALChecksumImage(GDALRasterBandH hBand, int nXOff, int nYOff,
CPLFree(panLineData);
}

// coverity[return_overflow]
return nChecksum;
}
96 changes: 61 additions & 35 deletions alg/viewshed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,19 +282,9 @@ bool Viewshed::calcOutputExtent(int nX, int nY)
oOutExtent.xStop = GDALGetRasterBandXSize(pSrcBand);
oOutExtent.yStop = GDALGetRasterBandYSize(pSrcBand);

if (!oOutExtent.containsY(nY))
{
CPLError(CE_Failure, CPLE_AppDefined,
"Observer position above or below the raster "
"not currently supported");
return false;
}
if (!oOutExtent.contains(nX, nY))
{
CPLError(CE_Warning, CPLE_AppDefined,
"NOTE: The observer location falls outside of the DEM area");
//ABELL - Make sure observer Z is specified.
}

constexpr double EPSILON = 1e-8;
if (oOpts.maxDistance > 0)
Expand Down Expand Up @@ -419,7 +409,8 @@ bool Viewshed::emitProgress(double fraction)
/// @param nX X location of the observer.
/// @param vThisLineVal Line height data.
/// @return [left, right) Leftmost and one past the rightmost cell in the line within
/// the max distance
/// the max distance. Indices are limited to the raster extent (right may be just
/// outside the raster).
std::pair<int, int> Viewshed::adjustHeight(int nYOffset, int nX,
std::vector<double> &vThisLineVal)
{
Expand Down Expand Up @@ -799,15 +790,15 @@ void Viewshed::setOutput(double &dfResult, double &dfCellVal, double dfZ)
///
/// @param nX X location of the observer
/// @param nY Y location of the observer
/// @param nLine Line number being processed (should always be the same as nY)
/// @param vLastLineVal Vector in which to store the read line. Becomes the last line
/// in further processing.
/// @return True on success, false otherwise.
bool Viewshed::processFirstLine(int nX, int nY, int nLine,
bool Viewshed::processFirstLine(int nX, int nY,
std::vector<double> &vLastLineVal)
{
int nLine = oOutExtent.clampY(nY);
int nYOffset = nLine - nY;
assert(nYOffset == 0);

std::vector<double> vResult(oOutExtent.xSize());
std::vector<double> vThisLineVal(oOutExtent.xSize());

Expand All @@ -832,28 +823,61 @@ bool Viewshed::processFirstLine(int nX, int nY, int nLine,
// iLeft and iRight are the processing limits for the line.
const auto [iLeft, iRight] = adjustHeight(nYOffset, nX, vThisLineVal);

auto t1 = std::async(
std::launch::async, [&, left = iLeft]()
{ processFirstLineLeft(nX, nX - 1, left - 1, vResult, vThisLineVal); });

auto t2 = std::async(
std::launch::async, [&, right = iRight]()
{ processFirstLineRight(nX, nX + 1, right, vResult, vThisLineVal); });
t1.wait();
t2.wait();
if (!oCurExtent.containsY(nY))
processFirstLineTopOrBottom(iLeft, iRight, vResult, vThisLineVal);
else
{
auto t1 = std::async(std::launch::async,
[&, left = iLeft]() {
processFirstLineLeft(nX, nX - 1, left - 1,
vResult, vThisLineVal);
});

auto t2 = std::async(std::launch::async,
[&, right = iRight]() {
processFirstLineRight(nX, nX + 1, right,
vResult, vThisLineVal);
});
t1.wait();
t2.wait();
}

// Make the current line the last line.
vLastLineVal = std::move(vThisLineVal);

// Create the output writer.
if (!writeLine(nY, vResult))
if (!writeLine(nLine, vResult))
return false;

if (!lineProgress())
return false;
return true;
}

// If the observer is above or below the raster, set all cells in the first line near the
// observer as observable provided they're in range. Mark cells out of range as such.
/// @param iLeft Leftmost observable raster position in range of the target line.
/// @param iRight One past the rightmost observable raster position of the target line.
/// @param vResult Result line.
/// @param vThisLineVal Heights of the cells in the target line
void Viewshed::processFirstLineTopOrBottom(int iLeft, int iRight,
std::vector<double> &vResult,
std::vector<double> &vThisLineVal)
{
double *pResult = vResult.data() + iLeft;
double *pThis = vThisLineVal.data() + iLeft;
for (int iPixel = iLeft; iPixel < iRight; ++iPixel, ++pResult, pThis++)
{
if (oOpts.outputMode == OutputMode::Normal)
*pResult = oOpts.visibleVal;
else
setOutput(*pResult, *pThis, *pThis);
}
std::fill(vResult.begin(), vResult.begin() + iLeft, oOpts.outOfRangeVal);
std::fill(vResult.begin() + iRight, vResult.begin() + oCurExtent.xStop,
oOpts.outOfRangeVal);
}

/// Process a line above or below the observer.
///
/// @param nX X location of the observer
Expand Down Expand Up @@ -989,7 +1013,7 @@ bool Viewshed::run(GDALRasterBandH band, GDALProgressFunc pfnProgress,

std::vector<double> vFirstLineVal(oCurExtent.xSize());

if (!processFirstLine(nX, nY, nY, vFirstLineVal))
if (!processFirstLine(nX, nY, vFirstLineVal))
return false;

if (oOpts.cellMode == CellMode::Edge)
Expand All @@ -1002,29 +1026,31 @@ bool Viewshed::run(GDALRasterBandH band, GDALProgressFunc pfnProgress,
oZcalc = doMax;

// scan upwards
int yStart = oCurExtent.clampY(nY);
std::atomic<bool> err(false);
auto tUp = std::async(std::launch::async,
[&]()
{
std::vector<double> vLastLineVal = vFirstLineVal;

for (int nLine = nY - 1;
for (int nLine = yStart - 1;
nLine >= oCurExtent.yStart && !err; nLine--)
if (!processLine(nX, nY, nLine, vLastLineVal))
err = true;
});

// scan downwards
auto tDown = std::async(
std::launch::async,
[&]()
{
std::vector<double> vLastLineVal = vFirstLineVal;
auto tDown =
std::async(std::launch::async,
[&]()
{
std::vector<double> vLastLineVal = vFirstLineVal;

for (int nLine = nY + 1; nLine < oCurExtent.yStop && !err; nLine++)
if (!processLine(nX, nY, nLine, vLastLineVal))
err = true;
});
for (int nLine = yStart + 1;
nLine < oCurExtent.yStop && !err; nLine++)
if (!processLine(nX, nY, nLine, vLastLineVal))
err = true;
});

tUp.wait();
tDown.wait();
Expand Down
14 changes: 12 additions & 2 deletions alg/viewshed.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ class Viewshed
return xSize() ? std::clamp(nX, xStart, xStop - 1) : xStart;
}

/// \brief Clamp the argument to be in the window in the Y dimension.
/// \param nY Value to clamp.
/// \return Clamped value.
int clampY(int nY) const
{
return ySize() ? std::clamp(nY, yStart, yStop - 1) : yStart;
}

/// \brief Shift the X dimension by nShift.
/// \param nShift Amount to shift
void shiftX(int nShift)
Expand Down Expand Up @@ -225,14 +233,16 @@ class Viewshed
bool writeLine(int nLine, std::vector<double> &vResult);
bool processLine(int nX, int nY, int nLine,
std::vector<double> &vLastLineVal);
bool processFirstLine(int nX, int nY, int nLine,
std::vector<double> &vLastLineVal);
bool processFirstLine(int nX, int nY, std::vector<double> &vLastLineVal);
void processFirstLineLeft(int nX, int iStart, int iEnd,
std::vector<double> &vResult,
std::vector<double> &vThisLineVal);
void processFirstLineRight(int nX, int iStart, int iEnd,
std::vector<double> &vResult,
std::vector<double> &vThisLineVal);
void processFirstLineTopOrBottom(int iLeft, int iRight,
std::vector<double> &vResult,
std::vector<double> &vThisLineVal);
void processLineLeft(int nX, int nYOffset, int iStart, int iEnd,
std::vector<double> &vResult,
std::vector<double> &vThisLineVal,
Expand Down
4 changes: 4 additions & 0 deletions apps/argparse/argparse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,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 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

0 comments on commit c87b3a5

Please sign in to comment.