~ubuntu-branches/debian/sid/gdal/sid

« back to all changes in this revision

Viewing changes to frmts/vrt/vrtdriver.cpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-05-07 15:04:42 UTC
  • mfrom: (5.5.16 experimental)
  • Revision ID: package-import@ubuntu.com-20120507150442-2eks97loeh6rq005
Tags: 1.9.0-1
* Ready for sid, starting transition.
* All symfiles updated to latest builds.
* Added dh_numpy call in debian/rules to depend on numpy ABI.
* Policy bumped to 3.9.3, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 $
3
3
 *
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"
33
34
 
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 $");
35
36
 
36
37
/************************************************************************/
37
38
/*                             VRTDriver()                              */
41
42
 
42
43
{
43
44
    papszSourceParsers = NULL;
 
45
    pDeserializerData = GDALRegisterTransformDeserializer("WarpedOverviewTransformer",
 
46
                                                          VRTWarpedOverviewTransform,
 
47
                                                          VRTDeserializeWarpedOverviewTransformer);
44
48
}
45
49
 
46
50
/************************************************************************/
51
55
 
52
56
{
53
57
    CSLDestroy( papszSourceParsers );
 
58
 
 
59
    if ( pDeserializerData )
 
60
    {
 
61
        GDALUnregisterTransformDeserializer( pDeserializerData );
 
62
    }
54
63
}
55
64
 
56
65
/************************************************************************/
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") )
154
164
    {
155
165
 
156
166
    /* -------------------------------------------------------------------- */
172
182
 
173
183
        if( 0 != strlen( pszFilename ) )
174
184
        {
175
 
            FILE *fpVRT = NULL;
 
185
            VSILFILE *fpVRT = NULL;
176
186
 
177
187
            fpVRT = VSIFOpenL( pszFilename, "wb" );
178
188
            if (fpVRT == NULL)
208
218
                            poSrcDS->GetRasterXSize(),
209
219
                            poSrcDS->GetRasterYSize(),
210
220
                            0, GDT_Byte, NULL );
 
221
    if (poVRTDS == NULL)
 
222
        return NULL;
211
223
 
212
224
/* -------------------------------------------------------------------- */
213
225
/*      Do we have a geotransform?                                      */
242
254
    if( papszMD )
243
255
        poVRTDS->SetMetadata( papszMD, "IMD" );
244
256
 
 
257
    papszMD = poSrcDS->GetMetadata( "GEOLOCATION" );
 
258
    if( papszMD )
 
259
        poVRTDS->SetMetadata( papszMD, "GEOLOCATION" );
 
260
 
245
261
/* -------------------------------------------------------------------- */
246
262
/*      GCPs                                                            */
247
263
/* -------------------------------------------------------------------- */
276
292
/*      Emit various band level metadata.                               */
277
293
/* -------------------------------------------------------------------- */
278
294
        poVRTBand->CopyCommonInfoFrom( poSrcBand );
 
295
 
 
296
/* -------------------------------------------------------------------- */
 
297
/*      Add specific mask band.                                         */
 
298
/* -------------------------------------------------------------------- */
 
299
        if ( (poSrcBand->GetMaskFlags() & (GMF_PER_DATASET | GMF_ALL_VALID | GMF_NODATA)) == 0)
 
300
        {
 
301
            VRTSourcedRasterBand* poVRTMaskBand = new VRTSourcedRasterBand(poVRTDS, 0,
 
302
                poSrcBand->GetMaskBand()->GetRasterDataType(),
 
303
                poSrcDS->GetRasterXSize(), poSrcDS->GetRasterYSize());
 
304
            poVRTMaskBand->AddMaskBandSource( poSrcBand );
 
305
            poVRTBand->SetMaskBand( poVRTMaskBand );
 
306
        }
 
307
    }
 
308
 
 
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)
 
315
    {
 
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 );
279
322
    }
280
323
 
281
324
    poVRTDS->FlushCache();