On Sun, Sep 18, 2016 at 5:49 AM, Even Rouault <even.roua...@spatialys.com>
wrote:

> Le dimanche 18 septembre 2016 11:02:20, Sean Gillies a écrit :
> > Hi Andrew, Even,
> >
> > I am so grateful you asked this question, Andrew.
>
> UPDATE: Andrew, after digging, I believe you have hit
> https://trac.osgeo.org/gdal/ticket/6592 whose fix hasn't yet reached any
> released version.
>

Thanks Even,

It seems like doing something else to set the metadata change flag will
make things work.  Unfortunately, the change flag seems to be guarded so
one has to make an actual change to get it to be set.  Something like the
following works, but is a little crufty and deserves a comment.  Perhaps
there's a better way?

int nBands = 5;
dataset->Create(filename, width, height, nBands, ...);

for (int i = 1; i <= nBands; ++i)
{
    GDALRasterBand *band = dataset->GetRasterBand(i);
    band->SetDescription(someString);

    // Force metadata change flag so that description gets written.
Current bug
    // (ticket 6592) requires something like this.
    band->SetOffset(band->GetOffset(NULL) + .00001);
    band->SetOffset(band->GetOffset(NULL) - .00001);

    band->WriteBlock(someData);
}

-- 
Andrew Bell
andrew.bell...@gmail.com
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to