-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
gdal_priv.h
1610 lines (1302 loc) · 61.3 KB
/
gdal_priv.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/******************************************************************************
* $Id$
*
* Name: gdal_priv.h
* Project: GDAL Core
* Purpose: GDAL Core C++/Private declarations.
* Author: Frank Warmerdam, [email protected]
*
******************************************************************************
* Copyright (c) 1998, Frank Warmerdam
* Copyright (c) 2007-2014, Even Rouault <even dot rouault at mines-paris dot org>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
#ifndef GDAL_PRIV_H_INCLUDED
#define GDAL_PRIV_H_INCLUDED
/**
* \file gdal_priv.h
*
* C++ GDAL entry points.
*/
/* -------------------------------------------------------------------- */
/* Predeclare various classes before pulling in gdal.h, the */
/* public declarations. */
/* -------------------------------------------------------------------- */
class GDALMajorObject;
class GDALDataset;
class GDALRasterBand;
class GDALDriver;
class GDALRasterAttributeTable;
class GDALProxyDataset;
class GDALProxyRasterBand;
class GDALAsyncReader;
/* -------------------------------------------------------------------- */
/* Pull in the public declarations. This gets the C apis, and */
/* also various constants. However, we will still get to */
/* provide the real class definitions for the GDAL classes. */
/* -------------------------------------------------------------------- */
#include "gdal.h"
#include "gdal_frmts.h"
#include "cpl_vsi.h"
#include "cpl_conv.h"
#include "cpl_string.h"
#include "cpl_minixml.h"
#include "cpl_multiproc.h"
#include "cpl_atomic_ops.h"
#include <vector>
#include <map>
#include "ogr_core.h"
//! @cond Doxygen_Suppress
#define GMO_VALID 0x0001
#define GMO_IGNORE_UNIMPLEMENTED 0x0002
#define GMO_SUPPORT_MD 0x0004
#define GMO_SUPPORT_MDMD 0x0008
#define GMO_MD_DIRTY 0x0010
#define GMO_PAM_CLASS 0x0020
//! @endcond
/************************************************************************/
/* GDALMultiDomainMetadata */
/************************************************************************/
//! @cond Doxygen_Suppress
class CPL_DLL GDALMultiDomainMetadata
{
private:
char **papszDomainList;
CPLStringList **papoMetadataLists;
public:
GDALMultiDomainMetadata();
~GDALMultiDomainMetadata();
int XMLInit( CPLXMLNode *psMetadata, int bMerge );
CPLXMLNode *Serialize();
char **GetDomainList() { return papszDomainList; }
char **GetMetadata( const char * pszDomain = "" );
CPLErr SetMetadata( char ** papszMetadata,
const char * pszDomain = "" );
const char *GetMetadataItem( const char * pszName,
const char * pszDomain = "" );
CPLErr SetMetadataItem( const char * pszName,
const char * pszValue,
const char * pszDomain = "" );
void Clear();
private:
CPL_DISALLOW_COPY_ASSIGN(GDALMultiDomainMetadata)
};
//! @endcond
/* ******************************************************************** */
/* GDALMajorObject */
/* */
/* Base class providing metadata, description and other */
/* services shared by major objects. */
/* ******************************************************************** */
/** Object with metadata. */
class CPL_DLL GDALMajorObject
{
protected:
//! @cond Doxygen_Suppress
int nFlags; // GMO_* flags.
CPLString sDescription;
GDALMultiDomainMetadata oMDMD;
//! @endcond
char **BuildMetadataDomainList( char** papszList,
int bCheckNonEmpty, ... ) CPL_NULL_TERMINATED;
public:
GDALMajorObject();
virtual ~GDALMajorObject();
int GetMOFlags() const;
void SetMOFlags( int nFlagsIn );
virtual const char *GetDescription() const;
virtual void SetDescription( const char * );
virtual char **GetMetadataDomainList();
virtual char **GetMetadata( const char * pszDomain = "" );
virtual CPLErr SetMetadata( char ** papszMetadata,
const char * pszDomain = "" );
virtual const char *GetMetadataItem( const char * pszName,
const char * pszDomain = "" );
virtual CPLErr SetMetadataItem( const char * pszName,
const char * pszValue,
const char * pszDomain = "" );
};
/* ******************************************************************** */
/* GDALDefaultOverviews */
/* ******************************************************************** */
//! @cond Doxygen_Suppress
class CPL_DLL GDALDefaultOverviews
{
friend class GDALDataset;
GDALDataset *poDS;
GDALDataset *poODS;
CPLString osOvrFilename;
bool bOvrIsAux;
bool bCheckedForMask;
bool bOwnMaskDS;
GDALDataset *poMaskDS;
// For "overview datasets" we record base level info so we can
// find our way back to get overview masks.
GDALDataset *poBaseDS;
// Stuff for deferred initialize/overviewscans.
bool bCheckedForOverviews;
void OverviewScan();
char *pszInitName;
bool bInitNameIsOVR;
char **papszInitSiblingFiles;
public:
GDALDefaultOverviews();
~GDALDefaultOverviews();
void Initialize( GDALDataset *poDSIn, const char *pszName = NULL,
char **papszSiblingFiles = NULL,
int bNameIsOVR = FALSE );
void TransferSiblingFiles( char** papszSiblingFiles );
int IsInitialized();
int CloseDependentDatasets();
// Overview Related
int GetOverviewCount( int nBand );
GDALRasterBand *GetOverview( int nBand, int iOverview );
CPLErr BuildOverviews( const char * pszBasename,
const char * pszResampling,
int nOverviews, int * panOverviewList,
int nBands, int * panBandList,
GDALProgressFunc pfnProgress,
void *pProgressData );
CPLErr BuildOverviewsSubDataset( const char * pszPhysicalFile,
const char * pszResampling,
int nOverviews, int * panOverviewList,
int nBands, int * panBandList,
GDALProgressFunc pfnProgress,
void *pProgressData );
CPLErr CleanOverviews();
// Mask Related
CPLErr CreateMaskBand( int nFlags, int nBand = -1 );
GDALRasterBand *GetMaskBand( int nBand );
int GetMaskFlags( int nBand );
int HaveMaskFile( char **papszSiblings = NULL,
const char *pszBasename = NULL );
char** GetSiblingFiles() { return papszInitSiblingFiles; }
private:
CPL_DISALLOW_COPY_ASSIGN(GDALDefaultOverviews)
};
//! @endcond
/* ******************************************************************** */
/* GDALOpenInfo */
/* ******************************************************************** */
/** Class for dataset open functions. */
class CPL_DLL GDALOpenInfo
{
bool bHasGotSiblingFiles;
char **papszSiblingFiles;
int nHeaderBytesTried;
public:
GDALOpenInfo( const char * pszFile, int nOpenFlagsIn,
char **papszSiblingFiles = NULL );
~GDALOpenInfo( void );
/** Filename */
char *pszFilename;
/** Open options */
char** papszOpenOptions;
/** Access flag */
GDALAccess eAccess;
/** Open flags */
int nOpenFlags;
/** Whether stat()'ing the file was successful */
int bStatOK;
/** Whether the file is a directory */
int bIsDirectory;
/** Pointer to the file */
VSILFILE *fpL;
/** Number of bytes in pabyHeader */
int nHeaderBytes;
/** Buffer with first bytes of the file */
GByte *pabyHeader;
/** Allowed drivers (NULL for all) */
const char* const* papszAllowedDrivers;
int TryToIngest(int nBytes);
char **GetSiblingFiles();
char **StealSiblingFiles();
bool AreSiblingFilesLoaded() const;
private:
CPL_DISALLOW_COPY_ASSIGN(GDALOpenInfo)
};
/* ******************************************************************** */
/* GDALDataset */
/* ******************************************************************** */
class OGRLayer;
class OGRGeometry;
class OGRSpatialReference;
class OGRStyleTable;
class swq_select;
class swq_select_parse_options;
//! @cond Doxygen_Suppress
typedef struct GDALSQLParseInfo GDALSQLParseInfo;
//! @endcond
#ifdef DETECT_OLD_IRASTERIO
typedef void signature_changed;
#endif
//! @cond Doxygen_Suppress
#ifdef GDAL_COMPILATION
#define OPTIONAL_OUTSIDE_GDAL(val)
#else
#define OPTIONAL_OUTSIDE_GDAL(val) = val
#endif
//! @endcond
class OGRFeature;
/** A set of associated raster bands, usually from one file. */
class CPL_DLL GDALDataset : public GDALMajorObject
{
friend GDALDatasetH CPL_STDCALL GDALOpenEx( const char* pszFilename,
unsigned int nOpenFlags,
const char* const* papszAllowedDrivers,
const char* const* papszOpenOptions,
const char* const* papszSiblingFiles );
friend void CPL_STDCALL GDALClose( GDALDatasetH hDS );
friend class GDALDriver;
friend class GDALDefaultOverviews;
friend class GDALProxyDataset;
friend class GDALDriverManager;
void AddToDatasetOpenList();
void Init( bool bForceCachedIO );
protected:
//! @cond Doxygen_Suppress
GDALDriver *poDriver;
GDALAccess eAccess;
// Stored raster information.
int nRasterXSize;
int nRasterYSize;
int nBands;
GDALRasterBand **papoBands;
int nOpenFlags;
int nRefCount;
bool bForceCachedIO;
bool bShared;
bool bIsInternal;
bool bSuppressOnClose;
GDALDataset(void);
explicit GDALDataset(int bForceCachedIO);
void RasterInitialize( int, int );
void SetBand( int, GDALRasterBand * );
GDALDefaultOverviews oOvManager;
virtual CPLErr IBuildOverviews( const char *, int, int *,
int, int *, GDALProgressFunc, void * );
#ifdef DETECT_OLD_IRASTERIO
virtual signature_changed IRasterIO( GDALRWFlag, int, int, int, int,
void *, int, int, GDALDataType,
int, int *, int, int, int ) {};
#endif
virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
void *, int, int, GDALDataType,
int, int *, GSpacing, GSpacing, GSpacing,
GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
CPLErr BlockBasedRasterIO( GDALRWFlag, int, int, int, int,
void *, int, int, GDALDataType,
int, int *, GSpacing, GSpacing, GSpacing,
GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
void BlockBasedFlushCache();
CPLErr BandBasedRasterIO( GDALRWFlag eRWFlag,
int nXOff, int nYOff, int nXSize, int nYSize,
void * pData, int nBufXSize, int nBufYSize,
GDALDataType eBufType,
int nBandCount, int *panBandMap,
GSpacing nPixelSpace, GSpacing nLineSpace,
GSpacing nBandSpace,
GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
CPLErr RasterIOResampled( GDALRWFlag eRWFlag,
int nXOff, int nYOff, int nXSize, int nYSize,
void * pData, int nBufXSize, int nBufYSize,
GDALDataType eBufType,
int nBandCount, int *panBandMap,
GSpacing nPixelSpace, GSpacing nLineSpace,
GSpacing nBandSpace,
GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
CPLErr ValidateRasterIOOrAdviseReadParameters(
const char* pszCallingFunc,
int* pbStopProcessingOnCENone,
int nXOff, int nYOff, int nXSize, int nYSize,
int nBufXSize, int nBufYSize,
int nBandCount, int *panBandMap);
CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag,
int nXOff, int nYOff, int nXSize, int nYSize,
void * pData, int nBufXSize, int nBufYSize,
GDALDataType eBufType,
int nBandCount, int *panBandMap,
GSpacing nPixelSpace, GSpacing nLineSpace,
GSpacing nBandSpace,
GDALRasterIOExtraArg* psExtraArg,
int* pbTried);
//! @endcond
virtual int CloseDependentDatasets();
//! @cond Doxygen_Suppress
int ValidateLayerCreationOptions( const char* const* papszLCO );
char **papszOpenOptions;
friend class GDALRasterBand;
// The below methods related to read write mutex are fragile logic, and
// should not be used by out-of-tree code if possible.
int EnterReadWrite(GDALRWFlag eRWFlag);
void LeaveReadWrite();
void InitRWLock();
void TemporarilyDropReadWriteLock();
void ReacquireReadWriteLock();
void DisableReadWriteMutex();
int AcquireMutex();
void ReleaseMutex();
//! @endcond
public:
virtual ~GDALDataset();
int GetRasterXSize( void );
int GetRasterYSize( void );
int GetRasterCount( void );
GDALRasterBand *GetRasterBand( int );
virtual void FlushCache(void);
virtual const char *GetProjectionRef(void);
virtual CPLErr SetProjection( const char * pszProjection );
virtual CPLErr GetGeoTransform( double * padfTransform );
virtual CPLErr SetGeoTransform( double * padfTransform );
virtual CPLErr AddBand( GDALDataType eType,
char **papszOptions=NULL );
virtual void *GetInternalHandle( const char * pszHandleName );
virtual GDALDriver *GetDriver(void);
virtual char **GetFileList(void);
virtual const char* GetDriverName();
virtual int GetGCPCount();
virtual const char *GetGCPProjection();
virtual const GDAL_GCP *GetGCPs();
virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
const char *pszGCPProjection );
virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
int nBufXSize, int nBufYSize,
GDALDataType eDT,
int nBandCount, int *panBandList,
char **papszOptions );
virtual CPLErr CreateMaskBand( int nFlagsIn );
virtual GDALAsyncReader*
BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize,
void *pBuf, int nBufXSize, int nBufYSize,
GDALDataType eBufType,
int nBandCount, int* panBandMap,
int nPixelSpace, int nLineSpace, int nBandSpace,
char **papszOptions);
virtual void EndAsyncReader(GDALAsyncReader *);
CPLErr RasterIO( GDALRWFlag, int, int, int, int,
void *, int, int, GDALDataType,
int, int *, GSpacing, GSpacing, GSpacing,
GDALRasterIOExtraArg* psExtraArg
#ifndef DOXYGEN_SKIP
OPTIONAL_OUTSIDE_GDAL(NULL)
#endif
) CPL_WARN_UNUSED_RESULT;
int Reference();
int Dereference();
int ReleaseRef();
/** Return access mode.
* @return access mode.
*/
GDALAccess GetAccess() const { return eAccess; }
int GetShared() const;
void MarkAsShared();
/** Set that the dataset must be deleted on close. */
void MarkSuppressOnClose() { bSuppressOnClose = true; }
/** Return open options.
* @return open options.
*/
char **GetOpenOptions() { return papszOpenOptions; }
static GDALDataset **GetOpenDatasets( int *pnDatasetCount );
CPLErr BuildOverviews( const char *, int, int *,
int, int *, GDALProgressFunc, void * );
void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
virtual char ** GetMetadata(const char * pszDomain = "") CPL_OVERRIDE;
// Only defined when Doxygen enabled
#ifdef DOXYGEN_SKIP
virtual CPLErr SetMetadata( char ** papszMetadata,
const char * pszDomain ) CPL_OVERRIDE;
virtual const char *GetMetadataItem( const char * pszName,
const char * pszDomain ) CPL_OVERRIDE;
virtual CPLErr SetMetadataItem( const char * pszName,
const char * pszValue,
const char * pszDomain ) CPL_OVERRIDE;
#endif
virtual char ** GetMetadataDomainList() CPL_OVERRIDE;
private:
void *m_hPrivateData;
OGRLayer* BuildLayerFromSelectInfo(swq_select* psSelectInfo,
OGRGeometry *poSpatialFilter,
const char *pszDialect,
swq_select_parse_options* poSelectParseOptions);
CPLStringList oDerivedMetadataList;
public:
virtual int GetLayerCount();
virtual OGRLayer *GetLayer(int iLayer);
virtual OGRLayer *GetLayerByName(const char *);
virtual OGRErr DeleteLayer(int iLayer);
virtual void ResetReading();
virtual OGRFeature* GetNextFeature( OGRLayer** ppoBelongingLayer,
double* pdfProgressPct,
GDALProgressFunc pfnProgress,
void* pProgressData );
virtual int TestCapability( const char * );
virtual OGRLayer *CreateLayer( const char *pszName,
OGRSpatialReference *poSpatialRef = NULL,
OGRwkbGeometryType eGType = wkbUnknown,
char ** papszOptions = NULL );
virtual OGRLayer *CopyLayer( OGRLayer *poSrcLayer,
const char *pszNewName,
char **papszOptions = NULL );
virtual OGRStyleTable *GetStyleTable();
virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable );
virtual void SetStyleTable(OGRStyleTable *poStyleTable);
virtual OGRLayer * ExecuteSQL( const char *pszStatement,
OGRGeometry *poSpatialFilter,
const char *pszDialect );
virtual void ReleaseResultSet( OGRLayer * poResultsSet );
int GetRefCount() const;
int GetSummaryRefCount() const;
OGRErr Release();
virtual OGRErr StartTransaction(int bForce=FALSE);
virtual OGRErr CommitTransaction();
virtual OGRErr RollbackTransaction();
//! @cond Doxygen_Suppress
static int IsGenericSQLDialect(const char* pszDialect);
// Semi-public methods. Only to be used by in-tree drivers.
GDALSQLParseInfo* BuildParseInfo(swq_select* psSelectInfo,
swq_select_parse_options* poSelectParseOptions);
static void DestroyParseInfo(GDALSQLParseInfo* psParseInfo );
OGRLayer * ExecuteSQL( const char *pszStatement,
OGRGeometry *poSpatialFilter,
const char *pszDialect,
swq_select_parse_options* poSelectParseOptions);
//! @endcond
protected:
virtual OGRLayer *ICreateLayer( const char *pszName,
OGRSpatialReference *poSpatialRef = NULL,
OGRwkbGeometryType eGType = wkbUnknown,
char ** papszOptions = NULL );
//! @cond Doxygen_Suppress
OGRErr ProcessSQLCreateIndex( const char * );
OGRErr ProcessSQLDropIndex( const char * );
OGRErr ProcessSQLDropTable( const char * );
OGRErr ProcessSQLAlterTableAddColumn( const char * );
OGRErr ProcessSQLAlterTableDropColumn( const char * );
OGRErr ProcessSQLAlterTableAlterColumn( const char * );
OGRErr ProcessSQLAlterTableRenameColumn( const char * );
OGRStyleTable *m_poStyleTable;
//! @endcond
private:
CPL_DISALLOW_COPY_ASSIGN(GDALDataset)
};
/* ******************************************************************** */
/* GDALRasterBlock */
/* ******************************************************************** */
/** A single raster block in the block cache.
*
* And the global block manager that manages a least-recently-used list of
* blocks from various datasets/bands */
class CPL_DLL GDALRasterBlock
{
friend class GDALAbstractBandBlockCache;
GDALDataType eType;
bool bDirty;
volatile int nLockCount;
int nXOff;
int nYOff;
int nXSize;
int nYSize;
void *pData;
GDALRasterBand *poBand;
GDALRasterBlock *poNext;
GDALRasterBlock *poPrevious;
bool bMustDetach;
void Detach_unlocked( void );
void Touch_unlocked( void );
void RecycleFor( int nXOffIn, int nYOffIn );
public:
GDALRasterBlock( GDALRasterBand *, int, int );
GDALRasterBlock( int nXOffIn, int nYOffIn ); /* only for lookup purpose */
virtual ~GDALRasterBlock();
CPLErr Internalize( void );
void Touch( void );
void MarkDirty( void );
void MarkClean( void );
/** Increment the lock count */
int AddLock( void ) { return CPLAtomicInc(&nLockCount); }
/** Decrement the lock count */
int DropLock( void ) { return CPLAtomicDec(&nLockCount); }
void Detach();
CPLErr Write();
/** Return the data type
* @return data type
*/
GDALDataType GetDataType() const { return eType; }
/** Return the x offset of the top-left corner of the block
* @return x offset
*/
int GetXOff() const { return nXOff; }
/** Return the y offset of the top-left corner of the block
* @return y offset
*/
int GetYOff() const { return nYOff; }
/** Return the width of the block
* @return width
*/
int GetXSize() const { return nXSize; }
/** Return the height of the block
* @return height
*/
int GetYSize() const { return nYSize; }
/** Return the dirty flag
* @return dirty flag
*/
int GetDirty() const { return bDirty; }
/** Return the data buffer
* @return data buffer
*/
void *GetDataRef( void ) { return pData; }
/** Return the block size in bytes
* @return block size.
*/
int GetBlockSize() const {
return nXSize * nYSize * GDALGetDataTypeSizeBytes(eType); }
int TakeLock();
int DropLockForRemovalFromStorage();
/// @brief Accessor to source GDALRasterBand object.
/// @return source raster band of the raster block.
GDALRasterBand *GetBand() { return poBand; }
static void FlushDirtyBlocks();
static int FlushCacheBlock(int bDirtyBlocksOnly = FALSE);
static void Verify();
static void EnterDisableDirtyBlockFlush();
static void LeaveDisableDirtyBlockFlush();
#ifdef notdef
static void CheckNonOrphanedBlocks(GDALRasterBand* poBand);
void DumpBlock();
static void DumpAll();
#endif
/* Should only be called by GDALDestroyDriverManager() */
//! @cond Doxygen_Suppress
static void DestroyRBMutex();
//! @endcond
private:
CPL_DISALLOW_COPY_ASSIGN(GDALRasterBlock)
};
/* ******************************************************************** */
/* GDALColorTable */
/* ******************************************************************** */
/** A color table / palette. */
class CPL_DLL GDALColorTable
{
GDALPaletteInterp eInterp;
std::vector<GDALColorEntry> aoEntries;
public:
explicit GDALColorTable( GDALPaletteInterp = GPI_RGB );
~GDALColorTable();
GDALColorTable *Clone() const;
int IsSame(const GDALColorTable* poOtherCT) const;
GDALPaletteInterp GetPaletteInterpretation() const;
int GetColorEntryCount() const;
const GDALColorEntry *GetColorEntry( int ) const;
int GetColorEntryAsRGB( int, GDALColorEntry * ) const;
void SetColorEntry( int, const GDALColorEntry * );
int CreateColorRamp( int, const GDALColorEntry * ,
int, const GDALColorEntry * );
};
/* ******************************************************************** */
/* GDALAbstractBandBlockCache */
/* ******************************************************************** */
//! @cond Doxygen_Suppress
//! This manages how a raster band store its cached block.
// CPL_DLL is just technical here. This is really a private concept
// only used by GDALRasterBand implementation.
class CPL_DLL GDALAbstractBandBlockCache
{
// List of blocks that can be freed or recycled, and its lock
CPLLock *hSpinLock;
GDALRasterBlock *psListBlocksToFree;
// Band keep alive counter, and its lock & condition
CPLCond *hCond;
CPLMutex *hCondMutex;
volatile int nKeepAliveCounter;
protected:
GDALRasterBand *poBand;
void FreeDanglingBlocks();
void UnreferenceBlockBase();
void WaitKeepAliveCounter();
public:
explicit GDALAbstractBandBlockCache(GDALRasterBand* poBand);
virtual ~GDALAbstractBandBlockCache();
GDALRasterBlock* CreateBlock(int nXBlockOff, int nYBlockOff);
void AddBlockToFreeList( GDALRasterBlock * );
virtual bool Init() = 0;
virtual bool IsInitOK() = 0;
virtual CPLErr FlushCache() = 0;
virtual CPLErr AdoptBlock( GDALRasterBlock* poBlock ) = 0;
virtual GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff,
int nYBlockYOff ) = 0;
virtual CPLErr UnreferenceBlock( GDALRasterBlock* poBlock ) = 0;
virtual CPLErr FlushBlock( int nXBlockOff, int nYBlockOff,
int bWriteDirtyBlock ) = 0;
};
GDALAbstractBandBlockCache* GDALArrayBandBlockCacheCreate(GDALRasterBand* poBand);
GDALAbstractBandBlockCache* GDALHashSetBandBlockCacheCreate(GDALRasterBand* poBand);
//! @endcond
/* ******************************************************************** */
/* GDALRasterBand */
/* ******************************************************************** */
/** A single raster band (or channel). */
class CPL_DLL GDALRasterBand : public GDALMajorObject
{
private:
friend class GDALArrayBandBlockCache;
friend class GDALHashSetBandBlockCache;
friend class GDALRasterBlock;
CPLErr eFlushBlockErr;
GDALAbstractBandBlockCache* poBandBlockCache;
void SetFlushBlockErr( CPLErr eErr );
CPLErr UnreferenceBlock( GDALRasterBlock* poBlock );
void Init(int bForceCachedIO);
protected:
//! @cond Doxygen_Suppress
GDALDataset *poDS;
int nBand; /* 1 based */
int nRasterXSize;
int nRasterYSize;
GDALDataType eDataType;
GDALAccess eAccess;
/* stuff related to blocking, and raster cache */
int nBlockXSize;
int nBlockYSize;
int nBlocksPerRow;
int nBlocksPerColumn;
int nBlockReads;
int bForceCachedIO;
GDALRasterBand *poMask;
bool bOwnMask;
int nMaskFlags;
void InvalidateMaskBand();
friend class GDALDataset;
friend class GDALProxyRasterBand;
friend class GDALDefaultOverviews;
CPLErr RasterIOResampled( GDALRWFlag, int, int, int, int,
void *, int, int, GDALDataType,
GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
int EnterReadWrite(GDALRWFlag eRWFlag);
void LeaveReadWrite();
void InitRWLock();
//! @endcond
protected:
virtual CPLErr IReadBlock( int nBlockXOff, int nBlockYOff, void * pData ) = 0;
virtual CPLErr IWriteBlock( int nBlockXOff, int nBlockYOff, void * pData );
#ifdef DETECT_OLD_IRASTERIO
virtual signature_changed IRasterIO( GDALRWFlag, int, int, int, int,
void *, int, int, GDALDataType,
int, int ) {};
#endif
virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
void *, int, int, GDALDataType,
GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
virtual int IGetDataCoverageStatus( int nXOff, int nYOff,
int nXSize, int nYSize,
int nMaskFlagStop,
double* pdfDataPct);
//! @cond Doxygen_Suppress
CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int,
void *, int, int, GDALDataType,
GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag,
int nXOff, int nYOff, int nXSize, int nYSize,
void * pData, int nBufXSize, int nBufYSize,
GDALDataType eBufType,
GSpacing nPixelSpace, GSpacing nLineSpace,
GDALRasterIOExtraArg* psExtraArg,
int* pbTried );
int InitBlockInfo();
void AddBlockToFreeList( GDALRasterBlock * );
//! @endcond
GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff );
public:
GDALRasterBand();
explicit GDALRasterBand(int bForceCachedIO);
virtual ~GDALRasterBand();
int GetXSize();
int GetYSize();
int GetBand();
GDALDataset*GetDataset();
GDALDataType GetRasterDataType( void );
void GetBlockSize( int *, int * );
CPLErr GetActualBlockSize ( int, int, int *, int * );
GDALAccess GetAccess();
CPLErr RasterIO( GDALRWFlag, int, int, int, int,
void *, int, int, GDALDataType,
GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg
#ifndef DOXYGEN_SKIP
OPTIONAL_OUTSIDE_GDAL(NULL)
#endif
) CPL_WARN_UNUSED_RESULT;
CPLErr ReadBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT;
CPLErr WriteBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT;
GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff,
int bJustInitialize = FALSE ) CPL_WARN_UNUSED_RESULT;
CPLErr FlushBlock( int, int, int bWriteDirtyBlock = TRUE );
unsigned char* GetIndexColorTranslationTo(/* const */ GDALRasterBand* poReferenceBand,
unsigned char* pTranslationTable = NULL,
int* pApproximateMatching = NULL);
// New OpengIS CV_SampleDimension stuff.
virtual CPLErr FlushCache();
virtual char **GetCategoryNames();
virtual double GetNoDataValue( int *pbSuccess = NULL );
virtual double GetMinimum( int *pbSuccess = NULL );
virtual double GetMaximum(int *pbSuccess = NULL );
virtual double GetOffset( int *pbSuccess = NULL );
virtual double GetScale( int *pbSuccess = NULL );
virtual const char *GetUnitType();
virtual GDALColorInterp GetColorInterpretation();
virtual GDALColorTable *GetColorTable();
virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
virtual CPLErr SetCategoryNames( char ** papszNames );
virtual CPLErr SetNoDataValue( double dfNoData );
virtual CPLErr DeleteNoDataValue();
virtual CPLErr SetColorTable( GDALColorTable * poCT );
virtual CPLErr SetColorInterpretation( GDALColorInterp eColorInterp );
virtual CPLErr SetOffset( double dfNewOffset );
virtual CPLErr SetScale( double dfNewScale );
virtual CPLErr SetUnitType( const char * pszNewValue );
virtual CPLErr GetStatistics( int bApproxOK, int bForce,
double *pdfMin, double *pdfMax,
double *pdfMean, double *padfStdDev );
virtual CPLErr ComputeStatistics( int bApproxOK,
double *pdfMin, double *pdfMax,
double *pdfMean, double *pdfStdDev,
GDALProgressFunc, void *pProgressData );
virtual CPLErr SetStatistics( double dfMin, double dfMax,
double dfMean, double dfStdDev );
virtual CPLErr ComputeRasterMinMax( int, double* );
// Only defined when Doxygen enabled
#ifdef DOXYGEN_SKIP
virtual char **GetMetadata( const char * pszDomain = "" ) CPL_OVERRIDE;
virtual CPLErr SetMetadata( char ** papszMetadata,
const char * pszDomain ) CPL_OVERRIDE;
virtual const char *GetMetadataItem( const char * pszName,
const char * pszDomain ) CPL_OVERRIDE;
virtual CPLErr SetMetadataItem( const char * pszName,