diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-03-10 19:01:41 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2021-03-10 20:45:01 +0100 |
| commit | ce97e244e3c67f3e84a0fb73233ee75f4ebe8b50 (patch) | |
| tree | cf23663fd66d527c37204abe9fc97d178bb8973b /src | |
| parent | 22f5eb4724c313a104dc1e55ef1f6833af59e3a1 (diff) | |
| download | PROJ-ce97e244e3c67f3e84a0fb73233ee75f4ebe8b50.tar.gz PROJ-ce97e244e3c67f3e84a0fb73233ee75f4ebe8b50.zip | |
Make proj_lp_dist() and proj_geod() work on a PJ* CRS object
Diffstat (limited to 'src')
| -rw-r--r-- | src/iso19111/c_api.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index 0d386e6b..48b3979a 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -59,6 +59,7 @@ #include "proj_experimental.h" // clang-format on #include "proj_constants.h" +#include "geodesic.h" using namespace NS_PROJ::common; using namespace NS_PROJ::crs; @@ -205,6 +206,26 @@ static PJ *pj_obj_create(PJ_CONTEXT *ctx, const IdentifiedObjectNNPtr &objIn) { pj->ctx = ctx; pj->descr = "ISO-19111 object"; pj->iso_obj = objIn; + try { + auto crs = dynamic_cast<const CRS *>(objIn.get()); + if (crs) { + auto geodCRS = crs->extractGeodeticCRS(); + if (geodCRS) { + const auto &ellps = geodCRS->ellipsoid(); + const double a = ellps->semiMajorAxis().getSIValue(); + const double es = ellps->squaredEccentricity(); + pj_calc_ellipsoid_params(pj, a, es); + assert(pj->geod == nullptr); + pj->geod = static_cast<struct geod_geodesic *>( + calloc(1, sizeof(struct geod_geodesic))); + if (pj->geod) { + geod_init(pj->geod, pj->a, + pj->es / (1 + sqrt(pj->one_es))); + } + } + } + } catch (const std::exception &) { + } } ctx->safeAutoCloseDbIfNeeded(); return pj; |
