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

« back to all changes in this revision

Viewing changes to frmts/til/tildataset.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: tildataset.cpp 17664 2009-09-21 21:16:45Z rouault $
 
2
 * $Id: tildataset.cpp 22713 2011-07-12 10:06:39Z rouault $
3
3
 *
4
4
 * Project:  EarthWatch .TIL Driver
5
5
 * Purpose:  Implementation of the TILDataset class.
35
35
#include "cpl_multiproc.h"
36
36
#include "cplkeywordparser.h"
37
37
 
38
 
CPL_CVSID("$Id: tildataset.cpp 17664 2009-09-21 21:16:45Z rouault $");
 
38
CPL_CVSID("$Id: tildataset.cpp 22713 2011-07-12 10:06:39Z rouault $");
39
39
 
40
40
/************************************************************************/
41
41
/* ==================================================================== */
48
48
    VRTDataset *poVRTDS;
49
49
    std::vector<GDALDataset *> apoTileDS;
50
50
 
 
51
    CPLString                  osRPBFilename;
 
52
    CPLString                  osIMDFilename;
 
53
 
 
54
  protected:
 
55
    virtual int         CloseDependentDatasets();
 
56
 
51
57
  public:
52
58
    TILDataset();
53
59
    ~TILDataset();
54
60
 
 
61
    virtual char **GetFileList(void);
 
62
 
55
63
    static GDALDataset *Open( GDALOpenInfo * );
56
64
    static int Identify( GDALOpenInfo *poOpenInfo );
57
65
};
124
132
TILDataset::~TILDataset()
125
133
 
126
134
{
 
135
    CloseDependentDatasets();
 
136
}
 
137
 
 
138
/************************************************************************/
 
139
/*                        CloseDependentDatasets()                      */
 
140
/************************************************************************/
 
141
 
 
142
int TILDataset::CloseDependentDatasets()
 
143
{
 
144
    int bHasDroppedRef = GDALPamDataset::CloseDependentDatasets();
 
145
 
127
146
    if( poVRTDS )
 
147
    {
 
148
        bHasDroppedRef = TRUE;
128
149
        delete poVRTDS;
 
150
        poVRTDS = NULL;
 
151
    }
129
152
 
130
153
    while( !apoTileDS.empty() )
131
154
    {
132
155
        GDALClose( (GDALDatasetH) apoTileDS.back() );
133
156
        apoTileDS.pop_back();
134
157
    }
 
158
 
 
159
    return bHasDroppedRef;
135
160
}
136
161
 
137
162
/************************************************************************/
177
202
/* -------------------------------------------------------------------- */
178
203
/*      Try to find the corresponding .IMD file.                        */
179
204
/* -------------------------------------------------------------------- */
180
 
    char **papszIMD = GDALLoadIMDFile( poOpenInfo->pszFilename, 
181
 
                                       poOpenInfo->papszSiblingFiles );
 
205
    char **papszIMD = NULL;
 
206
    CPLString osIMDFilename = 
 
207
        GDALFindAssociatedFile( poOpenInfo->pszFilename, "IMD", 
 
208
                                poOpenInfo->papszSiblingFiles, 0 );
 
209
 
 
210
    if( osIMDFilename != "" )
 
211
        papszIMD = GDALLoadIMDFile( osIMDFilename, NULL );
182
212
 
183
213
    if( papszIMD == NULL )
184
214
    {
200
230
/* -------------------------------------------------------------------- */
201
231
/*      Try to load and parse the .TIL file.                            */
202
232
/* -------------------------------------------------------------------- */
203
 
    FILE *fp = VSIFOpenL( poOpenInfo->pszFilename, "r" );
 
233
    VSILFILE *fp = VSIFOpenL( poOpenInfo->pszFilename, "r" );
204
234
    
205
235
    if( fp == NULL )
206
236
    {
228
258
 
229
259
    poDS = new TILDataset();
230
260
 
 
261
    poDS->osIMDFilename = osIMDFilename; 
 
262
    poDS->SetMetadata( papszIMD, "IMD" );
231
263
    poDS->nRasterXSize = atoi(CSLFetchNameValueDef(papszIMD,"numColumns","0"));
232
264
    poDS->nRasterYSize = atoi(CSLFetchNameValueDef(papszIMD,"numRows","0"));
233
265
    if (!GDALCheckDatasetDimensions(poDS->nRasterXSize, poDS->nRasterYSize))
338
370
        osKey.Printf( "TILE_%d.LRRowOffset", iTile );
339
371
        int nLRY = atoi(CSLFetchNameValueDef(papszTIL, osKey, "0"));
340
372
 
341
 
#ifdef notdef
342
 
        GDALDataset *poTileDS = (GDALDataset *) 
343
 
            GDALOpen(osFilename,GA_ReadOnly);
344
 
#else
345
373
        GDALDataset *poTileDS = 
346
374
            new GDALProxyPoolDataset( osFilename, 
347
375
                                      nLRX - nULX + 1, nLRY - nULY + 1 );
348
 
#endif
349
376
        if( poTileDS == NULL )
350
377
            continue;
351
378
 
353
380
 
354
381
        for( iBand = 1; iBand <= nBandCount; iBand++ )
355
382
        {
356
 
#ifndef notdef
357
383
            ((GDALProxyPoolDataset *) poTileDS)->
358
384
                AddSrcBandDescription( eDT, nLRX - nULX + 1, 1 );
359
 
#endif            
 
385
 
360
386
            GDALRasterBand *poSrcBand = poTileDS->GetRasterBand(iBand);
361
387
 
362
388
            VRTSourcedRasterBand *poVRTBand = 
373
399
/* -------------------------------------------------------------------- */
374
400
/*      Set RPC and IMD metadata.                                       */
375
401
/* -------------------------------------------------------------------- */
376
 
    char **papszRPCMD = GDALLoadRPBFile( poOpenInfo->pszFilename,
377
 
                                         poOpenInfo->papszSiblingFiles );
 
402
    poDS->osRPBFilename = 
 
403
        GDALFindAssociatedFile( poOpenInfo->pszFilename, "RPB", 
 
404
                                poOpenInfo->papszSiblingFiles, 0 );
 
405
    if( poDS->osRPBFilename != "" )
 
406
    {
 
407
        char **papszRPCMD = GDALLoadRPBFile( poOpenInfo->pszFilename,
 
408
                                             poOpenInfo->papszSiblingFiles );
378
409
        
379
 
    if( papszRPCMD != NULL )
380
 
    {
381
 
        poDS->SetMetadata( papszRPCMD, "RPC" );
382
 
        CSLDestroy( papszRPCMD );
 
410
        if( papszRPCMD != NULL )
 
411
        {
 
412
            poDS->SetMetadata( papszRPCMD, "RPC" );
 
413
            CSLDestroy( papszRPCMD );
 
414
        }
383
415
    }
384
416
 
385
 
    if( papszIMD != NULL )
386
 
        poDS->SetMetadata( papszIMD, "IMD" );
387
 
 
388
417
/* -------------------------------------------------------------------- */
389
418
/*      Cleanup                                                         */
390
419
/* -------------------------------------------------------------------- */
405
434
}
406
435
 
407
436
/************************************************************************/
 
437
/*                            GetFileList()                             */
 
438
/************************************************************************/
 
439
 
 
440
char **TILDataset::GetFileList()
 
441
 
 
442
{
 
443
    unsigned int  i;
 
444
    char **papszFileList = GDALPamDataset::GetFileList();
 
445
 
 
446
    for( i = 0; i < apoTileDS.size(); i++ )
 
447
        papszFileList = CSLAddString( papszFileList,
 
448
                                      apoTileDS[i]->GetDescription() );
 
449
    
 
450
    papszFileList = CSLAddString( papszFileList, osIMDFilename );
 
451
 
 
452
 
 
453
    if( osRPBFilename != "" )
 
454
        papszFileList = CSLAddString( papszFileList, osRPBFilename );
 
455
 
 
456
    return papszFileList;
 
457
}
 
458
 
 
459
/************************************************************************/
408
460
/*                          GDALRegister_TIL()                          */
409
461
/************************************************************************/
410
462
 
422
474
                                   "EarthWatch .TIL" );
423
475
        poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, 
424
476
                                   "frmt_til.html" );
425
 
        
 
477
 
 
478
        poDriver->SetMetadataItem( GDAL_DCAP_VIRTUALIO, "YES" );
 
479
 
426
480
        poDriver->pfnOpen = TILDataset::Open;
427
481
        poDriver->pfnIdentify = TILDataset::Identify;
428
482