1 : /******************************************************************************
2 : * $Id: gdal_priv.h 23431 2011-11-27 15:02:24Z 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 : CPLStringList **papoMetadataLists;
77 :
78 : public:
79 : GDALMultiDomainMetadata();
80 : ~GDALMultiDomainMetadata();
81 :
82 : int XMLInit( CPLXMLNode *psMetadata, int bMerge );
83 : CPLXMLNode *Serialize();
84 :
85 404058 : 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 : int CloseDependentDatasets();
175 :
176 : // Overview Related
177 :
178 : int GetOverviewCount(int);
179 : GDALRasterBand *GetOverview(int,int);
180 :
181 : CPLErr BuildOverviews( const char * pszBasename,
182 : const char * pszResampling,
183 : int nOverviews, int * panOverviewList,
184 : int nBands, int * panBandList,
185 : GDALProgressFunc pfnProgress,
186 : void *pProgressData );
187 :
188 : CPLErr BuildOverviewsSubDataset( const char * pszPhysicalFile,
189 : const char * pszResampling,
190 : int nOverviews, int * panOverviewList,
191 : int nBands, int * panBandList,
192 : GDALProgressFunc pfnProgress,
193 : void *pProgressData );
194 :
195 : CPLErr CleanOverviews();
196 :
197 : // Mask Related
198 :
199 : CPLErr CreateMaskBand( int nFlags, int nBand = -1 );
200 : GDALRasterBand *GetMaskBand( int nBand );
201 : int GetMaskFlags( int nBand );
202 :
203 : int HaveMaskFile( char **papszSiblings = NULL,
204 : const char *pszBasename = NULL );
205 :
206 8958 : char** GetSiblingFiles() { return papszInitSiblingFiles; }
207 : };
208 :
209 : /* ******************************************************************** */
210 : /* GDALOpenInfo */
211 : /* */
212 : /* Structure of data about dataset for open functions. */
213 : /* ******************************************************************** */
214 :
215 : class CPL_DLL GDALOpenInfo
216 : {
217 : public:
218 : GDALOpenInfo( const char * pszFile, GDALAccess eAccessIn,
219 : char **papszSiblingFiles = NULL );
220 : ~GDALOpenInfo( void );
221 :
222 : char *pszFilename;
223 : char **papszSiblingFiles;
224 :
225 : GDALAccess eAccess;
226 :
227 : int bStatOK;
228 : int bIsDirectory;
229 :
230 : FILE *fp;
231 :
232 : int nHeaderBytes;
233 : GByte *pabyHeader;
234 :
235 : };
236 :
237 : /* ******************************************************************** */
238 : /* GDALDataset */
239 : /* ******************************************************************** */
240 :
241 : /* Internal method for now. Might be subject to later revisions */
242 : GDALDatasetH GDALOpenInternal( const char * pszFilename, GDALAccess eAccess,
243 : const char* const * papszAllowedDrivers);
244 : GDALDatasetH GDALOpenInternal( GDALOpenInfo& oOpenInfo,
245 : const char* const * papszAllowedDrivers);
246 :
247 : //! A set of associated raster bands, usually from one file.
248 :
249 : class CPL_DLL GDALDataset : public GDALMajorObject
250 : {
251 : friend GDALDatasetH CPL_STDCALL GDALOpen( const char *, GDALAccess);
252 : friend GDALDatasetH CPL_STDCALL GDALOpenShared( const char *, GDALAccess);
253 :
254 : /* Internal method for now. Might be subject to later revisions */
255 : friend GDALDatasetH GDALOpenInternal( const char *, GDALAccess, const char* const * papszAllowedDrivers);
256 : friend GDALDatasetH GDALOpenInternal( GDALOpenInfo& oOpenInfo,
257 : const char* const * papszAllowedDrivers);
258 :
259 : friend class GDALDriver;
260 : friend class GDALDefaultOverviews;
261 : friend class GDALProxyDataset;
262 : friend class GDALDriverManager;
263 :
264 : protected:
265 : GDALDriver *poDriver;
266 : GDALAccess eAccess;
267 :
268 : // Stored raster information.
269 : int nRasterXSize;
270 : int nRasterYSize;
271 : int nBands;
272 : GDALRasterBand **papoBands;
273 :
274 : int bForceCachedIO;
275 :
276 : int nRefCount;
277 : int bShared;
278 :
279 : GDALDataset(void);
280 : void RasterInitialize( int, int );
281 : void SetBand( int, GDALRasterBand * );
282 :
283 : GDALDefaultOverviews oOvManager;
284 :
285 : virtual CPLErr IBuildOverviews( const char *, int, int *,
286 : int, int *, GDALProgressFunc, void * );
287 :
288 : virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
289 : void *, int, int, GDALDataType,
290 : int, int *, int, int, int );
291 :
292 : CPLErr BlockBasedRasterIO( GDALRWFlag, int, int, int, int,
293 : void *, int, int, GDALDataType,
294 : int, int *, int, int, int );
295 : void BlockBasedFlushCache();
296 :
297 : virtual int CloseDependentDatasets();
298 :
299 : friend class GDALRasterBand;
300 :
301 : public:
302 : virtual ~GDALDataset();
303 :
304 : int GetRasterXSize( void );
305 : int GetRasterYSize( void );
306 : int GetRasterCount( void );
307 : GDALRasterBand *GetRasterBand( int );
308 :
309 : virtual void FlushCache(void);
310 :
311 : virtual const char *GetProjectionRef(void);
312 : virtual CPLErr SetProjection( const char * );
313 :
314 : virtual CPLErr GetGeoTransform( double * );
315 : virtual CPLErr SetGeoTransform( double * );
316 :
317 : virtual CPLErr AddBand( GDALDataType eType,
318 : char **papszOptions=NULL );
319 :
320 : virtual void *GetInternalHandle( const char * );
321 : virtual GDALDriver *GetDriver(void);
322 : virtual char **GetFileList(void);
323 :
324 : virtual int GetGCPCount();
325 : virtual const char *GetGCPProjection();
326 : virtual const GDAL_GCP *GetGCPs();
327 : virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
328 : const char *pszGCPProjection );
329 :
330 : virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
331 : int nBufXSize, int nBufYSize,
332 : GDALDataType eDT,
333 : int nBandCount, int *panBandList,
334 : char **papszOptions );
335 :
336 : virtual CPLErr CreateMaskBand( int nFlags );
337 :
338 : virtual GDALAsyncReader*
339 : BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize,
340 : void *pBuf, int nBufXSize, int nBufYSize,
341 : GDALDataType eBufType,
342 : int nBandCount, int* panBandMap,
343 : int nPixelSpace, int nLineSpace, int nBandSpace,
344 : char **papszOptions);
345 : virtual void EndAsyncReader(GDALAsyncReader *);
346 :
347 : CPLErr RasterIO( GDALRWFlag, int, int, int, int,
348 : void *, int, int, GDALDataType,
349 : int, int *, int, int, int );
350 :
351 : int Reference();
352 : int Dereference();
353 26192 : GDALAccess GetAccess() { return eAccess; }
354 :
355 : int GetShared();
356 : void MarkAsShared();
357 :
358 : static GDALDataset **GetOpenDatasets( int *pnDatasetCount );
359 :
360 : CPLErr BuildOverviews( const char *, int, int *,
361 : int, int *, GDALProgressFunc, void * );
362 :
363 : void ReportError(CPLErr eErrClass, int err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
364 : };
365 :
366 : /* ******************************************************************** */
367 : /* GDALRasterBlock */
368 : /* ******************************************************************** */
369 :
370 : //! A single raster block in the block cache.
371 :
372 : class CPL_DLL GDALRasterBlock
373 : {
374 : GDALDataType eType;
375 :
376 : int bDirty;
377 : int nLockCount;
378 :
379 : int nXOff;
380 : int nYOff;
381 :
382 : int nXSize;
383 : int nYSize;
384 :
385 : void *pData;
386 :
387 : GDALRasterBand *poBand;
388 :
389 : GDALRasterBlock *poNext;
390 : GDALRasterBlock *poPrevious;
391 :
392 : public:
393 : GDALRasterBlock( GDALRasterBand *, int, int );
394 : virtual ~GDALRasterBlock();
395 :
396 : CPLErr Internalize( void );
397 : void Touch( void );
398 : void MarkDirty( void );
399 : void MarkClean( void );
400 5139356 : void AddLock( void ) { nLockCount++; }
401 5139356 : void DropLock( void ) { nLockCount--; }
402 : void Detach();
403 :
404 : CPLErr Write();
405 :
406 208 : GDALDataType GetDataType() { return eType; }
407 7493 : int GetXOff() { return nXOff; }
408 7493 : int GetYOff() { return nYOff; }
409 0 : int GetXSize() { return nXSize; }
410 0 : int GetYSize() { return nYSize; }
411 425705 : int GetDirty() { return bDirty; }
412 7493 : int GetLockCount() { return nLockCount; }
413 :
414 5263483 : void *GetDataRef( void ) { return pData; }
415 :
416 : /// @brief Accessor to source GDALRasterBand object.
417 : /// @return source raster band of the raster block.
418 7493 : GDALRasterBand *GetBand() { return poBand; }
419 :
420 : static int FlushCacheBlock();
421 : static void Verify();
422 :
423 : static int SafeLockBlock( GDALRasterBlock ** );
424 : };
425 :
426 : /* ******************************************************************** */
427 : /* GDALColorTable */
428 : /* ******************************************************************** */
429 :
430 : /*! A color table / palette. */
431 :
432 : class CPL_DLL GDALColorTable
433 1674 : {
434 : GDALPaletteInterp eInterp;
435 :
436 : std::vector<GDALColorEntry> aoEntries;
437 :
438 : public:
439 : GDALColorTable( GDALPaletteInterp = GPI_RGB );
440 : ~GDALColorTable();
441 :
442 : GDALColorTable *Clone() const;
443 :
444 : GDALPaletteInterp GetPaletteInterpretation() const;
445 :
446 : int GetColorEntryCount() const;
447 : const GDALColorEntry *GetColorEntry( int ) const;
448 : int GetColorEntryAsRGB( int, GDALColorEntry * ) const;
449 : void SetColorEntry( int, const GDALColorEntry * );
450 : int CreateColorRamp( int, const GDALColorEntry * ,
451 : int, const GDALColorEntry * );
452 : };
453 :
454 : /* ******************************************************************** */
455 : /* GDALRasterBand */
456 : /* ******************************************************************** */
457 :
458 : //! A single raster band (or channel).
459 :
460 : class CPL_DLL GDALRasterBand : public GDALMajorObject
461 : {
462 : private:
463 : CPLErr eFlushBlockErr;
464 :
465 : void SetFlushBlockErr( CPLErr eErr );
466 :
467 : friend class GDALRasterBlock;
468 :
469 : protected:
470 : GDALDataset *poDS;
471 : int nBand; /* 1 based */
472 :
473 : int nRasterXSize;
474 : int nRasterYSize;
475 :
476 : GDALDataType eDataType;
477 : GDALAccess eAccess;
478 :
479 : /* stuff related to blocking, and raster cache */
480 : int nBlockXSize;
481 : int nBlockYSize;
482 : int nBlocksPerRow;
483 : int nBlocksPerColumn;
484 :
485 : int bSubBlockingActive;
486 : int nSubBlocksPerRow;
487 : int nSubBlocksPerColumn;
488 : GDALRasterBlock **papoBlocks;
489 :
490 : int nBlockReads;
491 : int bForceCachedIO;
492 :
493 : GDALRasterBand *poMask;
494 : bool bOwnMask;
495 : int nMaskFlags;
496 :
497 : friend class GDALDataset;
498 : friend class GDALProxyRasterBand;
499 :
500 : protected:
501 : virtual CPLErr IReadBlock( int, int, void * ) = 0;
502 : virtual CPLErr IWriteBlock( int, int, void * );
503 : virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
504 : void *, int, int, GDALDataType,
505 : int, int );
506 : CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int,
507 : void *, int, int, GDALDataType,
508 : int, int );
509 :
510 : int InitBlockInfo();
511 :
512 : CPLErr AdoptBlock( int, int, GDALRasterBlock * );
513 : GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff );
514 :
515 : public:
516 : GDALRasterBand();
517 :
518 : virtual ~GDALRasterBand();
519 :
520 : int GetXSize();
521 : int GetYSize();
522 : int GetBand();
523 : GDALDataset*GetDataset();
524 :
525 : GDALDataType GetRasterDataType( void );
526 : void GetBlockSize( int *, int * );
527 : GDALAccess GetAccess();
528 :
529 : CPLErr RasterIO( GDALRWFlag, int, int, int, int,
530 : void *, int, int, GDALDataType,
531 : int, int );
532 : CPLErr ReadBlock( int, int, void * );
533 :
534 : CPLErr WriteBlock( int, int, void * );
535 :
536 : GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff,
537 : int bJustInitialize = FALSE );
538 : CPLErr FlushBlock( int = -1, int = -1, int bWriteDirtyBlock = TRUE );
539 :
540 : unsigned char* GetIndexColorTranslationTo(/* const */ GDALRasterBand* poReferenceBand,
541 : unsigned char* pTranslationTable = NULL,
542 : int* pApproximateMatching = NULL);
543 :
544 : // New OpengIS CV_SampleDimension stuff.
545 :
546 : virtual CPLErr FlushCache();
547 : virtual char **GetCategoryNames();
548 : virtual double GetNoDataValue( int *pbSuccess = NULL );
549 : virtual double GetMinimum( int *pbSuccess = NULL );
550 : virtual double GetMaximum(int *pbSuccess = NULL );
551 : virtual double GetOffset( int *pbSuccess = NULL );
552 : virtual double GetScale( int *pbSuccess = NULL );
553 : virtual const char *GetUnitType();
554 : virtual GDALColorInterp GetColorInterpretation();
555 : virtual GDALColorTable *GetColorTable();
556 : virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
557 :
558 : virtual CPLErr SetCategoryNames( char ** );
559 : virtual CPLErr SetNoDataValue( double );
560 : virtual CPLErr SetColorTable( GDALColorTable * );
561 : virtual CPLErr SetColorInterpretation( GDALColorInterp );
562 : virtual CPLErr SetOffset( double );
563 : virtual CPLErr SetScale( double );
564 : virtual CPLErr SetUnitType( const char * );
565 :
566 : virtual CPLErr GetStatistics( int bApproxOK, int bForce,
567 : double *pdfMin, double *pdfMax,
568 : double *pdfMean, double *padfStdDev );
569 : virtual CPLErr ComputeStatistics( int bApproxOK,
570 : double *pdfMin, double *pdfMax,
571 : double *pdfMean, double *pdfStdDev,
572 : GDALProgressFunc, void *pProgressData );
573 : virtual CPLErr SetStatistics( double dfMin, double dfMax,
574 : double dfMean, double dfStdDev );
575 : virtual CPLErr ComputeRasterMinMax( int, double* );
576 :
577 : virtual int HasArbitraryOverviews();
578 : virtual int GetOverviewCount();
579 : virtual GDALRasterBand *GetOverview(int);
580 : virtual GDALRasterBand *GetRasterSampleOverview( int );
581 : virtual CPLErr BuildOverviews( const char *, int, int *,
582 : GDALProgressFunc, void * );
583 :
584 : virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
585 : int nBufXSize, int nBufYSize,
586 : GDALDataType eDT, char **papszOptions );
587 :
588 : virtual CPLErr GetHistogram( double dfMin, double dfMax,
589 : int nBuckets, int * panHistogram,
590 : int bIncludeOutOfRange, int bApproxOK,
591 : GDALProgressFunc, void *pProgressData );
592 :
593 : virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
594 : int *pnBuckets, int ** ppanHistogram,
595 : int bForce,
596 : GDALProgressFunc, void *pProgressData);
597 : virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
598 : int nBuckets, int *panHistogram );
599 :
600 : virtual const GDALRasterAttributeTable *GetDefaultRAT();
601 : virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * );
602 :
603 : virtual GDALRasterBand *GetMaskBand();
604 : virtual int GetMaskFlags();
605 : virtual CPLErr CreateMaskBand( int nFlags );
606 :
607 : void ReportError(CPLErr eErrClass, int err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
608 : };
609 :
610 : /* ******************************************************************** */
611 : /* GDALAllValidMaskBand */
612 : /* ******************************************************************** */
613 :
614 : class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand
615 : {
616 : protected:
617 : virtual CPLErr IReadBlock( int, int, void * );
618 :
619 : public:
620 : GDALAllValidMaskBand( GDALRasterBand * );
621 : virtual ~GDALAllValidMaskBand();
622 :
623 : virtual GDALRasterBand *GetMaskBand();
624 : virtual int GetMaskFlags();
625 : };
626 :
627 : /* ******************************************************************** */
628 : /* GDALNoDataMaskBand */
629 : /* ******************************************************************** */
630 :
631 : class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
632 : {
633 : double dfNoDataValue;
634 : GDALRasterBand *poParent;
635 :
636 : protected:
637 : virtual CPLErr IReadBlock( int, int, void * );
638 :
639 : public:
640 : GDALNoDataMaskBand( GDALRasterBand * );
641 : virtual ~GDALNoDataMaskBand();
642 : };
643 :
644 : /* ******************************************************************** */
645 : /* GDALNoDataValuesMaskBand */
646 : /* ******************************************************************** */
647 :
648 : class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand
649 : {
650 : double *padfNodataValues;
651 :
652 : protected:
653 : virtual CPLErr IReadBlock( int, int, void * );
654 :
655 : public:
656 : GDALNoDataValuesMaskBand( GDALDataset * );
657 : virtual ~GDALNoDataValuesMaskBand();
658 : };
659 :
660 : /* ******************************************************************** */
661 : /* GDALDriver */
662 : /* ******************************************************************** */
663 :
664 :
665 : /**
666 : * \brief Format specific driver.
667 : *
668 : * An instance of this class is created for each supported format, and
669 : * manages information about the format.
670 : *
671 : * This roughly corresponds to a file format, though some
672 : * drivers may be gateways to many formats through a secondary
673 : * multi-library.
674 : */
675 :
676 : class CPL_DLL GDALDriver : public GDALMajorObject
677 : {
678 : public:
679 : GDALDriver();
680 : ~GDALDriver();
681 :
682 : /* -------------------------------------------------------------------- */
683 : /* Public C++ methods. */
684 : /* -------------------------------------------------------------------- */
685 : GDALDataset *Create( const char * pszName,
686 : int nXSize, int nYSize, int nBands,
687 : GDALDataType eType, char ** papszOptions ) CPL_WARN_UNUSED_RESULT;
688 :
689 : CPLErr Delete( const char * pszName );
690 : CPLErr Rename( const char * pszNewName,
691 : const char * pszOldName );
692 : CPLErr CopyFiles( const char * pszNewName,
693 : const char * pszOldName );
694 :
695 : GDALDataset *CreateCopy( const char *, GDALDataset *,
696 : int, char **,
697 : GDALProgressFunc pfnProgress,
698 : void * pProgressData ) CPL_WARN_UNUSED_RESULT;
699 :
700 : /* -------------------------------------------------------------------- */
701 : /* The following are semiprivate, not intended to be accessed */
702 : /* by anyone but the formats instantiating and populating the */
703 : /* drivers. */
704 : /* -------------------------------------------------------------------- */
705 : GDALDataset *(*pfnOpen)( GDALOpenInfo * );
706 :
707 : GDALDataset *(*pfnCreate)( const char * pszName,
708 : int nXSize, int nYSize, int nBands,
709 : GDALDataType eType,
710 : char ** papszOptions );
711 :
712 : CPLErr (*pfnDelete)( const char * pszName );
713 :
714 : GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *,
715 : int, char **,
716 : GDALProgressFunc pfnProgress,
717 : void * pProgressData );
718 :
719 : void *pDriverData;
720 :
721 : void (*pfnUnloadDriver)(GDALDriver *);
722 :
723 : int (*pfnIdentify)( GDALOpenInfo * );
724 :
725 : CPLErr (*pfnRename)( const char * pszNewName,
726 : const char * pszOldName );
727 : CPLErr (*pfnCopyFiles)( const char * pszNewName,
728 : const char * pszOldName );
729 :
730 : /* -------------------------------------------------------------------- */
731 : /* Helper methods. */
732 : /* -------------------------------------------------------------------- */
733 : GDALDataset *DefaultCreateCopy( const char *, GDALDataset *,
734 : int, char **,
735 : GDALProgressFunc pfnProgress,
736 : void * pProgressData ) CPL_WARN_UNUSED_RESULT;
737 : static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
738 : GDALDataset *poDstDS,
739 : int bStrict );
740 : static CPLErr QuietDelete( const char * pszName );
741 :
742 : CPLErr DefaultRename( const char * pszNewName,
743 : const char * pszOldName );
744 : CPLErr DefaultCopyFiles( const char * pszNewName,
745 : const char * pszOldName );
746 : };
747 :
748 : /* ******************************************************************** */
749 : /* GDALDriverManager */
750 : /* ******************************************************************** */
751 :
752 : /**
753 : * Class for managing the registration of file format drivers.
754 : *
755 : * Use GetGDALDriverManager() to fetch the global singleton instance of
756 : * this class.
757 : */
758 :
759 : class CPL_DLL GDALDriverManager : public GDALMajorObject
760 : {
761 : int nDrivers;
762 : GDALDriver **papoDrivers;
763 :
764 : char *pszHome;
765 :
766 : public:
767 : GDALDriverManager();
768 : ~GDALDriverManager();
769 :
770 : int GetDriverCount( void );
771 : GDALDriver *GetDriver( int );
772 : GDALDriver *GetDriverByName( const char * );
773 :
774 : int RegisterDriver( GDALDriver * );
775 : void MoveDriver( GDALDriver *, int );
776 : void DeregisterDriver( GDALDriver * );
777 :
778 : void AutoLoadDrivers();
779 : void AutoSkipDrivers();
780 :
781 : const char *GetHome();
782 : void SetHome( const char * );
783 : };
784 :
785 : CPL_C_START
786 : GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
787 : CPL_C_END
788 :
789 : /* ******************************************************************** */
790 : /* GDALAsyncReader */
791 : /* ******************************************************************** */
792 :
793 : /**
794 : * Class used as a session object for asynchronous requests. They are
795 : * created with GDALDataset::BeginAsyncReader(), and destroyed with
796 : * GDALDataset::EndAsyncReader().
797 : */
798 : class CPL_DLL GDALAsyncReader
799 : {
800 : protected:
801 : GDALDataset* poDS;
802 : int nXOff;
803 : int nYOff;
804 : int nXSize;
805 : int nYSize;
806 : void * pBuf;
807 : int nBufXSize;
808 : int nBufYSize;
809 : GDALDataType eBufType;
810 : int nBandCount;
811 : int* panBandMap;
812 : int nPixelSpace;
813 : int nLineSpace;
814 : int nBandSpace;
815 :
816 : public:
817 : GDALAsyncReader();
818 : virtual ~GDALAsyncReader();
819 :
820 : GDALDataset* GetGDALDataset() {return poDS;}
821 : int GetXOffset() {return nXOff;}
822 : int GetYOffset() {return nYOff;}
823 : int GetXSize() {return nXSize;}
824 : int GetYSize() {return nYSize;}
825 : void * GetBuffer() {return pBuf;}
826 : int GetBufferXSize() {return nBufXSize;}
827 : int GetBufferYSize() {return nBufYSize;}
828 : GDALDataType GetBufferType() {return eBufType;}
829 : int GetBandCount() {return nBandCount;}
830 : int* GetBandMap() {return panBandMap;}
831 : int GetPixelSpace() {return nPixelSpace;}
832 : int GetLineSpace() {return nLineSpace;}
833 : int GetBandSpace() {return nBandSpace;}
834 :
835 : virtual GDALAsyncStatusType
836 : GetNextUpdatedRegion(double dfTimeout,
837 : int* pnBufXOff, int* pnBufYOff,
838 : int* pnBufXSize, int* pnBufYSize) = 0;
839 : virtual int LockBuffer( double dfTimeout = -1.0 );
840 : virtual void UnlockBuffer();
841 : };
842 :
843 : /* ==================================================================== */
844 : /* An assortment of overview related stuff. */
845 : /* ==================================================================== */
846 :
847 : /* Not a public symbol for the moment */
848 : CPLErr
849 : GDALRegenerateOverviewsMultiBand(int nBands, GDALRasterBand** papoSrcBands,
850 : int nOverviews,
851 : GDALRasterBand*** papapoOverviewBands,
852 : const char * pszResampling,
853 : GDALProgressFunc pfnProgress, void * pProgressData );
854 :
855 : CPL_C_START
856 :
857 : #ifndef WIN32CE
858 :
859 : CPLErr CPL_DLL
860 : HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS,
861 : GDALDataset **ppoDS,
862 : int nBands, int *panBandList,
863 : int nNewOverviews, int *panNewOverviewList,
864 : const char *pszResampling,
865 : GDALProgressFunc pfnProgress,
866 : void *pProgressData );
867 :
868 : #endif /* WIN32CE */
869 :
870 : CPLErr CPL_DLL
871 : GTIFFBuildOverviews( const char * pszFilename,
872 : int nBands, GDALRasterBand **papoBandList,
873 : int nOverviews, int * panOverviewList,
874 : const char * pszResampling,
875 : GDALProgressFunc pfnProgress, void * pProgressData );
876 :
877 : CPLErr CPL_DLL
878 : GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename,
879 : const char * pszResampling,
880 : int nOverviews, int * panOverviewList,
881 : int nBands, int * panBandList,
882 : GDALProgressFunc pfnProgress, void * pProgressData);
883 :
884 : int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand* poBand,
885 : int &nXOff, int &nYOff,
886 : int &nXSize, int &nYSize,
887 : int nBufXSize, int nBufYSize);
888 :
889 : int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize );
890 :
891 : GDALDataset CPL_DLL *
892 : GDALFindAssociatedAuxFile( const char *pszBasefile, GDALAccess eAccess,
893 : GDALDataset *poDependentDS );
894 :
895 : /* ==================================================================== */
896 : /* Misc functions. */
897 : /* ==================================================================== */
898 :
899 : CPLErr CPL_DLL GDALParseGMLCoverage( CPLXMLNode *psTree,
900 : int *pnXSize, int *pnYSize,
901 : double *padfGeoTransform,
902 : char **ppszProjection );
903 :
904 : /* ==================================================================== */
905 : /* Infrastructure to check that dataset characteristics are valid */
906 : /* ==================================================================== */
907 :
908 : int CPL_DLL GDALCheckDatasetDimensions( int nXSize, int nYSize );
909 : int CPL_DLL GDALCheckBandCount( int nBands, int bIsZeroAllowed );
910 :
911 :
912 : // Test if 2 floating point values match. Usefull when comparing values
913 : // stored as a string at some point. See #3573, #4183
914 : #define ARE_REAL_EQUAL(dfVal1, dfVal2) \
915 : (fabs(dfVal1 - dfVal2) < 1e-10 || (dfVal2 != 0 && fabs(1 - dfVal1 / dfVal2) < 1e-10 ))
916 :
917 : /* Internal use only */
918 : int GDALReadWorldFile2( const char *pszBaseFilename, const char *pszExtension,
919 : double *padfGeoTransform, char** papszSiblingFiles,
920 : char** ppszWorldFileNameOut);
921 : int GDALReadTabFile2( const char * pszBaseFilename,
922 : double *padfGeoTransform, char **ppszWKT,
923 : int *pnGCPCount, GDAL_GCP **ppasGCPs,
924 : char** papszSiblingFiles, char** ppszTabFileNameOut );
925 :
926 : CPL_C_END
927 :
928 : CPLString GDALFindAssociatedFile( const char *pszBasename, const char *pszExt,
929 : char **papszSiblingFiles, int nFlags );
930 :
931 : #endif /* ndef GDAL_PRIV_H_INCLUDED */
|