diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/iso19111/c_api.cpp | 59 | ||||
| -rw-r--r-- | src/proj.h | 7 |
2 files changed, 66 insertions, 0 deletions
diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index bc1d0bd8..7a77ccfb 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -6976,3 +6976,62 @@ PJ *proj_normalize_for_visualization(PJ_CONTEXT *ctx, const PJ *obj) { return nullptr; } } + +// --------------------------------------------------------------------------- + +/** \brief Returns the number of steps of a concatenated operation. + * + * The input object must be a concatenated operation. + * + * @param ctx PROJ context, or NULL for default context + * @param concatoperation Concatenated operation (must not be NULL) + * @return the number of steps, or 0 in case of error. + */ +int proj_concatoperation_get_step_count(PJ_CONTEXT *ctx, + const PJ *concatoperation) { + SANITIZE_CTX(ctx); + assert(concatoperation); + auto l_co = dynamic_cast<const ConcatenatedOperation *>( + concatoperation->iso_obj.get()); + if (!l_co) { + proj_log_error(ctx, __FUNCTION__, + "Object is not a ConcatenatedOperation"); + return false; + } + return static_cast<int>(l_co->operations().size()); +} +// --------------------------------------------------------------------------- + +/** \brief Returns a step of a concatenated operation. + * + * The input object must be a concatenated operation. + * + * The returned object must be unreferenced with proj_destroy() after + * use. + * It should be used by at most one thread at a time. + * + * @param ctx PROJ context, or NULL for default context + * @param concatoperation Concatenated operation (must not be NULL) + * @param i_step Index of the step to extract. Between 0 and + * proj_concatoperation_get_step_count()-1 + * @return Object that must be unreferenced with proj_destroy(), or NULL + * in case of error. + */ +PJ *proj_concatoperation_get_step(PJ_CONTEXT *ctx, const PJ *concatoperation, + int i_step) { + SANITIZE_CTX(ctx); + assert(concatoperation); + auto l_co = dynamic_cast<const ConcatenatedOperation *>( + concatoperation->iso_obj.get()); + if (!l_co) { + proj_log_error(ctx, __FUNCTION__, + "Object is not a ConcatenatedOperation"); + return nullptr; + } + const auto &steps = l_co->operations(); + if (i_step < 0 || static_cast<size_t>(i_step) >= steps.size()) { + proj_log_error(ctx, __FUNCTION__, "Invalid step index"); + return nullptr; + } + return pj_obj_create(ctx, steps[i_step]); +} @@ -1064,6 +1064,13 @@ int PROJ_DLL proj_coordoperation_get_towgs84_values(PJ_CONTEXT *ctx, int value_count, int emit_error_if_incompatible); +int PROJ_DLL proj_concatoperation_get_step_count(PJ_CONTEXT *ctx, + const PJ *concatoperation); + +PJ PROJ_DLL *proj_concatoperation_get_step(PJ_CONTEXT *ctx, + const PJ *concatoperation, + int i_step); + /**@}*/ #ifdef __cplusplus |
