Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createFromCRSCodesWithIntermediates(): improve perf when no match #2583

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/iso19111/factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
?
Expand Down