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