\brief Return a list of objects, identifier by their name, with the name * on which the match occurred. * * The name on which the match occurred might be different from the object name, * if the match has been done on an alias name of that object. * * @param searchedName Searched name. Must be at least 2 character long. * @param allowedObjectTypes List of object types into which to search.
| 7995 | * @throw FactoryException |
| 7996 | */ |
| 7997 | std::list<AuthorityFactory::PairObjectName> |
| 7998 | AuthorityFactory::createObjectsFromNameEx( |
| 7999 | const std::string &searchedName, |
| 8000 | const std::vector<ObjectType> &allowedObjectTypes, bool approximateMatch, |
| 8001 | size_t limitResultCount) const { |
| 8002 | std::string searchedNameWithoutDeprecated(searchedName); |
| 8003 | bool deprecated = false; |
| 8004 | if (ends_with(searchedNameWithoutDeprecated, " (deprecated)")) { |
| 8005 | deprecated = true; |
| 8006 | searchedNameWithoutDeprecated.resize( |
| 8007 | searchedNameWithoutDeprecated.size() - strlen(" (deprecated)")); |
| 8008 | } |
| 8009 | |
| 8010 | const std::string canonicalizedSearchedName( |
| 8011 | metadata::Identifier::canonicalizeName(searchedNameWithoutDeprecated)); |
| 8012 | if (canonicalizedSearchedName.size() <= 1) { |
| 8013 | return {}; |
| 8014 | } |
| 8015 | |
| 8016 | std::string sql( |
| 8017 | "SELECT table_name, auth_name, code, name, deprecated, is_alias " |
| 8018 | "FROM ("); |
| 8019 | |
| 8020 | const auto getTableAndTypeConstraints = [&allowedObjectTypes, |
| 8021 | &searchedName]() { |
| 8022 | typedef std::pair<std::string, std::string> TableType; |
| 8023 | std::list<TableType> res; |
| 8024 | // Hide ESRI D_ vertical datums |
| 8025 | const bool startsWithDUnderscore = starts_with(searchedName, "D_"); |
| 8026 | if (allowedObjectTypes.empty()) { |
| 8027 | for (const auto &tableName : |
| 8028 | {"prime_meridian", "ellipsoid", "geodetic_datum", |
| 8029 | "vertical_datum", "geodetic_crs", "projected_crs", |
| 8030 | "vertical_crs", "compound_crs", "conversion", |
| 8031 | "helmert_transformation", "grid_transformation", |
| 8032 | "other_transformation", "concatenated_operation"}) { |
| 8033 | if (!(startsWithDUnderscore && |
| 8034 | strcmp(tableName, "vertical_datum") == 0)) { |
| 8035 | res.emplace_back(TableType(tableName, std::string())); |
| 8036 | } |
| 8037 | } |
| 8038 | } else { |
| 8039 | for (const auto type : allowedObjectTypes) { |
| 8040 | switch (type) { |
| 8041 | case ObjectType::PRIME_MERIDIAN: |
| 8042 | res.emplace_back( |
| 8043 | TableType("prime_meridian", std::string())); |
| 8044 | break; |
| 8045 | case ObjectType::ELLIPSOID: |
| 8046 | res.emplace_back(TableType("ellipsoid", std::string())); |
| 8047 | break; |
| 8048 | case ObjectType::DATUM: |
| 8049 | res.emplace_back( |
| 8050 | TableType("geodetic_datum", std::string())); |
| 8051 | if (!startsWithDUnderscore) { |
| 8052 | res.emplace_back( |
| 8053 | TableType("vertical_datum", std::string())); |
| 8054 | } |
no test coverage detected