From cae698abe380b3823c3f08151c25097031ae091f Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 6 Dec 2018 22:51:27 +0100 Subject: Speed-up createBoundCRSToWGS84IfPossible() --- src/c_api.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src/c_api.cpp') diff --git a/src/c_api.cpp b/src/c_api.cpp index 78ca1c24..03a0c0bd 100644 --- a/src/c_api.cpp +++ b/src/c_api.cpp @@ -1319,11 +1319,19 @@ PJ_OBJ *proj_obj_crs_create_bound_crs(PJ_CONTEXT *ctx, const PJ_OBJ *base_crs, * * @param ctx PROJ context, or NULL for default context * @param crs Objet of type CRS (must not be NULL) + * @param options null-terminated list of options, or NULL. Currently + * supported options are: + * * @return Object that must be unreferenced with proj_obj_unref(), or NULL * in case of error. */ PJ_OBJ *proj_obj_crs_create_bound_crs_to_WGS84(PJ_CONTEXT *ctx, - const PJ_OBJ *crs) { + const PJ_OBJ *crs, + const char *const *options) { SANITIZE_CTX(ctx); assert(crs); auto l_crs = dynamic_cast(crs->obj.get()); @@ -1333,8 +1341,20 @@ PJ_OBJ *proj_obj_crs_create_bound_crs_to_WGS84(PJ_CONTEXT *ctx, } auto dbContext = getDBcontextNoException(ctx, __FUNCTION__); try { - return PJ_OBJ::create( - l_crs->createBoundCRSToWGS84IfPossible(dbContext)); + bool allowIntermediateCRS = false; + for (auto iter = options; iter && iter[0]; ++iter) { + const char *value; + if ((value = getOptionValue(*iter, "ALLOW_INTERMEDIATE_CRS="))) { + allowIntermediateCRS = ci_equal(value, "YES"); + } else { + std::string msg("Unknown option :"); + msg += *iter; + proj_log_error(ctx, __FUNCTION__, msg.c_str()); + return nullptr; + } + } + return PJ_OBJ::create(l_crs->createBoundCRSToWGS84IfPossible( + dbContext, allowIntermediateCRS)); } catch (const std::exception &e) { proj_log_error(ctx, __FUNCTION__, e.what()); return nullptr; -- cgit v1.2.3