gooderp18绿色标准版
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1883 行
71KB

  1. /******************************************************************************
  2. * $Id: gdal_priv.h f01a85918e973b637f49cc8d0394fd3c18b22b1f 2019-04-30 18:25:03 +0200 Even 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. * \file gdal_priv.h
  35. *
  36. * C++ GDAL entry points.
  37. */
  38. /* -------------------------------------------------------------------- */
  39. /* Predeclare various classes before pulling in gdal.h, the */
  40. /* public declarations. */
  41. /* -------------------------------------------------------------------- */
  42. class GDALMajorObject;
  43. class GDALDataset;
  44. class GDALRasterBand;
  45. class GDALDriver;
  46. class GDALRasterAttributeTable;
  47. class GDALProxyDataset;
  48. class GDALProxyRasterBand;
  49. class GDALAsyncReader;
  50. /* -------------------------------------------------------------------- */
  51. /* Pull in the public declarations. This gets the C apis, and */
  52. /* also various constants. However, we will still get to */
  53. /* provide the real class definitions for the GDAL classes. */
  54. /* -------------------------------------------------------------------- */
  55. #include "gdal.h"
  56. #include "gdal_frmts.h"
  57. #include "cpl_vsi.h"
  58. #include "cpl_conv.h"
  59. #include "cpl_string.h"
  60. #include "cpl_minixml.h"
  61. #include "cpl_multiproc.h"
  62. #include "cpl_atomic_ops.h"
  63. #include <cmath>
  64. #include <iterator>
  65. #include <limits>
  66. #include <map>
  67. #include <memory>
  68. #include <vector>
  69. #include "ogr_core.h"
  70. #include "ogr_feature.h"
  71. //! @cond Doxygen_Suppress
  72. #define GMO_VALID 0x0001
  73. #define GMO_IGNORE_UNIMPLEMENTED 0x0002
  74. #define GMO_SUPPORT_MD 0x0004
  75. #define GMO_SUPPORT_MDMD 0x0008
  76. #define GMO_MD_DIRTY 0x0010
  77. #define GMO_PAM_CLASS 0x0020
  78. //! @endcond
  79. /************************************************************************/
  80. /* GDALMultiDomainMetadata */
  81. /************************************************************************/
  82. //! @cond Doxygen_Suppress
  83. class CPL_DLL GDALMultiDomainMetadata
  84. {
  85. private:
  86. char **papszDomainList;
  87. CPLStringList **papoMetadataLists;
  88. public:
  89. GDALMultiDomainMetadata();
  90. ~GDALMultiDomainMetadata();
  91. int XMLInit( CPLXMLNode *psMetadata, int bMerge );
  92. CPLXMLNode *Serialize();
  93. char **GetDomainList() { return papszDomainList; }
  94. char **GetMetadata( const char * pszDomain = "" );
  95. CPLErr SetMetadata( char ** papszMetadata,
  96. const char * pszDomain = "" );
  97. const char *GetMetadataItem( const char * pszName,
  98. const char * pszDomain = "" );
  99. CPLErr SetMetadataItem( const char * pszName,
  100. const char * pszValue,
  101. const char * pszDomain = "" );
  102. void Clear();
  103. private:
  104. CPL_DISALLOW_COPY_ASSIGN(GDALMultiDomainMetadata)
  105. };
  106. //! @endcond
  107. /* ******************************************************************** */
  108. /* GDALMajorObject */
  109. /* */
  110. /* Base class providing metadata, description and other */
  111. /* services shared by major objects. */
  112. /* ******************************************************************** */
  113. /** Object with metadata. */
  114. class CPL_DLL GDALMajorObject
  115. {
  116. protected:
  117. //! @cond Doxygen_Suppress
  118. int nFlags; // GMO_* flags.
  119. CPLString sDescription{};
  120. GDALMultiDomainMetadata oMDMD{};
  121. //! @endcond
  122. char **BuildMetadataDomainList( char** papszList,
  123. int bCheckNonEmpty, ... ) CPL_NULL_TERMINATED;
  124. public:
  125. GDALMajorObject();
  126. virtual ~GDALMajorObject();
  127. int GetMOFlags() const;
  128. void SetMOFlags( int nFlagsIn );
  129. virtual const char *GetDescription() const;
  130. virtual void SetDescription( const char * );
  131. virtual char **GetMetadataDomainList();
  132. virtual char **GetMetadata( const char * pszDomain = "" );
  133. virtual CPLErr SetMetadata( char ** papszMetadata,
  134. const char * pszDomain = "" );
  135. virtual const char *GetMetadataItem( const char * pszName,
  136. const char * pszDomain = "" );
  137. virtual CPLErr SetMetadataItem( const char * pszName,
  138. const char * pszValue,
  139. const char * pszDomain = "" );
  140. /** Convert a GDALMajorObject* to a GDALMajorObjectH.
  141. * @since GDAL 2.3
  142. */
  143. static inline GDALMajorObjectH ToHandle(GDALMajorObject* poMajorObject)
  144. { return static_cast<GDALMajorObjectH>(poMajorObject); }
  145. /** Convert a GDALMajorObjectH to a GDALMajorObject*.
  146. * @since GDAL 2.3
  147. */
  148. static inline GDALMajorObject* FromHandle(GDALMajorObjectH hMajorObject)
  149. { return static_cast<GDALMajorObject*>(hMajorObject); }
  150. };
  151. /* ******************************************************************** */
  152. /* GDALDefaultOverviews */
  153. /* ******************************************************************** */
  154. //! @cond Doxygen_Suppress
  155. class CPL_DLL GDALDefaultOverviews
  156. {
  157. friend class GDALDataset;
  158. GDALDataset *poDS;
  159. GDALDataset *poODS;
  160. CPLString osOvrFilename{};
  161. bool bOvrIsAux;
  162. bool bCheckedForMask;
  163. bool bOwnMaskDS;
  164. GDALDataset *poMaskDS;
  165. // For "overview datasets" we record base level info so we can
  166. // find our way back to get overview masks.
  167. GDALDataset *poBaseDS;
  168. // Stuff for deferred initialize/overviewscans.
  169. bool bCheckedForOverviews;
  170. void OverviewScan();
  171. char *pszInitName;
  172. bool bInitNameIsOVR;
  173. char **papszInitSiblingFiles;
  174. public:
  175. GDALDefaultOverviews();
  176. ~GDALDefaultOverviews();
  177. void Initialize( GDALDataset *poDSIn, const char *pszName = nullptr,
  178. char **papszSiblingFiles = nullptr,
  179. int bNameIsOVR = FALSE );
  180. void TransferSiblingFiles( char** papszSiblingFiles );
  181. int IsInitialized();
  182. int CloseDependentDatasets();
  183. // Overview Related
  184. int GetOverviewCount( int nBand );
  185. GDALRasterBand *GetOverview( int nBand, int iOverview );
  186. CPLErr BuildOverviews( const char * pszBasename,
  187. const char * pszResampling,
  188. int nOverviews, int * panOverviewList,
  189. int nBands, int * panBandList,
  190. GDALProgressFunc pfnProgress,
  191. void *pProgressData );
  192. CPLErr BuildOverviewsSubDataset( const char * pszPhysicalFile,
  193. const char * pszResampling,
  194. int nOverviews, int * panOverviewList,
  195. int nBands, int * panBandList,
  196. GDALProgressFunc pfnProgress,
  197. void *pProgressData );
  198. CPLErr CleanOverviews();
  199. // Mask Related
  200. CPLErr CreateMaskBand( int nFlags, int nBand = -1 );
  201. GDALRasterBand *GetMaskBand( int nBand );
  202. int GetMaskFlags( int nBand );
  203. int HaveMaskFile( char **papszSiblings = nullptr,
  204. const char *pszBasename = nullptr );
  205. char** GetSiblingFiles() { return papszInitSiblingFiles; }
  206. private:
  207. CPL_DISALLOW_COPY_ASSIGN(GDALDefaultOverviews)
  208. };
  209. //! @endcond
  210. /* ******************************************************************** */
  211. /* GDALOpenInfo */
  212. /* ******************************************************************** */
  213. /** Class for dataset open functions. */
  214. class CPL_DLL GDALOpenInfo
  215. {
  216. bool bHasGotSiblingFiles;
  217. char **papszSiblingFiles;
  218. int nHeaderBytesTried;
  219. public:
  220. GDALOpenInfo( const char * pszFile, int nOpenFlagsIn,
  221. const char * const * papszSiblingFiles = nullptr );
  222. ~GDALOpenInfo( void );
  223. /** Filename */
  224. char *pszFilename;
  225. /** Open options */
  226. char** papszOpenOptions;
  227. /** Access flag */
  228. GDALAccess eAccess;
  229. /** Open flags */
  230. int nOpenFlags;
  231. /** Whether stat()'ing the file was successful */
  232. int bStatOK;
  233. /** Whether the file is a directory */
  234. int bIsDirectory;
  235. /** Pointer to the file */
  236. VSILFILE *fpL;
  237. /** Number of bytes in pabyHeader */
  238. int nHeaderBytes;
  239. /** Buffer with first bytes of the file */
  240. GByte *pabyHeader;
  241. /** Allowed drivers (NULL for all) */
  242. const char* const* papszAllowedDrivers;
  243. int TryToIngest(int nBytes);
  244. char **GetSiblingFiles();
  245. char **StealSiblingFiles();
  246. bool AreSiblingFilesLoaded() const;
  247. private:
  248. CPL_DISALLOW_COPY_ASSIGN(GDALOpenInfo)
  249. };
  250. /* ******************************************************************** */
  251. /* GDALDataset */
  252. /* ******************************************************************** */
  253. class OGRLayer;
  254. class OGRGeometry;
  255. class OGRSpatialReference;
  256. class OGRStyleTable;
  257. class swq_select;
  258. class swq_select_parse_options;
  259. //! @cond Doxygen_Suppress
  260. typedef struct GDALSQLParseInfo GDALSQLParseInfo;
  261. //! @endcond
  262. //! @cond Doxygen_Suppress
  263. #ifdef GDAL_COMPILATION
  264. #define OPTIONAL_OUTSIDE_GDAL(val)
  265. #else
  266. #define OPTIONAL_OUTSIDE_GDAL(val) = val
  267. #endif
  268. //! @endcond
  269. /** A set of associated raster bands, usually from one file. */
  270. class CPL_DLL GDALDataset : public GDALMajorObject
  271. {
  272. friend GDALDatasetH CPL_STDCALL GDALOpenEx( const char* pszFilename,
  273. unsigned int nOpenFlags,
  274. const char* const* papszAllowedDrivers,
  275. const char* const* papszOpenOptions,
  276. const char* const* papszSiblingFiles );
  277. friend void CPL_STDCALL GDALClose( GDALDatasetH hDS );
  278. friend class GDALDriver;
  279. friend class GDALDefaultOverviews;
  280. friend class GDALProxyDataset;
  281. friend class GDALDriverManager;
  282. CPL_INTERNAL void AddToDatasetOpenList();
  283. protected:
  284. //! @cond Doxygen_Suppress
  285. GDALDriver *poDriver = nullptr;
  286. GDALAccess eAccess = GA_ReadOnly;
  287. // Stored raster information.
  288. int nRasterXSize = 512;
  289. int nRasterYSize = 512;
  290. int nBands = 0;
  291. GDALRasterBand **papoBands = nullptr;
  292. int nOpenFlags = 0;
  293. int nRefCount = 1;
  294. bool bForceCachedIO = false;
  295. bool bShared = false;
  296. bool bIsInternal = true;
  297. bool bSuppressOnClose = false;
  298. GDALDataset(void);
  299. explicit GDALDataset(int bForceCachedIO);
  300. void RasterInitialize( int, int );
  301. void SetBand( int, GDALRasterBand * );
  302. GDALDefaultOverviews oOvManager{};
  303. virtual CPLErr IBuildOverviews( const char *, int, int *,
  304. int, int *, GDALProgressFunc, void * );
  305. virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
  306. void *, int, int, GDALDataType,
  307. int, int *, GSpacing, GSpacing, GSpacing,
  308. GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
  309. CPLErr BlockBasedRasterIO( GDALRWFlag, int, int, int, int,
  310. void *, int, int, GDALDataType,
  311. int, int *, GSpacing, GSpacing, GSpacing,
  312. GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
  313. void BlockBasedFlushCache();
  314. CPLErr BandBasedRasterIO( GDALRWFlag eRWFlag,
  315. int nXOff, int nYOff, int nXSize, int nYSize,
  316. void * pData, int nBufXSize, int nBufYSize,
  317. GDALDataType eBufType,
  318. int nBandCount, int *panBandMap,
  319. GSpacing nPixelSpace, GSpacing nLineSpace,
  320. GSpacing nBandSpace,
  321. GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
  322. CPLErr RasterIOResampled( GDALRWFlag eRWFlag,
  323. int nXOff, int nYOff, int nXSize, int nYSize,
  324. void * pData, int nBufXSize, int nBufYSize,
  325. GDALDataType eBufType,
  326. int nBandCount, int *panBandMap,
  327. GSpacing nPixelSpace, GSpacing nLineSpace,
  328. GSpacing nBandSpace,
  329. GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
  330. CPLErr ValidateRasterIOOrAdviseReadParameters(
  331. const char* pszCallingFunc,
  332. int* pbStopProcessingOnCENone,
  333. int nXOff, int nYOff, int nXSize, int nYSize,
  334. int nBufXSize, int nBufYSize,
  335. int nBandCount, int *panBandMap);
  336. CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag,
  337. int nXOff, int nYOff, int nXSize, int nYSize,
  338. void * pData, int nBufXSize, int nBufYSize,
  339. GDALDataType eBufType,
  340. int nBandCount, int *panBandMap,
  341. GSpacing nPixelSpace, GSpacing nLineSpace,
  342. GSpacing nBandSpace,
  343. GDALRasterIOExtraArg* psExtraArg,
  344. int* pbTried);
  345. void ShareLockWithParentDataset(GDALDataset* poParentDataset);
  346. //! @endcond
  347. virtual int CloseDependentDatasets();
  348. //! @cond Doxygen_Suppress
  349. int ValidateLayerCreationOptions( const char* const* papszLCO );
  350. char **papszOpenOptions = nullptr;
  351. friend class GDALRasterBand;
  352. // The below methods related to read write mutex are fragile logic, and
  353. // should not be used by out-of-tree code if possible.
  354. int EnterReadWrite(GDALRWFlag eRWFlag);
  355. void LeaveReadWrite();
  356. void InitRWLock();
  357. void TemporarilyDropReadWriteLock();
  358. void ReacquireReadWriteLock();
  359. void DisableReadWriteMutex();
  360. int AcquireMutex();
  361. void ReleaseMutex();
  362. //! @endcond
  363. public:
  364. ~GDALDataset() override;
  365. int GetRasterXSize();
  366. int GetRasterYSize();
  367. int GetRasterCount();
  368. GDALRasterBand *GetRasterBand( int );
  369. /** Class returned by GetBands() that act as a container for raster bands. */
  370. class CPL_DLL Bands
  371. {
  372. private:
  373. friend class GDALDataset;
  374. GDALDataset* m_poSelf;
  375. CPL_INTERNAL explicit Bands(GDALDataset* poSelf): m_poSelf(poSelf) {}
  376. class CPL_DLL Iterator
  377. {
  378. struct Private;
  379. std::unique_ptr<Private> m_poPrivate;
  380. public:
  381. Iterator(GDALDataset* poDS, bool bStart);
  382. Iterator(const Iterator& oOther); // declared but not defined. Needed for gcc 5.4 at least
  383. Iterator(Iterator&& oOther) noexcept; // declared but not defined. Needed for gcc 5.4 at least
  384. ~Iterator();
  385. GDALRasterBand* operator*();
  386. Iterator& operator++();
  387. bool operator!=(const Iterator& it) const;
  388. };
  389. public:
  390. const Iterator begin() const;
  391. const Iterator end() const;
  392. size_t size() const;
  393. GDALRasterBand* operator[](int iBand);
  394. GDALRasterBand* operator[](size_t iBand);
  395. };
  396. Bands GetBands();
  397. virtual void FlushCache(void);
  398. virtual const OGRSpatialReference* GetSpatialRef() const;
  399. virtual CPLErr SetSpatialRef(const OGRSpatialReference* poSRS);
  400. // Compatibility layer
  401. const char *GetProjectionRef(void) const;
  402. CPLErr SetProjection( const char * pszProjection );
  403. virtual CPLErr GetGeoTransform( double * padfTransform );
  404. virtual CPLErr SetGeoTransform( double * padfTransform );
  405. virtual CPLErr AddBand( GDALDataType eType,
  406. char **papszOptions=nullptr );
  407. virtual void *GetInternalHandle( const char * pszHandleName );
  408. virtual GDALDriver *GetDriver(void);
  409. virtual char **GetFileList(void);
  410. virtual const char* GetDriverName();
  411. virtual const OGRSpatialReference* GetGCPSpatialRef() const;
  412. virtual int GetGCPCount();
  413. virtual const GDAL_GCP *GetGCPs();
  414. virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
  415. const OGRSpatialReference * poGCP_SRS );
  416. // Compatibility layer
  417. const char *GetGCPProjection();
  418. CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
  419. const char *pszGCPProjection );
  420. virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
  421. int nBufXSize, int nBufYSize,
  422. GDALDataType eDT,
  423. int nBandCount, int *panBandList,
  424. char **papszOptions );
  425. virtual CPLErr CreateMaskBand( int nFlagsIn );
  426. virtual GDALAsyncReader*
  427. BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize,
  428. void *pBuf, int nBufXSize, int nBufYSize,
  429. GDALDataType eBufType,
  430. int nBandCount, int* panBandMap,
  431. int nPixelSpace, int nLineSpace, int nBandSpace,
  432. char **papszOptions);
  433. virtual void EndAsyncReader(GDALAsyncReader *);
  434. CPLErr RasterIO( GDALRWFlag, int, int, int, int,
  435. void *, int, int, GDALDataType,
  436. int, int *, GSpacing, GSpacing, GSpacing,
  437. GDALRasterIOExtraArg* psExtraArg
  438. #ifndef DOXYGEN_SKIP
  439. OPTIONAL_OUTSIDE_GDAL(nullptr)
  440. #endif
  441. ) CPL_WARN_UNUSED_RESULT;
  442. int Reference();
  443. int Dereference();
  444. int ReleaseRef();
  445. /** Return access mode.
  446. * @return access mode.
  447. */
  448. GDALAccess GetAccess() const { return eAccess; }
  449. int GetShared() const;
  450. void MarkAsShared();
  451. /** Set that the dataset must be deleted on close. */
  452. void MarkSuppressOnClose() { bSuppressOnClose = true; }
  453. /** Return open options.
  454. * @return open options.
  455. */
  456. char **GetOpenOptions() { return papszOpenOptions; }
  457. static GDALDataset **GetOpenDatasets( int *pnDatasetCount );
  458. CPLErr BuildOverviews( const char *, int, int *,
  459. int, int *, GDALProgressFunc, void * );
  460. void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
  461. char ** GetMetadata(const char * pszDomain = "") override;
  462. // Only defined when Doxygen enabled
  463. #ifdef DOXYGEN_SKIP
  464. CPLErr SetMetadata( char ** papszMetadata,
  465. const char * pszDomain ) override;
  466. const char *GetMetadataItem( const char * pszName,
  467. const char * pszDomain ) override;
  468. CPLErr SetMetadataItem( const char * pszName,
  469. const char * pszValue,
  470. const char * pszDomain ) override;
  471. #endif
  472. char **GetMetadataDomainList() override;
  473. /** Convert a GDALDataset* to a GDALDatasetH.
  474. * @since GDAL 2.3
  475. */
  476. static inline GDALDatasetH ToHandle(GDALDataset* poDS)
  477. { return static_cast<GDALDatasetH>(poDS); }
  478. /** Convert a GDALDatasetH to a GDALDataset*.
  479. * @since GDAL 2.3
  480. */
  481. static inline GDALDataset* FromHandle(GDALDatasetH hDS)
  482. { return static_cast<GDALDataset*>(hDS); }
  483. /** @see GDALOpenEx().
  484. * @since GDAL 2.3
  485. */
  486. static GDALDataset* Open( const char* pszFilename,
  487. unsigned int nOpenFlags = 0,
  488. const char* const* papszAllowedDrivers = nullptr,
  489. const char* const* papszOpenOptions = nullptr,
  490. const char* const* papszSiblingFiles = nullptr )
  491. {
  492. return FromHandle(GDALOpenEx(pszFilename, nOpenFlags,
  493. papszAllowedDrivers,
  494. papszOpenOptions,
  495. papszSiblingFiles));
  496. }
  497. /** Object returned by GetFeatures() iterators */
  498. struct FeatureLayerPair
  499. {
  500. /** Unique pointer to a OGRFeature. */
  501. OGRFeatureUniquePtr feature{};
  502. /** Layer to which the feature belongs to. */
  503. OGRLayer* layer = nullptr;
  504. };
  505. private:
  506. class Private;
  507. Private *m_poPrivate;
  508. CPL_INTERNAL OGRLayer* BuildLayerFromSelectInfo(swq_select* psSelectInfo,
  509. OGRGeometry *poSpatialFilter,
  510. const char *pszDialect,
  511. swq_select_parse_options* poSelectParseOptions);
  512. CPLStringList oDerivedMetadataList{};
  513. public:
  514. virtual int GetLayerCount();
  515. virtual OGRLayer *GetLayer(int iLayer);
  516. /** Class returned by GetLayers() that acts as a range of layers.
  517. * @since GDAL 2.3
  518. */
  519. class CPL_DLL Layers
  520. {
  521. private:
  522. friend class GDALDataset;
  523. GDALDataset* m_poSelf;
  524. CPL_INTERNAL explicit Layers(GDALDataset* poSelf): m_poSelf(poSelf) {}
  525. public:
  526. /** Layer iterator.
  527. * @since GDAL 2.3
  528. */
  529. class CPL_DLL Iterator
  530. {
  531. struct Private;
  532. std::unique_ptr<Private> m_poPrivate;
  533. public:
  534. using value_type = OGRLayer*; /**< value_type */
  535. using reference = OGRLayer*; /**< reference */
  536. using difference_type = void; /**< difference_type */
  537. using pointer = void; /**< pointer */
  538. using iterator_category = std::input_iterator_tag; /**< iterator_category */
  539. Iterator(); /**< Default constructor */
  540. Iterator(GDALDataset* poDS, bool bStart); /**< Constructor */
  541. Iterator(const Iterator& oOther); /**< Copy constructor */
  542. Iterator(Iterator&& oOther) noexcept; /**< Move constructor */
  543. ~Iterator(); /**< Destructor */
  544. Iterator& operator=(const Iterator& oOther); /**< Assignment operator */
  545. Iterator& operator=(Iterator&& oOther) noexcept; /**< Move assignment operator */
  546. OGRLayer* operator*() const; /**< Dereference operator */
  547. Iterator& operator++(); /**< Pre-increment operator */
  548. Iterator operator++(int); /**< Post-increment operator */
  549. bool operator!=(const Iterator& it) const; /**< Difference comparison operator */
  550. };
  551. Iterator begin() const;
  552. Iterator end() const;
  553. size_t size() const;
  554. OGRLayer* operator[](int iLayer);
  555. OGRLayer* operator[](size_t iLayer);
  556. OGRLayer* operator[](const char* pszLayername);
  557. };
  558. Layers GetLayers();
  559. virtual OGRLayer *GetLayerByName(const char *);
  560. virtual OGRErr DeleteLayer(int iLayer);
  561. virtual void ResetReading();
  562. virtual OGRFeature* GetNextFeature( OGRLayer** ppoBelongingLayer,
  563. double* pdfProgressPct,
  564. GDALProgressFunc pfnProgress,
  565. void* pProgressData );
  566. /** Class returned by GetFeatures() that act as a container for vector features. */
  567. class CPL_DLL Features
  568. {
  569. private:
  570. friend class GDALDataset;
  571. GDALDataset* m_poSelf;
  572. CPL_INTERNAL explicit Features(GDALDataset* poSelf): m_poSelf(poSelf) {}
  573. class CPL_DLL Iterator
  574. {
  575. struct Private;
  576. std::unique_ptr<Private> m_poPrivate;
  577. public:
  578. Iterator(GDALDataset* poDS, bool bStart);
  579. Iterator(const Iterator& oOther); // declared but not defined. Needed for gcc 5.4 at least
  580. Iterator(Iterator&& oOther) noexcept; // declared but not defined. Needed for gcc 5.4 at least
  581. ~Iterator();
  582. const FeatureLayerPair& operator*() const;
  583. Iterator& operator++();
  584. bool operator!=(const Iterator& it) const;
  585. };
  586. public:
  587. const Iterator begin() const;
  588. const Iterator end() const;
  589. };
  590. Features GetFeatures();
  591. virtual int TestCapability( const char * );
  592. virtual OGRLayer *CreateLayer( const char *pszName,
  593. OGRSpatialReference *poSpatialRef = nullptr,
  594. OGRwkbGeometryType eGType = wkbUnknown,
  595. char ** papszOptions = nullptr );
  596. virtual OGRLayer *CopyLayer( OGRLayer *poSrcLayer,
  597. const char *pszNewName,
  598. char **papszOptions = nullptr );
  599. virtual OGRStyleTable *GetStyleTable();
  600. virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable );
  601. virtual void SetStyleTable(OGRStyleTable *poStyleTable);
  602. virtual OGRLayer * ExecuteSQL( const char *pszStatement,
  603. OGRGeometry *poSpatialFilter,
  604. const char *pszDialect );
  605. virtual void ReleaseResultSet( OGRLayer * poResultsSet );
  606. int GetRefCount() const;
  607. int GetSummaryRefCount() const;
  608. OGRErr Release();
  609. virtual OGRErr StartTransaction(int bForce=FALSE);
  610. virtual OGRErr CommitTransaction();
  611. virtual OGRErr RollbackTransaction();
  612. //! @cond Doxygen_Suppress
  613. static int IsGenericSQLDialect(const char* pszDialect);
  614. // Semi-public methods. Only to be used by in-tree drivers.
  615. GDALSQLParseInfo* BuildParseInfo(swq_select* psSelectInfo,
  616. swq_select_parse_options* poSelectParseOptions);
  617. static void DestroyParseInfo(GDALSQLParseInfo* psParseInfo );
  618. OGRLayer * ExecuteSQL( const char *pszStatement,
  619. OGRGeometry *poSpatialFilter,
  620. const char *pszDialect,
  621. swq_select_parse_options* poSelectParseOptions);
  622. //! @endcond
  623. protected:
  624. virtual OGRLayer *ICreateLayer( const char *pszName,
  625. OGRSpatialReference *poSpatialRef = nullptr,
  626. OGRwkbGeometryType eGType = wkbUnknown,
  627. char ** papszOptions = nullptr );
  628. //! @cond Doxygen_Suppress
  629. OGRErr ProcessSQLCreateIndex( const char * );
  630. OGRErr ProcessSQLDropIndex( const char * );
  631. OGRErr ProcessSQLDropTable( const char * );
  632. OGRErr ProcessSQLAlterTableAddColumn( const char * );
  633. OGRErr ProcessSQLAlterTableDropColumn( const char * );
  634. OGRErr ProcessSQLAlterTableAlterColumn( const char * );
  635. OGRErr ProcessSQLAlterTableRenameColumn( const char * );
  636. OGRStyleTable *m_poStyleTable = nullptr;
  637. // Compatibility layers
  638. const OGRSpatialReference* GetSpatialRefFromOldGetProjectionRef() const;
  639. CPLErr OldSetProjectionFromSetSpatialRef(const OGRSpatialReference* poSRS);
  640. const OGRSpatialReference* GetGCPSpatialRefFromOldGetGCPProjection() const;
  641. CPLErr OldSetGCPsFromNew( int nGCPCount, const GDAL_GCP *pasGCPList,
  642. const OGRSpatialReference * poGCP_SRS );
  643. friend class GDALProxyPoolDataset;
  644. virtual const char *_GetProjectionRef();
  645. const char *GetProjectionRefFromSpatialRef(const OGRSpatialReference*) const;
  646. virtual const char *_GetGCPProjection();
  647. const char *GetGCPProjectionFromSpatialRef(const OGRSpatialReference* poSRS) const;
  648. virtual CPLErr _SetProjection( const char * pszProjection );
  649. virtual CPLErr _SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
  650. const char *pszGCPProjection );
  651. //! @endcond
  652. private:
  653. CPL_DISALLOW_COPY_ASSIGN(GDALDataset)
  654. };
  655. //! @cond Doxygen_Suppress
  656. struct CPL_DLL GDALDatasetUniquePtrDeleter
  657. {
  658. void operator()(GDALDataset* poDataset) const
  659. { GDALClose(poDataset); }
  660. };
  661. //! @endcond
  662. /** Unique pointer type for GDALDataset.
  663. * Appropriate for use on datasets open in non-shared mode and onto which
  664. * reference counter has not been manually modified.
  665. * @since GDAL 2.3
  666. */
  667. typedef std::unique_ptr<GDALDataset, GDALDatasetUniquePtrDeleter> GDALDatasetUniquePtr;
  668. /* ******************************************************************** */
  669. /* GDALRasterBlock */
  670. /* ******************************************************************** */
  671. /** A single raster block in the block cache.
  672. *
  673. * And the global block manager that manages a least-recently-used list of
  674. * blocks from various datasets/bands */
  675. class CPL_DLL GDALRasterBlock
  676. {
  677. friend class GDALAbstractBandBlockCache;
  678. GDALDataType eType;
  679. bool bDirty;
  680. volatile int nLockCount;
  681. int nXOff;
  682. int nYOff;
  683. int nXSize;
  684. int nYSize;
  685. void *pData;
  686. GDALRasterBand *poBand;
  687. GDALRasterBlock *poNext;
  688. GDALRasterBlock *poPrevious;
  689. bool bMustDetach;
  690. CPL_INTERNAL void Detach_unlocked( void );
  691. CPL_INTERNAL void Touch_unlocked( void );
  692. CPL_INTERNAL void RecycleFor( int nXOffIn, int nYOffIn );
  693. public:
  694. GDALRasterBlock( GDALRasterBand *, int, int );
  695. GDALRasterBlock( int nXOffIn, int nYOffIn ); /* only for lookup purpose */
  696. virtual ~GDALRasterBlock();
  697. CPLErr Internalize( void );
  698. void Touch( void );
  699. void MarkDirty( void );
  700. void MarkClean( void );
  701. /** Increment the lock count */
  702. int AddLock( void ) { return CPLAtomicInc(&nLockCount); }
  703. /** Decrement the lock count */
  704. int DropLock( void ) { return CPLAtomicDec(&nLockCount); }
  705. void Detach();
  706. CPLErr Write();
  707. /** Return the data type
  708. * @return data type
  709. */
  710. GDALDataType GetDataType() const { return eType; }
  711. /** Return the x offset of the top-left corner of the block
  712. * @return x offset
  713. */
  714. int GetXOff() const { return nXOff; }
  715. /** Return the y offset of the top-left corner of the block
  716. * @return y offset
  717. */
  718. int GetYOff() const { return nYOff; }
  719. /** Return the width of the block
  720. * @return width
  721. */
  722. int GetXSize() const { return nXSize; }
  723. /** Return the height of the block
  724. * @return height
  725. */
  726. int GetYSize() const { return nYSize; }
  727. /** Return the dirty flag
  728. * @return dirty flag
  729. */
  730. int GetDirty() const { return bDirty; }
  731. /** Return the data buffer
  732. * @return data buffer
  733. */
  734. void *GetDataRef( void ) { return pData; }
  735. /** Return the block size in bytes
  736. * @return block size.
  737. */
  738. GPtrDiff_t GetBlockSize() const {
  739. return static_cast<GPtrDiff_t>(nXSize) * nYSize * GDALGetDataTypeSizeBytes(eType); }
  740. int TakeLock();
  741. int DropLockForRemovalFromStorage();
  742. /// @brief Accessor to source GDALRasterBand object.
  743. /// @return source raster band of the raster block.
  744. GDALRasterBand *GetBand() { return poBand; }
  745. static void FlushDirtyBlocks();
  746. static int FlushCacheBlock(int bDirtyBlocksOnly = FALSE);
  747. static void Verify();
  748. static void EnterDisableDirtyBlockFlush();
  749. static void LeaveDisableDirtyBlockFlush();
  750. #ifdef notdef
  751. static void CheckNonOrphanedBlocks(GDALRasterBand* poBand);
  752. void DumpBlock();
  753. static void DumpAll();
  754. #endif
  755. /* Should only be called by GDALDestroyDriverManager() */
  756. //! @cond Doxygen_Suppress
  757. CPL_INTERNAL static void DestroyRBMutex();
  758. //! @endcond
  759. private:
  760. CPL_DISALLOW_COPY_ASSIGN(GDALRasterBlock)
  761. };
  762. /* ******************************************************************** */
  763. /* GDALColorTable */
  764. /* ******************************************************************** */
  765. /** A color table / palette. */
  766. class CPL_DLL GDALColorTable
  767. {
  768. GDALPaletteInterp eInterp;
  769. std::vector<GDALColorEntry> aoEntries{};
  770. public:
  771. explicit GDALColorTable( GDALPaletteInterp = GPI_RGB );
  772. ~GDALColorTable();
  773. GDALColorTable *Clone() const;
  774. int IsSame(const GDALColorTable* poOtherCT) const;
  775. GDALPaletteInterp GetPaletteInterpretation() const;
  776. int GetColorEntryCount() const;
  777. const GDALColorEntry *GetColorEntry( int ) const;
  778. int GetColorEntryAsRGB( int, GDALColorEntry * ) const;
  779. void SetColorEntry( int, const GDALColorEntry * );
  780. int CreateColorRamp( int, const GDALColorEntry * ,
  781. int, const GDALColorEntry * );
  782. /** Convert a GDALColorTable* to a GDALRasterBandH.
  783. * @since GDAL 2.3
  784. */
  785. static inline GDALColorTableH ToHandle(GDALColorTable* poCT)
  786. { return static_cast<GDALColorTableH>(poCT); }
  787. /** Convert a GDALColorTableH to a GDALColorTable*.
  788. * @since GDAL 2.3
  789. */
  790. static inline GDALColorTable* FromHandle(GDALColorTableH hCT)
  791. { return static_cast<GDALColorTable*>(hCT); }
  792. };
  793. /* ******************************************************************** */
  794. /* GDALAbstractBandBlockCache */
  795. /* ******************************************************************** */
  796. //! @cond Doxygen_Suppress
  797. //! This manages how a raster band store its cached block.
  798. // only used by GDALRasterBand implementation.
  799. class GDALAbstractBandBlockCache
  800. {
  801. // List of blocks that can be freed or recycled, and its lock
  802. CPLLock *hSpinLock = nullptr;
  803. GDALRasterBlock *psListBlocksToFree = nullptr;
  804. // Band keep alive counter, and its lock & condition
  805. CPLCond *hCond = nullptr;
  806. CPLMutex *hCondMutex = nullptr;
  807. volatile int nKeepAliveCounter = 0;
  808. volatile int m_nDirtyBlocks = 0;
  809. CPL_DISALLOW_COPY_ASSIGN(GDALAbstractBandBlockCache)
  810. protected:
  811. GDALRasterBand *poBand;
  812. int m_nInitialDirtyBlocksInFlushCache = 0;
  813. int m_nLastTick = -1;
  814. void FreeDanglingBlocks();
  815. void UnreferenceBlockBase();
  816. void WaitKeepAliveCounter();
  817. void StartDirtyBlockFlushingLog();
  818. void UpdateDirtyBlockFlushingLog();
  819. void EndDirtyBlockFlushingLog();
  820. public:
  821. explicit GDALAbstractBandBlockCache(GDALRasterBand* poBand);
  822. virtual ~GDALAbstractBandBlockCache();
  823. GDALRasterBlock* CreateBlock(int nXBlockOff, int nYBlockOff);
  824. void AddBlockToFreeList( GDALRasterBlock * );
  825. void IncDirtyBlocks(int nInc);
  826. virtual bool Init() = 0;
  827. virtual bool IsInitOK() = 0;
  828. virtual CPLErr FlushCache() = 0;
  829. virtual CPLErr AdoptBlock( GDALRasterBlock* poBlock ) = 0;
  830. virtual GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff,
  831. int nYBlockYOff ) = 0;
  832. virtual CPLErr UnreferenceBlock( GDALRasterBlock* poBlock ) = 0;
  833. virtual CPLErr FlushBlock( int nXBlockOff, int nYBlockOff,
  834. int bWriteDirtyBlock ) = 0;
  835. };
  836. GDALAbstractBandBlockCache* GDALArrayBandBlockCacheCreate(GDALRasterBand* poBand);
  837. GDALAbstractBandBlockCache* GDALHashSetBandBlockCacheCreate(GDALRasterBand* poBand);
  838. //! @endcond
  839. /* ******************************************************************** */
  840. /* GDALRasterBand */
  841. /* ******************************************************************** */
  842. /** A single raster band (or channel). */
  843. class CPL_DLL GDALRasterBand : public GDALMajorObject
  844. {
  845. private:
  846. friend class GDALArrayBandBlockCache;
  847. friend class GDALHashSetBandBlockCache;
  848. friend class GDALRasterBlock;
  849. CPLErr eFlushBlockErr = CE_None;
  850. GDALAbstractBandBlockCache* poBandBlockCache = nullptr;
  851. CPL_INTERNAL void SetFlushBlockErr( CPLErr eErr );
  852. CPL_INTERNAL CPLErr UnreferenceBlock( GDALRasterBlock* poBlock );
  853. CPL_INTERNAL void SetValidPercent( GUIntBig nSampleCount, GUIntBig nValidCount );
  854. CPL_INTERNAL void IncDirtyBlocks(int nInc);
  855. protected:
  856. //! @cond Doxygen_Suppress
  857. GDALDataset *poDS = nullptr;
  858. int nBand = 0; /* 1 based */
  859. int nRasterXSize = 0;
  860. int nRasterYSize = 0;
  861. GDALDataType eDataType = GDT_Byte;
  862. GDALAccess eAccess = GA_ReadOnly;
  863. /* stuff related to blocking, and raster cache */
  864. int nBlockXSize = -1;
  865. int nBlockYSize = -1;
  866. int nBlocksPerRow = 0;
  867. int nBlocksPerColumn = 0;
  868. int nBlockReads = 0;
  869. int bForceCachedIO = 0;
  870. GDALRasterBand *poMask = nullptr;
  871. bool bOwnMask = false;
  872. int nMaskFlags = 0;
  873. void InvalidateMaskBand();
  874. friend class GDALDataset;
  875. friend class GDALProxyRasterBand;
  876. friend class GDALDefaultOverviews;
  877. CPLErr RasterIOResampled( GDALRWFlag, int, int, int, int,
  878. void *, int, int, GDALDataType,
  879. GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
  880. int EnterReadWrite(GDALRWFlag eRWFlag);
  881. void LeaveReadWrite();
  882. void InitRWLock();
  883. //! @endcond
  884. protected:
  885. virtual CPLErr IReadBlock( int nBlockXOff, int nBlockYOff, void * pData ) = 0;
  886. virtual CPLErr IWriteBlock( int nBlockXOff, int nBlockYOff, void * pData );
  887. virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
  888. void *, int, int, GDALDataType,
  889. GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
  890. virtual int IGetDataCoverageStatus( int nXOff, int nYOff,
  891. int nXSize, int nYSize,
  892. int nMaskFlagStop,
  893. double* pdfDataPct);
  894. //! @cond Doxygen_Suppress
  895. CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int,
  896. void *, int, int, GDALDataType,
  897. GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
  898. CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag,
  899. int nXOff, int nYOff, int nXSize, int nYSize,
  900. void * pData, int nBufXSize, int nBufYSize,
  901. GDALDataType eBufType,
  902. GSpacing nPixelSpace, GSpacing nLineSpace,
  903. GDALRasterIOExtraArg* psExtraArg,
  904. int* pbTried );
  905. int InitBlockInfo();
  906. void AddBlockToFreeList( GDALRasterBlock * );
  907. //! @endcond
  908. GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff );
  909. public:
  910. GDALRasterBand();
  911. explicit GDALRasterBand(int bForceCachedIO);
  912. ~GDALRasterBand() override;
  913. int GetXSize();
  914. int GetYSize();
  915. int GetBand();
  916. GDALDataset*GetDataset();
  917. GDALDataType GetRasterDataType( void );
  918. void GetBlockSize( int *, int * );
  919. CPLErr GetActualBlockSize ( int, int, int *, int * );
  920. GDALAccess GetAccess();
  921. CPLErr RasterIO( GDALRWFlag, int, int, int, int,
  922. void *, int, int, GDALDataType,
  923. GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg
  924. #ifndef DOXYGEN_SKIP
  925. OPTIONAL_OUTSIDE_GDAL(nullptr)
  926. #endif
  927. ) CPL_WARN_UNUSED_RESULT;
  928. CPLErr ReadBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT;
  929. CPLErr WriteBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT;
  930. GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff,
  931. int bJustInitialize = FALSE ) CPL_WARN_UNUSED_RESULT;
  932. CPLErr FlushBlock( int, int, int bWriteDirtyBlock = TRUE );
  933. unsigned char* GetIndexColorTranslationTo(/* const */ GDALRasterBand* poReferenceBand,
  934. unsigned char* pTranslationTable = nullptr,
  935. int* pApproximateMatching = nullptr);
  936. // New OpengIS CV_SampleDimension stuff.
  937. virtual CPLErr FlushCache();
  938. virtual char **GetCategoryNames();
  939. virtual double GetNoDataValue( int *pbSuccess = nullptr );
  940. virtual double GetMinimum( int *pbSuccess = nullptr );
  941. virtual double GetMaximum(int *pbSuccess = nullptr );
  942. virtual double GetOffset( int *pbSuccess = nullptr );
  943. virtual double GetScale( int *pbSuccess = nullptr );
  944. virtual const char *GetUnitType();
  945. virtual GDALColorInterp GetColorInterpretation();
  946. virtual GDALColorTable *GetColorTable();
  947. virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
  948. virtual CPLErr SetCategoryNames( char ** papszNames );
  949. virtual CPLErr SetNoDataValue( double dfNoData );
  950. virtual CPLErr DeleteNoDataValue();
  951. virtual CPLErr SetColorTable( GDALColorTable * poCT );
  952. virtual CPLErr SetColorInterpretation( GDALColorInterp eColorInterp );
  953. virtual CPLErr SetOffset( double dfNewOffset );
  954. virtual CPLErr SetScale( double dfNewScale );
  955. virtual CPLErr SetUnitType( const char * pszNewValue );
  956. virtual CPLErr GetStatistics( int bApproxOK, int bForce,
  957. double *pdfMin, double *pdfMax,
  958. double *pdfMean, double *padfStdDev );
  959. virtual CPLErr ComputeStatistics( int bApproxOK,
  960. double *pdfMin, double *pdfMax,
  961. double *pdfMean, double *pdfStdDev,
  962. GDALProgressFunc, void *pProgressData );
  963. virtual CPLErr SetStatistics( double dfMin, double dfMax,
  964. double dfMean, double dfStdDev );
  965. virtual CPLErr ComputeRasterMinMax( int, double* );
  966. // Only defined when Doxygen enabled
  967. #ifdef DOXYGEN_SKIP
  968. char **GetMetadata( const char * pszDomain = "" ) override;
  969. CPLErr SetMetadata( char ** papszMetadata,
  970. const char * pszDomain ) override;
  971. const char *GetMetadataItem( const char * pszName,
  972. const char * pszDomain ) override;
  973. CPLErr SetMetadataItem( const char * pszName,
  974. const char * pszValue,
  975. const char * pszDomain ) override;
  976. #endif
  977. virtual int HasArbitraryOverviews();
  978. virtual int GetOverviewCount();
  979. virtual GDALRasterBand *GetOverview(int);
  980. virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig );
  981. virtual CPLErr BuildOverviews( const char * pszResampling,
  982. int nOverviews,
  983. int * panOverviewList,
  984. GDALProgressFunc pfnProgress,
  985. void * pProgressData );
  986. virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
  987. int nBufXSize, int nBufYSize,
  988. GDALDataType eBufType, char **papszOptions );
  989. virtual CPLErr GetHistogram( double dfMin, double dfMax,
  990. int nBuckets, GUIntBig * panHistogram,
  991. int bIncludeOutOfRange, int bApproxOK,
  992. GDALProgressFunc, void *pProgressData );
  993. virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
  994. int *pnBuckets, GUIntBig ** ppanHistogram,
  995. int bForce,
  996. GDALProgressFunc, void *pProgressData);
  997. virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
  998. int nBuckets, GUIntBig *panHistogram );
  999. virtual GDALRasterAttributeTable *GetDefaultRAT();
  1000. virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * poRAT );
  1001. virtual GDALRasterBand *GetMaskBand();
  1002. virtual int GetMaskFlags();
  1003. virtual CPLErr CreateMaskBand( int nFlagsIn );
  1004. virtual CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag,
  1005. int *pnPixelSpace,
  1006. GIntBig *pnLineSpace,
  1007. char **papszOptions ) CPL_WARN_UNUSED_RESULT;
  1008. int GetDataCoverageStatus( int nXOff, int nYOff,
  1009. int nXSize, int nYSize,
  1010. int nMaskFlagStop = 0,
  1011. double* pdfDataPct = nullptr );
  1012. void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
  1013. /** Convert a GDALRasterBand* to a GDALRasterBandH.
  1014. * @since GDAL 2.3
  1015. */
  1016. static inline GDALRasterBandH ToHandle(GDALRasterBand* poBand)
  1017. { return static_cast<GDALRasterBandH>(poBand); }
  1018. /** Convert a GDALRasterBandH to a GDALRasterBand*.
  1019. * @since GDAL 2.3
  1020. */
  1021. static inline GDALRasterBand* FromHandle(GDALRasterBandH hBand)
  1022. { return static_cast<GDALRasterBand*>(hBand); }
  1023. private:
  1024. CPL_DISALLOW_COPY_ASSIGN(GDALRasterBand)
  1025. };
  1026. //! @cond Doxygen_Suppress
  1027. /* ******************************************************************** */
  1028. /* GDALAllValidMaskBand */
  1029. /* ******************************************************************** */
  1030. class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand
  1031. {
  1032. protected:
  1033. CPLErr IReadBlock( int, int, void * ) override;
  1034. CPL_DISALLOW_COPY_ASSIGN(GDALAllValidMaskBand)
  1035. public:
  1036. explicit GDALAllValidMaskBand( GDALRasterBand * );
  1037. ~GDALAllValidMaskBand() override;
  1038. GDALRasterBand *GetMaskBand() override;
  1039. int GetMaskFlags() override;
  1040. CPLErr ComputeStatistics( int bApproxOK,
  1041. double *pdfMin, double *pdfMax,
  1042. double *pdfMean, double *pdfStdDev,
  1043. GDALProgressFunc, void *pProgressData ) override;
  1044. };
  1045. /* ******************************************************************** */
  1046. /* GDALNoDataMaskBand */
  1047. /* ******************************************************************** */
  1048. class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
  1049. {
  1050. double dfNoDataValue;
  1051. GDALRasterBand *poParent;
  1052. CPL_DISALLOW_COPY_ASSIGN(GDALNoDataMaskBand)
  1053. protected:
  1054. CPLErr IReadBlock( int, int, void * ) override;
  1055. CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
  1056. void *, int, int, GDALDataType,
  1057. GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) override;
  1058. public:
  1059. explicit GDALNoDataMaskBand( GDALRasterBand * );
  1060. ~GDALNoDataMaskBand() override;
  1061. static bool IsNoDataInRange(double dfNoDataValue,
  1062. GDALDataType eDataType);
  1063. };
  1064. /* ******************************************************************** */
  1065. /* GDALNoDataValuesMaskBand */
  1066. /* ******************************************************************** */
  1067. class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand
  1068. {
  1069. double *padfNodataValues;
  1070. CPL_DISALLOW_COPY_ASSIGN(GDALNoDataValuesMaskBand)
  1071. protected:
  1072. CPLErr IReadBlock( int, int, void * ) override;
  1073. public:
  1074. explicit GDALNoDataValuesMaskBand( GDALDataset * );
  1075. ~GDALNoDataValuesMaskBand() override;
  1076. };
  1077. /* ******************************************************************** */
  1078. /* GDALRescaledAlphaBand */
  1079. /* ******************************************************************** */
  1080. class GDALRescaledAlphaBand : public GDALRasterBand
  1081. {
  1082. GDALRasterBand *poParent;
  1083. void *pTemp;
  1084. CPL_DISALLOW_COPY_ASSIGN(GDALRescaledAlphaBand)
  1085. protected:
  1086. CPLErr IReadBlock( int, int, void * ) override;
  1087. CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
  1088. void *, int, int, GDALDataType,
  1089. GSpacing, GSpacing,
  1090. GDALRasterIOExtraArg* psExtraArg ) override;
  1091. public:
  1092. explicit GDALRescaledAlphaBand( GDALRasterBand * );
  1093. ~GDALRescaledAlphaBand() override;
  1094. };
  1095. //! @endcond
  1096. /* ******************************************************************** */
  1097. /* GDALIdentifyEnum */
  1098. /* ******************************************************************** */
  1099. /**
  1100. * Enumeration used by GDALDriver::pfnIdentify().
  1101. *
  1102. * @since GDAL 2.1
  1103. */
  1104. typedef enum
  1105. {
  1106. /** Identify could not determine if the file is recognized or not by the probed driver. */
  1107. GDAL_IDENTIFY_UNKNOWN = -1,
  1108. /** Identify determined the file is not recognized by the probed driver. */
  1109. GDAL_IDENTIFY_FALSE = 0,
  1110. /** Identify determined the file is recognized by the probed driver. */
  1111. GDAL_IDENTIFY_TRUE = 1
  1112. } GDALIdentifyEnum;
  1113. /* ******************************************************************** */
  1114. /* GDALDriver */
  1115. /* ******************************************************************** */
  1116. /**
  1117. * \brief Format specific driver.
  1118. *
  1119. * An instance of this class is created for each supported format, and
  1120. * manages information about the format.
  1121. *
  1122. * This roughly corresponds to a file format, though some
  1123. * drivers may be gateways to many formats through a secondary
  1124. * multi-library.
  1125. */
  1126. class CPL_DLL GDALDriver : public GDALMajorObject
  1127. {
  1128. public:
  1129. GDALDriver();
  1130. ~GDALDriver() override;
  1131. CPLErr SetMetadataItem( const char * pszName,
  1132. const char * pszValue,
  1133. const char * pszDomain = "" ) override;
  1134. /* -------------------------------------------------------------------- */
  1135. /* Public C++ methods. */
  1136. /* -------------------------------------------------------------------- */
  1137. GDALDataset *Create( const char * pszName,
  1138. int nXSize, int nYSize, int nBands,
  1139. GDALDataType eType, char ** papszOptions ) CPL_WARN_UNUSED_RESULT;
  1140. CPLErr Delete( const char * pszName );
  1141. CPLErr Rename( const char * pszNewName,
  1142. const char * pszOldName );
  1143. CPLErr CopyFiles( const char * pszNewName,
  1144. const char * pszOldName );
  1145. GDALDataset *CreateCopy( const char *, GDALDataset *,
  1146. int, char **,
  1147. GDALProgressFunc pfnProgress,
  1148. void * pProgressData ) CPL_WARN_UNUSED_RESULT;
  1149. /* -------------------------------------------------------------------- */
  1150. /* The following are semiprivate, not intended to be accessed */
  1151. /* by anyone but the formats instantiating and populating the */
  1152. /* drivers. */
  1153. /* -------------------------------------------------------------------- */
  1154. //! @cond Doxygen_Suppress
  1155. GDALDataset *(*pfnOpen)( GDALOpenInfo * );
  1156. GDALDataset *(*pfnCreate)( const char * pszName,
  1157. int nXSize, int nYSize, int nBands,
  1158. GDALDataType eType,
  1159. char ** papszOptions );
  1160. CPLErr (*pfnDelete)( const char * pszName );
  1161. GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *,
  1162. int, char **,
  1163. GDALProgressFunc pfnProgress,
  1164. void * pProgressData );
  1165. void *pDriverData;
  1166. void (*pfnUnloadDriver)(GDALDriver *);
  1167. /** Identify() if the file is recognized or not by the driver.
  1168. Return GDAL_IDENTIFY_TRUE (1) if the passed file is certainly recognized by the driver.
  1169. Return GDAL_IDENTIFY_FALSE (0) if the passed file is certainly NOT recognized by the driver.
  1170. Return GDAL_IDENTIFY_UNKNOWN (-1) if the passed file may be or may not be recognized by the driver,
  1171. and that a potentially costly test must be done with pfnOpen.
  1172. */
  1173. int (*pfnIdentify)( GDALOpenInfo * );
  1174. CPLErr (*pfnRename)( const char * pszNewName,
  1175. const char * pszOldName );
  1176. CPLErr (*pfnCopyFiles)( const char * pszNewName,
  1177. const char * pszOldName );
  1178. /* For legacy OGR drivers */
  1179. GDALDataset *(*pfnOpenWithDriverArg)( GDALDriver*, GDALOpenInfo * );
  1180. GDALDataset *(*pfnCreateVectorOnly)( GDALDriver*,
  1181. const char * pszName,
  1182. char ** papszOptions );
  1183. CPLErr (*pfnDeleteDataSource)( GDALDriver*,
  1184. const char * pszName );
  1185. //! @endcond
  1186. /* -------------------------------------------------------------------- */
  1187. /* Helper methods. */
  1188. /* -------------------------------------------------------------------- */
  1189. //! @cond Doxygen_Suppress
  1190. GDALDataset *DefaultCreateCopy( const char *, GDALDataset *,
  1191. int, char **,
  1192. GDALProgressFunc pfnProgress,
  1193. void * pProgressData ) CPL_WARN_UNUSED_RESULT;
  1194. static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
  1195. GDALDataset *poDstDS,
  1196. int bStrict );
  1197. static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
  1198. GDALDataset *poDstDS,
  1199. int bStrict,
  1200. CSLConstList papszOptions,
  1201. GDALProgressFunc pfnProgress,
  1202. void * pProgressData );
  1203. //! @endcond
  1204. static CPLErr QuietDelete( const char * pszName );
  1205. //! @cond Doxygen_Suppress
  1206. static CPLErr DefaultRename( const char * pszNewName,
  1207. const char * pszOldName );
  1208. static CPLErr DefaultCopyFiles( const char * pszNewName,
  1209. const char * pszOldName );
  1210. //! @endcond
  1211. /** Convert a GDALDriver* to a GDALDriverH.
  1212. * @since GDAL 2.3
  1213. */
  1214. static inline GDALDriverH ToHandle(GDALDriver* poDriver)
  1215. { return static_cast<GDALDriverH>(poDriver); }
  1216. /** Convert a GDALDriverH to a GDALDriver*.
  1217. * @since GDAL 2.3
  1218. */
  1219. static inline GDALDriver* FromHandle(GDALDriverH hDriver)
  1220. { return static_cast<GDALDriver*>(hDriver); }
  1221. private:
  1222. CPL_DISALLOW_COPY_ASSIGN(GDALDriver)
  1223. };
  1224. /* ******************************************************************** */
  1225. /* GDALDriverManager */
  1226. /* ******************************************************************** */
  1227. /**
  1228. * Class for managing the registration of file format drivers.
  1229. *
  1230. * Use GetGDALDriverManager() to fetch the global singleton instance of
  1231. * this class.
  1232. */
  1233. class CPL_DLL GDALDriverManager : public GDALMajorObject
  1234. {
  1235. int nDrivers = 0;
  1236. GDALDriver **papoDrivers = nullptr;
  1237. std::map<CPLString, GDALDriver*> oMapNameToDrivers{};
  1238. GDALDriver *GetDriver_unlocked( int iDriver )
  1239. { return (iDriver >= 0 && iDriver < nDrivers) ?
  1240. papoDrivers[iDriver] : nullptr; }
  1241. GDALDriver *GetDriverByName_unlocked( const char * pszName )
  1242. { return oMapNameToDrivers[CPLString(pszName).toupper()]; }
  1243. CPL_DISALLOW_COPY_ASSIGN(GDALDriverManager)
  1244. public:
  1245. GDALDriverManager();
  1246. ~GDALDriverManager();
  1247. int GetDriverCount( void ) const;
  1248. GDALDriver *GetDriver( int );
  1249. GDALDriver *GetDriverByName( const char * );
  1250. int RegisterDriver( GDALDriver * );
  1251. void DeregisterDriver( GDALDriver * );
  1252. // AutoLoadDrivers is a no-op if compiled with GDAL_NO_AUTOLOAD defined.
  1253. static void AutoLoadDrivers();
  1254. void AutoSkipDrivers();
  1255. };
  1256. CPL_C_START
  1257. GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
  1258. CPL_C_END
  1259. /* ******************************************************************** */
  1260. /* GDALAsyncReader */
  1261. /* ******************************************************************** */
  1262. /**
  1263. * Class used as a session object for asynchronous requests. They are
  1264. * created with GDALDataset::BeginAsyncReader(), and destroyed with
  1265. * GDALDataset::EndAsyncReader().
  1266. */
  1267. class CPL_DLL GDALAsyncReader
  1268. {
  1269. CPL_DISALLOW_COPY_ASSIGN(GDALAsyncReader)
  1270. protected:
  1271. //! @cond Doxygen_Suppress
  1272. GDALDataset* poDS;
  1273. int nXOff;
  1274. int nYOff;
  1275. int nXSize;
  1276. int nYSize;
  1277. void * pBuf;
  1278. int nBufXSize;
  1279. int nBufYSize;
  1280. GDALDataType eBufType;
  1281. int nBandCount;
  1282. int* panBandMap;
  1283. int nPixelSpace;
  1284. int nLineSpace;
  1285. int nBandSpace;
  1286. //! @endcond
  1287. public:
  1288. GDALAsyncReader();
  1289. virtual ~GDALAsyncReader();
  1290. /** Return dataset.
  1291. * @return dataset
  1292. */
  1293. GDALDataset* GetGDALDataset() {return poDS;}
  1294. /** Return x offset.
  1295. * @return x offset.
  1296. */
  1297. int GetXOffset() const { return nXOff; }
  1298. /** Return y offset.
  1299. * @return y offset.
  1300. */
  1301. int GetYOffset() const { return nYOff; }
  1302. /** Return width.
  1303. * @return width
  1304. */
  1305. int GetXSize() const { return nXSize; }
  1306. /** Return height.
  1307. * @return height
  1308. */
  1309. int GetYSize() const { return nYSize; }
  1310. /** Return buffer.
  1311. * @return buffer
  1312. */
  1313. void * GetBuffer() {return pBuf;}
  1314. /** Return buffer width.
  1315. * @return buffer width.
  1316. */
  1317. int GetBufferXSize() const { return nBufXSize; }
  1318. /** Return buffer height.
  1319. * @return buffer height.
  1320. */
  1321. int GetBufferYSize() const { return nBufYSize; }
  1322. /** Return buffer data type.
  1323. * @return buffer data type.
  1324. */
  1325. GDALDataType GetBufferType() const { return eBufType; }
  1326. /** Return band count.
  1327. * @return band count
  1328. */
  1329. int GetBandCount() const { return nBandCount; }
  1330. /** Return band map.
  1331. * @return band map.
  1332. */
  1333. int* GetBandMap() { return panBandMap; }
  1334. /** Return pixel spacing.
  1335. * @return pixel spacing.
  1336. */
  1337. int GetPixelSpace() const { return nPixelSpace; }
  1338. /** Return line spacing.
  1339. * @return line spacing.
  1340. */
  1341. int GetLineSpace() const { return nLineSpace; }
  1342. /** Return band spacing.
  1343. * @return band spacing.
  1344. */
  1345. int GetBandSpace() const { return nBandSpace; }
  1346. virtual GDALAsyncStatusType
  1347. GetNextUpdatedRegion(double dfTimeout,
  1348. int* pnBufXOff, int* pnBufYOff,
  1349. int* pnBufXSize, int* pnBufYSize) = 0;
  1350. virtual int LockBuffer( double dfTimeout = -1.0 );
  1351. virtual void UnlockBuffer();
  1352. };
  1353. /* ==================================================================== */
  1354. /* An assortment of overview related stuff. */
  1355. /* ==================================================================== */
  1356. //! @cond Doxygen_Suppress
  1357. /* Only exported for drivers as plugin. Signature may change */
  1358. CPLErr CPL_DLL
  1359. GDALRegenerateOverviewsMultiBand(int nBands, GDALRasterBand** papoSrcBands,
  1360. int nOverviews,
  1361. GDALRasterBand*** papapoOverviewBands,
  1362. const char * pszResampling,
  1363. GDALProgressFunc pfnProgress, void * pProgressData );
  1364. typedef CPLErr (*GDALResampleFunction)
  1365. ( double dfXRatioDstToSrc,
  1366. double dfYRatioDstToSrc,
  1367. double dfSrcXDelta,
  1368. double dfSrcYDelta,
  1369. GDALDataType eWrkDataType,
  1370. void * pChunk,
  1371. GByte * pabyChunkNodataMask,
  1372. int nChunkXOff, int nChunkXSize,
  1373. int nChunkYOff, int nChunkYSize,
  1374. int nDstXOff, int nDstXOff2,
  1375. int nDstYOff, int nDstYOff2,
  1376. GDALRasterBand * poOverview,
  1377. const char * pszResampling,
  1378. int bHasNoData, float fNoDataValue,
  1379. GDALColorTable* poColorTable,
  1380. GDALDataType eSrcDataType,
  1381. bool bPropagateNoData );
  1382. GDALResampleFunction GDALGetResampleFunction(const char* pszResampling,
  1383. int* pnRadius);
  1384. #ifdef GDAL_ENABLE_RESAMPLING_MULTIBAND
  1385. typedef CPLErr (*GDALResampleFunctionMultiBands)
  1386. ( double dfXRatioDstToSrc,
  1387. double dfYRatioDstToSrc,
  1388. double dfSrcXDelta,
  1389. double dfSrcYDelta,
  1390. GDALDataType eWrkDataType,
  1391. void * pChunk, int nBands,
  1392. GByte * pabyChunkNodataMask,
  1393. int nChunkXOff, int nChunkXSize,
  1394. int nChunkYOff, int nChunkYSize,
  1395. int nDstXOff, int nDstXOff2,
  1396. int nDstYOff, int nDstYOff2,
  1397. GDALRasterBand ** papoDstBands,
  1398. const char * pszResampling,
  1399. int bHasNoData, float fNoDataValue,
  1400. GDALColorTable* poColorTable,
  1401. GDALDataType eSrcDataType);
  1402. GDALResampleFunctionMultiBands GDALGetResampleFunctionMultiBands(const char* pszResampling,
  1403. int* pnRadius);
  1404. #endif
  1405. GDALDataType GDALGetOvrWorkDataType(const char* pszResampling,
  1406. GDALDataType eSrcDataType);
  1407. CPL_C_START
  1408. CPLErr CPL_DLL
  1409. HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS,
  1410. GDALDataset **ppoDS,
  1411. int nBands, int *panBandList,
  1412. int nNewOverviews, int *panNewOverviewList,
  1413. const char *pszResampling,
  1414. GDALProgressFunc pfnProgress,
  1415. void *pProgressData );
  1416. CPLErr CPL_DLL
  1417. GTIFFBuildOverviews( const char * pszFilename,
  1418. int nBands, GDALRasterBand **papoBandList,
  1419. int nOverviews, int * panOverviewList,
  1420. const char * pszResampling,
  1421. GDALProgressFunc pfnProgress, void * pProgressData );
  1422. CPLErr CPL_DLL
  1423. GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename,
  1424. const char * pszResampling,
  1425. int nOverviews, int * panOverviewList,
  1426. int nBands, int * panBandList,
  1427. GDALProgressFunc pfnProgress, void * pProgressData);
  1428. int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand* poBand,
  1429. int &nXOff, int &nYOff,
  1430. int &nXSize, int &nYSize,
  1431. int nBufXSize, int nBufYSize) CPL_WARN_DEPRECATED("Use GDALBandGetBestOverviewLevel2 instead");
  1432. int CPL_DLL GDALBandGetBestOverviewLevel2(GDALRasterBand* poBand,
  1433. int &nXOff, int &nYOff,
  1434. int &nXSize, int &nYSize,
  1435. int nBufXSize, int nBufYSize,
  1436. GDALRasterIOExtraArg* psExtraArg);
  1437. int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize ) CPL_WARN_DEPRECATED("Use GDALOvLevelAdjust2 instead");
  1438. int CPL_DLL GDALOvLevelAdjust2( int nOvLevel, int nXSize, int nYSize );
  1439. int CPL_DLL GDALComputeOvFactor( int nOvrXSize, int nRasterXSize,
  1440. int nOvrYSize, int nRasterYSize );
  1441. GDALDataset CPL_DLL *
  1442. GDALFindAssociatedAuxFile( const char *pszBasefile, GDALAccess eAccess,
  1443. GDALDataset *poDependentDS );
  1444. /* ==================================================================== */
  1445. /* Infrastructure to check that dataset characteristics are valid */
  1446. /* ==================================================================== */
  1447. int CPL_DLL GDALCheckDatasetDimensions( int nXSize, int nYSize );
  1448. int CPL_DLL GDALCheckBandCount( int nBands, int bIsZeroAllowed );
  1449. /* Internal use only */
  1450. /* CPL_DLL exported, but only for in-tree drivers that can be built as plugins */
  1451. int CPL_DLL GDALReadWorldFile2( const char *pszBaseFilename, const char *pszExtension,
  1452. double *padfGeoTransform, char** papszSiblingFiles,
  1453. char** ppszWorldFileNameOut);
  1454. int GDALReadTabFile2( const char * pszBaseFilename,
  1455. double *padfGeoTransform, char **ppszWKT,
  1456. int *pnGCPCount, GDAL_GCP **ppasGCPs,
  1457. char** papszSiblingFiles, char** ppszTabFileNameOut );
  1458. void CPL_DLL GDALCopyRasterIOExtraArg(GDALRasterIOExtraArg* psDestArg,
  1459. GDALRasterIOExtraArg* psSrcArg);
  1460. CPL_C_END
  1461. void GDALNullifyOpenDatasetsList();
  1462. CPLMutex** GDALGetphDMMutex();
  1463. CPLMutex** GDALGetphDLMutex();
  1464. void GDALNullifyProxyPoolSingleton();
  1465. GDALDriver* GDALGetAPIPROXYDriver();
  1466. void GDALSetResponsiblePIDForCurrentThread(GIntBig responsiblePID);
  1467. GIntBig GDALGetResponsiblePIDForCurrentThread();
  1468. CPLString GDALFindAssociatedFile( const char *pszBasename, const char *pszExt,
  1469. CSLConstList papszSiblingFiles, int nFlags );
  1470. CPLErr EXIFExtractMetadata(char**& papszMetadata,
  1471. void *fpL, int nOffset,
  1472. int bSwabflag, int nTIFFHEADER,
  1473. int& nExifOffset, int& nInterOffset, int& nGPSOffset);
  1474. int GDALValidateOpenOptions( GDALDriverH hDriver,
  1475. const char* const* papszOptionOptions);
  1476. int GDALValidateOptions( const char* pszOptionList,
  1477. const char* const* papszOptionsToValidate,
  1478. const char* pszErrorMessageOptionType,
  1479. const char* pszErrorMessageContainerName);
  1480. GDALRIOResampleAlg GDALRasterIOGetResampleAlg(const char* pszResampling);
  1481. const char* GDALRasterIOGetResampleAlg(GDALRIOResampleAlg eResampleAlg);
  1482. void GDALRasterIOExtraArgSetResampleAlg(GDALRasterIOExtraArg* psExtraArg,
  1483. int nXSize, int nYSize,
  1484. int nBufXSize, int nBufYSize);
  1485. GDALDataset* GDALCreateOverviewDataset(GDALDataset* poDS, int nOvrLevel,
  1486. int bThisLevelOnly);
  1487. // Should cover particular cases of #3573, #4183, #4506, #6578
  1488. // Behaviour is undefined if fVal1 or fVal2 are NaN (should be tested before
  1489. // calling this function)
  1490. template<class T> inline bool ARE_REAL_EQUAL(T fVal1, T fVal2, int ulp = 2)
  1491. {
  1492. return fVal1 == fVal2 || /* Should cover infinity */
  1493. std::abs(fVal1 - fVal2) < std::numeric_limits<float>::epsilon() * std::abs(fVal1+fVal2) * ulp;
  1494. }
  1495. double GDALAdjustNoDataCloseToFloatMax(double dfVal);
  1496. #define DIV_ROUND_UP(a, b) ( ((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1) )
  1497. // Number of data samples that will be used to compute approximate statistics
  1498. // (minimum value, maximum value, etc.)
  1499. #define GDALSTAT_APPROX_NUMSAMPLES 2500
  1500. void GDALSerializeGCPListToXML( CPLXMLNode* psParentNode,
  1501. GDAL_GCP* pasGCPList,
  1502. int nGCPCount,
  1503. const OGRSpatialReference* poGCP_SRS );
  1504. void GDALDeserializeGCPListFromXML( CPLXMLNode* psGCPList,
  1505. GDAL_GCP** ppasGCPList,
  1506. int* pnGCPCount,
  1507. OGRSpatialReference** ppoGCP_SRS );
  1508. void GDALSerializeOpenOptionsToXML( CPLXMLNode* psParentNode, char** papszOpenOptions);
  1509. char** GDALDeserializeOpenOptionsFromXML( CPLXMLNode* psParentNode );
  1510. int GDALCanFileAcceptSidecarFile(const char* pszFilename);
  1511. //! @endcond
  1512. #endif /* ndef GDAL_PRIV_H_INCLUDED */
上海开阖软件有限公司 沪ICP备12045867号-1