gdal_priv.h 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237
  1. /******************************************************************************
  2. * $Id: gdal_priv.h 29284 2015-06-03 13:26:10Z rouault $
  3. *
  4. * Name: gdal_priv.h
  5. * Project: GDAL Core
  6. * Purpose: GDAL Core C++/Private declarations.
  7. * Author: Frank Warmerdam, warmerdam@pobox.com
  8. *
  9. ******************************************************************************
  10. * Copyright (c) 1998, Frank Warmerdam
  11. * Copyright (c) 2007-2014, Even Rouault <even dot rouault at mines-paris dot org>
  12. *
  13. * Permission is hereby granted, free of charge, to any person obtaining a
  14. * copy of this software and associated documentation files (the "Software"),
  15. * to deal in the Software without restriction, including without limitation
  16. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  17. * and/or sell copies of the Software, and to permit persons to whom the
  18. * Software is furnished to do so, subject to the following conditions:
  19. *
  20. * The above copyright notice and this permission notice shall be included
  21. * in all copies or substantial portions of the Software.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  24. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  25. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  26. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  27. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  28. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  29. * DEALINGS IN THE SOFTWARE.
  30. ****************************************************************************/
  31. #ifndef GDAL_PRIV_H_INCLUDED
  32. #define GDAL_PRIV_H_INCLUDED
  33. /* -------------------------------------------------------------------- */
  34. /* Predeclare various classes before pulling in gdal.h, the */
  35. /* public declarations. */
  36. /* -------------------------------------------------------------------- */
  37. class GDALMajorObject;
  38. class GDALDataset;
  39. class GDALRasterBand;
  40. class GDALDriver;
  41. class GDALRasterAttributeTable;
  42. class GDALProxyDataset;
  43. class GDALProxyRasterBand;
  44. class GDALAsyncReader;
  45. /* -------------------------------------------------------------------- */
  46. /* Pull in the public declarations. This gets the C apis, and */
  47. /* also various constants. However, we will still get to */
  48. /* provide the real class definitions for the GDAL classes. */
  49. /* -------------------------------------------------------------------- */
  50. #include "gdal.h"
  51. #include "gdal_frmts.h"
  52. #include "cpl_vsi.h"
  53. #include "cpl_conv.h"
  54. #include "cpl_string.h"
  55. #include "cpl_minixml.h"
  56. #include "cpl_multiproc.h"
  57. #include <vector>
  58. #include <map>
  59. #include "ogr_core.h"
  60. #define GMO_VALID 0x0001
  61. #define GMO_IGNORE_UNIMPLEMENTED 0x0002
  62. #define GMO_SUPPORT_MD 0x0004
  63. #define GMO_SUPPORT_MDMD 0x0008
  64. #define GMO_MD_DIRTY 0x0010
  65. #define GMO_PAM_CLASS 0x0020
  66. /************************************************************************/
  67. /* GDALMultiDomainMetadata */
  68. /************************************************************************/
  69. class CPL_DLL GDALMultiDomainMetadata
  70. {
  71. private:
  72. char **papszDomainList;
  73. CPLStringList **papoMetadataLists;
  74. public:
  75. GDALMultiDomainMetadata();
  76. ~GDALMultiDomainMetadata();
  77. int XMLInit( CPLXMLNode *psMetadata, int bMerge );
  78. CPLXMLNode *Serialize();
  79. char **GetDomainList() { return papszDomainList; }
  80. char **GetMetadata( const char * pszDomain = "" );
  81. CPLErr SetMetadata( char ** papszMetadata,
  82. const char * pszDomain = "" );
  83. const char *GetMetadataItem( const char * pszName,
  84. const char * pszDomain = "" );
  85. CPLErr SetMetadataItem( const char * pszName,
  86. const char * pszValue,
  87. const char * pszDomain = "" );
  88. void Clear();
  89. };
  90. /* ******************************************************************** */
  91. /* GDALMajorObject */
  92. /* */
  93. /* Base class providing metadata, description and other */
  94. /* services shared by major objects. */
  95. /* ******************************************************************** */
  96. //! Object with metadata.
  97. class CPL_DLL GDALMajorObject
  98. {
  99. protected:
  100. int nFlags; // GMO_* flags.
  101. CPLString sDescription;
  102. GDALMultiDomainMetadata oMDMD;
  103. char **BuildMetadataDomainList(char** papszList, int bCheckNonEmpty, ...) CPL_NULL_TERMINATED;
  104. public:
  105. GDALMajorObject();
  106. virtual ~GDALMajorObject();
  107. int GetMOFlags();
  108. void SetMOFlags(int nFlagsIn);
  109. virtual const char *GetDescription() const;
  110. virtual void SetDescription( const char * );
  111. virtual char **GetMetadataDomainList();
  112. virtual char **GetMetadata( const char * pszDomain = "" );
  113. virtual CPLErr SetMetadata( char ** papszMetadata,
  114. const char * pszDomain = "" );
  115. virtual const char *GetMetadataItem( const char * pszName,
  116. const char * pszDomain = "" );
  117. virtual CPLErr SetMetadataItem( const char * pszName,
  118. const char * pszValue,
  119. const char * pszDomain = "" );
  120. };
  121. /* ******************************************************************** */
  122. /* GDALDefaultOverviews */
  123. /* ******************************************************************** */
  124. class CPL_DLL GDALDefaultOverviews
  125. {
  126. friend class GDALDataset;
  127. GDALDataset *poDS;
  128. GDALDataset *poODS;
  129. CPLString osOvrFilename;
  130. int bOvrIsAux;
  131. int bCheckedForMask;
  132. int bOwnMaskDS;
  133. GDALDataset *poMaskDS;
  134. // for "overview datasets" we record base level info so we can
  135. // find our way back to get overview masks.
  136. GDALDataset *poBaseDS;
  137. // Stuff for deferred initialize/overviewscans...
  138. bool bCheckedForOverviews;
  139. void OverviewScan();
  140. char *pszInitName;
  141. int bInitNameIsOVR;
  142. char **papszInitSiblingFiles;
  143. public:
  144. GDALDefaultOverviews();
  145. ~GDALDefaultOverviews();
  146. void Initialize( GDALDataset *poDSIn, const char *pszName = NULL,
  147. char **papszSiblingFiles = NULL,
  148. int bNameIsOVR = FALSE );
  149. int IsInitialized();
  150. int CloseDependentDatasets();
  151. // Overview Related
  152. int GetOverviewCount(int);
  153. GDALRasterBand *GetOverview(int,int);
  154. CPLErr BuildOverviews( const char * pszBasename,
  155. const char * pszResampling,
  156. int nOverviews, int * panOverviewList,
  157. int nBands, int * panBandList,
  158. GDALProgressFunc pfnProgress,
  159. void *pProgressData );
  160. CPLErr BuildOverviewsSubDataset( const char * pszPhysicalFile,
  161. const char * pszResampling,
  162. int nOverviews, int * panOverviewList,
  163. int nBands, int * panBandList,
  164. GDALProgressFunc pfnProgress,
  165. void *pProgressData );
  166. CPLErr CleanOverviews();
  167. // Mask Related
  168. CPLErr CreateMaskBand( int nFlags, int nBand = -1 );
  169. GDALRasterBand *GetMaskBand( int nBand );
  170. int GetMaskFlags( int nBand );
  171. int HaveMaskFile( char **papszSiblings = NULL,
  172. const char *pszBasename = NULL );
  173. char** GetSiblingFiles() { return papszInitSiblingFiles; }
  174. };
  175. /* ******************************************************************** */
  176. /* GDALOpenInfo */
  177. /* */
  178. /* Structure of data about dataset for open functions. */
  179. /* ******************************************************************** */
  180. class CPL_DLL GDALOpenInfo
  181. {
  182. int bHasGotSiblingFiles;
  183. char **papszSiblingFiles;
  184. int nHeaderBytesTried;
  185. public:
  186. GDALOpenInfo( const char * pszFile, int nOpenFlagsIn,
  187. char **papszSiblingFiles = NULL );
  188. ~GDALOpenInfo( void );
  189. char *pszFilename;
  190. char** papszOpenOptions;
  191. GDALAccess eAccess;
  192. int nOpenFlags;
  193. int bStatOK;
  194. int bIsDirectory;
  195. VSILFILE *fpL;
  196. int nHeaderBytes;
  197. GByte *pabyHeader;
  198. int TryToIngest(int nBytes);
  199. char **GetSiblingFiles();
  200. };
  201. /* ******************************************************************** */
  202. /* GDALDataset */
  203. /* ******************************************************************** */
  204. class OGRLayer;
  205. class OGRGeometry;
  206. class OGRSpatialReference;
  207. class OGRStyleTable;
  208. class swq_select;
  209. class swq_select_parse_options;
  210. typedef struct GDALSQLParseInfo GDALSQLParseInfo;
  211. #ifdef DETECT_OLD_IRASTERIO
  212. typedef void signature_changed;
  213. #endif
  214. #ifdef GDAL_COMPILATION
  215. #define OPTIONAL_OUTSIDE_GDAL(val)
  216. #else
  217. #define OPTIONAL_OUTSIDE_GDAL(val) = val
  218. #endif
  219. //! A set of associated raster bands, usually from one file.
  220. class CPL_DLL GDALDataset : public GDALMajorObject
  221. {
  222. friend GDALDatasetH CPL_STDCALL GDALOpenEx( const char* pszFilename,
  223. unsigned int nOpenFlags,
  224. const char* const* papszAllowedDrivers,
  225. const char* const* papszOpenOptions,
  226. const char* const* papszSiblingFiles );
  227. friend void CPL_STDCALL GDALClose( GDALDatasetH hDS );
  228. friend class GDALDriver;
  229. friend class GDALDefaultOverviews;
  230. friend class GDALProxyDataset;
  231. friend class GDALDriverManager;
  232. void AddToDatasetOpenList();
  233. protected:
  234. GDALDriver *poDriver;
  235. GDALAccess eAccess;
  236. // Stored raster information.
  237. int nRasterXSize;
  238. int nRasterYSize;
  239. int nBands;
  240. GDALRasterBand **papoBands;
  241. int bForceCachedIO;
  242. int nRefCount;
  243. int bShared;
  244. GByte bIsInternal;
  245. GByte bSuppressOnClose;
  246. GByte bReserved1;
  247. GByte bReserved2;
  248. GDALDataset(void);
  249. void RasterInitialize( int, int );
  250. void SetBand( int, GDALRasterBand * );
  251. GDALDefaultOverviews oOvManager;
  252. virtual CPLErr IBuildOverviews( const char *, int, int *,
  253. int, int *, GDALProgressFunc, void * );
  254. #ifdef DETECT_OLD_IRASTERIO
  255. virtual signature_changed IRasterIO( GDALRWFlag, int, int, int, int,
  256. void *, int, int, GDALDataType,
  257. int, int *, int, int, int ) {};
  258. #endif
  259. virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
  260. void *, int, int, GDALDataType,
  261. int, int *, GSpacing, GSpacing, GSpacing,
  262. GDALRasterIOExtraArg* psExtraArg );
  263. CPLErr BlockBasedRasterIO( GDALRWFlag, int, int, int, int,
  264. void *, int, int, GDALDataType,
  265. int, int *, GSpacing, GSpacing, GSpacing,
  266. GDALRasterIOExtraArg* psExtraArg );
  267. void BlockBasedFlushCache();
  268. CPLErr ValidateRasterIOOrAdviseReadParameters(
  269. const char* pszCallingFunc,
  270. int* pbStopProcessingOnCENone,
  271. int nXOff, int nYOff, int nXSize, int nYSize,
  272. int nBufXSize, int nBufYSize,
  273. int nBandCount, int *panBandMap);
  274. virtual int CloseDependentDatasets();
  275. int ValidateLayerCreationOptions( const char* const* papszLCO );
  276. char **papszOpenOptions;
  277. friend class GDALRasterBand;
  278. int EnterReadWrite(GDALRWFlag eRWFlag);
  279. void LeaveReadWrite();
  280. public:
  281. virtual ~GDALDataset();
  282. int GetRasterXSize( void );
  283. int GetRasterYSize( void );
  284. int GetRasterCount( void );
  285. GDALRasterBand *GetRasterBand( int );
  286. virtual void FlushCache(void);
  287. virtual const char *GetProjectionRef(void);
  288. virtual CPLErr SetProjection( const char * );
  289. virtual CPLErr GetGeoTransform( double * );
  290. virtual CPLErr SetGeoTransform( double * );
  291. virtual CPLErr AddBand( GDALDataType eType,
  292. char **papszOptions=NULL );
  293. virtual void *GetInternalHandle( const char * );
  294. virtual GDALDriver *GetDriver(void);
  295. virtual char **GetFileList(void);
  296. virtual const char* GetDriverName();
  297. virtual int GetGCPCount();
  298. virtual const char *GetGCPProjection();
  299. virtual const GDAL_GCP *GetGCPs();
  300. virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
  301. const char *pszGCPProjection );
  302. virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
  303. int nBufXSize, int nBufYSize,
  304. GDALDataType eDT,
  305. int nBandCount, int *panBandList,
  306. char **papszOptions );
  307. virtual CPLErr CreateMaskBand( int nFlagsIn );
  308. virtual GDALAsyncReader*
  309. BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize,
  310. void *pBuf, int nBufXSize, int nBufYSize,
  311. GDALDataType eBufType,
  312. int nBandCount, int* panBandMap,
  313. int nPixelSpace, int nLineSpace, int nBandSpace,
  314. char **papszOptions);
  315. virtual void EndAsyncReader(GDALAsyncReader *);
  316. CPLErr RasterIO( GDALRWFlag, int, int, int, int,
  317. void *, int, int, GDALDataType,
  318. int, int *, GSpacing, GSpacing, GSpacing,
  319. GDALRasterIOExtraArg* psExtraArg
  320. #ifndef DOXYGEN_SKIP
  321. OPTIONAL_OUTSIDE_GDAL(NULL)
  322. #endif
  323. );
  324. int Reference();
  325. int Dereference();
  326. GDALAccess GetAccess() { return eAccess; }
  327. int GetShared();
  328. void MarkAsShared();
  329. void MarkSuppressOnClose() { bSuppressOnClose = TRUE; }
  330. char **GetOpenOptions() { return papszOpenOptions; }
  331. static GDALDataset **GetOpenDatasets( int *pnDatasetCount );
  332. CPLErr BuildOverviews( const char *, int, int *,
  333. int, int *, GDALProgressFunc, void * );
  334. void ReportError(CPLErr eErrClass, int err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
  335. private:
  336. CPLMutex *m_hMutex;
  337. OGRLayer* BuildLayerFromSelectInfo(swq_select* psSelectInfo,
  338. OGRGeometry *poSpatialFilter,
  339. const char *pszDialect,
  340. swq_select_parse_options* poSelectParseOptions);
  341. public:
  342. virtual int GetLayerCount();
  343. virtual OGRLayer *GetLayer(int);
  344. virtual OGRLayer *GetLayerByName(const char *);
  345. virtual OGRErr DeleteLayer(int);
  346. virtual int TestCapability( const char * );
  347. virtual OGRLayer *CreateLayer( const char *pszName,
  348. OGRSpatialReference *poSpatialRef = NULL,
  349. OGRwkbGeometryType eGType = wkbUnknown,
  350. char ** papszOptions = NULL );
  351. virtual OGRLayer *CopyLayer( OGRLayer *poSrcLayer,
  352. const char *pszNewName,
  353. char **papszOptions = NULL );
  354. virtual OGRStyleTable *GetStyleTable();
  355. virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable );
  356. virtual void SetStyleTable(OGRStyleTable *poStyleTable);
  357. virtual OGRLayer * ExecuteSQL( const char *pszStatement,
  358. OGRGeometry *poSpatialFilter,
  359. const char *pszDialect );
  360. virtual void ReleaseResultSet( OGRLayer * poResultsSet );
  361. int GetRefCount() const;
  362. int GetSummaryRefCount() const;
  363. OGRErr Release();
  364. virtual OGRErr StartTransaction(int bForce=FALSE);
  365. virtual OGRErr CommitTransaction();
  366. virtual OGRErr RollbackTransaction();
  367. static int IsGenericSQLDialect(const char* pszDialect);
  368. // Semi-public methods. Only to be used by in-tree drivers.
  369. GDALSQLParseInfo* BuildParseInfo(swq_select* psSelectInfo,
  370. swq_select_parse_options* poSelectParseOptions);
  371. void DestroyParseInfo(GDALSQLParseInfo* psParseInfo );
  372. OGRLayer * ExecuteSQL( const char *pszStatement,
  373. OGRGeometry *poSpatialFilter,
  374. const char *pszDialect,
  375. swq_select_parse_options* poSelectParseOptions);
  376. protected:
  377. virtual OGRLayer *ICreateLayer( const char *pszName,
  378. OGRSpatialReference *poSpatialRef = NULL,
  379. OGRwkbGeometryType eGType = wkbUnknown,
  380. char ** papszOptions = NULL );
  381. OGRErr ProcessSQLCreateIndex( const char * );
  382. OGRErr ProcessSQLDropIndex( const char * );
  383. OGRErr ProcessSQLDropTable( const char * );
  384. OGRErr ProcessSQLAlterTableAddColumn( const char * );
  385. OGRErr ProcessSQLAlterTableDropColumn( const char * );
  386. OGRErr ProcessSQLAlterTableAlterColumn( const char * );
  387. OGRErr ProcessSQLAlterTableRenameColumn( const char * );
  388. OGRStyleTable *m_poStyleTable;
  389. };
  390. /* ******************************************************************** */
  391. /* GDALRasterBlock */
  392. /* ******************************************************************** */
  393. //! A single raster block in the block cache.
  394. class CPL_DLL GDALRasterBlock
  395. {
  396. GDALDataType eType;
  397. int bDirty;
  398. int nLockCount;
  399. int nXOff;
  400. int nYOff;
  401. int nXSize;
  402. int nYSize;
  403. void *pData;
  404. GDALRasterBand *poBand;
  405. GDALRasterBlock *poNext;
  406. GDALRasterBlock *poPrevious;
  407. int bMustDetach;
  408. void Touch_unlocked( void );
  409. void Detach_unlocked( void );
  410. public:
  411. GDALRasterBlock( GDALRasterBand *, int, int );
  412. virtual ~GDALRasterBlock();
  413. CPLErr Internalize( void );
  414. void Touch( void );
  415. void MarkDirty( void );
  416. void MarkClean( void );
  417. void AddLock( void ) { nLockCount++; }
  418. void DropLock( void ) { nLockCount--; }
  419. void Detach();
  420. CPLErr Write();
  421. GDALDataType GetDataType() { return eType; }
  422. int GetXOff() { return nXOff; }
  423. int GetYOff() { return nYOff; }
  424. int GetXSize() { return nXSize; }
  425. int GetYSize() { return nYSize; }
  426. int GetDirty() { return bDirty; }
  427. int GetLockCount() { return nLockCount; }
  428. void *GetDataRef( void ) { return pData; }
  429. int GetBlockSize() { return nXSize * nYSize * (GDALGetDataTypeSize(eType) / 8); }
  430. /// @brief Accessor to source GDALRasterBand object.
  431. /// @return source raster band of the raster block.
  432. GDALRasterBand *GetBand() { return poBand; }
  433. static void FlushDirtyBlocks();
  434. static int FlushCacheBlock(int bDirtyBlocksOnly = FALSE);
  435. static void Verify();
  436. static int SafeLockBlock( GDALRasterBlock ** );
  437. /* Should only be called by GDALDestroyDriverManager() */
  438. static void DestroyRBMutex();
  439. };
  440. /* ******************************************************************** */
  441. /* GDALColorTable */
  442. /* ******************************************************************** */
  443. /*! A color table / palette. */
  444. class CPL_DLL GDALColorTable
  445. {
  446. GDALPaletteInterp eInterp;
  447. std::vector<GDALColorEntry> aoEntries;
  448. public:
  449. GDALColorTable( GDALPaletteInterp = GPI_RGB );
  450. ~GDALColorTable();
  451. GDALColorTable *Clone() const;
  452. int IsSame(const GDALColorTable* poOtherCT) const;
  453. GDALPaletteInterp GetPaletteInterpretation() const;
  454. int GetColorEntryCount() const;
  455. const GDALColorEntry *GetColorEntry( int ) const;
  456. int GetColorEntryAsRGB( int, GDALColorEntry * ) const;
  457. void SetColorEntry( int, const GDALColorEntry * );
  458. int CreateColorRamp( int, const GDALColorEntry * ,
  459. int, const GDALColorEntry * );
  460. };
  461. /* ******************************************************************** */
  462. /* GDALRasterBand */
  463. /* ******************************************************************** */
  464. //! A single raster band (or channel).
  465. class CPL_DLL GDALRasterBand : public GDALMajorObject
  466. {
  467. private:
  468. CPLErr eFlushBlockErr;
  469. void SetFlushBlockErr( CPLErr eErr );
  470. friend class GDALRasterBlock;
  471. CPLErr UnreferenceBlock( int nXBlockOff, int nYBlockOff );
  472. protected:
  473. GDALDataset *poDS;
  474. int nBand; /* 1 based */
  475. int nRasterXSize;
  476. int nRasterYSize;
  477. GDALDataType eDataType;
  478. GDALAccess eAccess;
  479. /* stuff related to blocking, and raster cache */
  480. int nBlockXSize;
  481. int nBlockYSize;
  482. int nBlocksPerRow;
  483. int nBlocksPerColumn;
  484. int bSubBlockingActive;
  485. int nSubBlocksPerRow;
  486. int nSubBlocksPerColumn;
  487. GDALRasterBlock **papoBlocks;
  488. int nBlockReads;
  489. int bForceCachedIO;
  490. GDALRasterBand *poMask;
  491. bool bOwnMask;
  492. int nMaskFlags;
  493. void InvalidateMaskBand();
  494. friend class GDALDataset;
  495. friend class GDALProxyRasterBand;
  496. friend class GDALDefaultOverviews;
  497. CPLErr RasterIOResampled( GDALRWFlag, int, int, int, int,
  498. void *, int, int, GDALDataType,
  499. GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg );
  500. int EnterReadWrite(GDALRWFlag eRWFlag);
  501. void LeaveReadWrite();
  502. protected:
  503. virtual CPLErr IReadBlock( int, int, void * ) = 0;
  504. virtual CPLErr IWriteBlock( int, int, void * );
  505. #ifdef DETECT_OLD_IRASTERIO
  506. virtual signature_changed IRasterIO( GDALRWFlag, int, int, int, int,
  507. void *, int, int, GDALDataType,
  508. int, int ) {};
  509. #endif
  510. virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
  511. void *, int, int, GDALDataType,
  512. GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg );
  513. CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int,
  514. void *, int, int, GDALDataType,
  515. GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg );
  516. int InitBlockInfo();
  517. CPLErr AdoptBlock( int, int, GDALRasterBlock * );
  518. GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff );
  519. public:
  520. GDALRasterBand();
  521. virtual ~GDALRasterBand();
  522. int GetXSize();
  523. int GetYSize();
  524. int GetBand();
  525. GDALDataset*GetDataset();
  526. GDALDataType GetRasterDataType( void );
  527. void GetBlockSize( int *, int * );
  528. GDALAccess GetAccess();
  529. CPLErr RasterIO( GDALRWFlag, int, int, int, int,
  530. void *, int, int, GDALDataType,
  531. GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg
  532. #ifndef DOXYGEN_SKIP
  533. OPTIONAL_OUTSIDE_GDAL(NULL)
  534. #endif
  535. );
  536. CPLErr ReadBlock( int, int, void * );
  537. CPLErr WriteBlock( int, int, void * );
  538. GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff,
  539. int bJustInitialize = FALSE );
  540. CPLErr FlushBlock( int = -1, int = -1, int bWriteDirtyBlock = TRUE );
  541. unsigned char* GetIndexColorTranslationTo(/* const */ GDALRasterBand* poReferenceBand,
  542. unsigned char* pTranslationTable = NULL,
  543. int* pApproximateMatching = NULL);
  544. // New OpengIS CV_SampleDimension stuff.
  545. virtual CPLErr FlushCache();
  546. virtual char **GetCategoryNames();
  547. virtual double GetNoDataValue( int *pbSuccess = NULL );
  548. virtual double GetMinimum( int *pbSuccess = NULL );
  549. virtual double GetMaximum(int *pbSuccess = NULL );
  550. virtual double GetOffset( int *pbSuccess = NULL );
  551. virtual double GetScale( int *pbSuccess = NULL );
  552. virtual const char *GetUnitType();
  553. virtual GDALColorInterp GetColorInterpretation();
  554. virtual GDALColorTable *GetColorTable();
  555. virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
  556. virtual CPLErr SetCategoryNames( char ** );
  557. virtual CPLErr SetNoDataValue( double );
  558. virtual CPLErr SetColorTable( GDALColorTable * );
  559. virtual CPLErr SetColorInterpretation( GDALColorInterp );
  560. virtual CPLErr SetOffset( double );
  561. virtual CPLErr SetScale( double );
  562. virtual CPLErr SetUnitType( const char * );
  563. virtual CPLErr GetStatistics( int bApproxOK, int bForce,
  564. double *pdfMin, double *pdfMax,
  565. double *pdfMean, double *padfStdDev );
  566. virtual CPLErr ComputeStatistics( int bApproxOK,
  567. double *pdfMin, double *pdfMax,
  568. double *pdfMean, double *pdfStdDev,
  569. GDALProgressFunc, void *pProgressData );
  570. virtual CPLErr SetStatistics( double dfMin, double dfMax,
  571. double dfMean, double dfStdDev );
  572. virtual CPLErr ComputeRasterMinMax( int, double* );
  573. virtual int HasArbitraryOverviews();
  574. virtual int GetOverviewCount();
  575. virtual GDALRasterBand *GetOverview(int);
  576. virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig );
  577. virtual CPLErr BuildOverviews( const char *, int, int *,
  578. GDALProgressFunc, void * );
  579. virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
  580. int nBufXSize, int nBufYSize,
  581. GDALDataType eDT, char **papszOptions );
  582. virtual CPLErr GetHistogram( double dfMin, double dfMax,
  583. int nBuckets, GUIntBig * panHistogram,
  584. int bIncludeOutOfRange, int bApproxOK,
  585. GDALProgressFunc, void *pProgressData );
  586. virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
  587. int *pnBuckets, GUIntBig ** ppanHistogram,
  588. int bForce,
  589. GDALProgressFunc, void *pProgressData);
  590. virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
  591. int nBuckets, GUIntBig *panHistogram );
  592. virtual GDALRasterAttributeTable *GetDefaultRAT();
  593. virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * );
  594. virtual GDALRasterBand *GetMaskBand();
  595. virtual int GetMaskFlags();
  596. virtual CPLErr CreateMaskBand( int nFlagsIn );
  597. virtual CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag,
  598. int *pnPixelSpace,
  599. GIntBig *pnLineSpace,
  600. char **papszOptions );
  601. void ReportError(CPLErr eErrClass, int err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
  602. };
  603. /* ******************************************************************** */
  604. /* GDALAllValidMaskBand */
  605. /* ******************************************************************** */
  606. class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand
  607. {
  608. protected:
  609. virtual CPLErr IReadBlock( int, int, void * );
  610. public:
  611. GDALAllValidMaskBand( GDALRasterBand * );
  612. virtual ~GDALAllValidMaskBand();
  613. virtual GDALRasterBand *GetMaskBand();
  614. virtual int GetMaskFlags();
  615. };
  616. /* ******************************************************************** */
  617. /* GDALNoDataMaskBand */
  618. /* ******************************************************************** */
  619. class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
  620. {
  621. double dfNoDataValue;
  622. GDALRasterBand *poParent;
  623. protected:
  624. virtual CPLErr IReadBlock( int, int, void * );
  625. virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
  626. void *, int, int, GDALDataType,
  627. GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg );
  628. public:
  629. GDALNoDataMaskBand( GDALRasterBand * );
  630. virtual ~GDALNoDataMaskBand();
  631. };
  632. /* ******************************************************************** */
  633. /* GDALNoDataValuesMaskBand */
  634. /* ******************************************************************** */
  635. class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand
  636. {
  637. double *padfNodataValues;
  638. protected:
  639. virtual CPLErr IReadBlock( int, int, void * );
  640. public:
  641. GDALNoDataValuesMaskBand( GDALDataset * );
  642. virtual ~GDALNoDataValuesMaskBand();
  643. };
  644. /* ******************************************************************** */
  645. /* GDALRescaledAlphaBand */
  646. /* ******************************************************************** */
  647. class GDALRescaledAlphaBand : public GDALRasterBand
  648. {
  649. GDALRasterBand *poParent;
  650. void *pTemp;
  651. protected:
  652. virtual CPLErr IReadBlock( int, int, void * );
  653. virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
  654. void *, int, int, GDALDataType,
  655. GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg );
  656. public:
  657. GDALRescaledAlphaBand( GDALRasterBand * );
  658. virtual ~GDALRescaledAlphaBand();
  659. };
  660. /* ******************************************************************** */
  661. /* GDALDriver */
  662. /* ******************************************************************** */
  663. /**
  664. * \brief Format specific driver.
  665. *
  666. * An instance of this class is created for each supported format, and
  667. * manages information about the format.
  668. *
  669. * This roughly corresponds to a file format, though some
  670. * drivers may be gateways to many formats through a secondary
  671. * multi-library.
  672. */
  673. class CPL_DLL GDALDriver : public GDALMajorObject
  674. {
  675. public:
  676. GDALDriver();
  677. ~GDALDriver();
  678. virtual CPLErr SetMetadataItem( const char * pszName,
  679. const char * pszValue,
  680. const char * pszDomain = "" );
  681. /* -------------------------------------------------------------------- */
  682. /* Public C++ methods. */
  683. /* -------------------------------------------------------------------- */
  684. GDALDataset *Create( const char * pszName,
  685. int nXSize, int nYSize, int nBands,
  686. GDALDataType eType, char ** papszOptions ) CPL_WARN_UNUSED_RESULT;
  687. CPLErr Delete( const char * pszName );
  688. CPLErr Rename( const char * pszNewName,
  689. const char * pszOldName );
  690. CPLErr CopyFiles( const char * pszNewName,
  691. const char * pszOldName );
  692. GDALDataset *CreateCopy( const char *, GDALDataset *,
  693. int, char **,
  694. GDALProgressFunc pfnProgress,
  695. void * pProgressData ) CPL_WARN_UNUSED_RESULT;
  696. /* -------------------------------------------------------------------- */
  697. /* The following are semiprivate, not intended to be accessed */
  698. /* by anyone but the formats instantiating and populating the */
  699. /* drivers. */
  700. /* -------------------------------------------------------------------- */
  701. GDALDataset *(*pfnOpen)( GDALOpenInfo * );
  702. GDALDataset *(*pfnCreate)( const char * pszName,
  703. int nXSize, int nYSize, int nBands,
  704. GDALDataType eType,
  705. char ** papszOptions );
  706. CPLErr (*pfnDelete)( const char * pszName );
  707. GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *,
  708. int, char **,
  709. GDALProgressFunc pfnProgress,
  710. void * pProgressData );
  711. void *pDriverData;
  712. void (*pfnUnloadDriver)(GDALDriver *);
  713. /* Return 1 if the passed file is certainly recognized by the driver */
  714. /* Return 0 if the passed file is certainly NOT recognized by the driver */
  715. /* Return -1 if the passed file may be or may not be recognized by the driver,
  716. and that a potentially costly test must be done with pfnOpen */
  717. int (*pfnIdentify)( GDALOpenInfo * );
  718. CPLErr (*pfnRename)( const char * pszNewName,
  719. const char * pszOldName );
  720. CPLErr (*pfnCopyFiles)( const char * pszNewName,
  721. const char * pszOldName );
  722. /* For legacy OGR drivers */
  723. GDALDataset *(*pfnOpenWithDriverArg)( GDALDriver*, GDALOpenInfo * );
  724. GDALDataset *(*pfnCreateVectorOnly)( GDALDriver*,
  725. const char * pszName,
  726. char ** papszOptions );
  727. CPLErr (*pfnDeleteDataSource)( GDALDriver*,
  728. const char * pszName );
  729. /* -------------------------------------------------------------------- */
  730. /* Helper methods. */
  731. /* -------------------------------------------------------------------- */
  732. GDALDataset *DefaultCreateCopy( const char *, GDALDataset *,
  733. int, char **,
  734. GDALProgressFunc pfnProgress,
  735. void * pProgressData ) CPL_WARN_UNUSED_RESULT;
  736. static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
  737. GDALDataset *poDstDS,
  738. int bStrict );
  739. static CPLErr QuietDelete( const char * pszName );
  740. CPLErr DefaultRename( const char * pszNewName,
  741. const char * pszOldName );
  742. CPLErr DefaultCopyFiles( const char * pszNewName,
  743. const char * pszOldName );
  744. };
  745. /* ******************************************************************** */
  746. /* GDALDriverManager */
  747. /* ******************************************************************** */
  748. /**
  749. * Class for managing the registration of file format drivers.
  750. *
  751. * Use GetGDALDriverManager() to fetch the global singleton instance of
  752. * this class.
  753. */
  754. class CPL_DLL GDALDriverManager : public GDALMajorObject
  755. {
  756. int nDrivers;
  757. GDALDriver **papoDrivers;
  758. std::map<CPLString, GDALDriver*> oMapNameToDrivers;
  759. GDALDriver *GetDriver_unlocked( int iDriver )
  760. { return (iDriver >= 0 && iDriver < nDrivers) ? papoDrivers[iDriver] : NULL; }
  761. GDALDriver *GetDriverByName_unlocked( const char * pszName )
  762. { return oMapNameToDrivers[CPLString(pszName).toupper()]; }
  763. public:
  764. GDALDriverManager();
  765. ~GDALDriverManager();
  766. int GetDriverCount( void );
  767. GDALDriver *GetDriver( int );
  768. GDALDriver *GetDriverByName( const char * );
  769. int RegisterDriver( GDALDriver * );
  770. void DeregisterDriver( GDALDriver * );
  771. void AutoLoadDrivers();
  772. void AutoSkipDrivers();
  773. };
  774. CPL_C_START
  775. GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
  776. CPL_C_END
  777. /* ******************************************************************** */
  778. /* GDALAsyncReader */
  779. /* ******************************************************************** */
  780. /**
  781. * Class used as a session object for asynchronous requests. They are
  782. * created with GDALDataset::BeginAsyncReader(), and destroyed with
  783. * GDALDataset::EndAsyncReader().
  784. */
  785. class CPL_DLL GDALAsyncReader
  786. {
  787. protected:
  788. GDALDataset* poDS;
  789. int nXOff;
  790. int nYOff;
  791. int nXSize;
  792. int nYSize;
  793. void * pBuf;
  794. int nBufXSize;
  795. int nBufYSize;
  796. GDALDataType eBufType;
  797. int nBandCount;
  798. int* panBandMap;
  799. int nPixelSpace;
  800. int nLineSpace;
  801. int nBandSpace;
  802. public:
  803. GDALAsyncReader();
  804. virtual ~GDALAsyncReader();
  805. GDALDataset* GetGDALDataset() {return poDS;}
  806. int GetXOffset() {return nXOff;}
  807. int GetYOffset() {return nYOff;}
  808. int GetXSize() {return nXSize;}
  809. int GetYSize() {return nYSize;}
  810. void * GetBuffer() {return pBuf;}
  811. int GetBufferXSize() {return nBufXSize;}
  812. int GetBufferYSize() {return nBufYSize;}
  813. GDALDataType GetBufferType() {return eBufType;}
  814. int GetBandCount() {return nBandCount;}
  815. int* GetBandMap() {return panBandMap;}
  816. int GetPixelSpace() {return nPixelSpace;}
  817. int GetLineSpace() {return nLineSpace;}
  818. int GetBandSpace() {return nBandSpace;}
  819. virtual GDALAsyncStatusType
  820. GetNextUpdatedRegion(double dfTimeout,
  821. int* pnBufXOff, int* pnBufYOff,
  822. int* pnBufXSize, int* pnBufYSize) = 0;
  823. virtual int LockBuffer( double dfTimeout = -1.0 );
  824. virtual void UnlockBuffer();
  825. };
  826. /* ==================================================================== */
  827. /* An assortment of overview related stuff. */
  828. /* ==================================================================== */
  829. /* Not a public symbol for the moment */
  830. CPLErr
  831. GDALRegenerateOverviewsMultiBand(int nBands, GDALRasterBand** papoSrcBands,
  832. int nOverviews,
  833. GDALRasterBand*** papapoOverviewBands,
  834. const char * pszResampling,
  835. GDALProgressFunc pfnProgress, void * pProgressData );
  836. typedef CPLErr (*GDALResampleFunction)
  837. ( double dfXRatioDstToSrc,
  838. double dfYRatioDstToSrc,
  839. double dfSrcXDelta,
  840. double dfSrcYDelta,
  841. GDALDataType eWrkDataType,
  842. void * pChunk,
  843. GByte * pabyChunkNodataMask,
  844. int nChunkXOff, int nChunkXSize,
  845. int nChunkYOff, int nChunkYSize,
  846. int nDstXOff, int nDstXOff2,
  847. int nDstYOff, int nDstYOff2,
  848. GDALRasterBand * poOverview,
  849. const char * pszResampling,
  850. int bHasNoData, float fNoDataValue,
  851. GDALColorTable* poColorTable,
  852. GDALDataType eSrcDataType);
  853. GDALResampleFunction GDALGetResampleFunction(const char* pszResampling,
  854. int* pnRadius);
  855. GDALDataType GDALGetOvrWorkDataType(const char* pszResampling,
  856. GDALDataType eSrcDataType);
  857. CPL_C_START
  858. #ifndef WIN32CE
  859. CPLErr CPL_DLL
  860. HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS,
  861. GDALDataset **ppoDS,
  862. int nBands, int *panBandList,
  863. int nNewOverviews, int *panNewOverviewList,
  864. const char *pszResampling,
  865. GDALProgressFunc pfnProgress,
  866. void *pProgressData );
  867. #endif /* WIN32CE */
  868. CPLErr CPL_DLL
  869. GTIFFBuildOverviews( const char * pszFilename,
  870. int nBands, GDALRasterBand **papoBandList,
  871. int nOverviews, int * panOverviewList,
  872. const char * pszResampling,
  873. GDALProgressFunc pfnProgress, void * pProgressData );
  874. CPLErr CPL_DLL
  875. GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename,
  876. const char * pszResampling,
  877. int nOverviews, int * panOverviewList,
  878. int nBands, int * panBandList,
  879. GDALProgressFunc pfnProgress, void * pProgressData);
  880. int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand* poBand,
  881. int &nXOff, int &nYOff,
  882. int &nXSize, int &nYSize,
  883. int nBufXSize, int nBufYSize) CPL_WARN_DEPRECATED("Use GDALBandGetBestOverviewLevel2 instead");
  884. int CPL_DLL GDALBandGetBestOverviewLevel2(GDALRasterBand* poBand,
  885. int &nXOff, int &nYOff,
  886. int &nXSize, int &nYSize,
  887. int nBufXSize, int nBufYSize,
  888. GDALRasterIOExtraArg* psExtraArg);
  889. int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize ) CPL_WARN_DEPRECATED("Use GDALOvLevelAdjust2 instead");
  890. int CPL_DLL GDALOvLevelAdjust2( int nOvLevel, int nXSize, int nYSize );
  891. int CPL_DLL GDALComputeOvFactor( int nOvrXSize, int nRasterXSize,
  892. int nOvrYSize, int nRasterYSize );
  893. GDALDataset CPL_DLL *
  894. GDALFindAssociatedAuxFile( const char *pszBasefile, GDALAccess eAccess,
  895. GDALDataset *poDependentDS );
  896. /* ==================================================================== */
  897. /* Misc functions. */
  898. /* ==================================================================== */
  899. CPLErr CPL_DLL GDALParseGMLCoverage( CPLXMLNode *psTree,
  900. int *pnXSize, int *pnYSize,
  901. double *padfGeoTransform,
  902. char **ppszProjection );
  903. /* ==================================================================== */
  904. /* Infrastructure to check that dataset characteristics are valid */
  905. /* ==================================================================== */
  906. int CPL_DLL GDALCheckDatasetDimensions( int nXSize, int nYSize );
  907. int CPL_DLL GDALCheckBandCount( int nBands, int bIsZeroAllowed );
  908. // Test if 2 floating point values match. Useful when comparing values
  909. // stored as a string at some point. See #3573, #4183, #4506
  910. #define ARE_REAL_EQUAL(dfVal1, dfVal2) \
  911. (dfVal1 == dfVal2 || fabs(dfVal1 - dfVal2) < 1e-10 || (dfVal2 != 0 && fabs(1 - dfVal1 / dfVal2) < 1e-10 ))
  912. /* Internal use only */
  913. /* CPL_DLL exported, but only for in-tree drivers that can be built as plugins */
  914. int CPL_DLL GDALReadWorldFile2( const char *pszBaseFilename, const char *pszExtension,
  915. double *padfGeoTransform, char** papszSiblingFiles,
  916. char** ppszWorldFileNameOut);
  917. int GDALReadTabFile2( const char * pszBaseFilename,
  918. double *padfGeoTransform, char **ppszWKT,
  919. int *pnGCPCount, GDAL_GCP **ppasGCPs,
  920. char** papszSiblingFiles, char** ppszTabFileNameOut );
  921. void CPL_DLL GDALCopyRasterIOExtraArg(GDALRasterIOExtraArg* psDestArg,
  922. GDALRasterIOExtraArg* psSrcArg);
  923. CPL_C_END
  924. void GDALNullifyOpenDatasetsList();
  925. CPLMutex** GDALGetphDMMutex();
  926. CPLMutex** GDALGetphDLMutex();
  927. void GDALNullifyProxyPoolSingleton();
  928. GDALDriver* GDALGetAPIPROXYDriver();
  929. void GDALSetResponsiblePIDForCurrentThread(GIntBig responsiblePID);
  930. GIntBig GDALGetResponsiblePIDForCurrentThread();
  931. CPLString GDALFindAssociatedFile( const char *pszBasename, const char *pszExt,
  932. char **papszSiblingFiles, int nFlags );
  933. CPLErr EXIFExtractMetadata(char**& papszMetadata,
  934. void *fpL, int nOffset,
  935. int bSwabflag, int nTIFFHEADER,
  936. int& nExifOffset, int& nInterOffset, int& nGPSOffset);
  937. int GDALValidateOpenOptions( GDALDriverH hDriver,
  938. const char* const* papszOptionOptions);
  939. int GDALValidateOptions( const char* pszOptionList,
  940. const char* const* papszOptionsToValidate,
  941. const char* pszErrorMessageOptionType,
  942. const char* pszErrorMessageContainerName);
  943. GDALRIOResampleAlg GDALRasterIOGetResampleAlg(const char* pszResampling);
  944. void GDALRasterIOExtraArgSetResampleAlg(GDALRasterIOExtraArg* psExtraArg,
  945. int nXSize, int nYSize,
  946. int nBufXSize, int nBufYSize);
  947. /* CPL_DLL exported, but only for gdalwarp */
  948. GDALDataset CPL_DLL* GDALCreateOverviewDataset(GDALDataset* poDS, int nOvrLevel,
  949. int bThisLevelOnly, int bOwnDS);
  950. #define DIV_ROUND_UP(a, b) ( ((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1) )
  951. // Number of data samples that will be used to compute approximate statistics
  952. // (minimum value, maximum value, etc.)
  953. #define GDALSTAT_APPROX_NUMSAMPLES 2500
  954. CPL_C_START
  955. /* Caution: for technical reason this declaration is duplicated in gdal_crs.c */
  956. /* so any signature change should be reflected there too */
  957. void GDALSerializeGCPListToXML( CPLXMLNode* psParentNode,
  958. GDAL_GCP* pasGCPList,
  959. int nGCPCount,
  960. const char* pszGCPProjection );
  961. void GDALDeserializeGCPListFromXML( CPLXMLNode* psGCPList,
  962. GDAL_GCP** ppasGCPList,
  963. int* pnGCPCount,
  964. char** ppszGCPProjection );
  965. CPL_C_END
  966. void GDALSerializeOpenOptionsToXML( CPLXMLNode* psParentNode, char** papszOpenOptions);
  967. char** GDALDeserializeOpenOptionsFromXML( CPLXMLNode* psParentNode );
  968. int GDALCanFileAcceptSidecarFile(const char* pszFilename);
  969. #endif /* ndef GDAL_PRIV_H_INCLUDED */