diff options
| author | Even Rouault <even.rouault@mines-paris.org> | 2019-03-29 11:25:52 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-29 11:25:52 +0100 |
| commit | 8d7a01bc3d3d9662812242880b8ab1231d014edc (patch) | |
| tree | d55a77d1188d2bd18b726c2ca81aa02a532bd15c /src/iso19111/c_api.cpp | |
| parent | 154cc0fc8226d646db81cc83b6dd86b3414227b2 (diff) | |
| parent | 6a7e24dce79f93b73f4919f267df2fdf3ee95713 (diff) | |
| download | PROJ-8d7a01bc3d3d9662812242880b8ab1231d014edc.tar.gz PROJ-8d7a01bc3d3d9662812242880b8ab1231d014edc.zip | |
Merge pull request #1387 from rouault/proj_normalize_for_visualization
Add proj_normalize_for_visualization()
Diffstat (limited to 'src/iso19111/c_api.cpp')
| -rw-r--r-- | src/iso19111/c_api.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index e62d3f56..1f4cecde 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -6767,3 +6767,35 @@ int proj_cs_get_axis_info(PJ_CONTEXT *ctx, const PJ *cs, int index, } return true; } + +// --------------------------------------------------------------------------- + +/** \brief Returns a PJ* object whose axis order is the one expected for + * visualization purposes. + * + * The input object must be a coordinate operation, that has been created with + * proj_create_crs_to_crs(). + * If the axis order of its source or target CRS is northing,easting, then an + * axis swap operation will be inserted. + * + * @param ctx PROJ context, or NULL for default context + * @param obj Object of type CoordinateOperation, + * created with proj_create_crs_to_crs() (must not be NULL) + * @return a new PJ* object to free with proj_destroy() in case of success, or + * nullptr in case of error + */ +PJ *proj_normalize_for_visualization(PJ_CONTEXT *ctx, const PJ *obj) { + auto co = dynamic_cast<const CoordinateOperation *>(obj->iso_obj.get()); + if (!co) { + proj_log_error(ctx, __FUNCTION__, "Object is not a CoordinateOperation " + "created with " + "proj_create_crs_to_crs"); + return nullptr; + } + try { + return pj_obj_create(ctx, co->normalizeForVisualization()); + } catch (const std::exception &e) { + proj_log_debug(ctx, __FUNCTION__, e.what()); + return nullptr; + } +} |
