<div dir="ltr"><div>Even,</div><div><br></div><div>thank you so much for your reply.</div><div><br></div><div>My intent here is just to replicate the 
PROJ 4 API behavior of:</div><div><br></div><div>
<span style="font-family:monospace">//------------------------------------------------

</span></div><div><span style="font-family:monospace">const char *pj_carto_string = 
"+proj=ortho +datum=WGS84 +ellps=WGS84 +lat_0=60 +lon_0=90";

</span></div><div><span style="font-family:monospace">pj_cart = pj_init_plus(  pj_carto_string );</span></div><div><span style="font-family:monospace">     projPJ pj_ll = pj_latlong_from_proj(
pj_cart 

);<br>    char *pj_ll_string = pj_get_def(
pj_ll, 0 );</span></div><div><span style="font-family:monospace">
//------------------------------------------------ <br></span></div><div></div><div>I am only interested in getting the geographic coordinate string <i>pj_ll_string</i> underlying the input cartographic projection <i>pj_carto_string</i>. So, in this context, I am not interested in performing any transformation with those projection strings.</div><div><br></div><div>Thank you so much!</div><div>Pierluigi<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 30, 2020 at 9:00 PM Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Pierluigi,<br>
<br>
> I've successfully compiled PROJ ver 7.2.0 on Windows 10 (build 19041.630)<br>
> and I am trying to port my code from PROJ ver 4 API to PROJ ver 7 API but I<br>
> can't find a clear matching between the old version 4 API<br>
> *pj_latlong_from_proj* routine and version 7 API code.<br>
> <br>
> I tried the suggested function mapping as specified here<br>
> <a href="https://proj.org/development/migration.html#function-mapping-from-old-to-new" rel="noreferrer" target="_blank">https://proj.org/development/migration.html#function-mapping-from-old-to-new</a><br>
> -api, but I am consistently getting a NULL pointer returned by the<br>
> *proj_crs_get_horizontal_datum()*. Here is my sample code:<br>
> <br>
> //------------------------------------------------<br>
> #include <iostream><br>
> #include <proj.h><br>
> <br>
> int main()<br>
> {<br>
>    PJ *proj_test = proj_create(PJ_DEFAULT_CTX, "+proj=ortho +datum=WGS84<br>
> +ellps=WGS84 +lat_0=60 +lon_0=90");<br>
<br>
The above is instanciated as a coordinate operation, not a CRS, so you can't <br>
use CRS related API on it. You likely need to add " +type=crs" to the PROJ <br>
string<br>
<br>
>    PJ *datum = proj_crs_get_horizontal_datum(PJ_DEFAULT_CTX, proj_test);<br>
<br>
You'll rather want to use proj_get_source_crs() to extract the geographic CRS <br>
from the projected CRS ( proj_crs_get_geodetic_crs() would also do the job <br>
here ).<br>
<br>
The resulting PJ* object will be a CRS too, so as you likely want to do a <br>
coordinate operation from your projected CRS to the base geographic CRS, <br>
you'll need to create a coordinate operation object with:<br>
<br>
        proj_create_crs_to_crs_from_pj(PJ_DEFAULT_CTX, proj_test, geog_crs, NULL, <br>
NULL)<br>
<br>
and then you can use proj_trans() on the resulting object.<br>
<br>
<br>
Another option is to use proj_crs_get_coordoperation(PJ_DEFAULT_CTX, <br>
proj_test) (with the PROJ string of proj_test having " +type=crs"), which will <br>
give you the coordinate operation to convert from the base geographic CRS of <br>
the projected CRS to the projected CRS.<br>
You can use proj_trans() on it (in the reverse direction, if you want to go <br>
from projected to geographic)<br>
<br>
Even<br>
<br>
-- <br>
Spatialys - Geospatial professional services<br>
<a href="http://www.spatialys.com" rel="noreferrer" target="_blank">http://www.spatialys.com</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Pierluigi Guasqui<br>Software Engineer<br><br>Applied Coherent Technology Corporation (ACT)<br><a href="http://www.actgate.com" target="_blank">www.actgate.com</a><br></div></div>