From 5ac60ad200ce77fca0b6964cd7a7e55d2f9e80e5 Mon Sep 17 00:00:00 2001 From: rouault Date: Thu, 20 Aug 2015 16:52:14 +0000 Subject: [PATCH] VRT: honour relativeToVRT when using AddBand() to add a VRTRawRasterBand (patch by Antonio Valentino, https://github.com/OSGeo/gdal/pull/67) git-svn-id: https://svn.osgeo.org/gdal/trunk/gdal@29691 f0d54148-0727-0410-94bb-9a71ac55c965 --- frmts/vrt/vrtdataset.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/frmts/vrt/vrtdataset.cpp b/frmts/vrt/vrtdataset.cpp index 9a6d940c5e..f02bc4be49 100644 --- a/frmts/vrt/vrtdataset.cpp +++ b/frmts/vrt/vrtdataset.cpp @@ -921,10 +921,18 @@ CPLErr VRTDataset::AddBand( GDALDataType eType, char **papszOptions ) VRTRawRasterBand *poBand = new VRTRawRasterBand( this, GetRasterCount() + 1, eType ); - eErr = - poBand->SetRawLink( pszFilename, NULL, bRelativeToVRT, - nImageOffset, nPixelOffset, nLineOffset, + char* pszVRTPath = CPLStrdup(CPLGetPath(GetDescription())); + if EQUAL(pszVRTPath, "") + { + CPLFree(pszVRTPath); + pszVRTPath = NULL; + } + + eErr = + poBand->SetRawLink( pszFilename, pszVRTPath, bRelativeToVRT, + nImageOffset, nPixelOffset, nLineOffset, pszByteOrder ); + CPLFree(pszVRTPath); if( eErr != CE_None ) { delete poBand;