Skip to content

Commit

Permalink
Merge pull request #2583 from rouault/improve_perf_createFromCRSCodes…
Browse files Browse the repository at this point in the history
…WithIntermediates

createFromCRSCodesWithIntermediates(): improve perf when no match
  • Loading branch information
rouault authored Mar 18, 2021
2 parents 1e4ad55 + 862cb97 commit d20145a
Showing 1 changed file with 16 additions and 0 deletions.
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

0 comments on commit d20145a

Please sign in to comment.