Changeset 11744

Show
Ignore:
Timestamp:
07/12/07 11:40:19 (1 year ago)
Author:
dron
Message:

Added support for BigTIFF enabled libtiff. New option BIGTIFF to force
BigTIFF creation.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/frmts/gtiff/geotiff.cpp

    r11699 r11744  
    7676    TIFF        *hTIFF; 
    7777 
    78     uint32      nDirOffset; 
     78    toff_t      nDirOffset; 
    7979    int         bBase; 
    8080 
     
    114114 
    115115    void        WriteGeoTIFFInfo(); 
    116     int         SetDirectory( uint32 nDirOffset = 0 ); 
     116    int         SetDirectory( toff_t nDirOffset = 0 ); 
    117117    void        SetupTFW(const char *pszBasename); 
    118118 
     
    151151                                    GDALProgressFunc, void * ); 
    152152 
    153     CPLErr         OpenOffset( TIFF *, uint32 nDirOffset, int, GDALAccess ); 
     153    CPLErr         OpenOffset( TIFF *, toff_t nDirOffset, int, GDALAccess ); 
    154154 
    155155    static GDALDataset *OpenDir( const char *pszFilename ); 
     
    531531/************************************************************************/ 
    532532/*                            IWriteBlock()                             */ 
    533 /*                                                                      */ 
    534 /*      This is still limited to writing stripped datasets.             */ 
    535533/************************************************************************/ 
    536534 
     
    19121910 
    19131911{ 
    1914     uint32 *panByteCounts = NULL; 
     1912    toff_t *panByteCounts = NULL; 
    19151913 
    19161914    if( ( TIFFIsTiled( hTIFF )  
     
    25622560/************************************************************************/ 
    25632561 
    2564 int GTiffDataset::SetDirectory( uint32 nNewOffset ) 
     2562int GTiffDataset::SetDirectory( toff_t nNewOffset ) 
    25652563 
    25662564{ 
     
    26072605        return FALSE; 
    26082606 
     2607#ifndef BIGTIFF_SUPPORT 
    26092608    if( poOpenInfo->pabyHeader[2] == 43 && poOpenInfo->pabyHeader[3] == 0 ) 
    26102609    { 
     
    26142613        return FALSE; 
    26152614    } 
     2615#endif 
    26162616 
    26172617    if( (poOpenInfo->pabyHeader[2] != 0x2A || poOpenInfo->pabyHeader[3] != 0) 
    2618         && (poOpenInfo->pabyHeader[3] != 0x2A || poOpenInfo->pabyHeader[2] != 0) ) 
     2618        && (poOpenInfo->pabyHeader[3] != 0x2A || poOpenInfo->pabyHeader[2] != 0) 
     2619        && (poOpenInfo->pabyHeader[2] != 0x2B || poOpenInfo->pabyHeader[3] != 0) 
     2620        && (poOpenInfo->pabyHeader[3] != 0x2B || poOpenInfo->pabyHeader[2] != 0)) 
    26192621        return FALSE; 
    26202622 
     
    26492651        return NULL; 
    26502652 
     2653#ifndef BIGTIFF_SUPPORT 
    26512654    if( poOpenInfo->pabyHeader[2] == 43 && poOpenInfo->pabyHeader[3] == 0 ) 
    26522655    { 
     
    26562659        return NULL; 
    26572660    } 
     2661#endif 
    26582662 
    26592663    if( (poOpenInfo->pabyHeader[2] != 0x2A || poOpenInfo->pabyHeader[3] != 0) 
    2660         && (poOpenInfo->pabyHeader[3] != 0x2A || poOpenInfo->pabyHeader[2] != 0) ) 
     2664        && (poOpenInfo->pabyHeader[3] != 0x2A || poOpenInfo->pabyHeader[2] != 0) 
     2665        && (poOpenInfo->pabyHeader[2] != 0x2B || poOpenInfo->pabyHeader[3] != 0) 
     2666        && (poOpenInfo->pabyHeader[3] != 0x2B || poOpenInfo->pabyHeader[2] != 0)) 
    26612667        return NULL; 
    26622668 
     
    28292835/************************************************************************/ 
    28302836 
    2831 CPLErr GTiffDataset::OpenOffset( TIFF *hTIFFIn, uint32 nDirOffsetIn,  
     2837CPLErr GTiffDataset::OpenOffset( TIFF *hTIFFIn, toff_t nDirOffsetIn,  
    28322838                                 int bBaseIn, GDALAccess eAccess ) 
    28332839 
     
    34633469    const char          *pszValue; 
    34643470    const char          *pszProfile; 
     3471    int                 bCreateBigTIFF = FALSE; 
    34653472 
    34663473    GTiffOneTimeInit(); 
     
    35673574            > 4200000000.0 ) 
    35683575        { 
     3576#ifndef BIGTIFF_SUPPORT 
    35693577            CPLError( CE_Failure, CPLE_AppDefined,  
    35703578                      "A %d pixels x %d lines x %d bands %s image would be larger than 4GB\n" 
     
    35723580                      nXSize, nYSize, nBands, GDALGetDataTypeName(eType) ); 
    35733581            return NULL; 
    3574         } 
    3575     } 
     3582#else 
     3583            bCreateBigTIFF = TRUE; 
     3584#endif 
     3585        } 
     3586    } 
     3587 
     3588/* -------------------------------------------------------------------- */ 
     3589/*      Create BigTIFF file on user's request, even if total image      */ 
     3590/*      size is enough for ClassicTIFF.                                 */ 
     3591/* -------------------------------------------------------------------- */ 
     3592#ifdef BIGTIFF_SUPPORT 
     3593    if( CSLFetchNameValue(papszParmList, "BigTIFF") != NULL ) 
     3594        bCreateBigTIFF = TRUE; 
     3595#endif 
    35763596 
    35773597/* -------------------------------------------------------------------- */ 
    35783598/*      Try opening the dataset.                                        */ 
    35793599/* -------------------------------------------------------------------- */ 
    3580     hTIFF = VSI_TIFFOpen( pszFilename, "w+" ); 
     3600    hTIFF = VSI_TIFFOpen( pszFilename, (bCreateBigTIFF) ? "w+8" : "w+" ); 
    35813601    if( hTIFF == NULL ) 
    35823602    { 
     
    49644984"       <Value>GeoTIFF</value>" 
    49654985"       <Value>BASELINE</Value>" 
     4986#ifdef BIGTIFF_SUPPORT 
     4987"   <Option name='BIGTIFF' type='boolean' description='Force creation of BigTIFF file'/>" 
     4988#endif 
    49664989"   </Option>" 
    49674990"</CreationOptionList>" );