diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2018-12-10 22:18:47 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2018-12-10 22:18:47 +0100 |
| commit | b51e1159cc59df1bc89f521ed0217f86550fd941 (patch) | |
| tree | f1d551b0a6ed2daab9a972d76f5ad8f64d3e2185 /src | |
| parent | 3e4fe5e6b5ddec8d426606ca996a81eced154adf (diff) | |
| download | PROJ-b51e1159cc59df1bc89f521ed0217f86550fd941.tar.gz PROJ-b51e1159cc59df1bc89f521ed0217f86550fd941.zip | |
C API: add a proj_coordoperation_get_method_info() method
Diffstat (limited to 'src')
| -rw-r--r-- | src/c_api.cpp | 49 | ||||
| -rw-r--r-- | src/proj.h | 11 |
2 files changed, 44 insertions, 16 deletions
diff --git a/src/c_api.cpp b/src/c_api.cpp index 539675e2..230b4492 100644 --- a/src/c_api.cpp +++ b/src/c_api.cpp @@ -1914,19 +1914,10 @@ void proj_free_string_list(PROJ_STRING_LIST list) { * * @param ctx PROJ context, or NULL for default context * @param crs Objet of type DerivedCRS or BoundCRSs (must not be NULL) - * @param out_method_name Pointer to a string value to store the method - * (projection) name. or NULL - * @param out_method_auth_name Pointer to a string value to store the method - * authority name. or NULL - * @param out_method_code Pointer to a string value to store the method - * code. or NULL * @return Object of type SingleOperation that must be unreferenced with * proj_obj_unref(), or NULL in case of error. */ -PJ_OBJ *proj_obj_crs_get_coordoperation(PJ_CONTEXT *ctx, const PJ_OBJ *crs, - const char **out_method_name, - const char **out_method_auth_name, - const char **out_method_code) { +PJ_OBJ *proj_obj_crs_get_coordoperation(PJ_CONTEXT *ctx, const PJ_OBJ *crs) { SANITIZE_CTX(ctx); assert(crs); SingleOperationPtr co; @@ -1945,7 +1936,41 @@ PJ_OBJ *proj_obj_crs_get_coordoperation(PJ_CONTEXT *ctx, const PJ_OBJ *crs, } } - const auto &method = co->method(); + return PJ_OBJ::create(NN_NO_CHECK(co)); +} + +// --------------------------------------------------------------------------- + +/** \brief Return informatin on the operation method of the SingleOperation. + * + * @param ctx PROJ context, or NULL for default context + * @param coordoperation Objet of type SingleOperation (typically a Conversion + * or Transformation) (must not be NULL) + * @param out_method_name Pointer to a string value to store the method + * (projection) name. or NULL + * @param out_method_auth_name Pointer to a string value to store the method + * authority name. or NULL + * @param out_method_code Pointer to a string value to store the method + * code. or NULL + * @return TRUE in case of success. + */ +int proj_coordoperation_get_method_info(PJ_CONTEXT *ctx, + const PJ_OBJ *coordoperation, + const char **out_method_name, + const char **out_method_auth_name, + const char **out_method_code) { + SANITIZE_CTX(ctx); + assert(coordoperation); + + auto singleOp = + dynamic_cast<const SingleOperation *>(coordoperation->obj.get()); + if (!singleOp) { + proj_log_error(ctx, __FUNCTION__, + "Object is not a DerivedCRS or BoundCRS"); + return false; + } + + const auto &method = singleOp->method(); const auto &method_ids = method->identifiers(); if (out_method_name) { *out_method_name = method->name()->description()->c_str(); @@ -1964,7 +1989,7 @@ PJ_OBJ *proj_obj_crs_get_coordoperation(PJ_CONTEXT *ctx, const PJ_OBJ *crs, *out_method_code = nullptr; } } - return PJ_OBJ::create(NN_NO_CHECK(co)); + return true; } // --------------------------------------------------------------------------- @@ -872,10 +872,13 @@ int PROJ_DLL proj_obj_prime_meridian_get_parameters(PJ_CONTEXT *ctx, const char **out_unit_name); PJ_OBJ PROJ_DLL *proj_obj_crs_get_coordoperation(PJ_CONTEXT *ctx, - const PJ_OBJ *crs, - const char **out_method_name, - const char **out_method_auth_name, - const char **out_method_code); + const PJ_OBJ *crs); + +int PROJ_DLL proj_coordoperation_get_method_info(PJ_CONTEXT *ctx, + const PJ_OBJ *coordoperation, + const char **out_method_name, + const char **out_method_auth_name, + const char **out_method_code); int PROJ_DLL proj_coordoperation_is_instanciable(PJ_CONTEXT *ctx, const PJ_OBJ *coordoperation); |
