diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/apps/projinfo.cpp | 13 | ||||
| -rw-r--r-- | src/apps/projsync.cpp | 7 | ||||
| -rw-r--r-- | src/filemanager.cpp | 14 | ||||
| -rw-r--r-- | src/grids.cpp | 21 | ||||
| -rw-r--r-- | src/iso19111/c_api.cpp | 14 | ||||
| -rw-r--r-- | src/iso19111/crs.cpp | 78 | ||||
| -rw-r--r-- | src/iso19111/datum.cpp | 14 | ||||
| -rw-r--r-- | src/iso19111/factory.cpp | 122 | ||||
| -rw-r--r-- | src/iso19111/io.cpp | 128 | ||||
| -rw-r--r-- | src/iso19111/operation/conversion.cpp | 45 | ||||
| -rw-r--r-- | src/iso19111/operation/coordinateoperationfactory.cpp | 261 | ||||
| -rw-r--r-- | src/iso19111/operation/parammappings.cpp | 70 | ||||
| -rw-r--r-- | src/iso19111/operation/singleoperation.cpp | 18 | ||||
| -rw-r--r-- | src/iso19111/operation/transformation.cpp | 66 | ||||
| -rw-r--r-- | src/networkfilemanager.cpp | 185 | ||||
| -rw-r--r-- | src/quadtree.hpp | 2 | ||||
| -rw-r--r-- | src/transformations/defmodel.cpp | 20 | ||||
| -rw-r--r-- | src/transformations/defmodel.hpp | 14 | ||||
| -rw-r--r-- | src/transformations/defmodel_impl.hpp | 27 | ||||
| -rw-r--r-- | src/transformations/tinshift_exceptions.hpp | 2 |
20 files changed, 587 insertions, 534 deletions
diff --git a/src/apps/projinfo.cpp b/src/apps/projinfo.cpp index 8d389019..8c266e94 100644 --- a/src/apps/projinfo.cpp +++ b/src/apps/projinfo.cpp @@ -187,8 +187,8 @@ static BaseObjectNNPtr buildObject( try { auto tokens = split(l_user_string, ':'); if (kind == "operation" && tokens.size() == 2) { - auto urn = "urn:ogc:def:coordinateOperation:" + tokens[0] + "::" + - tokens[1]; + auto urn = "urn:ogc:def:coordinateOperation:" + tokens[0] + + "::" + tokens[1]; obj = createFromUserInput(urn, dbContext).as_nullable(); } else if ((kind == "ellipsoid" || kind == "datum" || kind == "ensemble") && @@ -1214,11 +1214,10 @@ int main(int argc, char **argv) { if (crs) { try { auto res = crs->identify( - dbContext - ? AuthorityFactory::create( - NN_NO_CHECK(dbContext), authority) - .as_nullable() - : nullptr); + dbContext ? AuthorityFactory::create( + NN_NO_CHECK(dbContext), authority) + .as_nullable() + : nullptr); std::cout << std::endl; std::cout << "Identification match count: " << res.size() diff --git a/src/apps/projsync.cpp b/src/apps/projsync.cpp index 7f3d5e56..ec4d00fd 100644 --- a/src/apps/projsync.cpp +++ b/src/apps/projsync.cpp @@ -55,7 +55,7 @@ class ParsingException : public std::exception { explicit ParsingException(const char *msg) : msg_(msg) {} const char *what() const noexcept override { return msg_.c_str(); } }; -} +} // namespace // --------------------------------------------------------------------------- @@ -514,9 +514,8 @@ int main(int argc, char *argv[]) { std::cout << url << "... (" << i + 1 << " / " << to_download.size() << ")" << std::endl; } - if (!dryRun && - !proj_download_file(ctx, url.c_str(), false, nullptr, - nullptr)) { + if (!dryRun && !proj_download_file(ctx, url.c_str(), false, nullptr, + nullptr)) { std::cerr << "Cannot download " << url << std::endl; std::exit(1); } diff --git a/src/filemanager.cpp b/src/filemanager.cpp index 121a4b3a..43a705fc 100644 --- a/src/filemanager.cpp +++ b/src/filemanager.cpp @@ -1110,7 +1110,7 @@ void proj_context_set_sqlite3_vfs_name(PJ_CONTEXT *ctx, const char *name) { * already. * @return The path to the PROJ user writable directory. * @since 7.1 -*/ + */ const char *proj_context_get_user_writable_directory(PJ_CONTEXT *ctx, int create) { @@ -1181,12 +1181,12 @@ const char *proj_context_get_user_writable_directory(PJ_CONTEXT *ctx, } /** Get the URL endpoint to query for remote grids. -* -* @param ctx PROJ context, or NULL -* @return Endpoint URL. The returned pointer would be invalidated -* by a later call to proj_context_set_url_endpoint() -* @since 7.1 -*/ + * + * @param ctx PROJ context, or NULL + * @return Endpoint URL. The returned pointer would be invalidated + * by a later call to proj_context_set_url_endpoint() + * @since 7.1 + */ const char *proj_context_get_url_endpoint(PJ_CONTEXT *ctx) { if (ctx == nullptr) { ctx = pj_get_default_ctx(); diff --git a/src/grids.cpp b/src/grids.cpp index b7ab526a..f67ae42d 100644 --- a/src/grids.cpp +++ b/src/grids.cpp @@ -897,8 +897,9 @@ std::unique_ptr<GTiffGrid> GTiffDataset::nextGrid() { else if (sampleFormat == SAMPLEFORMAT_IEEEFP && bitsPerSample == 64) dt = TIFFDataType::Float64; else { - pj_log(m_ctx, PJ_LOG_ERROR, _("Unsupported combination of SampleFormat " - "and BitsPerSample values")); + pj_log(m_ctx, PJ_LOG_ERROR, + _("Unsupported combination of SampleFormat " + "and BitsPerSample values")); return nullptr; } @@ -998,8 +999,9 @@ std::unique_ptr<GTiffGrid> GTiffDataset::nextGrid() { // a GeoTransformationMatrix, since negative values in GeoPixelScale // have historically been implementation bugs. if (matrix[1] != 0 || matrix[4] != 0) { - pj_log(m_ctx, PJ_LOG_ERROR, _("Rotational terms not supported in " - "GeoTransformationMatrix tag")); + pj_log(m_ctx, PJ_LOG_ERROR, + _("Rotational terms not supported in " + "GeoTransformationMatrix tag")); return nullptr; } @@ -1833,10 +1835,9 @@ bool NTv2Grid::valueAt(int x, int y, bool compensateNTConvention, float two_float[2]; // NTv2 is organized from east to west ! // there are 4 components: lat shift, lon shift, lat error, lon error - m_fp->seek( - m_offset + - 4 * sizeof(float) * - (static_cast<unsigned long long>(y) * m_width + m_width - 1 - x)); + m_fp->seek(m_offset + 4 * sizeof(float) * + (static_cast<unsigned long long>(y) * m_width + + m_width - 1 - x)); if (m_fp->read(&two_float[0], sizeof(two_float)) != sizeof(two_float)) { proj_context_errno_set(m_ctx, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); @@ -2893,7 +2894,9 @@ ListOfHGrids pj_hgrid_init(PJ *P, const char *gridkey) { // --------------------------------------------------------------------------- -typedef struct { pj_int32 lam, phi; } ILP; +typedef struct { + pj_int32 lam, phi; +} ILP; // Apply bilinear interpolation for horizontal shift grids static PJ_LP pj_hgrid_interpolate(PJ_LP t, const HorizontalShiftGrid *grid, diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index c3e428d2..0d386e6b 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -8323,9 +8323,10 @@ double proj_dynamic_datum_get_frame_reference_epoch(PJ_CONTEXT *ctx, auto dvrf = dynamic_cast<const DynamicVerticalReferenceFrame *>( datum->iso_obj.get()); if (!dgrf && !dvrf) { - proj_log_error(ctx, __FUNCTION__, "Object is not a " - "DynamicGeodeticReferenceFrame or " - "DynamicVerticalReferenceFrame"); + proj_log_error(ctx, __FUNCTION__, + "Object is not a " + "DynamicGeodeticReferenceFrame or " + "DynamicVerticalReferenceFrame"); return -1; } const auto &frameReferenceEpoch = @@ -8592,9 +8593,10 @@ PJ *proj_normalize_for_visualization(PJ_CONTEXT *ctx, const PJ *obj) { auto co = dynamic_cast<const CoordinateOperation *>(obj->iso_obj.get()); if (!co) { - proj_log_error(ctx, __FUNCTION__, "Object is not a CoordinateOperation " - "created with " - "proj_create_crs_to_crs"); + proj_log_error(ctx, __FUNCTION__, + "Object is not a CoordinateOperation " + "created with " + "proj_create_crs_to_crs"); return nullptr; } try { diff --git a/src/iso19111/crs.cpp b/src/iso19111/crs.cpp index 1ac60d88..9c4c04c3 100644 --- a/src/iso19111/crs.cpp +++ b/src/iso19111/crs.cpp @@ -586,9 +586,8 @@ CRSNNPtr CRS::createBoundCRSToWGS84IfPossible( firstOpIsConversion)) { transf = util::nn_dynamic_pointer_cast< operation::Transformation>(subops[1]); - if (transf && - !starts_with(transf->nameStr(), - "Ballpark geo")) { + if (transf && !starts_with(transf->nameStr(), + "Ballpark geo")) { try { transf->getTOWGS84Parameters(); } catch (const std::exception &) { @@ -2128,23 +2127,25 @@ GeodeticCRS::identify(const io::AuthorityFactoryPtr &authorityFactory) const { const auto thisDatum(datumNonNull(dbContext)); - auto searchByDatumCode = [this, &authorityFactory, &res, - &geodetic_crs_type, crsCriterion, &dbContext]( - const common::IdentifiedObjectNNPtr &l_datum) { - for (const auto &id : l_datum->identifiers()) { - try { - auto tempRes = authorityFactory->createGeodeticCRSFromDatum( - *id->codeSpace(), id->code(), geodetic_crs_type); - for (const auto &crs : tempRes) { - if (_isEquivalentTo(crs.get(), crsCriterion, - dbContext)) { - res.emplace_back(crs, 70); + auto searchByDatumCode = + [this, &authorityFactory, &res, &geodetic_crs_type, crsCriterion, + &dbContext](const common::IdentifiedObjectNNPtr &l_datum) { + for (const auto &id : l_datum->identifiers()) { + try { + auto tempRes = + authorityFactory->createGeodeticCRSFromDatum( + *id->codeSpace(), id->code(), + geodetic_crs_type); + for (const auto &crs : tempRes) { + if (_isEquivalentTo(crs.get(), crsCriterion, + dbContext)) { + res.emplace_back(crs, 70); + } } + } catch (const std::exception &) { } - } catch (const std::exception &) { } - } - }; + }; auto searchByEllipsoid = [this, &authorityFactory, &res, &thisDatum, &geodetic_crs_type, l_implicitCS, @@ -2193,8 +2194,9 @@ GeodeticCRS::identify(const io::AuthorityFactoryPtr &authorityFactory) const { searchByDatumCode(thisDatum); } else { auto candidateDatums = authorityFactory->createObjectsFromName( - thisDatum->nameStr(), {io::AuthorityFactory::ObjectType:: - GEODETIC_REFERENCE_FRAME}, + thisDatum->nameStr(), + {io::AuthorityFactory::ObjectType:: + GEODETIC_REFERENCE_FRAME}, false); const size_t sizeBefore = res.size(); for (const auto &candidateDatum : candidateDatums) { @@ -2682,9 +2684,8 @@ GeographicCRS::demoteTo2D(const std::string &newName, const auto &firstRes = res.front(); auto firstResAsGeogCRS = util::nn_dynamic_pointer_cast<GeographicCRS>(firstRes); - if (firstResAsGeogCRS && - firstResAsGeogCRS->is2DPartOf3D(NN_NO_CHECK(this), - dbContext)) { + if (firstResAsGeogCRS && firstResAsGeogCRS->is2DPartOf3D( + NN_NO_CHECK(this), dbContext)) { return NN_NO_CHECK(firstResAsGeogCRS); } } @@ -4132,9 +4133,8 @@ ProjectedCRS::identify(const io::AuthorityFactoryPtr &authorityFactory) const { l_datum->nameStr() != "unnamed"; const auto &ellipsoid = l_baseCRS->ellipsoid(); auto geogCRS = dynamic_cast<const GeographicCRS *>(l_baseCRS.get()); - if (geogCRS && - geogCRS->coordinateSystem()->axisOrder() == - cs::EllipsoidalCS::AxisOrder::LONG_EAST_LAT_NORTH) { + if (geogCRS && geogCRS->coordinateSystem()->axisOrder() == + cs::EllipsoidalCS::AxisOrder::LONG_EAST_LAT_NORTH) { baseRes = GeographicCRS::create( util::PropertyMap().set(common::IdentifiedObject::NAME_KEY, @@ -4218,16 +4218,18 @@ ProjectedCRS::identify(const io::AuthorityFactoryPtr &authorityFactory) const { const bool l_implicitCS = hasImplicitCS(); const auto addCRS = [&](const ProjectedCRSNNPtr &crs, const bool eqName) { const auto &l_unit = cs->axisList()[0]->unit(); - if (_isEquivalentTo(crs.get(), util::IComparable::Criterion:: - EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS, + if (_isEquivalentTo(crs.get(), + util::IComparable::Criterion:: + EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS, dbContext) || (l_implicitCS && l_unit._isEquivalentTo( crs->coordinateSystem()->axisList()[0]->unit(), util::IComparable::Criterion::EQUIVALENT) && l_baseCRS->_isEquivalentTo( - crs->baseCRS().get(), util::IComparable::Criterion:: - EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS, + crs->baseCRS().get(), + util::IComparable::Criterion:: + EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS, dbContext) && derivingConversionRef()->_isEquivalentTo( crs->derivingConversionRef().get(), @@ -4285,8 +4287,9 @@ ProjectedCRS::identify(const io::AuthorityFactoryPtr &authorityFactory) const { *id->codeSpace()) ->createProjectedCRS(id->code()); bool match = _isEquivalentTo( - crs.get(), util::IComparable::Criterion:: - EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS, + crs.get(), + util::IComparable::Criterion:: + EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS, dbContext); res.emplace_back(crs, match ? 100 : 25); return res; @@ -4961,8 +4964,8 @@ CompoundCRS::identify(const io::AuthorityFactoryPtr &authorityFactory) const { thisName.c_str(), newCRS->nameStr().c_str()); res.emplace_back( newCRS, - std::min(thisName == newCRS->nameStr() ? 100 : eqName ? 90 - : 70, + std::min(thisName == newCRS->nameStr() ? 100 + : eqName ? 90 : 70, std::min(candidatesHorizCRS.front().second, candidatesVertCRS.front().second))); } @@ -5433,10 +5436,11 @@ BoundCRS::_identify(const io::AuthorityFactoryPtr &authorityFactory) const { opTransfPROJString = opNormalized->exportToPROJString( io::PROJStringFormatter::create().get()); opTransfPROJStringValid = true; - opTransfPROJString = replaceAll( - opTransfPROJString, " +rx=0 +ry=0 +rz=0 +s=0 " - "+convention=position_vector", - ""); + opTransfPROJString = + replaceAll(opTransfPROJString, + " +rx=0 +ry=0 +rz=0 +s=0 " + "+convention=position_vector", + ""); } catch (const std::exception &) { } if ((refTransfPROJStringValid && opTransfPROJStringValid && diff --git a/src/iso19111/datum.cpp b/src/iso19111/datum.cpp index 8e1b8257..96952866 100644 --- a/src/iso19111/datum.cpp +++ b/src/iso19111/datum.cpp @@ -835,9 +835,8 @@ void Ellipsoid::_exportToWKT( } formatter->add(computedInverseFlattening()); const auto &unit = semiMajor.unit(); - if (isWKT2 && - !(formatter->ellipsoidUnitOmittedIfMetre() && - unit == common::UnitOfMeasure::METRE)) { + if (isWKT2 && !(formatter->ellipsoidUnitOmittedIfMetre() && + unit == common::UnitOfMeasure::METRE)) { unit._exportToWKT(formatter, io::WKTConstants::LENGTHUNIT); } if (formatter->outputId()) { @@ -1269,8 +1268,9 @@ void GeodeticReferenceFrame::_exportToWKT( // as to trigger the caching done in createObjectsFromName() // in that case. auto matches = factory->createObjectsFromName( - l_name, {io::AuthorityFactory::ObjectType:: - GEODETIC_REFERENCE_FRAME}, + l_name, + {io::AuthorityFactory::ObjectType:: + GEODETIC_REFERENCE_FRAME}, true, 2); if (matches.size() == 1) { const auto &match = matches.front(); @@ -1870,8 +1870,8 @@ RealizationMethod::RealizationMethod(const std::string &nameIn) // --------------------------------------------------------------------------- -RealizationMethod &RealizationMethod:: -operator=(const RealizationMethod &other) { +RealizationMethod & +RealizationMethod::operator=(const RealizationMethod &other) { CodeList::operator=(other); return *this; } diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp index 0a5f58a4..49d2a737 100644 --- a/src/iso19111/factory.cpp +++ b/src/iso19111/factory.cpp @@ -193,28 +193,28 @@ struct DatabaseContext::Private { void cache(const std::string &code, const crs::CRSNNPtr &crs); datum::GeodeticReferenceFramePtr - // cppcheck-suppress functionStatic - getGeodeticDatumFromCache(const std::string &code); + // cppcheck-suppress functionStatic + getGeodeticDatumFromCache(const std::string &code); // cppcheck-suppress functionStatic void cache(const std::string &code, const datum::GeodeticReferenceFrameNNPtr &datum); datum::DatumEnsemblePtr - // cppcheck-suppress functionStatic - getDatumEnsembleFromCache(const std::string &code); + // cppcheck-suppress functionStatic + getDatumEnsembleFromCache(const std::string &code); // cppcheck-suppress functionStatic void cache(const std::string &code, const datum::DatumEnsembleNNPtr &datumEnsemble); datum::EllipsoidPtr - // cppcheck-suppress functionStatic - getEllipsoidFromCache(const std::string &code); + // cppcheck-suppress functionStatic + getEllipsoidFromCache(const std::string &code); // cppcheck-suppress functionStatic void cache(const std::string &code, const datum::EllipsoidNNPtr &ellipsoid); datum::PrimeMeridianPtr - // cppcheck-suppress functionStatic - getPrimeMeridianFromCache(const std::string &code); + // cppcheck-suppress functionStatic + getPrimeMeridianFromCache(const std::string &code); // cppcheck-suppress functionStatic void cache(const std::string &code, const datum::PrimeMeridianNNPtr &pm); @@ -617,20 +617,20 @@ void DatabaseContext::Private::checkDatabaseLayout() { } } if (nMajor != DATABASE_LAYOUT_VERSION_MAJOR) { - throw FactoryException(databasePath_ + - " contains DATABASE.LAYOUT.VERSION.MAJOR = " + - toString(nMajor) + " whereas " + - toString(DATABASE_LAYOUT_VERSION_MAJOR) + - " is expected. " - "It comes from another PROJ installation."); + throw FactoryException( + databasePath_ + + " contains DATABASE.LAYOUT.VERSION.MAJOR = " + toString(nMajor) + + " whereas " + toString(DATABASE_LAYOUT_VERSION_MAJOR) + + " is expected. " + "It comes from another PROJ installation."); } if (nMinor < DATABASE_LAYOUT_VERSION_MINOR) { - throw FactoryException(databasePath_ + - " contains DATABASE.LAYOUT.VERSION.MINOR = " + - toString(nMinor) + " whereas a number >= " + - toString(DATABASE_LAYOUT_VERSION_MINOR) + - " is expected. " - "It comes from another PROJ installation."); + throw FactoryException( + databasePath_ + + " contains DATABASE.LAYOUT.VERSION.MINOR = " + toString(nMinor) + + " whereas a number >= " + toString(DATABASE_LAYOUT_VERSION_MINOR) + + " is expected. " + "It comes from another PROJ installation."); } } @@ -4322,8 +4322,9 @@ AuthorityFactory::createFromCRSCodesWithIntermediates( // Case (source->intermediate) and (intermediate->target) std::string sql( - sqlProlog + "ON v1.target_crs_auth_name = v2.source_crs_auth_name " - "AND v1.target_crs_code = v2.source_crs_code " + + sqlProlog + + "ON v1.target_crs_auth_name = v2.source_crs_auth_name " + "AND v1.target_crs_code = v2.source_crs_code " + joinArea + "WHERE v1.source_crs_auth_name = ? AND v1.source_crs_code = ? " "AND v2.target_crs_auth_name = ? AND v2.target_crs_code = ? "); @@ -4432,24 +4433,25 @@ AuthorityFactory::createFromCRSCodesWithIntermediates( } } - const auto buildIntermediateWhere = [&intermediateCRSAuthCodes]( - const std::string &first_field, const std::string &second_field) { - if (intermediateCRSAuthCodes.empty()) { - return std::string(); - } - std::string l_sql(" AND ("); - for (size_t i = 0; i < intermediateCRSAuthCodes.size(); ++i) { - if (i > 0) { - l_sql += " OR"; + const auto buildIntermediateWhere = + [&intermediateCRSAuthCodes](const std::string &first_field, + const std::string &second_field) { + if (intermediateCRSAuthCodes.empty()) { + return std::string(); } - l_sql += "(v1." + first_field + "_crs_auth_name = ? AND "; - l_sql += "v1." + first_field + "_crs_code = ? AND "; - l_sql += "v2." + second_field + "_crs_auth_name = ? AND "; - l_sql += "v2." + second_field + "_crs_code = ?) "; - } - l_sql += ')'; - return l_sql; - }; + std::string l_sql(" AND ("); + for (size_t i = 0; i < intermediateCRSAuthCodes.size(); ++i) { + if (i > 0) { + l_sql += " OR"; + } + l_sql += "(v1." + first_field + "_crs_auth_name = ? AND "; + l_sql += "v1." + first_field + "_crs_code = ? AND "; + l_sql += "v2." + second_field + "_crs_auth_name = ? AND "; + l_sql += "v2." + second_field + "_crs_code = ?) "; + } + l_sql += ')'; + return l_sql; + }; std::string intermediateWhere = buildIntermediateWhere("target", "source"); for (const auto &pair : intermediateCRSAuthCodes) { @@ -4537,8 +4539,9 @@ AuthorityFactory::createFromCRSCodesWithIntermediates( } // Case (source->intermediate) and (target->intermediate) - sql = sqlProlog + "ON v1.target_crs_auth_name = v2.target_crs_auth_name " - "AND v1.target_crs_code = v2.target_crs_code " + + sql = sqlProlog + + "ON v1.target_crs_auth_name = v2.target_crs_auth_name " + "AND v1.target_crs_code = v2.target_crs_code " + joinArea + "WHERE v1.source_crs_auth_name = ? AND v1.source_crs_code = ? " "AND v2.source_crs_auth_name = ? AND v2.source_crs_code = ? "; @@ -4580,8 +4583,9 @@ AuthorityFactory::createFromCRSCodesWithIntermediates( } // Case (intermediate->source) and (intermediate->target) - sql = sqlProlog + "ON v1.source_crs_auth_name = v2.source_crs_auth_name " - "AND v1.source_crs_code = v2.source_crs_code " + + sql = sqlProlog + + "ON v1.source_crs_auth_name = v2.source_crs_auth_name " + "AND v1.source_crs_code = v2.source_crs_code " + joinArea + "WHERE v1.target_crs_auth_name = ? AND v1.target_crs_code = ? " "AND v2.target_crs_auth_name = ? AND v2.target_crs_code = ? "; @@ -4644,8 +4648,9 @@ AuthorityFactory::createFromCRSCodesWithIntermediates( } // Case (intermediate->source) and (target->intermediate) - sql = sqlProlog + "ON v1.source_crs_auth_name = v2.target_crs_auth_name " - "AND v1.source_crs_code = v2.target_crs_code " + + sql = sqlProlog + + "ON v1.source_crs_auth_name = v2.target_crs_auth_name " + "AND v1.source_crs_code = v2.target_crs_code " + joinArea + "WHERE v1.target_crs_auth_name = ? AND v1.target_crs_code = ? " "AND v2.source_crs_auth_name = ? AND v2.source_crs_code = ? "; @@ -4871,7 +4876,6 @@ AuthorityFactory::createBetweenGeodeticCRSWithDatumBasedIntermediates( const auto filterDeprecatedAndNotMatchingAuth = [&](SQLResultSet &&resultSet) { - SQLResultSet filteredResultSet; for (const auto &row : resultSet) { const auto &deprecated1 = row[3]; @@ -4930,9 +4934,11 @@ AuthorityFactory::createBetweenGeodeticCRSWithDatumBasedIntermediates( ListOfParams findSupersededParams; std::set<std::string> setAlreadyAsked; - const auto keyMapSupersession = []( - const std::string &table_name, const std::string &auth_name, - const std::string &code) { return table_name + auth_name + code; }; + const auto keyMapSupersession = [](const std::string &table_name, + const std::string &auth_name, + const std::string &code) { + return table_name + auth_name + code; + }; for (const auto &row : resultSet) { const auto &table1 = row[0]; @@ -5588,12 +5594,13 @@ std::list<AuthorityFactory::CRSInfo> AuthorityFactory::getCRSInfoList() const { const auto getSqlArea = [](const std::string &table_name) { return "JOIN usage u ON " "u.object_table_name = '" + - table_name + "' AND " - "u.object_auth_name = c.auth_name AND " - "u.object_code = c.code " - "JOIN extent a " - "ON a.auth_name = u.extent_auth_name AND " - "a.code = u.extent_code "; + table_name + + "' AND " + "u.object_auth_name = c.auth_name AND " + "u.object_code = c.code " + "JOIN extent a " + "ON a.auth_name = u.extent_auth_name AND " + "a.code = u.extent_code "; }; std::string sql = "SELECT c.auth_name, c.code, c.name, c.type, " @@ -6258,8 +6265,9 @@ AuthorityFactory::createObjectsFromNameEx( } auto factory = d->createFactory(auth_name); auto getObject = [&factory, datumEnsembleAllowed]( - const std::string &l_table_name, - const std::string &l_code) -> common::IdentifiedObjectNNPtr { + const std::string &l_table_name, + const std::string &l_code) + -> common::IdentifiedObjectNNPtr { if (l_table_name == "prime_meridian") { return factory->createPrimeMeridian(l_code); } else if (l_table_name == "ellipsoid") { diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index 6ea6316c..51162365 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -916,9 +916,9 @@ struct WKTNode::Private { // --------------------------------------------------------------------------- -const WKTNodeNNPtr &WKTNode::Private::lookForChild(const std::string &childName, - int occurrence) const - noexcept { +const WKTNodeNNPtr & +WKTNode::Private::lookForChild(const std::string &childName, + int occurrence) const noexcept { int occCount = 0; for (const auto &child : children_) { if (ci_equal(child->GP()->value(), childName)) { @@ -3408,8 +3408,8 @@ ConversionNNPtr WKTParser::Private::buildProjectionFromESRI( } struct ci_less_struct { - bool operator()(const std::string &lhs, const std::string &rhs) const - noexcept { + bool operator()(const std::string &lhs, + const std::string &rhs) const noexcept { return ci_less(lhs, rhs); } }; @@ -3750,14 +3750,12 @@ ConversionNNPtr WKTParser::Private::buildProjectionStandard( // Krovak East-North Oriented methods if (ci_equal(projectionName, "Krovak") && projCRSNode->countChildrenOfName(WKTConstants::AXIS) == 2 && - &buildAxis( - projCRSNode->GP()->lookForChild(WKTConstants::AXIS, 0), - defaultLinearUnit, UnitOfMeasure::Type::LINEAR, false, - 1)->direction() == &AxisDirection::SOUTH && - &buildAxis( - projCRSNode->GP()->lookForChild(WKTConstants::AXIS, 1), - defaultLinearUnit, UnitOfMeasure::Type::LINEAR, false, - 2)->direction() == &AxisDirection::WEST) { + &buildAxis(projCRSNode->GP()->lookForChild(WKTConstants::AXIS, 0), + defaultLinearUnit, UnitOfMeasure::Type::LINEAR, false, 1) + ->direction() == &AxisDirection::SOUTH && + &buildAxis(projCRSNode->GP()->lookForChild(WKTConstants::AXIS, 1), + defaultLinearUnit, UnitOfMeasure::Type::LINEAR, false, 2) + ->direction() == &AxisDirection::WEST) { mapping = getMapping(EPSG_CODE_METHOD_KROVAK); } @@ -6442,50 +6440,52 @@ static BaseObjectNNPtr createFromUserInput(const std::string &text, auto factory = AuthorityFactory::create(NN_NO_CHECK(dbContext), std::string()); - const auto searchObject = [&factory]( - const std::string &objectName, bool approximateMatch, - const std::vector<AuthorityFactory::ObjectType> &objectTypes, - bool &goOn) { - constexpr size_t limitResultCount = 10; - auto res = factory->createObjectsFromName( - objectName, objectTypes, approximateMatch, limitResultCount); - if (res.size() == 1) { - return res.front(); - } - if (res.size() > 1) { - if (objectTypes.size() == 1 && - objectTypes[0] == AuthorityFactory::ObjectType::CRS) { - for (size_t ndim = 2; ndim <= 3; ndim++) { - for (const auto &obj : res) { - auto crs = - dynamic_cast<crs::GeographicCRS *>(obj.get()); - if (crs && - crs->coordinateSystem()->axisList().size() == - ndim) { - return obj; + const auto searchObject = + [&factory]( + const std::string &objectName, bool approximateMatch, + const std::vector<AuthorityFactory::ObjectType> &objectTypes, + bool &goOn) { + constexpr size_t limitResultCount = 10; + auto res = factory->createObjectsFromName( + objectName, objectTypes, approximateMatch, + limitResultCount); + if (res.size() == 1) { + return res.front(); + } + if (res.size() > 1) { + if (objectTypes.size() == 1 && + objectTypes[0] == AuthorityFactory::ObjectType::CRS) { + for (size_t ndim = 2; ndim <= 3; ndim++) { + for (const auto &obj : res) { + auto crs = dynamic_cast<crs::GeographicCRS *>( + obj.get()); + if (crs && crs->coordinateSystem() + ->axisList() + .size() == ndim) { + return obj; + } } } } - } - std::string msg("several objects matching this name: "); - bool first = true; - for (const auto &obj : res) { - if (msg.size() > 200) { - msg += ", ..."; - break; - } - if (!first) { - msg += ", "; + std::string msg("several objects matching this name: "); + bool first = true; + for (const auto &obj : res) { + if (msg.size() > 200) { + msg += ", ..."; + break; + } + if (!first) { + msg += ", "; + } + first = false; + msg += obj->nameStr(); } - first = false; - msg += obj->nameStr(); + throw ParsingException(msg); } - throw ParsingException(msg); - } - goOn = true; - throw ParsingException("dummy"); - }; + goOn = true; + throw ParsingException("dummy"); + }; const auto searchCRS = [&searchObject](const std::string &objectName) { bool goOn = false; @@ -6808,7 +6808,9 @@ WKTParser::guessDialect(const std::string &wkt) noexcept { } } static const char *const wkt2_2019_only_substrings[] = { - "CS[TemporalDateTime,", "CS[TemporalCount,", "CS[TemporalMeasure,", + "CS[TemporalDateTime,", + "CS[TemporalCount,", + "CS[TemporalMeasure,", }; for (const auto &substrings : wkt2_2019_only_substrings) { if (ci_find(wkt, substrings) != std::string::npos) { @@ -9086,7 +9088,7 @@ static double getNumericValue(const std::string ¶mValue, // --------------------------------------------------------------------------- namespace { template <class T> inline void ignoreRetVal(T) {} -} +} // namespace GeographicCRSNNPtr PROJStringParser::Private::buildGeographicCRS( int iStep, int iUnitConvert, int iAxisSwap, bool ignorePROJAxis) { @@ -10097,9 +10099,8 @@ PROJStringParser::createFromPROJString(const std::string &projString) { } else { for (auto cur = pj->params; cur; cur = cur->next) { const char *equal = strchr(cur->param, '='); - if (equal && - static_cast<size_t>(equal - cur->param) == - kv.key.size()) { + if (equal && static_cast<size_t>(equal - cur->param) == + kv.key.size()) { if (memcmp(cur->param, kv.key.c_str(), kv.key.size()) == 0) { recognizedByPROJ = (cur->used == 1); @@ -10197,13 +10198,14 @@ PROJStringParser::createFromPROJString(const std::string &projString) { iProjStep, d->buildProjectedCRS( iProjStep, - d->buildGeographicCRS( - iFirstGeogStep, iFirstUnitConvert < iFirstGeogStep - ? iFirstUnitConvert - : -1, - iFirstAxisSwap < iFirstGeogStep ? iFirstAxisSwap - : -1, - true), + d->buildGeographicCRS(iFirstGeogStep, + iFirstUnitConvert < iFirstGeogStep + ? iFirstUnitConvert + : -1, + iFirstAxisSwap < iFirstGeogStep + ? iFirstAxisSwap + : -1, + true), iFirstUnitConvert < iFirstGeogStep ? iSecondUnitConvert : iFirstUnitConvert, iFirstAxisSwap < iFirstGeogStep ? iSecondAxisSwap diff --git a/src/iso19111/operation/conversion.cpp b/src/iso19111/operation/conversion.cpp index 1808dbe7..e9d688b7 100644 --- a/src/iso19111/operation/conversion.cpp +++ b/src/iso19111/operation/conversion.cpp @@ -2238,15 +2238,16 @@ ConversionNNPtr Conversion::createPoleRotationGRIBConvention( ConversionNNPtr Conversion::createChangeVerticalUnit(const util::PropertyMap &properties, const common::Scale &factor) { - return create(properties, createMethodMapNameEPSGCode( - EPSG_CODE_METHOD_CHANGE_VERTICAL_UNIT), - VectorOfParameters{ - createOpParamNameEPSGCode( - EPSG_CODE_PARAMETER_UNIT_CONVERSION_SCALAR), - }, - VectorOfValues{ - factor, - }); + return create( + properties, + createMethodMapNameEPSGCode(EPSG_CODE_METHOD_CHANGE_VERTICAL_UNIT), + VectorOfParameters{ + createOpParamNameEPSGCode( + EPSG_CODE_PARAMETER_UNIT_CONVERSION_SCALAR), + }, + VectorOfValues{ + factor, + }); } // --------------------------------------------------------------------------- @@ -2264,9 +2265,10 @@ Conversion::createChangeVerticalUnit(const util::PropertyMap &properties, */ ConversionNNPtr Conversion::createHeightDepthReversal(const util::PropertyMap &properties) { - return create(properties, createMethodMapNameEPSGCode( - EPSG_CODE_METHOD_HEIGHT_DEPTH_REVERSAL), - {}, {}); + return create( + properties, + createMethodMapNameEPSGCode(EPSG_CODE_METHOD_HEIGHT_DEPTH_REVERSAL), {}, + {}); } // --------------------------------------------------------------------------- @@ -2310,9 +2312,10 @@ ConversionNNPtr Conversion::createAxisOrderReversal(bool is3D) { */ ConversionNNPtr Conversion::createGeographicGeocentric(const util::PropertyMap &properties) { - return create(properties, createMethodMapNameEPSGCode( - EPSG_CODE_METHOD_GEOGRAPHIC_GEOCENTRIC), - {}, {}); + return create( + properties, + createMethodMapNameEPSGCode(EPSG_CODE_METHOD_GEOGRAPHIC_GEOCENTRIC), {}, + {}); } // --------------------------------------------------------------------------- @@ -2458,9 +2461,10 @@ static double lcc_1sp_to_2sp_f(double sinphi, double K, double ec, double n) { const double x = sinphi; const double ecx = ec * x; return (1 - x * x) / (1 - ecx * ecx) - - K * K * std::pow((1.0 - x) / (1.0 + x) * - std::pow((1.0 + ecx) / (1.0 - ecx), ec), - n); + K * K * + std::pow((1.0 - x) / (1.0 + x) * + std::pow((1.0 + ecx) / (1.0 - ecx), ec), + n); } // --------------------------------------------------------------------------- @@ -2748,8 +2752,9 @@ ConversionPtr Conversion::convertToOtherMethod(int targetEPSGCode) const { common::Angle(phi0Deg, common::UnitOfMeasure::DEGREE), common::Angle(parameterValueMeasure( EPSG_CODE_PARAMETER_LONGITUDE_FALSE_ORIGIN)), - common::Scale(k0), common::Length(parameterValueMeasure( - EPSG_CODE_PARAMETER_EASTING_FALSE_ORIGIN)), + common::Scale(k0), + common::Length(parameterValueMeasure( + EPSG_CODE_PARAMETER_EASTING_FALSE_ORIGIN)), common::Length( parameterValueNumericAsSI( EPSG_CODE_PARAMETER_NORTHING_FALSE_ORIGIN) + diff --git a/src/iso19111/operation/coordinateoperationfactory.cpp b/src/iso19111/operation/coordinateoperationfactory.cpp index e4b989c8..44d9b570 100644 --- a/src/iso19111/operation/coordinateoperationfactory.cpp +++ b/src/iso19111/operation/coordinateoperationfactory.cpp @@ -30,8 +30,8 @@ #define FROM_PROJ_CPP #endif -#include "proj/coordinateoperation.hpp" #include "proj/common.hpp" +#include "proj/coordinateoperation.hpp" #include "proj/crs.hpp" #include "proj/io.hpp" #include "proj/metadata.hpp" @@ -1892,8 +1892,8 @@ struct MyPROJStringExportableGeodToGeod final ~MyPROJStringExportableGeodToGeod() override; void - // cppcheck-suppress functionStatic - _exportToPROJString(io::PROJStringFormatter *formatter) const override { + // cppcheck-suppress functionStatic + _exportToPROJString(io::PROJStringFormatter *formatter) const override { formatter->startInversion(); geodSrc->_exportToPROJString(formatter); @@ -1922,8 +1922,8 @@ struct MyPROJStringExportableHorizVertical final ~MyPROJStringExportableHorizVertical() override; void - // cppcheck-suppress functionStatic - _exportToPROJString(io::PROJStringFormatter *formatter) const override { + // cppcheck-suppress functionStatic + _exportToPROJString(io::PROJStringFormatter *formatter) const override { formatter->pushOmitZUnitConversion(); @@ -1970,8 +1970,8 @@ struct MyPROJStringExportableHorizVerticalHorizPROJBased final ~MyPROJStringExportableHorizVerticalHorizPROJBased() override; void - // cppcheck-suppress functionStatic - _exportToPROJString(io::PROJStringFormatter *formatter) const override { + // cppcheck-suppress functionStatic + _exportToPROJString(io::PROJStringFormatter *formatter) const override { formatter->pushOmitZUnitConversion(); @@ -2321,10 +2321,9 @@ CoordinateOperationFactory::Private::createOperationsGeogToGeog( } // Do they differ by vertical units ? - if (vconvSrc != vconvDst && - geogSrc->ellipsoid()->_isEquivalentTo( - geogDst->ellipsoid().get(), - util::IComparable::Criterion::EQUIVALENT)) { + if (vconvSrc != vconvDst && geogSrc->ellipsoid()->_isEquivalentTo( + geogDst->ellipsoid().get(), + util::IComparable::Criterion::EQUIVALENT)) { if (offset_pm.value() == 0 && !axisReversal2D && !axisReversal3D) { // If only by vertical units, use a Change of Vertical // Unit @@ -3267,7 +3266,6 @@ CoordinateOperationFactory::Private::createOperationsGeogToVertFromGeoid( const auto useTransf = [&sourceCRS, &targetCRS, &context, vertDst](const CoordinateOperationNNPtr &op) { - // If the source geographic CRS has a non-metre vertical unit, we need // to create an intermediate and operation to do the vertical unit // conversion from that vertical unit to the one of the geographic CRS @@ -3324,85 +3322,86 @@ CoordinateOperationFactory::Private::createOperationsGeogToVertFromGeoid( return ret; }; - const auto getProjGeoidTransformation = [&sourceCRS, &targetCRS, &vertDst, - &context]( - const CoordinateOperationNNPtr &model, - const std::string &projFilename) { - - const auto getNameVertCRSMetre = [](const std::string &name) { - if (name.empty()) - return std::string("unnamed"); - auto ret(name); - bool haveOriginalUnit = false; - if (name.back() == ')') { - const auto pos = ret.rfind(" ("); + const auto getProjGeoidTransformation = + [&sourceCRS, &targetCRS, &vertDst, + &context](const CoordinateOperationNNPtr &model, + const std::string &projFilename) { + const auto getNameVertCRSMetre = [](const std::string &name) { + if (name.empty()) + return std::string("unnamed"); + auto ret(name); + bool haveOriginalUnit = false; + if (name.back() == ')') { + const auto pos = ret.rfind(" ("); + if (pos != std::string::npos) { + haveOriginalUnit = true; + ret = ret.substr(0, pos); + } + } + const auto pos = ret.rfind(" depth"); if (pos != std::string::npos) { - haveOriginalUnit = true; - ret = ret.substr(0, pos); + ret = ret.substr(0, pos) + " height"; } - } - const auto pos = ret.rfind(" depth"); - if (pos != std::string::npos) { - ret = ret.substr(0, pos) + " height"; - } - if (!haveOriginalUnit) { - ret += " (metre)"; - } - return ret; - }; + if (!haveOriginalUnit) { + ret += " (metre)"; + } + return ret; + }; - const auto &axis = vertDst->coordinateSystem()->axisList()[0]; - const auto &authFactory = context.context->getAuthorityFactory(); - const auto dbContext = - authFactory ? authFactory->databaseContext().as_nullable() - : nullptr; + const auto &axis = vertDst->coordinateSystem()->axisList()[0]; + const auto &authFactory = context.context->getAuthorityFactory(); + const auto dbContext = + authFactory ? authFactory->databaseContext().as_nullable() + : nullptr; - const auto geogSrcCRS = - dynamic_cast<crs::GeographicCRS *>(model->interpolationCRS().get()) - ? NN_NO_CHECK(model->interpolationCRS()) - : sourceCRS->demoteTo2D(std::string(), dbContext) - ->promoteTo3D(std::string(), dbContext); - const auto vertCRSMetre = - axis->unit() == common::UnitOfMeasure::METRE && - axis->direction() == cs::AxisDirection::UP - ? targetCRS - : util::nn_static_pointer_cast<crs::CRS>( - crs::VerticalCRS::create( - util::PropertyMap().set( - common::IdentifiedObject::NAME_KEY, - getNameVertCRSMetre(targetCRS->nameStr())), - vertDst->datum(), vertDst->datumEnsemble(), - cs::VerticalCS::createGravityRelatedHeight( - common::UnitOfMeasure::METRE))); - const auto properties = util::PropertyMap().set( - common::IdentifiedObject::NAME_KEY, - buildOpName("Transformation", vertCRSMetre, geogSrcCRS)); - - // Try to find a representative value for the accuracy of this grid - // from the registered transformations. - std::vector<metadata::PositionalAccuracyNNPtr> accuracies; - const auto &modelAccuracies = model->coordinateOperationAccuracies(); - if (modelAccuracies.empty()) { - if (authFactory) { - const auto transformationsForGrid = - io::DatabaseContext::getTransformationsForGridName( - authFactory->databaseContext(), projFilename); - double accuracy = -1; - for (const auto &transf : transformationsForGrid) { - accuracy = std::max(accuracy, getAccuracy(transf)); - } - if (accuracy >= 0) { - accuracies.emplace_back( - metadata::PositionalAccuracy::create( - toString(accuracy))); + const auto geogSrcCRS = + dynamic_cast<crs::GeographicCRS *>( + model->interpolationCRS().get()) + ? NN_NO_CHECK(model->interpolationCRS()) + : sourceCRS->demoteTo2D(std::string(), dbContext) + ->promoteTo3D(std::string(), dbContext); + const auto vertCRSMetre = + axis->unit() == common::UnitOfMeasure::METRE && + axis->direction() == cs::AxisDirection::UP + ? targetCRS + : util::nn_static_pointer_cast<crs::CRS>( + crs::VerticalCRS::create( + util::PropertyMap().set( + common::IdentifiedObject::NAME_KEY, + getNameVertCRSMetre(targetCRS->nameStr())), + vertDst->datum(), vertDst->datumEnsemble(), + cs::VerticalCS::createGravityRelatedHeight( + common::UnitOfMeasure::METRE))); + const auto properties = util::PropertyMap().set( + common::IdentifiedObject::NAME_KEY, + buildOpName("Transformation", vertCRSMetre, geogSrcCRS)); + + // Try to find a representative value for the accuracy of this grid + // from the registered transformations. + std::vector<metadata::PositionalAccuracyNNPtr> accuracies; + const auto &modelAccuracies = + model->coordinateOperationAccuracies(); + if (modelAccuracies.empty()) { + if (authFactory) { + const auto transformationsForGrid = + io::DatabaseContext::getTransformationsForGridName( + authFactory->databaseContext(), projFilename); + double accuracy = -1; + for (const auto &transf : transformationsForGrid) { + accuracy = std::max(accuracy, getAccuracy(transf)); + } + if (accuracy >= 0) { + accuracies.emplace_back( + metadata::PositionalAccuracy::create( + toString(accuracy))); + } } } - } - return Transformation::createGravityRelatedHeightToGeographic3D( - properties, vertCRSMetre, geogSrcCRS, nullptr, projFilename, - !modelAccuracies.empty() ? modelAccuracies : accuracies); - }; + return Transformation::createGravityRelatedHeightToGeographic3D( + properties, vertCRSMetre, geogSrcCRS, nullptr, projFilename, + !modelAccuracies.empty() ? modelAccuracies : accuracies); + }; std::vector<CoordinateOperationNNPtr> res; const auto &authFactory = context.context->getAuthorityFactory(); @@ -3593,35 +3592,38 @@ void CoordinateOperationFactory::Private:: // NAD83 only exists in 2D version in EPSG, so if it has been // promoted to 3D, when researching a vertical to geog // transformation, try to down cast to 2D. - const auto geog3DToVertTryThroughGeog2D = [&res, &context]( - const crs::GeographicCRS *geogSrcIn, const crs::VerticalCRS *vertDstIn, - const crs::CRSNNPtr &targetCRSIn) { - if (res.empty() && geogSrcIn && vertDstIn && - geogSrcIn->coordinateSystem()->axisList().size() == 3) { - const auto &authFactory = context.context->getAuthorityFactory(); - const auto dbContext = - authFactory ? authFactory->databaseContext().as_nullable() - : nullptr; - const auto candidatesSrcGeod(findCandidateGeodCRSForDatum( - authFactory, geogSrcIn, - geogSrcIn->datumNonNull(dbContext).get())); - for (const auto &candidate : candidatesSrcGeod) { - auto geogCandidate = - util::nn_dynamic_pointer_cast<crs::GeographicCRS>( - candidate); - if (geogCandidate && - geogCandidate->coordinateSystem()->axisList().size() == 2) { - bool ignored; - res = - findOpsInRegistryDirect(NN_NO_CHECK(geogCandidate), - targetCRSIn, context, ignored); - break; + const auto geog3DToVertTryThroughGeog2D = + [&res, &context](const crs::GeographicCRS *geogSrcIn, + const crs::VerticalCRS *vertDstIn, + const crs::CRSNNPtr &targetCRSIn) { + if (res.empty() && geogSrcIn && vertDstIn && + geogSrcIn->coordinateSystem()->axisList().size() == 3) { + const auto &authFactory = + context.context->getAuthorityFactory(); + const auto dbContext = + authFactory ? authFactory->databaseContext().as_nullable() + : nullptr; + const auto candidatesSrcGeod(findCandidateGeodCRSForDatum( + authFactory, geogSrcIn, + geogSrcIn->datumNonNull(dbContext).get())); + for (const auto &candidate : candidatesSrcGeod) { + auto geogCandidate = + util::nn_dynamic_pointer_cast<crs::GeographicCRS>( + candidate); + if (geogCandidate && + geogCandidate->coordinateSystem()->axisList().size() == + 2) { + bool ignored; + res = findOpsInRegistryDirect( + NN_NO_CHECK(geogCandidate), targetCRSIn, context, + ignored); + break; + } } + return true; } - return true; - } - return false; - }; + return false; + }; if (geog3DToVertTryThroughGeog2D(geogSrc, vertDst, targetCRS)) { // do nothing @@ -5169,26 +5171,27 @@ crs::CRSNNPtr CRS::getResolvedCRS(const crs::CRSNNPtr &crs, // Even if they aren't equivalent, we update extentOut with the one of the // identified CRS if our input one is absent/not reliable. - const auto tryToIdentifyByName = [&crs, &name, &authFactory, approxExtent, - &extentOut]( - io::AuthorityFactory::ObjectType objectType) { - if (name != "unknown" && name != "unnamed") { - auto matches = authFactory->createObjectsFromName( - name, {objectType}, false, 2); - if (matches.size() == 1) { - const auto match = - util::nn_static_pointer_cast<crs::CRS>(matches.front()); - if (approxExtent || !extentOut) { - extentOut = operation::getExtent(match); - } - if (match->isEquivalentTo( - crs.get(), util::IComparable::Criterion::EQUIVALENT)) { - return match; + const auto tryToIdentifyByName = + [&crs, &name, &authFactory, approxExtent, + &extentOut](io::AuthorityFactory::ObjectType objectType) { + if (name != "unknown" && name != "unnamed") { + auto matches = authFactory->createObjectsFromName( + name, {objectType}, false, 2); + if (matches.size() == 1) { + const auto match = + util::nn_static_pointer_cast<crs::CRS>(matches.front()); + if (approxExtent || !extentOut) { + extentOut = operation::getExtent(match); + } + if (match->isEquivalentTo( + crs.get(), + util::IComparable::Criterion::EQUIVALENT)) { + return match; + } } } - } - return crs; - }; + return crs; + }; auto geogCRS = dynamic_cast<crs::GeographicCRS *>(crs.get()); if (geogCRS && authFactory) { diff --git a/src/iso19111/operation/parammappings.cpp b/src/iso19111/operation/parammappings.cpp index de5f4c7e..03200468 100644 --- a/src/iso19111/operation/parammappings.cpp +++ b/src/iso19111/operation/parammappings.cpp @@ -760,8 +760,11 @@ static const MethodMapping projectionMethodMappings[] = { { EPSG_NAME_METHOD_OBLIQUE_STEREOGRAPHIC, - EPSG_CODE_METHOD_OBLIQUE_STEREOGRAPHIC, "Oblique_Stereographic", - "sterea", nullptr, paramsObliqueStereo, + EPSG_CODE_METHOD_OBLIQUE_STEREOGRAPHIC, + "Oblique_Stereographic", + "sterea", + nullptr, + paramsObliqueStereo, }, {EPSG_NAME_METHOD_ORTHOGRAPHIC, EPSG_CODE_METHOD_ORTHOGRAPHIC, @@ -884,13 +887,16 @@ const struct MethodNameCode methodNameCodes[] = { // Projection methods METHOD_NAME_CODE(TRANSVERSE_MERCATOR), METHOD_NAME_CODE(TRANSVERSE_MERCATOR_SOUTH_ORIENTATED), - METHOD_NAME_CODE(LAMBERT_CONIC_CONFORMAL_1SP), METHOD_NAME_CODE(NZMG), - METHOD_NAME_CODE(TUNISIA_MAPPING_GRID), METHOD_NAME_CODE(ALBERS_EQUAL_AREA), + METHOD_NAME_CODE(LAMBERT_CONIC_CONFORMAL_1SP), + METHOD_NAME_CODE(NZMG), + METHOD_NAME_CODE(TUNISIA_MAPPING_GRID), + METHOD_NAME_CODE(ALBERS_EQUAL_AREA), METHOD_NAME_CODE(LAMBERT_CONIC_CONFORMAL_2SP), METHOD_NAME_CODE(LAMBERT_CONIC_CONFORMAL_2SP_BELGIUM), METHOD_NAME_CODE(LAMBERT_CONIC_CONFORMAL_2SP_MICHIGAN), METHOD_NAME_CODE(MODIFIED_AZIMUTHAL_EQUIDISTANT), - METHOD_NAME_CODE(GUAM_PROJECTION), METHOD_NAME_CODE(BONNE), + METHOD_NAME_CODE(GUAM_PROJECTION), + METHOD_NAME_CODE(BONNE), METHOD_NAME_CODE(LAMBERT_CYLINDRICAL_EQUAL_AREA_SPHERICAL), METHOD_NAME_CODE(LAMBERT_CYLINDRICAL_EQUAL_AREA), METHOD_NAME_CODE(CASSINI_SOLDNER), @@ -898,16 +904,20 @@ const struct MethodNameCode methodNameCodes[] = { METHOD_NAME_CODE(EQUIDISTANT_CYLINDRICAL_SPHERICAL), METHOD_NAME_CODE(HOTINE_OBLIQUE_MERCATOR_VARIANT_A), METHOD_NAME_CODE(HOTINE_OBLIQUE_MERCATOR_VARIANT_B), - METHOD_NAME_CODE(KROVAK_NORTH_ORIENTED), METHOD_NAME_CODE(KROVAK), + METHOD_NAME_CODE(KROVAK_NORTH_ORIENTED), + METHOD_NAME_CODE(KROVAK), METHOD_NAME_CODE(LAMBERT_AZIMUTHAL_EQUAL_AREA), METHOD_NAME_CODE(POPULAR_VISUALISATION_PSEUDO_MERCATOR), - METHOD_NAME_CODE(MERCATOR_VARIANT_A), METHOD_NAME_CODE(MERCATOR_VARIANT_B), + METHOD_NAME_CODE(MERCATOR_VARIANT_A), + METHOD_NAME_CODE(MERCATOR_VARIANT_B), METHOD_NAME_CODE(OBLIQUE_STEREOGRAPHIC), METHOD_NAME_CODE(AMERICAN_POLYCONIC), METHOD_NAME_CODE(POLAR_STEREOGRAPHIC_VARIANT_A), METHOD_NAME_CODE(POLAR_STEREOGRAPHIC_VARIANT_B), - METHOD_NAME_CODE(EQUAL_EARTH), METHOD_NAME_CODE(LABORDE_OBLIQUE_MERCATOR), - METHOD_NAME_CODE(VERTICAL_PERSPECTIVE), METHOD_NAME_CODE(COLOMBIA_URBAN), + METHOD_NAME_CODE(EQUAL_EARTH), + METHOD_NAME_CODE(LABORDE_OBLIQUE_MERCATOR), + METHOD_NAME_CODE(VERTICAL_PERSPECTIVE), + METHOD_NAME_CODE(COLOMBIA_URBAN), // Other conversions METHOD_NAME_CODE(CHANGE_VERTICAL_UNIT), METHOD_NAME_CODE(HEIGHT_DEPTH_REVERSAL), @@ -940,11 +950,15 @@ const struct MethodNameCode methodNameCodes[] = { METHOD_NAME_CODE(MOLODENSKY_BADEKAS_PV_GEOCENTRIC), METHOD_NAME_CODE(MOLODENSKY_BADEKAS_PV_GEOGRAPHIC_2D), METHOD_NAME_CODE(MOLODENSKY_BADEKAS_PV_GEOGRAPHIC_3D), - METHOD_NAME_CODE(MOLODENSKY), METHOD_NAME_CODE(ABRIDGED_MOLODENSKY), + METHOD_NAME_CODE(MOLODENSKY), + METHOD_NAME_CODE(ABRIDGED_MOLODENSKY), METHOD_NAME_CODE(GEOGRAPHIC2D_OFFSETS), METHOD_NAME_CODE(GEOGRAPHIC2D_WITH_HEIGHT_OFFSETS), - METHOD_NAME_CODE(GEOGRAPHIC3D_OFFSETS), METHOD_NAME_CODE(VERTICAL_OFFSET), - METHOD_NAME_CODE(NTV2), METHOD_NAME_CODE(NTV1), METHOD_NAME_CODE(NADCON), + METHOD_NAME_CODE(GEOGRAPHIC3D_OFFSETS), + METHOD_NAME_CODE(VERTICAL_OFFSET), + METHOD_NAME_CODE(NTV2), + METHOD_NAME_CODE(NTV1), + METHOD_NAME_CODE(NADCON), METHOD_NAME_CODE(VERTCON), METHOD_NAME_CODE(GEOCENTRIC_TRANSLATION_BY_GRID_INTERPOLATION_IGN), }; @@ -963,7 +977,8 @@ const struct ParamNameCode paramNameCodes[] = { PARAM_NAME_CODE(LATITUDE_OF_NATURAL_ORIGIN), PARAM_NAME_CODE(LONGITUDE_OF_NATURAL_ORIGIN), PARAM_NAME_CODE(SCALE_FACTOR_AT_NATURAL_ORIGIN), - PARAM_NAME_CODE(FALSE_EASTING), PARAM_NAME_CODE(FALSE_NORTHING), + PARAM_NAME_CODE(FALSE_EASTING), + PARAM_NAME_CODE(FALSE_NORTHING), PARAM_NAME_CODE(LATITUDE_PROJECTION_CENTRE), PARAM_NAME_CODE(LONGITUDE_PROJECTION_CENTRE), PARAM_NAME_CODE(AZIMUTH_INITIAL_LINE), @@ -994,21 +1009,32 @@ const struct ParamNameCode paramNameCodes[] = { PARAM_NAME_CODE(VERTICAL_OFFSET_FILE), PARAM_NAME_CODE(LATITUDE_DIFFERENCE_FILE), PARAM_NAME_CODE(LONGITUDE_DIFFERENCE_FILE), - PARAM_NAME_CODE(UNIT_CONVERSION_SCALAR), PARAM_NAME_CODE(LATITUDE_OFFSET), - PARAM_NAME_CODE(LONGITUDE_OFFSET), PARAM_NAME_CODE(VERTICAL_OFFSET), - PARAM_NAME_CODE(GEOID_UNDULATION), PARAM_NAME_CODE(A0), PARAM_NAME_CODE(A1), - PARAM_NAME_CODE(A2), PARAM_NAME_CODE(B0), PARAM_NAME_CODE(B1), - PARAM_NAME_CODE(B2), PARAM_NAME_CODE(X_AXIS_TRANSLATION), - PARAM_NAME_CODE(Y_AXIS_TRANSLATION), PARAM_NAME_CODE(Z_AXIS_TRANSLATION), - PARAM_NAME_CODE(X_AXIS_ROTATION), PARAM_NAME_CODE(Y_AXIS_ROTATION), - PARAM_NAME_CODE(Z_AXIS_ROTATION), PARAM_NAME_CODE(SCALE_DIFFERENCE), + PARAM_NAME_CODE(UNIT_CONVERSION_SCALAR), + PARAM_NAME_CODE(LATITUDE_OFFSET), + PARAM_NAME_CODE(LONGITUDE_OFFSET), + PARAM_NAME_CODE(VERTICAL_OFFSET), + PARAM_NAME_CODE(GEOID_UNDULATION), + PARAM_NAME_CODE(A0), + PARAM_NAME_CODE(A1), + PARAM_NAME_CODE(A2), + PARAM_NAME_CODE(B0), + PARAM_NAME_CODE(B1), + PARAM_NAME_CODE(B2), + PARAM_NAME_CODE(X_AXIS_TRANSLATION), + PARAM_NAME_CODE(Y_AXIS_TRANSLATION), + PARAM_NAME_CODE(Z_AXIS_TRANSLATION), + PARAM_NAME_CODE(X_AXIS_ROTATION), + PARAM_NAME_CODE(Y_AXIS_ROTATION), + PARAM_NAME_CODE(Z_AXIS_ROTATION), + PARAM_NAME_CODE(SCALE_DIFFERENCE), PARAM_NAME_CODE(RATE_X_AXIS_TRANSLATION), PARAM_NAME_CODE(RATE_Y_AXIS_TRANSLATION), PARAM_NAME_CODE(RATE_Z_AXIS_TRANSLATION), PARAM_NAME_CODE(RATE_X_AXIS_ROTATION), PARAM_NAME_CODE(RATE_Y_AXIS_ROTATION), PARAM_NAME_CODE(RATE_Z_AXIS_ROTATION), - PARAM_NAME_CODE(RATE_SCALE_DIFFERENCE), PARAM_NAME_CODE(REFERENCE_EPOCH), + PARAM_NAME_CODE(RATE_SCALE_DIFFERENCE), + PARAM_NAME_CODE(REFERENCE_EPOCH), PARAM_NAME_CODE(TRANSFORMATION_REFERENCE_EPOCH), PARAM_NAME_CODE(ORDINATE_1_EVAL_POINT), PARAM_NAME_CODE(ORDINATE_2_EVAL_POINT), diff --git a/src/iso19111/operation/singleoperation.cpp b/src/iso19111/operation/singleoperation.cpp index b32b61cd..6812819c 100644 --- a/src/iso19111/operation/singleoperation.cpp +++ b/src/iso19111/operation/singleoperation.cpp @@ -103,10 +103,8 @@ GridDescription::GridDescription(const GridDescription &) = default; GridDescription::GridDescription(GridDescription &&other) noexcept : shortName(std::move(other.shortName)), fullName(std::move(other.fullName)), - packageName(std::move(other.packageName)), - url(std::move(other.url)), - directDownload(other.directDownload), - openLicense(other.openLicense), + packageName(std::move(other.packageName)), url(std::move(other.url)), + directDownload(other.directDownload), openLicense(other.openLicense), available(other.available) {} //! @endcond @@ -1108,8 +1106,8 @@ SingleOperation::parameterValue(const std::string ¶mName, * @param epsg_code the parameter EPSG code * @return the value, or nullptr if not found. */ -const ParameterValuePtr &SingleOperation::parameterValue(int epsg_code) const - noexcept { +const ParameterValuePtr & +SingleOperation::parameterValue(int epsg_code) const noexcept { for (const auto &genOpParamvalue : parameterValues()) { auto opParamvalue = dynamic_cast<const OperationParameterValue *>( genOpParamvalue.get()); @@ -1160,8 +1158,8 @@ SingleOperation::parameterValueMeasure(int epsg_code) const noexcept { //! @cond Doxygen_Suppress -double SingleOperation::parameterValueNumericAsSI(int epsg_code) const - noexcept { +double +SingleOperation::parameterValueNumericAsSI(int epsg_code) const noexcept { const auto &val = parameterValue(epsg_code); if (val && val->type() == ParameterValue::Type::MEASURE) { return val->value().getSIValue(); @@ -1179,8 +1177,8 @@ double SingleOperation::parameterValueNumeric( } double SingleOperation::parameterValueNumeric( - const char *param_name, const common::UnitOfMeasure &targetUnit) const - noexcept { + const char *param_name, + const common::UnitOfMeasure &targetUnit) const noexcept { const auto &val = parameterValue(param_name, 0); if (val && val->type() == ParameterValue::Type::MEASURE) { return val->value().convertToUnit(targetUnit); diff --git a/src/iso19111/operation/transformation.cpp b/src/iso19111/operation/transformation.cpp index 932b9e4e..984f2756 100644 --- a/src/iso19111/operation/transformation.cpp +++ b/src/iso19111/operation/transformation.cpp @@ -268,23 +268,20 @@ Transformation::getTOWGS84Parameters() const // throw(io::FormattingException) } else if (epsg_code == EPSG_CODE_PARAMETER_X_AXIS_ROTATION) { params[3] = fixNegativeZero( - rotSign * - measure.convertToUnit( - common::UnitOfMeasure::ARC_SECOND)); + rotSign * measure.convertToUnit( + common::UnitOfMeasure::ARC_SECOND)); foundRotX = true; } else if (epsg_code == EPSG_CODE_PARAMETER_Y_AXIS_ROTATION) { params[4] = fixNegativeZero( - rotSign * - measure.convertToUnit( - common::UnitOfMeasure::ARC_SECOND)); + rotSign * measure.convertToUnit( + common::UnitOfMeasure::ARC_SECOND)); foundRotY = true; } else if (epsg_code == EPSG_CODE_PARAMETER_Z_AXIS_ROTATION) { params[5] = fixNegativeZero( - rotSign * - measure.convertToUnit( - common::UnitOfMeasure::ARC_SECOND)); + rotSign * measure.convertToUnit( + common::UnitOfMeasure::ARC_SECOND)); foundRotZ = true; } else if (epsg_code == EPSG_CODE_PARAMETER_SCALE_DIFFERENCE) { @@ -2178,14 +2175,13 @@ TransformationNNPtr Transformation::substitutePROJAlternativeGridNames( } } const auto &horizontalGridName = - !NTv1Filename.empty() ? NTv1Filename : !NTv2Filename.empty() - ? NTv2Filename - : lasFilename; + !NTv1Filename.empty() + ? NTv1Filename + : !NTv2Filename.empty() ? NTv2Filename : lasFilename; - if (!horizontalGridName.empty() && - databaseContext->lookForGridAlternative(horizontalGridName, - projFilename, projGridFormat, - inverseDirection)) { + if (!horizontalGridName.empty() && databaseContext->lookForGridAlternative( + horizontalGridName, projFilename, + projGridFormat, inverseDirection)) { if (horizontalGridName == projFilename) { if (inverseDirection) { @@ -2296,13 +2292,14 @@ TransformationNNPtr Transformation::substitutePROJAlternativeGridNames( EPSG_CODE_PARAMETER_GEOID_CORRECTION_FILENAME)}; #ifdef disabled_for_now if (inverseDirection) { - return create(createPropertiesForInverse( - self.as_nullable().get(), true, false), - targetCRS(), sourceCRS(), nullptr, - createSimilarPropertiesMethod(method()), - parameters, {ParameterValue::createFilename( - projFilename)}, - coordinateOperationAccuracies()) + return create( + createPropertiesForInverse( + self.as_nullable().get(), true, false), + targetCRS(), sourceCRS(), nullptr, + createSimilarPropertiesMethod(method()), + parameters, + {ParameterValue::createFilename(projFilename)}, + coordinateOperationAccuracies()) ->inverseAsTransformation(); } else #endif @@ -2373,13 +2370,14 @@ TransformationNNPtr Transformation::substitutePROJAlternativeGridNames( createOpParamNameEPSGCode( EPSG_CODE_PARAMETER_VERTICAL_OFFSET_FILE)}; if (inverseDirection) { - return create(createPropertiesForInverse( - self.as_nullable().get(), true, false), - targetCRS(), sourceCRS(), nullptr, - createSimilarPropertiesMethod(method()), - parameters, {ParameterValue::createFilename( - projFilename)}, - coordinateOperationAccuracies()) + return create( + createPropertiesForInverse( + self.as_nullable().get(), true, false), + targetCRS(), sourceCRS(), nullptr, + createSimilarPropertiesMethod(method()), + parameters, + {ParameterValue::createFilename(projFilename)}, + coordinateOperationAccuracies()) ->inverseAsTransformation(); } else { return create( @@ -2985,9 +2983,9 @@ void Transformation::_exportToPROJString( const auto &hGridShiftFilename = !HorizontalShiftGTIFFFilename.empty() ? HorizontalShiftGTIFFFilename - : !NTv1Filename.empty() ? NTv1Filename : !NTv2Filename.empty() - ? NTv2Filename - : CTABLE2Filename; + : !NTv1Filename.empty() + ? NTv1Filename + : !NTv2Filename.empty() ? NTv2Filename : CTABLE2Filename; if (!hGridShiftFilename.empty()) { auto sourceCRSGeog = extractGeographicCRSIfGeographicCRSOrEquivalent(sourceCRS()); @@ -3282,5 +3280,5 @@ void Transformation::_exportToPROJString( throw io::FormattingException("Unimplemented"); } -} // namespace crs +} // namespace operation NS_PROJ_END diff --git a/src/networkfilemanager.cpp b/src/networkfilemanager.cpp index 102d3d15..b68a60a3 100644 --- a/src/networkfilemanager.cpp +++ b/src/networkfilemanager.cpp @@ -53,7 +53,7 @@ class MyMutex { // cppcheck-suppress functionStatic void unlock() { pj_release_lock(); } }; -} +} // namespace #else #include <mutex> #define MyMutex std::mutex @@ -839,50 +839,51 @@ void NetworkChunkCache::insert(PJ_CONTEXT *ctx, const std::string &url, // Lambda to recycle an existing entry that was either invalidated, or // least recently used. - const auto reuseExistingEntry = [ctx, &blob, &diskCache, hDB, &url, - chunkIdx, &dataPtr]( - std::unique_ptr<SQLiteStatement> &stmtIn) { - const auto chunk_id = stmtIn->getInt64(); - const auto data_id = stmtIn->getInt64(); - if (data_id <= 0) { - pj_log(ctx, PJ_LOG_ERROR, "data_id <= 0"); - return; - } + const auto reuseExistingEntry = + [ctx, &blob, &diskCache, hDB, &url, chunkIdx, + &dataPtr](std::unique_ptr<SQLiteStatement> &stmtIn) { + const auto chunk_id = stmtIn->getInt64(); + const auto data_id = stmtIn->getInt64(); + if (data_id <= 0) { + pj_log(ctx, PJ_LOG_ERROR, "data_id <= 0"); + return; + } - auto l_stmt = - diskCache->prepare("UPDATE chunk_data SET data = ? WHERE id = ?"); - if (!l_stmt) - return; - l_stmt->bindBlob(blob.data(), blob.size()); - l_stmt->bindInt64(data_id); - { - const auto ret2 = l_stmt->execute(); - if (ret2 != SQLITE_DONE) { - pj_log(ctx, PJ_LOG_ERROR, "%s", sqlite3_errmsg(hDB)); + auto l_stmt = diskCache->prepare( + "UPDATE chunk_data SET data = ? WHERE id = ?"); + if (!l_stmt) return; + l_stmt->bindBlob(blob.data(), blob.size()); + l_stmt->bindInt64(data_id); + { + const auto ret2 = l_stmt->execute(); + if (ret2 != SQLITE_DONE) { + pj_log(ctx, PJ_LOG_ERROR, "%s", sqlite3_errmsg(hDB)); + return; + } } - } - l_stmt = diskCache->prepare("UPDATE chunks SET url = ?, " - "offset = ?, data_size = ?, data_id = ? " - "WHERE id = ?"); - if (!l_stmt) - return; - l_stmt->bindText(url.c_str()); - l_stmt->bindInt64(chunkIdx * DOWNLOAD_CHUNK_SIZE); - l_stmt->bindInt64(dataPtr->size()); - l_stmt->bindInt64(data_id); - l_stmt->bindInt64(chunk_id); - { - const auto ret2 = l_stmt->execute(); - if (ret2 != SQLITE_DONE) { - pj_log(ctx, PJ_LOG_ERROR, "%s", sqlite3_errmsg(hDB)); + l_stmt = + diskCache->prepare("UPDATE chunks SET url = ?, " + "offset = ?, data_size = ?, data_id = ? " + "WHERE id = ?"); + if (!l_stmt) return; + l_stmt->bindText(url.c_str()); + l_stmt->bindInt64(chunkIdx * DOWNLOAD_CHUNK_SIZE); + l_stmt->bindInt64(dataPtr->size()); + l_stmt->bindInt64(data_id); + l_stmt->bindInt64(chunk_id); + { + const auto ret2 = l_stmt->execute(); + if (ret2 != SQLITE_DONE) { + pj_log(ctx, PJ_LOG_ERROR, "%s", sqlite3_errmsg(hDB)); + return; + } } - } - diskCache->move_to_head(chunk_id); - }; + diskCache->move_to_head(chunk_id); + }; // Find if there is an invalidated chunk we can reuse stmt = diskCache->prepare( @@ -2017,16 +2018,16 @@ int proj_context_set_network_callbacks( // --------------------------------------------------------------------------- /** Enable or disable network access. -* -* This overrides the default endpoint in the PROJ configuration file or with -* the PROJ_NETWORK environment variable. -* -* @param ctx PROJ context, or NULL -* @param enable TRUE if network access is allowed. -* @return TRUE if network access is possible. That is either libcurl is -* available, or an alternate interface has been set. -* @since 7.0 -*/ + * + * This overrides the default endpoint in the PROJ configuration file or with + * the PROJ_NETWORK environment variable. + * + * @param ctx PROJ context, or NULL + * @param enable TRUE if network access is allowed. + * @return TRUE if network access is possible. That is either libcurl is + * available, or an alternate interface has been set. + * @since 7.0 + */ int proj_context_set_enable_network(PJ_CONTEXT *ctx, int enable) { if (ctx == nullptr) { ctx = pj_get_default_ctx(); @@ -2046,11 +2047,11 @@ int proj_context_set_enable_network(PJ_CONTEXT *ctx, int enable) { // --------------------------------------------------------------------------- /** Return if network access is enabled. -* -* @param ctx PROJ context, or NULL -* @return TRUE if network access has been enabled -* @since 7.0 -*/ + * + * @param ctx PROJ context, or NULL + * @return TRUE if network access has been enabled + * @since 7.0 + */ int proj_context_is_network_enabled(PJ_CONTEXT *ctx) { if (ctx == nullptr) { ctx = pj_get_default_ctx(); @@ -2074,14 +2075,14 @@ int proj_context_is_network_enabled(PJ_CONTEXT *ctx) { // --------------------------------------------------------------------------- /** Define the URL endpoint to query for remote grids. -* -* This overrides the default endpoint in the PROJ configuration file or with -* the PROJ_NETWORK_ENDPOINT environment variable. -* -* @param ctx PROJ context, or NULL -* @param url Endpoint URL. Must NOT be NULL. -* @since 7.0 -*/ + * + * This overrides the default endpoint in the PROJ configuration file or with + * the PROJ_NETWORK_ENDPOINT environment variable. + * + * @param ctx PROJ context, or NULL + * @param url Endpoint URL. Must NOT be NULL. + * @since 7.0 + */ void proj_context_set_url_endpoint(PJ_CONTEXT *ctx, const char *url) { if (ctx == nullptr) { ctx = pj_get_default_ctx(); @@ -2094,13 +2095,13 @@ void proj_context_set_url_endpoint(PJ_CONTEXT *ctx, const char *url) { // --------------------------------------------------------------------------- /** Enable or disable the local cache of grid chunks -* -* This overrides the setting in the PROJ configuration file. -* -* @param ctx PROJ context, or NULL -* @param enabled TRUE if the cache is enabled. -* @since 7.0 -*/ + * + * This overrides the setting in the PROJ configuration file. + * + * @param ctx PROJ context, or NULL + * @param enabled TRUE if the cache is enabled. + * @since 7.0 + */ void proj_grid_cache_set_enable(PJ_CONTEXT *ctx, int enabled) { if (ctx == nullptr) { ctx = pj_get_default_ctx(); @@ -2113,13 +2114,13 @@ void proj_grid_cache_set_enable(PJ_CONTEXT *ctx, int enabled) { // --------------------------------------------------------------------------- /** Override, for the considered context, the path and file of the local -* cache of grid chunks. -* -* @param ctx PROJ context, or NULL -* @param fullname Full name to the cache (encoded in UTF-8). If set to NULL, -* caching will be disabled. -* @since 7.0 -*/ + * cache of grid chunks. + * + * @param ctx PROJ context, or NULL + * @param fullname Full name to the cache (encoded in UTF-8). If set to NULL, + * caching will be disabled. + * @since 7.0 + */ void proj_grid_cache_set_filename(PJ_CONTEXT *ctx, const char *fullname) { if (ctx == nullptr) { ctx = pj_get_default_ctx(); @@ -2132,13 +2133,13 @@ void proj_grid_cache_set_filename(PJ_CONTEXT *ctx, const char *fullname) { // --------------------------------------------------------------------------- /** Override, for the considered context, the maximum size of the local -* cache of grid chunks. -* -* @param ctx PROJ context, or NULL -* @param max_size_MB Maximum size, in mega-bytes (1024*1024 bytes), or -* negative value to set unlimited size. -* @since 7.0 -*/ + * cache of grid chunks. + * + * @param ctx PROJ context, or NULL + * @param max_size_MB Maximum size, in mega-bytes (1024*1024 bytes), or + * negative value to set unlimited size. + * @since 7.0 + */ void proj_grid_cache_set_max_size(PJ_CONTEXT *ctx, int max_size_MB) { if (ctx == nullptr) { ctx = pj_get_default_ctx(); @@ -2160,12 +2161,12 @@ void proj_grid_cache_set_max_size(PJ_CONTEXT *ctx, int max_size_MB) { // --------------------------------------------------------------------------- /** Override, for the considered context, the time-to-live delay for -* re-checking if the cached properties of files are still up-to-date. -* -* @param ctx PROJ context, or NULL -* @param ttl_seconds Delay in seconds. Use negative value for no expiration. -* @since 7.0 -*/ + * re-checking if the cached properties of files are still up-to-date. + * + * @param ctx PROJ context, or NULL + * @param ttl_seconds Delay in seconds. Use negative value for no expiration. + * @since 7.0 + */ void proj_grid_cache_set_ttl(PJ_CONTEXT *ctx, int ttl_seconds) { if (ctx == nullptr) { ctx = pj_get_default_ctx(); @@ -2178,10 +2179,10 @@ void proj_grid_cache_set_ttl(PJ_CONTEXT *ctx, int ttl_seconds) { // --------------------------------------------------------------------------- /** Clear the local cache of grid chunks. -* -* @param ctx PROJ context, or NULL -* @since 7.0 -*/ + * + * @param ctx PROJ context, or NULL + * @since 7.0 + */ void proj_grid_cache_clear(PJ_CONTEXT *ctx) { if (ctx == nullptr) { ctx = pj_get_default_ctx(); diff --git a/src/quadtree.hpp b/src/quadtree.hpp index b744c83d..6c67b30e 100644 --- a/src/quadtree.hpp +++ b/src/quadtree.hpp @@ -101,7 +101,7 @@ template <class Feature> class QuadTree { public: /** Construct a new quadtree with the global bounds of all objects to be - * inserted */ + * inserted */ explicit QuadTree(const RectObj &globalBounds) : root(globalBounds) {} /** Add a new feature, with its bounds specified in featureBounds */ diff --git a/src/transformations/defmodel.cpp b/src/transformations/defmodel.cpp index 0d9f6690..443660c9 100644 --- a/src/transformations/defmodel.cpp +++ b/src/transformations/defmodel.cpp @@ -89,15 +89,17 @@ struct Grid : public GridPrototype { } } if (foundDesc && (!foundDescX || !foundDescY)) { - pj_log(ctx, PJ_LOG_ERROR, "grid %s : Found band description, " - "but not the ones expected", + pj_log(ctx, PJ_LOG_ERROR, + "grid %s : Found band description, " + "but not the ones expected", realGrid->name().c_str()); return false; } const auto unit = realGrid->unit(sampleX); if (!unit.empty() && unit != expectedUnit) { - pj_log(ctx, PJ_LOG_ERROR, "grid %s : Only unit=%s " - "currently handled for this mode", + pj_log(ctx, PJ_LOG_ERROR, + "grid %s : Only unit=%s " + "currently handled for this mode", realGrid->name().c_str(), expectedUnit.c_str()); return false; } @@ -145,15 +147,17 @@ struct Grid : public GridPrototype { } } if (foundDesc && !foundDescZ) { - pj_log(ctx, PJ_LOG_ERROR, "grid %s : Found band description, " - "but not the ones expected", + pj_log(ctx, PJ_LOG_ERROR, + "grid %s : Found band description, " + "but not the ones expected", realGrid->name().c_str()); return false; } const auto unit = realGrid->unit(sampleZ); if (!unit.empty() && unit != STR_METRE) { - pj_log(ctx, PJ_LOG_ERROR, "grid %s : Only unit=metre currently " - "handled for this mode", + pj_log(ctx, PJ_LOG_ERROR, + "grid %s : Only unit=metre currently " + "handled for this mode", realGrid->name().c_str()); return false; } diff --git a/src/transformations/defmodel.hpp b/src/transformations/defmodel.hpp index 6bf37d8b..7b511495 100644 --- a/src/transformations/defmodel.hpp +++ b/src/transformations/defmodel.hpp @@ -66,9 +66,9 @@ using json = nlohmann::json; class SpatialExtent { public: /** Parse the provided object as an extent. - * - * @throws ParsingException - */ + * + * @throws ParsingException + */ static SpatialExtent parse(const json &j); double minx() const { return mMinx; } @@ -130,9 +130,9 @@ class Epoch { class Component { public: /** Parse the provided object as a component. - * - * @throws ParsingException - */ + * + * @throws ParsingException + */ static Component parse(const json &j); /** Get a text description of the component. */ @@ -630,7 +630,7 @@ class Evaluator { // --------------------------------------------------------------------------- -} // namespace DeformationModel +} // namespace DEFORMATON_MODEL_NAMESPACE // --------------------------------------------------------------------------- diff --git a/src/transformations/defmodel_impl.hpp b/src/transformations/defmodel_impl.hpp index abd07286..afbf15ce 100644 --- a/src/transformations/defmodel_impl.hpp +++ b/src/transformations/defmodel_impl.hpp @@ -246,9 +246,8 @@ static double ISO8601ToDecimalYear(const std::string &dt) { throw ParsingException("Wrong formatting / invalid date-time for " + dt); } - return year + - (dayInYear * 86400 + hour * 3600 + min * 60 + sec) / - (isLeapYear ? 86400. * 366 : 86400. * 365); + return year + (dayInYear * 86400 + hour * 3600 + min * 60 + sec) / + (isLeapYear ? 86400. * 366 : 86400. * 365); } // --------------------------------------------------------------------------- @@ -1004,7 +1003,9 @@ bool Evaluator<Grid, GridSet, EvaluatorIface>::forward( !grid->getLonLatOffset(ix1, iy1, dx11, dy11)) { return false; } - } else /* if (compEx->displacementType == DisplacementType::THREE_D) */ { + } else /* if (compEx->displacementType == DisplacementType::THREE_D) + */ + { double dz00 = 0; double dz01 = 0; double dz10 = 0; @@ -1051,7 +1052,9 @@ bool Evaluator<Grid, GridSet, EvaluatorIface>::forward( !grid->getEastingNorthingOffset(ix1, iy1, de11, dn11)) { return false; } - } else /* if (compEx->displacementType == DisplacementType::THREE_D) */ { + } else /* if (compEx->displacementType == DisplacementType::THREE_D) + */ + { double dz00 = 0; double dz01 = 0; double dz10 = 0; @@ -1117,14 +1120,12 @@ bool Evaluator<Grid, GridSet, EvaluatorIface>::forward( const double sinlam = gridwithCacheRef.smallResx ? lam_rel_to_cell_center * - (1 - - (1. / 6) * (lam_rel_to_cell_center * - lam_rel_to_cell_center)) + (1 - (1. / 6) * (lam_rel_to_cell_center * + lam_rel_to_cell_center)) : sin(lam_rel_to_cell_center); const double coslam = gridwithCacheRef.smallResx - ? (1 - - 0.5 * (lam_rel_to_cell_center * - lam_rel_to_cell_center)) + ? (1 - 0.5 * (lam_rel_to_cell_center * + lam_rel_to_cell_center)) : cos(lam_rel_to_cell_center); // Convert back from geocentric deltas to easting, northing @@ -1243,8 +1244,8 @@ bool Evaluator<Grid, GridSet, EvaluatorIface>::inverse( return false; } #ifdef DEBUG_DEFMODEL - iface.log("After forward: x=" + toString(x_new) + ", y=" + - toString(y_new)); + iface.log("After forward: x=" + toString(x_new) + + ", y=" + toString(y_new)); #endif const double dx = x_new - x; const double dy = y_new - y; diff --git a/src/transformations/tinshift_exceptions.hpp b/src/transformations/tinshift_exceptions.hpp index d6d71302..1d13c2b1 100644 --- a/src/transformations/tinshift_exceptions.hpp +++ b/src/transformations/tinshift_exceptions.hpp @@ -49,4 +49,4 @@ const char *ParsingException::what() const noexcept { return msg_.c_str(); } // --------------------------------------------------------------------------- -} // namespace DEFORMATON_MODEL_NAMESPACE +} // namespace TINSHIFT_NAMESPACE |
