[PROJ] proj_create_crs_to_crs_from_pj fails with no error
Even Rouault
even.rouault at spatialys.com
Thu Jul 30 08:51:32 PDT 2020
Eric,
nothing strikes me as obviously wrong in your code, but as it is not a self contained snippet, I
cannot reproduce exactly
I've tried with the projinfo utility:
$ projinfo -s "+type=crs +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs" -t
"+type=crs +proj=geocent +units=m" -o PROJ -q
and it outputs a correct pipeline:
+proj=pipeline +step +proj=unitconvert +xy_in=deg +z_in=m +xy_out=rad +z_out=m +step
+proj=cart +ellps=WGS84
The following also works fine:
cs2cs +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs +to +proj=geocent
This is with latest PROJ. It might be a bug in the version you use.
Even
> I'm upgrading old code to use modern proj routines and use WKS strings
> instead. To handle old PROJ strings (because I don't know the correct
> WKS string), I hack in an extra "+type=crs".
>
> When I do this, the call to proj_create succeeds, but
> proj_create_crs_to_crs_from_pj() returns NULL and proj_errno(NULL)
> returns 0. I want an error message!
>
> Are my expectations for error reporting wrong here?
>
> Here's the code snippet that's failing (throws "failed with no error")
> with crs_string2 =
> "+type=crs +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs"
>
> <code>
> PJptr const crs1 = proj_create (PJ_DEFAULT_CTX, crs_string2.c_str());
> if (crs1.ptr == NULL)
> throw std::runtime_error
> (std::string ("proj_create (dest):")
> + proj_errno_string (proj_errno (crs1.ptr)));
>
> PJptr const crs_ecef = proj_create (PJ_DEFAULT_CTX,
> "+type=crs +proj=geocent +units=m");
> if (crs_ecef.ptr == NULL)
> throw std::runtime_error
> (std::string ("proj_create (ecef):")
> + proj_errno_string (proj_errno (crs1.ptr)));
>
> PJ* proj0 = proj_create_crs_to_crs_from_pj
> (PJ_DEFAULT_CTX, crs1.ptr, crs_ecef.ptr, NULL, NULL);
> if (proj0 == NULL)
> {
> int const err_no = proj_errno (NULL);
> char const * err_str = proj_errno_string (err_no);
> if (err_str == NULL)
> throw std::runtime_error
> ("proj_create_crs_to_crs failed with no error");
> else
> throw std::runtime_error (std::string ("proj_crs_to_crs")
> + proj_errno_string (proj_errno
> (NULL))); }
> </code>
>
> I'd appreciate any advice!
>
> -Eric
> _______________________________________________
> PROJ mailing list
> PROJ at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/proj
--
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/proj/attachments/20200730/9a889a80/attachment.html>
More information about the PROJ
mailing list