diff options
| -rw-r--r-- | include/proj/io.hpp | 2 | ||||
| -rw-r--r-- | scripts/reference_exported_symbols.txt | 1 | ||||
| -rw-r--r-- | src/apps/projinfo.cpp | 78 | ||||
| -rw-r--r-- | src/iso19111/c_api.cpp | 19 |
4 files changed, 58 insertions, 42 deletions
diff --git a/include/proj/io.hpp b/include/proj/io.hpp index eefec11e..47703442 100644 --- a/include/proj/io.hpp +++ b/include/proj/io.hpp @@ -922,7 +922,7 @@ class PROJ_GCC_DLL DatabaseContext { const std::string &version, std::string &versionedAuthNameOut); - PROJ_INTERNAL std::vector<std::string> + PROJ_DLL std::vector<std::string> getVersionedAuthoritiesFromName(const std::string &authName); //! @endcond diff --git a/scripts/reference_exported_symbols.txt b/scripts/reference_exported_symbols.txt index 6cb734e2..682f5d39 100644 --- a/scripts/reference_exported_symbols.txt +++ b/scripts/reference_exported_symbols.txt @@ -371,6 +371,7 @@ osgeo::proj::io::DatabaseContext::getInsertStatementsFor(dropbox::oxygen::nn<std osgeo::proj::io::DatabaseContext::getMetadata(char const*) const osgeo::proj::io::DatabaseContext::getPath() const osgeo::proj::io::DatabaseContext::getSqliteHandle() const +osgeo::proj::io::DatabaseContext::getVersionedAuthoritiesFromName(std::string const&) osgeo::proj::io::DatabaseContext::lookForGridInfo(std::string const&, bool, std::string&, std::string&, std::string&, bool&, bool&, bool&) const osgeo::proj::io::DatabaseContext::startInsertStatementsSession() osgeo::proj::io::DatabaseContext::stopInsertStatementsSession() diff --git a/src/apps/projinfo.cpp b/src/apps/projinfo.cpp index 5dfc4f72..add4119d 100644 --- a/src/apps/projinfo.cpp +++ b/src/apps/projinfo.cpp @@ -968,7 +968,7 @@ int main(int argc, char **argv) { double minimumAccuracy = -1; bool outputAll = false; bool dumpDbStructure = false; - std::string listCRS; + std::string listCRSFilter; bool listCRSSpecified = false; for (int i = 1; i < argc; i++) { @@ -1251,7 +1251,7 @@ int main(int argc, char **argv) { listCRSSpecified = true; if (i + 1 < argc && argv[i + 1][0] != '-') { i++; - listCRS = argv[i]; + listCRSFilter = argv[i]; } } else if (ci_equal(arg, "--searchpaths")) { #ifdef _WIN32 @@ -1354,11 +1354,11 @@ int main(int argc, char **argv) { if (listCRSSpecified) { bool allow_deprecated = false; std::set<AuthorityFactory::ObjectType> types; - auto tokens = split(listCRS, ','); - if (listCRS.empty()) { + auto tokens = split(listCRSFilter, ','); + if (listCRSFilter.empty()) { tokens.clear(); } - for (auto token : tokens) { + for (const auto &token : tokens) { if (ci_equal(token, "allow_deprecated")) { allow_deprecated = true; } else if (ci_equal(token, "geodetic")) { @@ -1397,44 +1397,50 @@ int main(int argc, char **argv) { } for (const auto &auth_name : allowedAuthorities) { try { - auto factory = - AuthorityFactory::create(NN_NO_CHECK(dbContext), auth_name); - const auto list = factory->getCRSInfoList(); - for (const auto &info : list) { - if (!allow_deprecated && info.deprecated) { - continue; - } - if (!types.empty() && - types.find(info.type) == types.end()) { - continue; - } - if (bboxFilter) { - if (!info.bbox_valid) { + auto actualAuthNames = + dbContext->getVersionedAuthoritiesFromName(auth_name); + if (actualAuthNames.empty()) + actualAuthNames.push_back(auth_name); + for (const auto &actualAuthName : actualAuthNames) { + auto factory = AuthorityFactory::create( + NN_NO_CHECK(dbContext), actualAuthName); + const auto list = factory->getCRSInfoList(); + for (const auto &info : list) { + if (!allow_deprecated && info.deprecated) { + continue; + } + if (!types.empty() && + types.find(info.type) == types.end()) { continue; } - auto crsExtent = Extent::createFromBBOX( - info.west_lon_degree, info.south_lat_degree, - info.east_lon_degree, info.north_lat_degree); - if (spatialCriterion == - CoordinateOperationContext::SpatialCriterion:: - STRICT_CONTAINMENT) { - if (!bboxFilter->contains(crsExtent)) { + if (bboxFilter) { + if (!info.bbox_valid) { continue; } - } else { - if (!bboxFilter->intersects(crsExtent)) { - continue; + auto crsExtent = Extent::createFromBBOX( + info.west_lon_degree, info.south_lat_degree, + info.east_lon_degree, info.north_lat_degree); + if (spatialCriterion == + CoordinateOperationContext::SpatialCriterion:: + STRICT_CONTAINMENT) { + if (!bboxFilter->contains(crsExtent)) { + continue; + } + } else { + if (!bboxFilter->intersects(crsExtent)) { + continue; + } } + } else if (!area.empty() && + tolower(info.areaName).find(areaLower) == + std::string::npos) { + continue; } - } else if (!area.empty() && - tolower(info.areaName).find(areaLower) == - std::string::npos) { - continue; + std::cout << info.authName << ":" << info.code << " \"" + << info.name << "\"" + << (info.deprecated ? " [deprecated]" : "") + << std::endl; } - std::cout << info.authName << ":" << info.code << " \"" - << info.name << "\"" - << (info.deprecated ? " [deprecated]" : "") - << std::endl; } } catch (const std::exception &e) { std::cerr << "ERROR: list-crs failed with: " << e.what() diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index a5e1bc81..9493452c 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -2766,10 +2766,19 @@ proj_get_crs_info_list_from_database(PJ_CONTEXT *ctx, const char *auth_name, PROJ_CRS_INFO **ret = nullptr; int i = 0; try { - auto factory = AuthorityFactory::create(getDBcontext(ctx), - auth_name ? auth_name : ""); - auto list = factory->getCRSInfoList(); - ret = new PROJ_CRS_INFO *[list.size() + 1]; + auto dbContext = getDBcontext(ctx); + const std::string authName = auth_name ? auth_name : ""; + auto actualAuthNames = + dbContext->getVersionedAuthoritiesFromName(authName); + if (actualAuthNames.empty()) + actualAuthNames.push_back(authName); + std::list<AuthorityFactory::CRSInfo> concatList; + for (const auto &actualAuthName : actualAuthNames) { + auto factory = AuthorityFactory::create(dbContext, actualAuthName); + auto list = factory->getCRSInfoList(); + concatList.splice(concatList.end(), std::move(list)); + } + ret = new PROJ_CRS_INFO *[concatList.size() + 1]; GeographicBoundingBoxPtr bbox; if (params && params->bbox_valid) { bbox = GeographicBoundingBox::create( @@ -2777,7 +2786,7 @@ proj_get_crs_info_list_from_database(PJ_CONTEXT *ctx, const char *auth_name, params->east_lon_degree, params->north_lat_degree) .as_nullable(); } - for (const auto &info : list) { + for (const auto &info : concatList) { auto type = PJ_TYPE_CRS; if (info.type == AuthorityFactory::ObjectType::GEOGRAPHIC_2D_CRS) { type = PJ_TYPE_GEOGRAPHIC_2D_CRS; |
