Skip to content

Commit

Permalink
Rework code a bit to avoid false positive CSA warnings in C++17 mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Jan 3, 2025
1 parent d93fc9a commit 853bef7
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 72 deletions.
19 changes: 12 additions & 7 deletions src/iso19111/coordinates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,18 @@ CoordinateMetadataNNPtr
CoordinateMetadata::promoteTo3D(const std::string &newName,
const io::DatabaseContextPtr &dbContext) const {
auto crs = d->crs_->promoteTo3D(newName, dbContext);
auto coordinateMetadata(
d->coordinateEpoch_.has_value()
? CoordinateMetadata::nn_make_shared<CoordinateMetadata>(
crs, coordinateEpochAsDecimalYear())
: CoordinateMetadata::nn_make_shared<CoordinateMetadata>(crs));
coordinateMetadata->assignSelf(coordinateMetadata);
return coordinateMetadata;
if (d->coordinateEpoch_.has_value()) {
auto coordinateMetadata(
CoordinateMetadata::nn_make_shared<CoordinateMetadata>(
crs, coordinateEpochAsDecimalYear()));
coordinateMetadata->assignSelf(coordinateMetadata);
return coordinateMetadata;
} else {
auto coordinateMetadata(
CoordinateMetadata::nn_make_shared<CoordinateMetadata>(crs));
coordinateMetadata->assignSelf(coordinateMetadata);
return coordinateMetadata;
}
}

// ---------------------------------------------------------------------------
Expand Down
18 changes: 11 additions & 7 deletions src/iso19111/datum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -818,13 +818,17 @@ EllipsoidNNPtr Ellipsoid::createSphere(const util::PropertyMap &properties,
EllipsoidNNPtr Ellipsoid::createFlattenedSphere(
const util::PropertyMap &properties, const common::Length &semiMajorAxisIn,
const common::Scale &invFlattening, const std::string &celestialBody) {
auto ellipsoid(invFlattening.value() == 0
? Ellipsoid::nn_make_shared<Ellipsoid>(semiMajorAxisIn,
celestialBody)
: Ellipsoid::nn_make_shared<Ellipsoid>(
semiMajorAxisIn, invFlattening, celestialBody));
ellipsoid->setProperties(properties);
return ellipsoid;
if (invFlattening.value() == 0) {
auto ellipsoid(Ellipsoid::nn_make_shared<Ellipsoid>(semiMajorAxisIn,
celestialBody));
ellipsoid->setProperties(properties);
return ellipsoid;
} else {
auto ellipsoid(Ellipsoid::nn_make_shared<Ellipsoid>(
semiMajorAxisIn, invFlattening, celestialBody));
ellipsoid->setProperties(properties);
return ellipsoid;
}
}

// ---------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/iso19111/factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3114,9 +3114,9 @@ std::string
DatabaseContext::suggestsCodeFor(const common::IdentifiedObjectNNPtr &object,
const std::string &authName,
bool numericCode) {
const char *tableName = "";
const char *tableName = "prime_meridian";
if (dynamic_cast<const datum::PrimeMeridian *>(object.get())) {
tableName = "prime_meridian";
// tableName = "prime_meridian";
} else if (dynamic_cast<const datum::Ellipsoid *>(object.get())) {
tableName = "ellipsoid";
} else if (dynamic_cast<const datum::GeodeticReferenceFrame *>(
Expand Down
4 changes: 2 additions & 2 deletions src/iso19111/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2832,9 +2832,9 @@ WKTParser::Private::buildCS(const WKTNodeNNPtr &node, /* maybe null */
children[1]->GP()->value()));
}
} else {
const char *csTypeCStr = "";
const char *csTypeCStr = CartesianCS::WKT2_TYPE;
if (ci_equal(parentNodeName, WKTConstants::GEOCCS)) {
csTypeCStr = CartesianCS::WKT2_TYPE;
// csTypeCStr = CartesianCS::WKT2_TYPE;
isGeocentric = true;
if (axisCount == 0) {
auto unit =
Expand Down
101 changes: 47 additions & 54 deletions src/iso19111/operation/singleoperation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "operationmethod_private.hpp"
#include "oputils.hpp"
#include "parammappings.hpp"
#include "vectorofvaluesparams.hpp"

// PROJ include order is sensitive
// clang-format off
Expand Down Expand Up @@ -2285,18 +2286,13 @@ createNTv1(const util::PropertyMap &properties,
const crs::CRSNNPtr &sourceCRSIn, const crs::CRSNNPtr &targetCRSIn,
const std::string &filename,
const std::vector<metadata::PositionalAccuracyNNPtr> &accuracies) {
const VectorOfParameters parameters{OperationParameter::create(
createOpParamNameEPSGCode(EPSG_CODE_PARAMETER_LATITUDE_LONGITUDE_DIFFERENCE_FILE)};
const VectorOfValues values{ParameterValue::createFilename(filename)};
return Transformation::create(
properties, sourceCRSIn, targetCRSIn, nullptr,
createMethodMapNameEPSGCode(EPSG_CODE_METHOD_NTV1),
{OperationParameter::create(
util::PropertyMap()
.set(common::IdentifiedObject::NAME_KEY,
EPSG_NAME_PARAMETER_LATITUDE_LONGITUDE_DIFFERENCE_FILE)
.set(metadata::Identifier::CODESPACE_KEY,
metadata::Identifier::EPSG)
.set(metadata::Identifier::CODE_KEY,
EPSG_CODE_PARAMETER_LATITUDE_LONGITUDE_DIFFERENCE_FILE))},
{ParameterValue::createFilename(filename)}, accuracies);
createMethodMapNameEPSGCode(EPSG_CODE_METHOD_NTV1), parameters, values,
accuracies);
}
//! @endcond

Expand Down Expand Up @@ -2417,7 +2413,7 @@ TransformationNNPtr SingleOperation::substitutePROJAlternativeGridNames(
auto l_targetCRS = NN_NO_CHECK(l_targetCRSNull);
const auto &l_accuracies = coordinateOperationAccuracies();
if (projGridFormat == "GTiff") {
auto parameters = std::vector<OperationParameterNNPtr>{
const VectorOfParameters parameters{
methodEPSGCode == EPSG_CODE_METHOD_NADCON5_3D
? OperationParameter::create(util::PropertyMap().set(
common::IdentifiedObject::NAME_KEY,
Expand All @@ -2430,7 +2426,7 @@ TransformationNNPtr SingleOperation::substitutePROJAlternativeGridNames(
methodEPSGCode == EPSG_CODE_METHOD_NADCON5_3D)
? PROJ_WKT2_NAME_METHOD_GENERAL_SHIFT_GTIFF
: PROJ_WKT2_NAME_METHOD_HORIZONTAL_SHIFT_GTIFF);
auto values = std::vector<ParameterValueNNPtr>{
const VectorOfValues values{
ParameterValue::createFilename(projFilename)};
if (inverseDirection) {
return Transformation::create(
Expand Down Expand Up @@ -2471,13 +2467,12 @@ TransformationNNPtr SingleOperation::substitutePROJAlternativeGridNames(
l_targetCRS, projFilename, l_accuracies);
}
} else if (projGridFormat == "CTable2") {
auto parameters =
std::vector<OperationParameterNNPtr>{createOpParamNameEPSGCode(
EPSG_CODE_PARAMETER_LATITUDE_LONGITUDE_DIFFERENCE_FILE)};
const VectorOfParameters parameters{createOpParamNameEPSGCode(
EPSG_CODE_PARAMETER_LATITUDE_LONGITUDE_DIFFERENCE_FILE)};
auto methodProperties =
util::PropertyMap().set(common::IdentifiedObject::NAME_KEY,
PROJ_WKT2_NAME_METHOD_CTABLE2);
auto values = std::vector<ParameterValueNNPtr>{
const VectorOfValues values{
ParameterValue::createFilename(projFilename)};
if (inverseDirection) {
return Transformation::create(
Expand Down Expand Up @@ -2528,18 +2523,18 @@ TransformationNNPtr SingleOperation::substitutePROJAlternativeGridNames(
}
auto l_sourceCRS = NN_NO_CHECK(l_sourceCRSNull);
auto l_targetCRS = NN_NO_CHECK(l_targetCRSNull);
auto parameters = std::vector<OperationParameterNNPtr>{
createOpParamNameEPSGCode(
EPSG_CODE_PARAMETER_GEOID_CORRECTION_FILENAME)};
const VectorOfParameters parameters{createOpParamNameEPSGCode(
EPSG_CODE_PARAMETER_GEOID_CORRECTION_FILENAME)};
const VectorOfValues values{
ParameterValue::createFilename(projFilename)};
#ifdef disabled_for_now
if (inverseDirection) {
return Transformation::create(
createPropertiesForInverse(
self.as_nullable().get(), true, false),
l_targetCRS, l_sourceCRS, l_interpolationCRS,
createSimilarPropertiesMethod(method()),
parameters,
{ParameterValue::createFilename(projFilename)},
parameters, values,
coordinateOperationAccuracies())
->inverseAsTransformation();
} else
Expand All @@ -2549,8 +2544,7 @@ TransformationNNPtr SingleOperation::substitutePROJAlternativeGridNames(
createSimilarPropertiesOperation(self), l_sourceCRS,
l_targetCRS, l_interpolationCRS,
createSimilarPropertiesMethod(method()), parameters,
{ParameterValue::createFilename(projFilename)},
coordinateOperationAccuracies());
values, coordinateOperationAccuracies());
}
}
}
Expand Down Expand Up @@ -2583,14 +2577,14 @@ TransformationNNPtr SingleOperation::substitutePROJAlternativeGridNames(
}
auto l_sourceCRS = NN_NO_CHECK(l_sourceCRSNull);
auto l_targetCRS = NN_NO_CHECK(l_targetCRSNull);
auto parameters =
std::vector<OperationParameterNNPtr>{createOpParamNameEPSGCode(
EPSG_CODE_PARAMETER_GEOCENTRIC_TRANSLATION_FILE)};
const VectorOfParameters parameters{createOpParamNameEPSGCode(
EPSG_CODE_PARAMETER_GEOCENTRIC_TRANSLATION_FILE)};
const VectorOfValues values{
ParameterValue::createFilename(projFilename)};
return Transformation::create(
createSimilarPropertiesOperation(self), l_sourceCRS,
l_targetCRS, l_interpolationCRS,
createSimilarPropertiesMethod(method()), parameters,
{ParameterValue::createFilename(projFilename)},
createSimilarPropertiesMethod(method()), parameters, values,
coordinateOperationAccuracies());
}
}
Expand Down Expand Up @@ -2622,14 +2616,14 @@ TransformationNNPtr SingleOperation::substitutePROJAlternativeGridNames(
}
auto l_sourceCRS = NN_NO_CHECK(l_sourceCRSNull);
auto l_targetCRS = NN_NO_CHECK(l_targetCRSNull);
auto parameters =
std::vector<OperationParameterNNPtr>{createOpParamNameEPSGCode(
EPSG_CODE_PARAMETER_POINT_MOTION_VELOCITY_GRID_FILE)};
const VectorOfParameters parameters{createOpParamNameEPSGCode(
EPSG_CODE_PARAMETER_POINT_MOTION_VELOCITY_GRID_FILE)};
const VectorOfValues values{
ParameterValue::createFilename(projFilename)};
return Transformation::create(
createSimilarPropertiesOperation(self), l_sourceCRS,
l_targetCRS, l_interpolationCRS,
createSimilarPropertiesMethod(method()), parameters,
{ParameterValue::createFilename(projFilename)},
createSimilarPropertiesMethod(method()), parameters, values,
coordinateOperationAccuracies());
}
}
Expand Down Expand Up @@ -2661,14 +2655,14 @@ TransformationNNPtr SingleOperation::substitutePROJAlternativeGridNames(
}
auto l_sourceCRS = NN_NO_CHECK(l_sourceCRSNull);
auto l_targetCRS = NN_NO_CHECK(l_targetCRSNull);
auto parameters =
std::vector<OperationParameterNNPtr>{createOpParamNameEPSGCode(
EPSG_CODE_PARAMETER_POINT_MOTION_VELOCITY_GRID_FILE)};
const VectorOfParameters parameters{createOpParamNameEPSGCode(
EPSG_CODE_PARAMETER_POINT_MOTION_VELOCITY_GRID_FILE)};
const VectorOfValues values{
ParameterValue::createFilename(projFilename)};
return Transformation::create(
createSimilarPropertiesOperation(self), l_sourceCRS,
l_targetCRS, l_interpolationCRS,
createSimilarPropertiesMethod(method()), parameters,
{ParameterValue::createFilename(projFilename)},
createSimilarPropertiesMethod(method()), parameters, values,
coordinateOperationAccuracies());
}
}
Expand Down Expand Up @@ -2712,25 +2706,25 @@ TransformationNNPtr SingleOperation::substitutePROJAlternativeGridNames(
}
auto l_sourceCRS = NN_NO_CHECK(l_sourceCRSNull);
auto l_targetCRS = NN_NO_CHECK(l_targetCRSNull);
auto parameters = std::vector<OperationParameterNNPtr>{
const VectorOfParameters parameters{
createOpParamNameEPSGCode(parameterCode)};
const VectorOfValues values{
ParameterValue::createFilename(projFilename)};
if (inverseDirection) {
return Transformation::create(
createPropertiesForInverse(
self.as_nullable().get(), true, false),
l_targetCRS, l_sourceCRS, l_interpolationCRS,
createSimilarPropertiesMethod(method()),
parameters,
{ParameterValue::createFilename(projFilename)},
parameters, values,
coordinateOperationAccuracies())
->inverseAsTransformation();
} else {
return Transformation::create(
createSimilarPropertiesOperation(self), l_sourceCRS,
l_targetCRS, l_interpolationCRS,
createSimilarPropertiesMethod(method()), parameters,
{ParameterValue::createFilename(projFilename)},
coordinateOperationAccuracies());
values, coordinateOperationAccuracies());
}
}
}
Expand Down Expand Up @@ -2786,27 +2780,26 @@ TransformationNNPtr SingleOperation::substitutePROJAlternativeGridNames(
}
auto l_sourceCRS = NN_NO_CHECK(l_sourceCRSNull);
auto l_targetCRS = NN_NO_CHECK(l_targetCRSNull);
auto parameters = std::vector<OperationParameterNNPtr>{
const VectorOfParameters parameters{
createOpParamNameEPSGCode(
gridTransf.gridFilenameParamEPSGCode)};
const VectorOfValues values{
ParameterValue::createFilename(projFilename)};
if (inverseDirection) {
return Transformation::create(
createPropertiesForInverse(
self.as_nullable().get(), true, false),
l_targetCRS, l_sourceCRS, l_interpolationCRS,
createSimilarPropertiesMethod(method()),
parameters,
{ParameterValue::createFilename(
projFilename)},
parameters, values,
coordinateOperationAccuracies())
->inverseAsTransformation();
} else {
return Transformation::create(
createSimilarPropertiesOperation(self), l_sourceCRS,
l_targetCRS, l_interpolationCRS,
createSimilarPropertiesMethod(method()), parameters,
{ParameterValue::createFilename(projFilename)},
coordinateOperationAccuracies());
values, coordinateOperationAccuracies());
}
}
}
Expand Down Expand Up @@ -5162,13 +5155,13 @@ PointMotionOperation::substitutePROJAlternativeGridNames(
return self;
}

auto parameters =
std::vector<OperationParameterNNPtr>{createOpParamNameEPSGCode(
EPSG_CODE_PARAMETER_POINT_MOTION_VELOCITY_GRID_FILE)};
const VectorOfParameters parameters{createOpParamNameEPSGCode(
EPSG_CODE_PARAMETER_POINT_MOTION_VELOCITY_GRID_FILE)};
const VectorOfValues values{
ParameterValue::createFilename(projFilename)};
return PointMotionOperation::create(
createSimilarPropertiesOperation(self), sourceCRS(),
createSimilarPropertiesMethod(method()), parameters,
{ParameterValue::createFilename(projFilename)},
createSimilarPropertiesMethod(method()), parameters, values,
coordinateOperationAccuracies());
}

Expand Down

0 comments on commit 853bef7

Please sign in to comment.