aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-03-18 16:04:19 +0100
committerGitHub <noreply@github.com>2021-03-18 16:04:19 +0100
commitd20145a979e32f0d2dc09398a4e8f9d2eccf8820 (patch)
tree437756ba4bff7f0ae3b1ff98c5dbb16e87f327a5
parent1e4ad55fbe8f34228f0fd2bbab2e9dc57910621d (diff)
parent862cb97c22d5ddab3b91f44a4d1b2267c234bd0f (diff)
downloadPROJ-d20145a979e32f0d2dc09398a4e8f9d2eccf8820.tar.gz
PROJ-d20145a979e32f0d2dc09398a4e8f9d2eccf8820.zip
Merge pull request #2583 from rouault/improve_perf_createFromCRSCodesWithIntermediates
createFromCRSCodesWithIntermediates(): improve perf when no match
-rw-r--r--src/iso19111/factory.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp
index 421cdb88..1ec741e1 100644
--- a/src/iso19111/factory.cpp
+++ b/src/iso19111/factory.cpp
@@ -6081,6 +6081,22 @@ AuthorityFactory::createFromCRSCodesWithIntermediates(
return listTmp;
}
+ const auto CheckIfHasOperations = [=](const std::string &auth_name,
+ const std::string &code) {
+ return !(d->run("SELECT 1 FROM coordinate_operation_view WHERE "
+ "(source_crs_auth_name = ? AND source_crs_code = ?) OR "
+ "(target_crs_auth_name = ? AND target_crs_code = ?)",
+ {auth_name, code, auth_name, code})
+ .empty());
+ };
+
+ // If the source or target CRS are not the source or target of an operation,
+ // do not run the next costly requests.
+ if (!CheckIfHasOperations(sourceCRSAuthName, sourceCRSCode) ||
+ !CheckIfHasOperations(targetCRSAuthName, targetCRSCode)) {
+ return listTmp;
+ }
+
const std::string sqlProlog(
discardSuperseded
?