1 : /******************************************************************************
2 : * $Id: gdal_priv.h 19692 2010-05-13 17:16:55Z 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 : *
12 : * Permission is hereby granted, free of charge, to any person obtaining a
13 : * copy of this software and associated documentation files (the "Software"),
14 : * to deal in the Software without restriction, including without limitation
15 : * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 : * and/or sell copies of the Software, and to permit persons to whom the
17 : * Software is furnished to do so, subject to the following conditions:
18 : *
19 : * The above copyright notice and this permission notice shall be included
20 : * in all copies or substantial portions of the Software.
21 : *
22 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 : * DEALINGS IN THE SOFTWARE.
29 : ****************************************************************************/
30 :
31 : #ifndef GDAL_PRIV_H_INCLUDED
32 : #define GDAL_PRIV_H_INCLUDED
33 :
34 : /* -------------------------------------------------------------------- */
35 : /* Predeclare various classes before pulling in gdal.h, the */
36 : /* public declarations. */
37 : /* -------------------------------------------------------------------- */
38 : class GDALMajorObject;
39 : class GDALDataset;
40 : class GDALRasterBand;
41 : class GDALDriver;
42 : class GDALRasterAttributeTable;
43 : class GDALProxyDataset;
44 : class GDALProxyRasterBand;
45 : class GDALAsyncReader;
46 :
47 : /* -------------------------------------------------------------------- */
48 : /* Pull in the public declarations. This gets the C apis, and */
49 : /* also various constants. However, we will still get to */
50 : /* provide the real class definitions for the GDAL classes. */
51 : /* -------------------------------------------------------------------- */
52 :
53 : #include "gdal.h"
54 : #include "gdal_frmts.h"
55 : #include "cpl_vsi.h"
56 : #include "cpl_conv.h"
57 : #include "cpl_string.h"
58 : #include "cpl_minixml.h"
59 : #include <vector>
60 :
61 : #define GMO_VALID 0x0001
62 : #define GMO_IGNORE_UNIMPLEMENTED 0x0002
63 : #define GMO_SUPPORT_MD 0x0004
64 : #define GMO_SUPPORT_MDMD 0x0008
65 : #define GMO_MD_DIRTY 0x0010
66 : #define GMO_PAM_CLASS 0x0020
67 :
68 : /************************************************************************/
69 : /* GDALMultiDomainMetadata */
70 : /************************************************************************/
71 :
72 : class CPL_DLL GDALMultiDomainMetadata
73 : {
74 : private:
75 : char **papszDomainList;
76 : char ***papapszMetadataLists;
77 :
78 : public:
79 : GDALMultiDomainMetadata();
80 : ~GDALMultiDomainMetadata();
81 :
82 : int XMLInit( CPLXMLNode *psMetadata, int bMerge );
83 : CPLXMLNode *Serialize();
84 :
85 403059 : char **GetDomainList() { return papszDomainList; }
86 :
87 : char **GetMetadata( const char * pszDomain = "" );
88 : CPLErr SetMetadata( char ** papszMetadata,
89 : const char * pszDomain = "" );
90 : const char *GetMetadataItem( const char * pszName,
91 : const char * pszDomain = "" );
92 : CPLErr SetMetadataItem( const char * pszName,
93 : const char * pszValue,
94 : const char * pszDomain = "" );
95 :
96 : void Clear();
97 : };
98 :
99 : /* ******************************************************************** */
100 : /* GDALMajorObject */
101 : /* */
102 : /* Base class providing metadata, description and other */
103 : /* services shared by major objects. */
104 : /* ******************************************************************** */
105 :
106 : //! Object with metadata.
107 :
108 : class CPL_DLL GDALMajorObject
109 : {
110 : protected:
111 : int nFlags; // GMO_* flags.
112 : CPLString sDescription;
113 : GDALMultiDomainMetadata oMDMD;
114 :
115 : public:
116 : GDALMajorObject();
117 : virtual ~GDALMajorObject();
118 :
119 : int GetMOFlags();
120 : void SetMOFlags(int nFlags);
121 :
122 : virtual const char *GetDescription() const;
123 : virtual void SetDescription( const char * );
124 :
125 : virtual char **GetMetadata( const char * pszDomain = "" );
126 : virtual CPLErr SetMetadata( char ** papszMetadata,
127 : const char * pszDomain = "" );
128 : virtual const char *GetMetadataItem( const char * pszName,
129 : const char * pszDomain = "" );
130 : virtual CPLErr SetMetadataItem( const char * pszName,
131 : const char * pszValue,
132 : const char * pszDomain = "" );
133 : };
134 :
135 : /* ******************************************************************** */
136 : /* GDALDefaultOverviews */
137 : /* ******************************************************************** */
138 : class CPL_DLL GDALDefaultOverviews
139 : {
140 : friend class GDALDataset;
141 :
142 : GDALDataset *poDS;
143 : GDALDataset *poODS;
144 :
145 : CPLString osOvrFilename;
146 :
147 : int bOvrIsAux;
148 :
149 : int bCheckedForMask;
150 : int bOwnMaskDS;
151 : GDALDataset *poMaskDS;
152 :
153 : // for "overview datasets" we record base level info so we can
154 : // find our way back to get overview masks.
155 : GDALDataset *poBaseDS;
156 :
157 : // Stuff for deferred initialize/overviewscans...
158 : bool bCheckedForOverviews;
159 : void OverviewScan();
160 : char *pszInitName;
161 : int bInitNameIsOVR;
162 : char **papszInitSiblingFiles;
163 :
164 : public:
165 : GDALDefaultOverviews();
166 : ~GDALDefaultOverviews();
167 :
168 : void Initialize( GDALDataset *poDS, const char *pszName = NULL,
169 : char **papszSiblingFiles = NULL,
170 : int bNameIsOVR = FALSE );
171 :
172 : int IsInitialized();
173 :
174 : // Overview Related
175 :
176 : int GetOverviewCount(int);
177 : GDALRasterBand *GetOverview(int,int);
178 :
179 : CPLErr BuildOverviews( const char * pszBasename,
180 : const char * pszResampling,
181 : int nOverviews, int * panOverviewList,
182 : int nBands, int * panBandList,
183 : GDALProgressFunc pfnProgress,
184 : void *pProgressData );
185 :
186 : CPLErr BuildOverviewsSubDataset( const char * pszPhysicalFile,
187 : const char * pszResampling,
188 : int nOverviews, int * panOverviewList,
189 : int nBands, int * panBandList,
190 : GDALProgressFunc pfnProgress,
191 : void *pProgressData );
192 :
193 : CPLErr CleanOverviews();
194 :
195 : // Mask Related
196 :
197 : CPLErr CreateMaskBand( int nFlags, int nBand = -1 );
198 : GDALRasterBand *GetMaskBand( int nBand );
199 : int GetMaskFlags( int nBand );
200 :
201 : int HaveMaskFile( char **papszSiblings = NULL,
202 : const char *pszBasename = NULL );
203 :
204 : };
205 :
206 : /* ******************************************************************** */
207 : /* GDALDataset */
208 : /* ******************************************************************** */
209 :
210 : //! A set of associated raster bands, usually from one file.
211 :
212 : class CPL_DLL GDALDataset : public GDALMajorObject
213 : {
214 : friend GDALDatasetH CPL_STDCALL GDALOpen( const char *, GDALAccess);
215 : friend GDALDatasetH CPL_STDCALL GDALOpenShared( const char *, GDALAccess);
216 : friend class GDALDriver;
217 : friend class GDALDefaultOverviews;
218 : friend class GDALProxyDataset;
219 :
220 : protected:
221 : GDALDriver *poDriver;
222 : GDALAccess eAccess;
223 :
224 : // Stored raster information.
225 : int nRasterXSize;
226 : int nRasterYSize;
227 : int nBands;
228 : GDALRasterBand **papoBands;
229 :
230 : int bForceCachedIO;
231 :
232 : int nRefCount;
233 : int bShared;
234 :
235 : GDALDataset(void);
236 : void RasterInitialize( int, int );
237 : void SetBand( int, GDALRasterBand * );
238 :
239 : GDALDefaultOverviews oOvManager;
240 :
241 : virtual CPLErr IBuildOverviews( const char *, int, int *,
242 : int, int *, GDALProgressFunc, void * );
243 :
244 : virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
245 : void *, int, int, GDALDataType,
246 : int, int *, int, int, int );
247 :
248 : CPLErr BlockBasedRasterIO( GDALRWFlag, int, int, int, int,
249 : void *, int, int, GDALDataType,
250 : int, int *, int, int, int );
251 : void BlockBasedFlushCache();
252 :
253 : friend class GDALRasterBand;
254 :
255 : public:
256 : virtual ~GDALDataset();
257 :
258 : int GetRasterXSize( void );
259 : int GetRasterYSize( void );
260 : int GetRasterCount( void );
261 : GDALRasterBand *GetRasterBand( int );
262 :
263 : virtual void FlushCache(void);
264 :
265 : virtual const char *GetProjectionRef(void);
266 : virtual CPLErr SetProjection( const char * );
267 :
268 : virtual CPLErr GetGeoTransform( double * );
269 : virtual CPLErr SetGeoTransform( double * );
270 :
271 : virtual CPLErr AddBand( GDALDataType eType,
272 : char **papszOptions=NULL );
273 :
274 : virtual void *GetInternalHandle( const char * );
275 : virtual GDALDriver *GetDriver(void);
276 : virtual char **GetFileList(void);
277 :
278 : virtual int GetGCPCount();
279 : virtual const char *GetGCPProjection();
280 : virtual const GDAL_GCP *GetGCPs();
281 : virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
282 : const char *pszGCPProjection );
283 :
284 : virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
285 : int nBufXSize, int nBufYSize,
286 : GDALDataType eDT,
287 : int nBandCount, int *panBandList,
288 : char **papszOptions );
289 :
290 : virtual CPLErr CreateMaskBand( int nFlags );
291 :
292 : virtual GDALAsyncReader*
293 : BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize,
294 : void *pBuf, int nBufXSize, int nBufYSize,
295 : GDALDataType eBufType,
296 : int nBandCount, int* panBandMap,
297 : int nPixelSpace, int nLineSpace, int nBandSpace,
298 : char **papszOptions);
299 : virtual void EndAsyncReader(GDALAsyncReader *);
300 :
301 : CPLErr RasterIO( GDALRWFlag, int, int, int, int,
302 : void *, int, int, GDALDataType,
303 : int, int *, int, int, int );
304 :
305 : int Reference();
306 : int Dereference();
307 19692 : GDALAccess GetAccess() { return eAccess; }
308 :
309 : int GetShared();
310 : void MarkAsShared();
311 :
312 : static GDALDataset **GetOpenDatasets( int *pnDatasetCount );
313 :
314 : CPLErr BuildOverviews( const char *, int, int *,
315 : int, int *, GDALProgressFunc, void * );
316 : };
317 :
318 : /* ******************************************************************** */
319 : /* GDALRasterBlock */
320 : /* ******************************************************************** */
321 :
322 : //! A single raster block in the block cache.
323 :
324 : class CPL_DLL GDALRasterBlock
325 : {
326 : GDALDataType eType;
327 :
328 : int bDirty;
329 : int nLockCount;
330 :
331 : int nXOff;
332 : int nYOff;
333 :
334 : int nXSize;
335 : int nYSize;
336 :
337 : void *pData;
338 :
339 : GDALRasterBand *poBand;
340 :
341 : GDALRasterBlock *poNext;
342 : GDALRasterBlock *poPrevious;
343 :
344 : public:
345 : GDALRasterBlock( GDALRasterBand *, int, int );
346 : virtual ~GDALRasterBlock();
347 :
348 : CPLErr Internalize( void );
349 : void Touch( void );
350 : void MarkDirty( void );
351 : void MarkClean( void );
352 4605742 : void AddLock( void ) { nLockCount++; }
353 4605742 : void DropLock( void ) { nLockCount--; }
354 : void Detach();
355 :
356 : CPLErr Write();
357 :
358 182 : GDALDataType GetDataType() { return eType; }
359 634 : int GetXOff() { return nXOff; }
360 634 : int GetYOff() { return nYOff; }
361 0 : int GetXSize() { return nXSize; }
362 0 : int GetYSize() { return nYSize; }
363 319304 : int GetDirty() { return bDirty; }
364 634 : int GetLockCount() { return nLockCount; }
365 :
366 4826137 : void *GetDataRef( void ) { return pData; }
367 :
368 : /// @brief Accessor to source GDALRasterBand object.
369 : /// @return source raster band of the raster block.
370 634 : GDALRasterBand *GetBand() { return poBand; }
371 :
372 : static int FlushCacheBlock();
373 : static void Verify();
374 :
375 : static int SafeLockBlock( GDALRasterBlock ** );
376 : };
377 :
378 : /* ******************************************************************** */
379 : /* GDALColorTable */
380 : /* ******************************************************************** */
381 :
382 : /*! A color table / palette. */
383 :
384 : class CPL_DLL GDALColorTable
385 1656 : {
386 : GDALPaletteInterp eInterp;
387 :
388 : std::vector<GDALColorEntry> aoEntries;
389 :
390 : public:
391 : GDALColorTable( GDALPaletteInterp = GPI_RGB );
392 : ~GDALColorTable();
393 :
394 : GDALColorTable *Clone() const;
395 :
396 : GDALPaletteInterp GetPaletteInterpretation() const;
397 :
398 : int GetColorEntryCount() const;
399 : const GDALColorEntry *GetColorEntry( int ) const;
400 : int GetColorEntryAsRGB( int, GDALColorEntry * ) const;
401 : void SetColorEntry( int, const GDALColorEntry * );
402 : int CreateColorRamp( int, const GDALColorEntry * ,
403 : int, const GDALColorEntry * );
404 : };
405 :
406 : /* ******************************************************************** */
407 : /* GDALRasterBand */
408 : /* ******************************************************************** */
409 :
410 : //! A single raster band (or channel).
411 :
412 : class CPL_DLL GDALRasterBand : public GDALMajorObject
413 : {
414 : protected:
415 : GDALDataset *poDS;
416 : int nBand; /* 1 based */
417 :
418 : int nRasterXSize;
419 : int nRasterYSize;
420 :
421 : GDALDataType eDataType;
422 : GDALAccess eAccess;
423 :
424 : /* stuff related to blocking, and raster cache */
425 : int nBlockXSize;
426 : int nBlockYSize;
427 : int nBlocksPerRow;
428 : int nBlocksPerColumn;
429 :
430 : int bSubBlockingActive;
431 : int nSubBlocksPerRow;
432 : int nSubBlocksPerColumn;
433 : GDALRasterBlock **papoBlocks;
434 :
435 : int nBlockReads;
436 : int bForceCachedIO;
437 :
438 : GDALRasterBand *poMask;
439 : bool bOwnMask;
440 : int nMaskFlags;
441 :
442 : friend class GDALDataset;
443 : friend class GDALRasterBlock;
444 : friend class GDALProxyRasterBand;
445 :
446 : protected:
447 : virtual CPLErr IReadBlock( int, int, void * ) = 0;
448 : virtual CPLErr IWriteBlock( int, int, void * );
449 : virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
450 : void *, int, int, GDALDataType,
451 : int, int );
452 : CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int,
453 : void *, int, int, GDALDataType,
454 : int, int );
455 :
456 : int InitBlockInfo();
457 :
458 : CPLErr AdoptBlock( int, int, GDALRasterBlock * );
459 : GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff );
460 :
461 : public:
462 : GDALRasterBand();
463 :
464 : virtual ~GDALRasterBand();
465 :
466 : int GetXSize();
467 : int GetYSize();
468 : int GetBand();
469 : GDALDataset*GetDataset();
470 :
471 : GDALDataType GetRasterDataType( void );
472 : void GetBlockSize( int *, int * );
473 : GDALAccess GetAccess();
474 :
475 : CPLErr RasterIO( GDALRWFlag, int, int, int, int,
476 : void *, int, int, GDALDataType,
477 : int, int );
478 : CPLErr ReadBlock( int, int, void * );
479 :
480 : CPLErr WriteBlock( int, int, void * );
481 :
482 : GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff,
483 : int bJustInitialize = FALSE );
484 : CPLErr FlushBlock( int = -1, int = -1 );
485 :
486 : unsigned char* GetIndexColorTranslationTo(/* const */ GDALRasterBand* poReferenceBand,
487 : unsigned char* pTranslationTable = NULL,
488 : int* pApproximateMatching = NULL);
489 :
490 : // New OpengIS CV_SampleDimension stuff.
491 :
492 : virtual CPLErr FlushCache();
493 : virtual char **GetCategoryNames();
494 : virtual double GetNoDataValue( int *pbSuccess = NULL );
495 : virtual double GetMinimum( int *pbSuccess = NULL );
496 : virtual double GetMaximum(int *pbSuccess = NULL );
497 : virtual double GetOffset( int *pbSuccess = NULL );
498 : virtual double GetScale( int *pbSuccess = NULL );
499 : virtual const char *GetUnitType();
500 : virtual GDALColorInterp GetColorInterpretation();
501 : virtual GDALColorTable *GetColorTable();
502 : virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
503 :
504 : virtual CPLErr SetCategoryNames( char ** );
505 : virtual CPLErr SetNoDataValue( double );
506 : virtual CPLErr SetColorTable( GDALColorTable * );
507 : virtual CPLErr SetColorInterpretation( GDALColorInterp );
508 : virtual CPLErr SetOffset( double );
509 : virtual CPLErr SetScale( double );
510 : virtual CPLErr SetUnitType( const char * );
511 :
512 : virtual CPLErr GetStatistics( int bApproxOK, int bForce,
513 : double *pdfMin, double *pdfMax,
514 : double *pdfMean, double *padfStdDev );
515 : virtual CPLErr ComputeStatistics( int bApproxOK,
516 : double *pdfMin, double *pdfMax,
517 : double *pdfMean, double *pdfStdDev,
518 : GDALProgressFunc, void *pProgressData );
519 : virtual CPLErr SetStatistics( double dfMin, double dfMax,
520 : double dfMean, double dfStdDev );
521 : virtual CPLErr ComputeRasterMinMax( int, double* );
522 :
523 : virtual int HasArbitraryOverviews();
524 : virtual int GetOverviewCount();
525 : virtual GDALRasterBand *GetOverview(int);
526 : virtual GDALRasterBand *GetRasterSampleOverview( int );
527 : virtual CPLErr BuildOverviews( const char *, int, int *,
528 : GDALProgressFunc, void * );
529 :
530 : virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
531 : int nBufXSize, int nBufYSize,
532 : GDALDataType eDT, char **papszOptions );
533 :
534 : virtual CPLErr GetHistogram( double dfMin, double dfMax,
535 : int nBuckets, int * panHistogram,
536 : int bIncludeOutOfRange, int bApproxOK,
537 : GDALProgressFunc, void *pProgressData );
538 :
539 : virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
540 : int *pnBuckets, int ** ppanHistogram,
541 : int bForce,
542 : GDALProgressFunc, void *pProgressData);
543 : virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
544 : int nBuckets, int *panHistogram );
545 :
546 : virtual const GDALRasterAttributeTable *GetDefaultRAT();
547 : virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * );
548 :
549 : virtual GDALRasterBand *GetMaskBand();
550 : virtual int GetMaskFlags();
551 : virtual CPLErr CreateMaskBand( int nFlags );
552 : };
553 :
554 : /* ******************************************************************** */
555 : /* GDALAllValidMaskBand */
556 : /* ******************************************************************** */
557 :
558 : class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand
559 : {
560 : protected:
561 : virtual CPLErr IReadBlock( int, int, void * );
562 :
563 : public:
564 : GDALAllValidMaskBand( GDALRasterBand * );
565 : virtual ~GDALAllValidMaskBand();
566 :
567 : virtual GDALRasterBand *GetMaskBand();
568 : virtual int GetMaskFlags();
569 : };
570 :
571 : /* ******************************************************************** */
572 : /* GDALNoDataMaskBand */
573 : /* ******************************************************************** */
574 :
575 : class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
576 : {
577 : double dfNoDataValue;
578 : GDALRasterBand *poParent;
579 :
580 : protected:
581 : virtual CPLErr IReadBlock( int, int, void * );
582 :
583 : public:
584 : GDALNoDataMaskBand( GDALRasterBand * );
585 : virtual ~GDALNoDataMaskBand();
586 : };
587 :
588 : /* ******************************************************************** */
589 : /* GDALNoDataValuesMaskBand */
590 : /* ******************************************************************** */
591 :
592 : class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand
593 : {
594 : double *padfNodataValues;
595 :
596 : protected:
597 : virtual CPLErr IReadBlock( int, int, void * );
598 :
599 : public:
600 : GDALNoDataValuesMaskBand( GDALDataset * );
601 : virtual ~GDALNoDataValuesMaskBand();
602 : };
603 :
604 : /* ******************************************************************** */
605 : /* GDALOpenInfo */
606 : /* */
607 : /* Structure of data about dataset for open functions. */
608 : /* ******************************************************************** */
609 :
610 : class CPL_DLL GDALOpenInfo
611 : {
612 : public:
613 : GDALOpenInfo( const char * pszFile, GDALAccess eAccessIn,
614 : char **papszSiblingFiles = NULL );
615 : ~GDALOpenInfo( void );
616 :
617 : char *pszFilename;
618 : char **papszSiblingFiles;
619 :
620 : GDALAccess eAccess;
621 :
622 : int bStatOK;
623 : int bIsDirectory;
624 :
625 : FILE *fp;
626 :
627 : int nHeaderBytes;
628 : GByte *pabyHeader;
629 :
630 : };
631 :
632 : /* ******************************************************************** */
633 : /* GDALDriver */
634 : /* ******************************************************************** */
635 :
636 :
637 : /**
638 : * \brief Format specific driver.
639 : *
640 : * An instance of this class is created for each supported format, and
641 : * manages information about the format.
642 : *
643 : * This roughly corresponds to a file format, though some
644 : * drivers may be gateways to many formats through a secondary
645 : * multi-library.
646 : */
647 :
648 : class CPL_DLL GDALDriver : public GDALMajorObject
649 : {
650 : public:
651 : GDALDriver();
652 : ~GDALDriver();
653 :
654 : /* -------------------------------------------------------------------- */
655 : /* Public C++ methods. */
656 : /* -------------------------------------------------------------------- */
657 : GDALDataset *Create( const char * pszName,
658 : int nXSize, int nYSize, int nBands,
659 : GDALDataType eType, char ** papszOptions );
660 :
661 : CPLErr Delete( const char * pszName );
662 : CPLErr Rename( const char * pszNewName,
663 : const char * pszOldName );
664 : CPLErr CopyFiles( const char * pszNewName,
665 : const char * pszOldName );
666 :
667 : GDALDataset *CreateCopy( const char *, GDALDataset *,
668 : int, char **,
669 : GDALProgressFunc pfnProgress,
670 : void * pProgressData );
671 :
672 : /* -------------------------------------------------------------------- */
673 : /* The following are semiprivate, not intended to be accessed */
674 : /* by anyone but the formats instantiating and populating the */
675 : /* drivers. */
676 : /* -------------------------------------------------------------------- */
677 : GDALDataset *(*pfnOpen)( GDALOpenInfo * );
678 :
679 : GDALDataset *(*pfnCreate)( const char * pszName,
680 : int nXSize, int nYSize, int nBands,
681 : GDALDataType eType,
682 : char ** papszOptions );
683 :
684 : CPLErr (*pfnDelete)( const char * pszName );
685 :
686 : GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *,
687 : int, char **,
688 : GDALProgressFunc pfnProgress,
689 : void * pProgressData );
690 :
691 : void *pDriverData;
692 :
693 : void (*pfnUnloadDriver)(GDALDriver *);
694 :
695 : int (*pfnIdentify)( GDALOpenInfo * );
696 :
697 : CPLErr (*pfnRename)( const char * pszNewName,
698 : const char * pszOldName );
699 : CPLErr (*pfnCopyFiles)( const char * pszNewName,
700 : const char * pszOldName );
701 :
702 : /* -------------------------------------------------------------------- */
703 : /* Helper methods. */
704 : /* -------------------------------------------------------------------- */
705 : GDALDataset *DefaultCreateCopy( const char *, GDALDataset *,
706 : int, char **,
707 : GDALProgressFunc pfnProgress,
708 : void * pProgressData );
709 : static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
710 : GDALDataset *poDstDS,
711 : int bStrict );
712 : static CPLErr QuietDelete( const char * pszName );
713 : };
714 :
715 : /* ******************************************************************** */
716 : /* GDALDriverManager */
717 : /* ******************************************************************** */
718 :
719 : /**
720 : * Class for managing the registration of file format drivers.
721 : *
722 : * Use GetGDALDriverManager() to fetch the global singleton instance of
723 : * this class.
724 : */
725 :
726 : class CPL_DLL GDALDriverManager : public GDALMajorObject
727 : {
728 : int nDrivers;
729 : GDALDriver **papoDrivers;
730 :
731 : char *pszHome;
732 :
733 : public:
734 : GDALDriverManager();
735 : ~GDALDriverManager();
736 :
737 : int GetDriverCount( void );
738 : GDALDriver *GetDriver( int );
739 : GDALDriver *GetDriverByName( const char * );
740 :
741 : int RegisterDriver( GDALDriver * );
742 : void MoveDriver( GDALDriver *, int );
743 : void DeregisterDriver( GDALDriver * );
744 :
745 : void AutoLoadDrivers();
746 : void AutoSkipDrivers();
747 :
748 : const char *GetHome();
749 : void SetHome( const char * );
750 : };
751 :
752 : CPL_C_START
753 : GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
754 : CPL_C_END
755 :
756 : /* ******************************************************************** */
757 : /* GDALAsyncReader */
758 : /* ******************************************************************** */
759 :
760 : /**
761 : * Class used as a session object for asynchronous requests. They are
762 : * created with GDALDataset::BeginAsyncReader(), and destroyed with
763 : * GDALDataset::EndAsyncReader().
764 : */
765 : class CPL_DLL GDALAsyncReader
766 : {
767 : protected:
768 : GDALDataset* poDS;
769 : int nXOff;
770 : int nYOff;
771 : int nXSize;
772 : int nYSize;
773 : void * pBuf;
774 : int nBufXSize;
775 : int nBufYSize;
776 : GDALDataType eBufType;
777 : int nBandCount;
778 : int* panBandMap;
779 : int nPixelSpace;
780 : int nLineSpace;
781 : int nBandSpace;
782 :
783 : public:
784 : GDALAsyncReader();
785 : virtual ~GDALAsyncReader();
786 :
787 : GDALDataset* GetGDALDataset() {return poDS;}
788 : int GetXOffset() {return nXOff;}
789 : int GetYOffset() {return nYOff;}
790 : int GetXSize() {return nXSize;}
791 : int GetYSize() {return nYSize;}
792 : void * GetBuffer() {return pBuf;}
793 : int GetBufferXSize() {return nBufXSize;}
794 : int GetBufferYSize() {return nBufYSize;}
795 : GDALDataType GetBufferType() {return eBufType;}
796 : int GetBandCount() {return nBandCount;}
797 : int* GetBandMap() {return panBandMap;}
798 : int GetPixelSpace() {return nPixelSpace;}
799 : int GetLineSpace() {return nLineSpace;}
800 : int GetBandSpace() {return nBandSpace;}
801 :
802 : virtual GDALAsyncStatusType
803 : GetNextUpdatedRegion(double dfTimeout,
804 : int* pnBufXOff, int* pnBufYOff,
805 : int* pnBufXSize, int* pnBufYSize) = 0;
806 : virtual int LockBuffer( double dfTimeout = -1.0 );
807 : virtual void UnlockBuffer();
808 : };
809 :
810 : /* ==================================================================== */
811 : /* An assortment of overview related stuff. */
812 : /* ==================================================================== */
813 :
814 : /* Not a public symbol for the moment */
815 : CPLErr
816 : GDALRegenerateOverviewsMultiBand(int nBands, GDALRasterBand** papoSrcBands,
817 : int nOverviews,
818 : GDALRasterBand*** papapoOverviewBands,
819 : const char * pszResampling,
820 : GDALProgressFunc pfnProgress, void * pProgressData );
821 :
822 : CPL_C_START
823 :
824 : #ifndef WIN32CE
825 :
826 : CPLErr CPL_DLL
827 : HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS,
828 : GDALDataset **ppoDS,
829 : int nBands, int *panBandList,
830 : int nNewOverviews, int *panNewOverviewList,
831 : const char *pszResampling,
832 : GDALProgressFunc pfnProgress,
833 : void *pProgressData );
834 :
835 : #endif /* WIN32CE */
836 :
837 : CPLErr CPL_DLL
838 : GTIFFBuildOverviews( const char * pszFilename,
839 : int nBands, GDALRasterBand **papoBandList,
840 : int nOverviews, int * panOverviewList,
841 : const char * pszResampling,
842 : GDALProgressFunc pfnProgress, void * pProgressData );
843 :
844 : CPLErr CPL_DLL
845 : GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename,
846 : const char * pszResampling,
847 : int nOverviews, int * panOverviewList,
848 : int nBands, int * panBandList,
849 : GDALProgressFunc pfnProgress, void * pProgressData);
850 :
851 : int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand* poBand,
852 : int &nXOff, int &nYOff,
853 : int &nXSize, int &nYSize,
854 : int nBufXSize, int nBufYSize);
855 :
856 : int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize );
857 :
858 : GDALDataset CPL_DLL *
859 : GDALFindAssociatedAuxFile( const char *pszBasefile, GDALAccess eAccess,
860 : GDALDataset *poDependentDS );
861 :
862 : /* ==================================================================== */
863 : /* Misc functions. */
864 : /* ==================================================================== */
865 :
866 : CPLErr CPL_DLL GDALParseGMLCoverage( CPLXMLNode *psTree,
867 : int *pnXSize, int *pnYSize,
868 : double *padfGeoTransform,
869 : char **ppszProjection );
870 :
871 : /* ==================================================================== */
872 : /* Infrastructure to check that dataset characteristics are valid */
873 : /* ==================================================================== */
874 :
875 : int CPL_DLL GDALCheckDatasetDimensions( int nXSize, int nYSize );
876 : int CPL_DLL GDALCheckBandCount( int nBands, int bIsZeroAllowed );
877 :
878 :
879 : // Test if pixel value matches nodata value. Avoid using strict comparison as
880 : // the stored nodata value in GeoTIFF files is stored as a string, so there might
881 : // be numerical imprecision when reading it back. See #3573
882 : #define EQUAL_TO_NODATA(dfValue, dfNoDataValue) \
883 : (dfValue == dfNoDataValue || (dfNoDataValue != 0 && fabs(1 - dfValue / dfNoDataValue) < 1e-10 ))
884 :
885 :
886 : CPL_C_END
887 :
888 : #endif /* ndef GDAL_PRIV_H_INCLUDED */
|