[PROJ] Affine transformation using DERIVEDPROJCRS
Even Rouault
even.rouault at spatialys.com
Tue Jul 5 14:51:35 PDT 2022
Le 05/07/2022 à 23:35, Bart.Duijndam at ziggo.nl a écrit :
>
> Hi Even,
>
> Thanks for your help; you’re working late…
>
> Please be advised that I already started with using
> nn_dynamic_pointer_cast<ProjectedCRS>(crs);
>
> But then I got the following obscure error message:
>
> D:\Source\VS19\PROJ\test\unit\test_crs.cpp(5516): error C2280:
> 'dropbox::oxygen::nn<osgeo::proj::crs::ProjectedCRSPtr>::nn(PtrType)':
> attempting to reference a deleted function
>
> with
>
> [
>
> PtrType=osgeo::proj::crs::ProjectedCRSPtr
>
> ]
>
> D:\Source\VS19\PROJ\include\proj\nn.hpp(126): note: see declaration of
> 'dropbox::oxygen::nn<osgeo::proj::crs::ProjectedCRSPtr>::nn'
>
> D:\Source\VS19\PROJ\include\proj\nn.hpp(126): note:
> 'dropbox::oxygen::nn<osgeo::proj::crs::ProjectedCRSPtr>::nn(PtrType)':
> function was explicitly deleted
>
> with
>
> [
>
> PtrType=osgeo::proj::crs::ProjectedCRSPtr
>
> ]
>
> ninja: build stopped: subcommand failed.
>
> Build All failed.
>
Ah I see, the issue is that nn_dynamic_pointer_cast<ProjectedCRS>
returns a ProjectedCRSPtr (which is a typedef for
std::shared_ptr<ProjectedCRS>), which is potentially null (because
nn_dynamic_pointer_cast<> might fail and return a null pointer). Whereas
your function signature returns a ProjectedCRSNNPtr, which is an alias
for nn<ProjectedCRSPtr>, that is a ProjectedCRSPtr that cannot be null.
The conversion from ProjectedCRSPtr to nn<ProjectedCRSPtr> must be
explicit, so you should typically modify the return statement to be
return NN_CHECK_ASSERT(proj_crs);
> So that’s why I tried ProjectedCRSNNPtrinstead
>
That would leak to a shared pointer of a null-nullable shared pointer.
Definitely not something you want.
>
> Cheers,
>
> Bart
>
> *From:*Even Rouault <even.rouault at spatialys.com>
> *Sent:* Tuesday, 5 July 2022 23:30
> *To:* Bart.Duijndam at ziggo.nl; proj at lists.osgeo.org
> *Subject:* Re: [PROJ] Affine transformation using DERIVEDPROJCRS
>
> autoproj_crs = nn_dynamic_pointer_cast<ProjectedCRSNNPtr>(crs);
>
> ==> autoproj_crs = nn_dynamic_pointer_cast<ProjectedCRS>(crs);
>
> --
> http://www.spatialys.com
> My software is free, but my time generally not.
--
http://www.spatialys.com
My software is free, but my time generally not.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/proj/attachments/20220705/39bc138e/attachment-0001.htm>
More information about the PROJ
mailing list