diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2022-02-22 20:51:05 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-22 20:51:05 +0100 |
| commit | 5b7c4575e549d2765da39a9708a42fa6317926f1 (patch) | |
| tree | 32ea9e79e558f0576170cc6fa85e693739b1e7ec | |
| parent | dd96597e86a0d4df1c6af0e32e1bb6bee1f840dd (diff) | |
| parent | 27d6a335dba16a083f5ecf76e8ce8d6034bb130f (diff) | |
| download | PROJ-5b7c4575e549d2765da39a9708a42fa6317926f1.tar.gz PROJ-5b7c4575e549d2765da39a9708a42fa6317926f1.zip | |
Merge pull request #3072 from rouault/coverity_scan
Fix various issues found by Coverity scan
| -rw-r--r-- | src/4D_api.cpp | 37 | ||||
| -rw-r--r-- | src/grids.cpp | 1 | ||||
| -rw-r--r-- | src/iso19111/common.cpp | 3 | ||||
| -rw-r--r-- | src/iso19111/crs.cpp | 66 | ||||
| -rw-r--r-- | src/iso19111/io.cpp | 2 | ||||
| -rw-r--r-- | src/iso19111/operation/coordinateoperationfactory.cpp | 9 |
6 files changed, 59 insertions, 59 deletions
diff --git a/src/4D_api.cpp b/src/4D_api.cpp index 94458398..a7baaf93 100644 --- a/src/4D_api.cpp +++ b/src/4D_api.cpp @@ -2276,24 +2276,25 @@ PJ_GRID_INFO proj_grid_info(const char *gridname) { strncpy (grinfo.gridname, gridname, sizeof(grinfo.gridname) - 1); /* full path of grid */ - pj_find_file(ctx, gridname, grinfo.filename, sizeof(grinfo.filename) - 1); - - /* grid format */ - strncpy (grinfo.format, format.c_str(), sizeof(grinfo.format) - 1); - - /* grid size */ - grinfo.n_lon = grid.width(); - grinfo.n_lat = grid.height(); - - /* cell size */ - grinfo.cs_lon = extent.resX; - grinfo.cs_lat = extent.resY; - - /* bounds of grid */ - grinfo.lowerleft.lam = extent.west; - grinfo.lowerleft.phi = extent.south; - grinfo.upperright.lam = extent.east; - grinfo.upperright.phi = extent.north; + if( pj_find_file(ctx, gridname, grinfo.filename, sizeof(grinfo.filename) - 1) ) + { + /* grid format */ + strncpy (grinfo.format, format.c_str(), sizeof(grinfo.format) - 1); + + /* grid size */ + grinfo.n_lon = grid.width(); + grinfo.n_lat = grid.height(); + + /* cell size */ + grinfo.cs_lon = extent.resX; + grinfo.cs_lat = extent.resY; + + /* bounds of grid */ + grinfo.lowerleft.lam = extent.west; + grinfo.lowerleft.phi = extent.south; + grinfo.upperright.lam = extent.east; + grinfo.upperright.phi = extent.north; + } }; { diff --git a/src/grids.cpp b/src/grids.cpp index 1842fc54..c00325a8 100644 --- a/src/grids.cpp +++ b/src/grids.cpp @@ -1747,6 +1747,7 @@ CTable2Grid *CTable2Grid::open(PJ_CONTEXT *ctx, std::unique_ptr<File> fp, } extent.east = extent.west + (width - 1) * extent.resX; extent.north = extent.south + (height - 1) * extent.resX; + extent.computeInvRes(); return new CTable2Grid(ctx, std::move(fp), filename, width, height, extent); } diff --git a/src/iso19111/common.cpp b/src/iso19111/common.cpp index b70845ae..1d7e2030 100644 --- a/src/iso19111/common.cpp +++ b/src/iso19111/common.cpp @@ -120,8 +120,9 @@ UnitOfMeasure &UnitOfMeasure::operator=(const UnitOfMeasure &other) { //! @cond Doxygen_Suppress UnitOfMeasure &UnitOfMeasure::operator=(UnitOfMeasure &&other) { - BaseObject::operator=(std::move(static_cast<BaseObject &&>(other))); *d = std::move(*(other.d)); + other.d = nullptr; + BaseObject::operator=(std::move(static_cast<BaseObject &&>(other))); return *this; } //! @endcond diff --git a/src/iso19111/crs.cpp b/src/iso19111/crs.cpp index 4750896a..881aec0b 100644 --- a/src/iso19111/crs.cpp +++ b/src/iso19111/crs.cpp @@ -4059,50 +4059,50 @@ void ProjectedCRS::_exportToWKT(io::WKTFormatter *formatter) const { if (found) l_esri_name = l_name; } - } - if (!isWKT2 && formatter->useESRIDialect() && !l_identifiers.empty() && - *(l_identifiers[0]->codeSpace()) == "ESRI" && dbContext) { - try { - const auto definition = dbContext->getTextDefinition( - "projected_crs", "ESRI", l_identifiers[0]->code()); - if (starts_with(definition, "PROJCS")) { - auto crsFromFromDef = io::WKTParser() - .attachDatabaseContext(dbContext) - .createFromWKT(definition); - if (_isEquivalentTo( - dynamic_cast<IComparable *>(crsFromFromDef.get()), - util::IComparable::Criterion::EQUIVALENT)) { - formatter->ingestWKTNode( - io::WKTNode::createFrom(definition)); - return; - } - } - } catch (const std::exception &) { - } - } else if (!isWKT2 && formatter->useESRIDialect() && !l_esri_name.empty()) { - try { - auto res = - io::AuthorityFactory::create(NN_NO_CHECK(dbContext), "ESRI") - ->createObjectsFromName( - l_esri_name, - {io::AuthorityFactory::ObjectType::PROJECTED_CRS}, - false); - if (res.size() == 1) { + if (!isWKT2 && !l_identifiers.empty() && + *(l_identifiers[0]->codeSpace()) == "ESRI") { + try { const auto definition = dbContext->getTextDefinition( - "projected_crs", "ESRI", - res.front()->identifiers()[0]->code()); + "projected_crs", "ESRI", l_identifiers[0]->code()); if (starts_with(definition, "PROJCS")) { + auto crsFromFromDef = io::WKTParser() + .attachDatabaseContext(dbContext) + .createFromWKT(definition); if (_isEquivalentTo( - dynamic_cast<IComparable *>(res.front().get()), + dynamic_cast<IComparable *>(crsFromFromDef.get()), util::IComparable::Criterion::EQUIVALENT)) { formatter->ingestWKTNode( io::WKTNode::createFrom(definition)); return; } } + } catch (const std::exception &) { + } + } else if (!isWKT2 && !l_esri_name.empty()) { + try { + auto res = + io::AuthorityFactory::create(NN_NO_CHECK(dbContext), "ESRI") + ->createObjectsFromName( + l_esri_name, + {io::AuthorityFactory::ObjectType::PROJECTED_CRS}, + false); + if (res.size() == 1) { + const auto definition = dbContext->getTextDefinition( + "projected_crs", "ESRI", + res.front()->identifiers()[0]->code()); + if (starts_with(definition, "PROJCS")) { + if (_isEquivalentTo( + dynamic_cast<IComparable *>(res.front().get()), + util::IComparable::Criterion::EQUIVALENT)) { + formatter->ingestWKTNode( + io::WKTNode::createFrom(definition)); + return; + } + } + } + } catch (const std::exception &) { } - } catch (const std::exception &) { } } diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index 02bcf3b0..b7f26fe5 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -4072,7 +4072,7 @@ WKTParser::Private::buildProjectedCRS(const WKTNodeNNPtr &node) { props.set(IdentifiedObject::NAME_KEY, "WGS 84 / UPS North (E,N)"); } else if (projCRSName == "UPS_South") { props.set(IdentifiedObject::NAME_KEY, "WGS 84 / UPS South (E,N)"); - } else { + } else if (cartesianCS) { std::string outTableName; std::string authNameFromAlias; std::string codeFromAlias; diff --git a/src/iso19111/operation/coordinateoperationfactory.cpp b/src/iso19111/operation/coordinateoperationfactory.cpp index 6b7d4d20..20042f22 100644 --- a/src/iso19111/operation/coordinateoperationfactory.cpp +++ b/src/iso19111/operation/coordinateoperationfactory.cpp @@ -3829,13 +3829,10 @@ void CoordinateOperationFactory::Private:: [&res, &context](const crs::GeographicCRS *geogSrcIn, const crs::VerticalCRS *vertDstIn, const crs::CRSNNPtr &targetCRSIn) { - if (res.empty() && geogSrcIn && vertDstIn && + const auto &authFactory = context.context->getAuthorityFactory(); + if (res.empty() && geogSrcIn && vertDstIn && authFactory && geogSrcIn->coordinateSystem()->axisList().size() == 3) { - const auto &authFactory = - context.context->getAuthorityFactory(); - const auto dbContext = - authFactory ? authFactory->databaseContext().as_nullable() - : nullptr; + const auto &dbContext = authFactory->databaseContext(); const auto candidatesSrcGeod(findCandidateGeodCRSForDatum( authFactory, geogSrcIn, geogSrcIn->datumNonNull(dbContext).get())); |
