/****************************************************************************** * $Id: gdaltorture.cpp $ * * Project: GDAL Utilities * Purpose: Commandline utility to torture GDAL API on datasets * Author: Even Rouault, * ****************************************************************************** * Copyright (c) 2008, Even Rouault * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "gdal.h" #include "cpl_string.h" #include "cpl_conv.h" CPL_CVSID("$Id: gdaltorture.cpp $"); /************************************************************************/ /* Usage() */ /************************************************************************/ static void Usage() { printf( "Usage: gdaltorture [-r] [-u] [-rw] files*\n" ); exit( 1 ); } /************************************************************************/ /* TortureDS() */ /************************************************************************/ static void TortureBand(GDALRasterBandH hBand, int bReadWriteOperations) { int nBlockXSize, nBlockYSize; int nRasterXSize, nRasterYSize; int iOverview, nOverviewCount; int bHasNoData; int bSuccess; double dfMin, dfMax, dfMean, dfStdDev; //double adfMinMax[2]; float afSampleBuf; GDALRasterBandH hMaskBand; GDALGetRasterDataType(hBand); GDALGetBlockSize(hBand, &nBlockXSize, &nBlockYSize); //GDALRasterAdviseRead //GDALRasterIO //GDALReadBlock //GDALWriteBlock nRasterXSize = GDALGetRasterBandXSize(hBand); nRasterYSize = GDALGetRasterBandYSize(hBand); GDALGetRasterAccess(hBand); GDALGetBandNumber(hBand); GDALGetBandDataset(hBand); GDALGetRasterColorInterpretation(hBand); // GDALSetRasterColorInterpretation GDALGetRasterColorTable(hBand); //GDALSetRasterColorTable GDALHasArbitraryOverviews (hBand); nOverviewCount = GDALGetOverviewCount(hBand); for(iOverview=0;iOverview 0 && papszArgv[0][0] == '-' ) { if( EQUAL(papszArgv[0],"-r") ) bRecursive = TRUE; else if( EQUAL(papszArgv[0],"-u") ) bReportFailures = TRUE; else if( EQUAL(papszArgv[0],"-rw") ) bReadWriteOperations = TRUE; else Usage(); papszArgv++; argc--; } /* -------------------------------------------------------------------- */ /* Process given files. */ /* -------------------------------------------------------------------- */ while( argc > 0 ) { ProcessTortureTarget( papszArgv[0], NULL, bRecursive, bReportFailures, bReadWriteOperations ); argc--; papszArgv++; } /* -------------------------------------------------------------------- */ /* Cleanup */ /* -------------------------------------------------------------------- */ CSLDestroy( argv ); GDALDestroyDriverManager(); exit( 0 ); }