MCPcopy Create free account
hub / github.com/OSGeo/PROJ / buildSqlLookForAuthNameCode

Function buildSqlLookForAuthNameCode

src/iso19111/factory.cpp:9923–9967  ·  view source on GitHub ↗

@cond Doxygen_Suppress

Source from the content-addressed store, hash-verified

9921
9922//! @cond Doxygen_Suppress
9923static std::string buildSqlLookForAuthNameCode(
9924 const std::list<std::pair<crs::CRSNNPtr, int>> &list, ListOfParams &params,
9925 const char *prefixField) {
9926 std::string sql("(");
9927
9928 std::set<std::string> authorities;
9929 for (const auto &crs : list) {
9930 auto boundCRS = dynamic_cast<crs::BoundCRS *>(crs.first.get());
9931 const auto &ids = boundCRS ? boundCRS->baseCRS()->identifiers()
9932 : crs.first->identifiers();
9933 if (!ids.empty()) {
9934 authorities.insert(*(ids[0]->codeSpace()));
9935 }
9936 }
9937 bool firstAuth = true;
9938 for (const auto &auth_name : authorities) {
9939 if (!firstAuth) {
9940 sql += " OR ";
9941 }
9942 firstAuth = false;
9943 sql += "( ";
9944 sql += prefixField;
9945 sql += "auth_name = ? AND ";
9946 sql += prefixField;
9947 sql += "code IN (";
9948 params.emplace_back(auth_name);
9949 bool firstGeodCRSForAuth = true;
9950 for (const auto &crs : list) {
9951 auto boundCRS = dynamic_cast<crs::BoundCRS *>(crs.first.get());
9952 const auto &ids = boundCRS ? boundCRS->baseCRS()->identifiers()
9953 : crs.first->identifiers();
9954 if (!ids.empty() && *(ids[0]->codeSpace()) == auth_name) {
9955 if (!firstGeodCRSForAuth) {
9956 sql += ',';
9957 }
9958 firstGeodCRSForAuth = false;
9959 sql += '?';
9960 params.emplace_back(ids[0]->code());
9961 }
9962 }
9963 sql += "))";
9964 }
9965 sql += ')';
9966 return sql;
9967}
9968//! @endcond
9969
9970// ---------------------------------------------------------------------------

Calls 4

baseCRSMethod · 0.80
getMethod · 0.45
emptyMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected