1
1
/******************************************************************************
2
* $Id: vrtdriver.cpp 20881 2010-10-18 21:30:32Z rouault $
2
* $Id: vrtdriver.cpp 21945 2011-03-12 21:11:37Z warmerdam $
4
4
* Project: Virtual GDAL Datasets
5
5
* Purpose: Implementation of VRTDriver
30
30
#include "vrtdataset.h"
31
31
#include "cpl_minixml.h"
32
32
#include "cpl_string.h"
33
#include "gdal_alg_priv.h"
34
CPL_CVSID("$Id: vrtdriver.cpp 20881 2010-10-18 21:30:32Z rouault $");
35
CPL_CVSID("$Id: vrtdriver.cpp 21945 2011-03-12 21:11:37Z warmerdam $");
36
37
/************************************************************************/
43
44
papszSourceParsers = NULL;
45
pDeserializerData = GDALRegisterTransformDeserializer("WarpedOverviewTransformer",
46
VRTWarpedOverviewTransform,
47
VRTDeserializeWarpedOverviewTransformer);
46
50
/************************************************************************/
150
159
/* it to disk as a special case to avoid extra layers of */
151
160
/* indirection. */
152
161
/* -------------------------------------------------------------------- */
153
if( EQUAL(poSrcDS->GetDriver()->GetDescription(),"VRT") )
162
if( poSrcDS->GetDriver() != NULL &&
163
EQUAL(poSrcDS->GetDriver()->GetDescription(),"VRT") )
156
166
/* -------------------------------------------------------------------- */
208
218
poSrcDS->GetRasterXSize(),
209
219
poSrcDS->GetRasterYSize(),
210
220
0, GDT_Byte, NULL );
212
224
/* -------------------------------------------------------------------- */
213
225
/* Do we have a geotransform? */
243
255
poVRTDS->SetMetadata( papszMD, "IMD" );
257
papszMD = poSrcDS->GetMetadata( "GEOLOCATION" );
259
poVRTDS->SetMetadata( papszMD, "GEOLOCATION" );
245
261
/* -------------------------------------------------------------------- */
247
263
/* -------------------------------------------------------------------- */
276
292
/* Emit various band level metadata. */
277
293
/* -------------------------------------------------------------------- */
278
294
poVRTBand->CopyCommonInfoFrom( poSrcBand );
296
/* -------------------------------------------------------------------- */
297
/* Add specific mask band. */
298
/* -------------------------------------------------------------------- */
299
if ( (poSrcBand->GetMaskFlags() & (GMF_PER_DATASET | GMF_ALL_VALID | GMF_NODATA)) == 0)
301
VRTSourcedRasterBand* poVRTMaskBand = new VRTSourcedRasterBand(poVRTDS, 0,
302
poSrcBand->GetMaskBand()->GetRasterDataType(),
303
poSrcDS->GetRasterXSize(), poSrcDS->GetRasterYSize());
304
poVRTMaskBand->AddMaskBandSource( poSrcBand );
305
poVRTBand->SetMaskBand( poVRTMaskBand );
309
/* -------------------------------------------------------------------- */
310
/* Add dataset mask band */
311
/* -------------------------------------------------------------------- */
312
if (poSrcDS->GetRasterCount() != 0 &&
313
poSrcDS->GetRasterBand(1) != NULL &&
314
poSrcDS->GetRasterBand(1)->GetMaskFlags() == GMF_PER_DATASET)
316
GDALRasterBand *poSrcBand = poSrcDS->GetRasterBand(1);
317
VRTSourcedRasterBand* poVRTMaskBand = new VRTSourcedRasterBand(poVRTDS, 0,
318
poSrcBand->GetMaskBand()->GetRasterDataType(),
319
poSrcDS->GetRasterXSize(), poSrcDS->GetRasterYSize());
320
poVRTMaskBand->AddMaskBandSource( poSrcBand );
321
poVRTDS->SetMaskBand( poVRTMaskBand );
281
324
poVRTDS->FlushCache();