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 #142

Merged
merged 21 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4dc6363
VRT: avoid artifacts on source boundaries when the VRT has an alpha o…
rouault Jan 6, 2025
d7d1f8b
GRIB: apply a heuristics to auto-fix wrong registration of latitudeOf…
rouault Jan 7, 2025
fadf31f
Add a OGRGeometryFactory::GetDefaultArcStepSize() method to get value…
rouault Jan 8, 2025
ad15a8e
Add CPLErrorOnce() and CPLDebugOnce()
rouault Jan 8, 2025
d80db05
Add GDALExpandPackedBitsToByteAt0Or255() and GDALExpandPackedBitsToBy…
rouault Jan 8, 2025
4b1e872
GTiff: use GDALExpandPackedBitsToByteAt0Or255() and GDALExpandPackedB…
rouault Jan 8, 2025
4bb4f4c
LIBERTIFF: use GDALExpandPackedBitsToByteAt0Or255() and GDALExpandPac…
rouault Jan 8, 2025
60adea2
SWIG: stricter type use
rouault Jan 8, 2025
6465523
explicitly set CMAKE_CXX_SCAN_FOR_MODULES=0
hobu Jan 8, 2025
b5389d2
Add a gdal_fwd.h public header with forward definitions of GDAL/OGR/O…
rouault Jan 8, 2025
29ba8b7
Add a data/gdal_algorithm.schema.json to validate 'gdal [command] [su…
rouault Jan 9, 2025
fb37e01
CPLErrorOnce()/CPLDebugOnce(): append a 'Further messages of this typ…
rouault Jan 9, 2025
d4c58d2
Merge pull request #11585 from rouault/fix_11583
rouault Jan 9, 2025
3358a9d
Merge pull request #11595 from rouault/grib2_japan_wrong_lcc
rouault Jan 9, 2025
39cbe84
Merge pull request #11605 from rouault/GetDefaultArcStepSize
rouault Jan 9, 2025
6713bba
Merge pull request #11606 from rouault/CPLErrorOnce
rouault Jan 9, 2025
4487cb9
Merge pull request #11612 from rouault/GDALExpandPackedBitsToByteAt0O…
rouault Jan 9, 2025
3d48504
Merge pull request #11613 from rouault/fix_11611
rouault Jan 9, 2025
3aacd02
Merge pull request #11615 from hobu/scandeps
rouault Jan 9, 2025
9bef0dc
Merge pull request #11616 from rouault/gdal_algorithm_schema
rouault Jan 9, 2025
697111e
Doc: vrt.rst: fix pansharpened XML example
rouault Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/alpine/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,12 @@ else
echo "DeclareDeferredFOO() has NOT been run"
exit 1
fi

#
echo "Validating gdal --json-usage output"
apps/gdal --json-usage > out.json
export PYTHON_CMD=python3
$PYTHON_CMD -m venv myvenv
source myvenv/bin/activate
$PYTHON_CMD -m pip install -U check-jsonschema
check-jsonschema --schemafile data/gdal_algorithm.schema.json out.json
7 changes: 1 addition & 6 deletions alg/gdalwarpkernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1240,13 +1240,8 @@ CPLErr GDALWarpKernel::PerformWarp()
if (pafUnifiedSrcDensity != nullptr)
{
// Typically if there's a cutline or an alpha band
static bool bHasWarned = false;
if (!bHasWarned)
{
bHasWarned = true;
CPLDebug("WARP", "pafUnifiedSrcDensity is not null, "
CPLDebugOnce("WARP", "pafUnifiedSrcDensity is not null, "
"hence OpenCL warper cannot be used");
}
}
else
{
Expand Down
1 change: 1 addition & 0 deletions apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ if (BUILD_APPS)
endif ()

set(GDAL_DATA_FILES
${CMAKE_CURRENT_SOURCE_DIR}/data/gdal_algorithm.schema.json
${CMAKE_CURRENT_SOURCE_DIR}/data/gdalinfo_output.schema.json
${CMAKE_CURRENT_SOURCE_DIR}/data/gdalmdiminfo_output.schema.json
${CMAKE_CURRENT_SOURCE_DIR}/data/ogrinfo_output.schema.json
Expand Down
198 changes: 198 additions & 0 deletions apps/data/gdal_algorithm.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
{
"$id": "https://gdal.org/gdal_algorithm.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Validate the output of the 'gdal [command] [subcommand] --json-usage'",

"oneOf": [
{
"$ref": "#/definitions/algorithm"
}
],

"definitions": {

"algorithm": {
"type": "object",
"properties": {
"name": {
"type": "string",
"$comment": "Algorithm name. Normally always set, except for the top 'gdal' algorithm"
},
"full_path": {
"type": "array",
"items": {
"type": "string"
},
"$comment": "Full path to get to this algorithm. For example, for 'gdal raster info', this will be [\"gdal\", \"raster\", \"info\"]"
},
"description": {
"type": "string",
"$comment": "One sentence description of the algorithm"
},
"short_url": {
"type": "string",
"$comment": "URL to the help page, without the server. For example \"/programs/gdal_raster_info.html\""
},
"url": {
"type": "string",
"$comment": "Full URL to the help page. For example \"https://gdal.org/programs/gdal_raster_info.html\""
},
"sub_algorithms": {
"type": "array",
"items": {
"$ref": "#/definitions/algorithm"
},
"$comment": "Names of the immediate sub-algorithm of this algorithm. For example, or 'gdal raster', this will be [\"info\", \"convert\", ...]"
},
"input_arguments": {
"type": "array",
"items": {
"$ref": "#/definitions/argument"
},
"$comment": "Input arguments of the algorithm"
},
"output_arguments": {
"type": "array",
"items": {
"$ref": "#/definitions/argument"
},
"$comment": "Output arguments of the algorithm, that is arguments that are set by the algorithm (typically an output dataset)"
},
"input_output_arguments": {
"type": "array",
"items": {
"$ref": "#/definitions/argument"
},
"$comment": "Arguments of the algorithm that are both read and written by it."
},
"pipeline_algorithms": {
"type": "array",
"items": {
"$ref": "#/definitions/algorithm"
},
"$comment": "For pipeline algorithm, description of the accepted step algorithms. Only present for such pipeline algorithms"
}
},
"required": [
"description",
"short_url",
"url",
"sub_algorithms",
"input_arguments",
"output_arguments",
"input_output_arguments"
],
"additionalProperties": false
},

"argument": {
"type": "object",
"properties": {
"name": {
"type": "string",
"$comment": "Argument name"
},
"type": {
"enum": [
"boolean",
"integer",
"real",
"string",
"dataset",
"integer_list",
"real_list",
"string_list",
"dataset_list"
],
"$comment": "Argument type"
},
"description": {
"type": "string",
"$comment": "Argument description"
},
"choices": {
"type": "array",
"items": {
"type": "string"
},
"$comment": "Valid values for the argument, when it accepts an enumeration as a value"
},
"default": {
"$comment": "Default value (optional)"
},
"required": {
"type": "boolean",
"$comment": "Whether this argument is required"
},
"packed_values_allowed": {
"type": "boolean",
"$comment": "For command-line specification, for multi-valued arguments (type: integer_list, real_list, string_list), whether comma-separated values are accepted. e.g. '--my-arg=first,second'"
},
"repeated_arg_allowed": {
"type": "boolean",
"$comment": "For command-line specification, for multi-valued arguments (type: integer_list, real_list, string_list), whether several repetition of the argument are accepted. e.g. '--my-arg first --my-arg second'"
},
"min_count": {
"type": "integer",
"$comment": "For multi-valued arguments (type: integer_list, real_list, string_list, dataset_list), minimum number of values"
},
"max_count": {
"type": "integer",
"$comment": "For multi-valued arguments (type: integer_list, real_list, string_list, dataset_list), maximum number of values"
},
"category": {
"type": "string",
"$comment": "Category of the argument. Common categories include \"Base\", \"Advanced\", \"Esoteric\", but algorithms may define their own categories."
},
"mutual_exclusion_group": {
"type": "string",
"$comment": "Identifier shared by several arguments to mean they are mutually exclusive."
},
"metadata": {
"type": "object",
"$comment": "Object whose keys are metadata item names. This is typically used for type=dataset arguments. e.g. \"metadata\":{ \"required_capabilities\":[ \"DCAP_RASTER\", \"DCAP_CREATECOPY\" ] }"
},
"dataset_type": {
"type": "array",
"items": {
"enum": [
"raster",
"vector",
"multidim_raster"
]
},
"$comment": "Type of accepted datasets. Only used for type=dataset or type=dataset_list."
},
"input_flags": {
"type": "array",
"items": {
"enum": [
"name",
"dataset"
]
},
"$comment": "Which fields of a dataset argument may be set, by the user, when the argument is dealt as an input dataset. Only used for type=dataset or type=dataset_list."
},
"output_flags": {
"type": "array",
"items": {
"enum": [
"name",
"dataset"
]
},
"$comment": "Which fields of a dataset argument may be set, by the algorithm, when the argument is dealt as an output dataset. Only used for type=dataset or type=dataset_list."
}
},
"required": [
"name",
"type",
"description",
"required",
"category"
],
"additionalProperties": false
}

}
}
5 changes: 1 addition & 4 deletions apps/ogr2ogr_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5987,12 +5987,9 @@ SetupCT(TargetLayerInfo *psInfo, OGRLayer *poSrcLayer, bool bTransform,
}
else
{
static bool bHasWarned = false;
if (!bHasWarned)
CPLError(CE_Failure, CPLE_IllegalArg,
CPLErrorOnce(CE_Failure, CPLE_IllegalArg,
"-wrapdateline option only works when "
"reprojecting to a geographic SRS");
bHasWarned = true;
}

psInfo->m_aoReprojectionInfo[iGeom].m_aosTransformOptions.Assign(
Expand Down
68 changes: 68 additions & 0 deletions autotest/cpp/test_gdal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5124,4 +5124,72 @@ TEST_F(test_gdal, GDALTranspose2D_Byte_optims)
}
}

TEST_F(test_gdal, GDALExpandPackedBitsToByteAt0Or1)
{
unsigned next = 1;
const auto badRand = [&next]()
{
next = static_cast<unsigned>(static_cast<uint64_t>(next) * 1103515245 +
12345);
return next;
};

constexpr int BITS_PER_BYTE = 8;
constexpr int SSE_REGISTER_SIZE_IN_BYTES = 16;
constexpr int LESS_THAN_8BITS = 5;
std::vector<GByte> expectedOut(SSE_REGISTER_SIZE_IN_BYTES * BITS_PER_BYTE +
BITS_PER_BYTE + LESS_THAN_8BITS);
std::vector<GByte> in((expectedOut.size() + BITS_PER_BYTE - 1) /
BITS_PER_BYTE);
for (int i = 0; i < static_cast<int>(expectedOut.size()); ++i)
{
expectedOut[i] = (badRand() % 2) == 0 ? 0 : 1;
if (expectedOut[i])
{
in[i / BITS_PER_BYTE] = static_cast<GByte>(
in[i / BITS_PER_BYTE] |
(1 << (BITS_PER_BYTE - 1 - (i % BITS_PER_BYTE))));
}
}

std::vector<GByte> out(expectedOut.size());
GDALExpandPackedBitsToByteAt0Or1(in.data(), out.data(), out.size());

EXPECT_EQ(out, expectedOut);
}

TEST_F(test_gdal, GDALExpandPackedBitsToByteAt0Or255)
{
unsigned next = 1;
const auto badRand = [&next]()
{
next = static_cast<unsigned>(static_cast<uint64_t>(next) * 1103515245 +
12345);
return next;
};

constexpr int BITS_PER_BYTE = 8;
constexpr int SSE_REGISTER_SIZE_IN_BYTES = 16;
constexpr int LESS_THAN_8BITS = 5;
std::vector<GByte> expectedOut(SSE_REGISTER_SIZE_IN_BYTES * BITS_PER_BYTE +
BITS_PER_BYTE + LESS_THAN_8BITS);
std::vector<GByte> in((expectedOut.size() + BITS_PER_BYTE - 1) /
BITS_PER_BYTE);
for (int i = 0; i < static_cast<int>(expectedOut.size()); ++i)
{
expectedOut[i] = (badRand() % 2) == 0 ? 0 : 255;
if (expectedOut[i])
{
in[i / BITS_PER_BYTE] = static_cast<GByte>(
in[i / BITS_PER_BYTE] |
(1 << (BITS_PER_BYTE - 1 - (i % BITS_PER_BYTE))));
}
}

std::vector<GByte> out(expectedOut.size());
GDALExpandPackedBitsToByteAt0Or255(in.data(), out.data(), out.size());

EXPECT_EQ(out, expectedOut);
}

} // namespace
27 changes: 27 additions & 0 deletions autotest/cpp/test_ogr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4571,4 +4571,31 @@ TEST_F(test_ogr, OGRFieldDefnGetFieldTypeByName)
}
}

// Test OGRGeometryFactory::GetDefaultArcStepSize()
TEST_F(test_ogr, GetDefaultArcStepSize)
{
if (CPLGetConfigOption("OGR_ARC_STEPSIZE", nullptr) == nullptr)
{
EXPECT_EQ(OGRGeometryFactory::GetDefaultArcStepSize(), 4.0);
}
{
CPLConfigOptionSetter oSetter("OGR_ARC_STEPSIZE", "0.00001",
/* bSetOnlyIfUndefined = */ false);
CPLErrorHandlerPusher oErrorHandler(CPLQuietErrorHandler);
EXPECT_EQ(OGRGeometryFactory::GetDefaultArcStepSize(), 1e-2);
EXPECT_TRUE(
strstr(CPLGetLastErrorMsg(),
"Too small value for OGR_ARC_STEPSIZE. Clamping it to"));
}
{
CPLConfigOptionSetter oSetter("OGR_ARC_STEPSIZE", "190",
/* bSetOnlyIfUndefined = */ false);
CPLErrorHandlerPusher oErrorHandler(CPLQuietErrorHandler);
EXPECT_EQ(OGRGeometryFactory::GetDefaultArcStepSize(), 180);
EXPECT_TRUE(
strstr(CPLGetLastErrorMsg(),
"Too large value for OGR_ARC_STEPSIZE. Clamping it to"));
}
}

} // namespace
Loading
Loading