[gdal-dev] VRTComplexSource with a LUT, proposal

Saâd HESSANE saad.hessane at gmail.com
Sat May 19 10:58:07 EDT 2012


Hi,

In wanting to add programmatically a LUT to a VRTComplexSource, I read the
VRT driver source code.
VRTComplexSource have three public attributes : *double
*padfLUTInputs*, *double
*padfLUTOutputs* and *int nLUTItemCount.*
*
*
To set the LUT we have to affect directly two pointers and set the number
of elements. There's no other method to set the LUT.
Maybe in other langage like Python it can be useful. But in C++, I think
it's wrong for encapsulation.

But the worst think in my opinion is the VRTComplexSource destructor :

VRTComplexSource::~VRTComplexSource()
> {
>     if (padfLUTInputs)
>         VSIFree( padfLUTInputs );
>     if (padfLUTOutputs)
>         VSIFree( padfLUTOutputs );
> }


The destructor frees the two pointer. This can be an issue if I do that :

> double padfLUTInputs[] = {0,1,2};

double padfLUTOutputs[] = {4,5,6};

complexSource->padfLUTInputs = padfLUTInputs
> ; complexSource->padfLUTOutputs = padfLUTOutputs;


And what happens if I want to change the LUT?

I suggest to add a method VRTComplexSource::setLUT (const double *, const
double *, int), and to make the public attributes protected.
The setLUT method frees the pointers, and clones the tables.

Best regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120519/01ab711a/attachment.html


More information about the gdal-dev mailing list