aboutsummaryrefslogtreecommitdiff
path: root/src/iso19111/c_api.cpp
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2019-02-18 09:45:18 +0100
committerGitHub <noreply@github.com>2019-02-18 09:45:18 +0100
commit4277e15cefae5bb1d49312498e0f626b652e7524 (patch)
tree189e5bc87ac99a73f515b3800c2e1898c732f7b3 /src/iso19111/c_api.cpp
parent455cb889e8259d8799f4cc9cce6b06ebe076f363 (diff)
parente8b2e2a36324006146406fb1fc89ce6ed863807f (diff)
downloadPROJ-4277e15cefae5bb1d49312498e0f626b652e7524.tar.gz
PROJ-4277e15cefae5bb1d49312498e0f626b652e7524.zip
Merge pull request #1276 from rouault/intermediate_crs_use_only_if_no_direct_transformation
Modify the default strategy of researching intermediate CRS to do it only if there is no direct transformation
Diffstat (limited to 'src/iso19111/c_api.cpp')
-rw-r--r--src/iso19111/c_api.cpp44
1 files changed, 33 insertions, 11 deletions
diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp
index 79732bab..b3f200fe 100644
--- a/src/iso19111/c_api.cpp
+++ b/src/iso19111/c_api.cpp
@@ -1475,7 +1475,8 @@ PJ *proj_crs_create_bound_crs(PJ_CONTEXT *ctx, const PJ *base_crs,
* @param options null-terminated list of options, or NULL. Currently
* supported options are:
* <ul>
- * <li>ALLOW_INTERMEDIATE_CRS=YES/NO. Defaults to NO. When set to YES,
+ * <li>ALLOW_INTERMEDIATE_CRS=ALWAYS/IF_NO_DIRECT_TRANSFORMATION/NEVER. Defaults
+ * to NEVER. When set to ALWAYS/IF_NO_DIRECT_TRANSFORMATION,
* intermediate CRS may be considered when computing the possible
* transformations. Slower.</li>
* </ul>
@@ -1493,11 +1494,18 @@ PJ *proj_crs_create_bound_crs_to_WGS84(PJ_CONTEXT *ctx, const PJ *crs,
}
auto dbContext = getDBcontextNoException(ctx, __FUNCTION__);
try {
- bool allowIntermediateCRS = false;
+ CoordinateOperationContext::IntermediateCRSUse allowIntermediateCRS =
+ CoordinateOperationContext::IntermediateCRSUse::NEVER;
for (auto iter = options; iter && iter[0]; ++iter) {
const char *value;
if ((value = getOptionValue(*iter, "ALLOW_INTERMEDIATE_CRS="))) {
- allowIntermediateCRS = ci_equal(value, "YES");
+ if (ci_equal(value, "YES") || ci_equal(value, "ALWAYS")) {
+ allowIntermediateCRS =
+ CoordinateOperationContext::IntermediateCRSUse::ALWAYS;
+ } else if (ci_equal(value, "IF_NO_DIRECT_TRANSFORMATION")) {
+ allowIntermediateCRS = CoordinateOperationContext::
+ IntermediateCRSUse::IF_NO_DIRECT_TRANSFORMATION;
+ }
} else {
std::string msg("Unknown option :");
msg += *iter;
@@ -6378,22 +6386,36 @@ void proj_operation_factory_context_set_use_proj_alternative_grid_names(
* The current implementation is limited to researching one intermediate
* step.
*
- * By default, all potential C candidates will be used.
- * proj_operation_factory_context_set_allowed_intermediate_crs()
- * can be used to restrict them.
- *
- * The default is true.
+ * By default, with the IF_NO_DIRECT_TRANSFORMATION stratgey, all potential
+ * C candidates will be used if there is no direct tranformation.
*
* @param ctx PROJ context, or NULL for default context
* @param factory_ctx Operation factory context. must not be NULL
- * @param allow whether intermediate CRS may be used.
+ * @param use whether and how intermediate CRS may be used.
*/
void proj_operation_factory_context_set_allow_use_intermediate_crs(
- PJ_CONTEXT *ctx, PJ_OPERATION_FACTORY_CONTEXT *factory_ctx, int allow) {
+ PJ_CONTEXT *ctx, PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
+ PROJ_INTERMEDIATE_CRS_USE use) {
SANITIZE_CTX(ctx);
assert(factory_ctx);
try {
- factory_ctx->operationContext->setAllowUseIntermediateCRS(allow != 0);
+ switch (use) {
+ case PROJ_INTERMEDIATE_CRS_USE_ALWAYS:
+ factory_ctx->operationContext->setAllowUseIntermediateCRS(
+ CoordinateOperationContext::IntermediateCRSUse::ALWAYS);
+ break;
+
+ case PROJ_INTERMEDIATE_CRS_USE_IF_NO_DIRECT_TRANSFORMATION:
+ factory_ctx->operationContext->setAllowUseIntermediateCRS(
+ CoordinateOperationContext::IntermediateCRSUse::
+ IF_NO_DIRECT_TRANSFORMATION);
+ break;
+
+ case PROJ_INTERMEDIATE_CRS_USE_NEVER:
+ factory_ctx->operationContext->setAllowUseIntermediateCRS(
+ CoordinateOperationContext::IntermediateCRSUse::NEVER);
+ break;
+ }
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}