[PROJ] Affine transformation using DERIVEDPROJCRS
Bart.Duijndam at ziggo.nl
Bart.Duijndam at ziggo.nl
Tue Jul 5 14:56:25 PDT 2022
Thanks Even,
This removed the error message, and the code now compiles okay.
Next thing is to step through the code, and see if it does what I hope it does.
But that will be by Friday earliest, I expect.
Kind regards,
Bart
From: Even Rouault <even.rouault at spatialys.com>
Sent: Tuesday, 5 July 2022 23:52
To: Bart.Duijndam at ziggo.nl; proj at lists.osgeo.org
Subject: Re: [PROJ] Affine transformation using DERIVEDPROJCRS
Le 05/07/2022 à 23:35, Bart.Duijndam at ziggo.nl <mailto: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 ProjectedCRSNNPtr instead
That would leak to a shared pointer of a null-nullable shared pointer. Definitely not something you want.
Cheers,
Bart
From: Even Rouault <mailto:even.rouault at spatialys.com> <even.rouault at spatialys.com>
Sent: Tuesday, 5 July 2022 23:30
To: Bart.Duijndam at ziggo.nl <mailto:Bart.Duijndam at ziggo.nl> ; proj at lists.osgeo.org <mailto:proj at lists.osgeo.org>
Subject: Re: [PROJ] Affine transformation using DERIVEDPROJCRS
auto proj_crs = nn_dynamic_pointer_cast<ProjectedCRSNNPtr>(crs);
==> auto proj_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/ac332012/attachment.htm>
More information about the PROJ
mailing list