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

« back to all changes in this revision

Viewing changes to frmts/raw/fastdataset.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: fastdataset.cpp 18415 2009-12-30 23:56:35Z warmerdam $
 
2
 * $Id: fastdataset.cpp 22610 2011-06-28 21:20:06Z rouault $
3
3
 *
4
4
 * Project:  EOSAT FAST Format reader
5
5
 * Purpose:  Reads Landsat FAST-L7A, IRS 1C/1D
32
32
#include "ogr_spatialref.h"
33
33
#include "rawdataset.h"
34
34
 
35
 
CPL_CVSID("$Id: fastdataset.cpp 18415 2009-12-30 23:56:35Z warmerdam $");
 
35
CPL_CVSID("$Id: fastdataset.cpp 22610 2011-06-28 21:20:06Z rouault $");
36
36
 
37
37
CPL_C_START
38
38
void    GDALRegister_FAST(void);
110
110
    double      adfGeoTransform[6];
111
111
    char        *pszProjection;
112
112
 
113
 
    FILE        *fpHeader;
 
113
    VSILFILE    *fpHeader;
114
114
    CPLString apoChannelFilenames[7];
115
 
    FILE        *fpChannels[7];
 
115
    VSILFILE    *fpChannels[7];
116
116
    const char  *pszFilename;
117
117
    char        *pszDirname;
118
118
    GDALDataType eDataType;
128
128
 
129
129
    CPLErr      GetGeoTransform( double * );
130
130
    const char  *GetProjectionRef();
131
 
    FILE        *FOpenChannel( const char *, int iBand, int iFASTBand );
 
131
    VSILFILE    *FOpenChannel( const char *, int iBand, int iFASTBand );
132
132
    void        TryEuromap_IRS_1C_1D_ChannelNameConvention();
133
133
    
134
134
    virtual  char** GetFileList();
146
146
 
147
147
  public:
148
148
 
149
 
                FASTRasterBand( FASTDataset *, int, FILE *, vsi_l_offset,
 
149
                FASTRasterBand( FASTDataset *, int, VSILFILE *, vsi_l_offset,
150
150
                                int, int, GDALDataType, int );
151
151
};
152
152
 
155
155
/*                           FASTRasterBand()                           */
156
156
/************************************************************************/
157
157
 
158
 
FASTRasterBand::FASTRasterBand( FASTDataset *poDS, int nBand, FILE * fpRaw,
 
158
FASTRasterBand::FASTRasterBand( FASTDataset *poDS, int nBand, VSILFILE * fpRaw,
159
159
                                vsi_l_offset nImgOffset, int nPixelOffset,
160
160
                                int nLineOffset, GDALDataType eDataType,
161
161
                                int bNativeOrder) :
209
209
        if ( fpChannels[i] )
210
210
            VSIFCloseL( fpChannels[i] );
211
211
    if( fpHeader != NULL )
212
 
        VSIFClose( fpHeader );
 
212
        VSIFCloseL( fpHeader );
213
213
}
214
214
 
215
215
/************************************************************************/
271
271
/************************************************************************/
272
272
 
273
273
 
274
 
FILE *FASTDataset::FOpenChannel( const char *pszBandname, int iBand, int iFASTBand )
 
274
VSILFILE *FASTDataset::FOpenChannel( const char *pszBandname, int iBand, int iFASTBand )
275
275
{
276
276
    const char  *pszChannelFilename = NULL;
277
277
    char        *pszPrefix = CPLStrdup( CPLGetBasename( pszFilename ) );
463
463
            for (int j = 0; j < 2; j ++)
464
464
            {
465
465
                char* pszChannelFilename = CPLStrdup(pszFilename);
466
 
                pszChannelFilename[strlen(pszChannelFilename)-1] = '1' + j;
 
466
                pszChannelFilename[strlen(pszChannelFilename)-1] 
 
467
                    = (char) ('1' + j);
467
468
                if (OpenChannel( pszChannelFilename, nBands ))
468
469
                    nBands++;
469
470
                else
591
592
 
592
593
{
593
594
    int         i;
594
 
        
595
 
    if( poOpenInfo->fp == NULL )
 
595
 
 
596
    if( poOpenInfo->nHeaderBytes < 1024)
596
597
        return NULL;
597
598
 
598
599
    if( !EQUALN((const char *) poOpenInfo->pabyHeader + 52,
608
609
 
609
610
    poDS = new FASTDataset();
610
611
 
611
 
    poDS->fpHeader = poOpenInfo->fp;
612
 
    poOpenInfo->fp = NULL;
 
612
    poDS->fpHeader = VSIFOpenL(poOpenInfo->pszFilename, "rb");
 
613
    if (poDS->fpHeader == NULL)
 
614
    {
 
615
        delete poDS;
 
616
        return NULL;
 
617
    }
 
618
 
613
619
    poDS->pszFilename = poOpenInfo->pszFilename;
614
620
    poDS->pszDirname = CPLStrdup( CPLGetDirname( poOpenInfo->pszFilename ) );
615
621
    
620
626
    char        *pszHeader = (char *) CPLMalloc( ADM_HEADER_SIZE + 1 );
621
627
    size_t      nBytesRead;
622
628
 
623
 
    VSIFSeek( poDS->fpHeader, 0, SEEK_SET );
624
 
    nBytesRead = VSIFRead( pszHeader, 1, ADM_HEADER_SIZE, poDS->fpHeader );
 
629
    VSIFSeekL( poDS->fpHeader, 0, SEEK_SET );
 
630
    nBytesRead = VSIFReadL( pszHeader, 1, ADM_HEADER_SIZE, poDS->fpHeader );
625
631
    if ( nBytesRead < ADM_MIN_HEADER_SIZE )
626
632
    {
627
633
        CPLDebug( "FAST", "Header file too short. Reading failed" );
669
675
    CPLFree( pszTemp );
670
676
 
671
677
    // Read filenames
672
 
    pszTemp = pszHeader;
673
678
    poDS->nBands = 0;
674
679
    
675
680
    if (strstr( pszHeader, FILENAME ) == NULL)
728
733
    /* the usual patterns like bandX.dat, etc... */
729
734
    if ( !poDS->nBands )
730
735
    {
 
736
        pszTemp = pszHeader;
731
737
        for ( i = 0; i < 7; i++ )
732
738
        {
733
739
            char *pszFilename = NULL ;
734
 
    
735
740
            if ( pszTemp )
736
741
                pszTemp = strstr( pszTemp, FILENAME );
737
742
            if ( pszTemp )
1129
1134
                                   "EOSAT FAST Format" );
1130
1135
        poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, 
1131
1136
                                   "frmt_fast.html" );
 
1137
        poDriver->SetMetadataItem( GDAL_DCAP_VIRTUALIO, "YES" );
1132
1138
 
1133
1139
        poDriver->pfnOpen = FASTDataset::Open;
1134
1140