GDAL

- Main Page
- Related Pages
- Classes
- Files
- Download
- Issue Tracker

- File List
- File Members

vrtdataset.h
1 /******************************************************************************
2 * $Id$
3 *
4 * Project: Virtual GDAL Datasets
5 * Purpose: Declaration of virtual gdal dataset classes.
6 * Author: Frank Warmerdam, warmerdam@pobox.com
7 *
8 ******************************************************************************
9 * Copyright (c) 2001, Frank Warmerdam <warmerdam@pobox.com>
10 * Copyright (c) 2007-2013, Even Rouault <even dot rouault at spatialys.com>
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 VIRTUALDATASET_H_INCLUDED
32 #define VIRTUALDATASET_H_INCLUDED
33
34 #ifndef DOXYGEN_SKIP
35
36 #include "cpl_hash_set.h"
37 #include "cpl_minixml.h"
38 #include "gdal_pam.h"
39 #include "gdal_priv.h"
40 #include "gdal_rat.h"
41 #include "gdal_vrt.h"
42 #include "gdal_rat.h"
43
44 #include <map>
45 #include <memory>
46 #include <vector>
47
48 int VRTApplyMetadata( CPLXMLNode *, GDALMajorObject * );
49 CPLXMLNode *VRTSerializeMetadata( GDALMajorObject * );
50 CPLErr GDALRegisterDefaultPixelFunc();
51 CPLString VRTSerializeNoData(double dfVal, GDALDataType eDataType, int nPrecision);
52 #if 0
53 int VRTWarpedOverviewTransform( void *pTransformArg, int bDstToSrc,
54 int nPointCount,
55 double *padfX, double *padfY, double *padfZ,
56 int *panSuccess );
57 void* VRTDeserializeWarpedOverviewTransformer( CPLXMLNode *psTree );
58 #endif
59
60 /************************************************************************/
61 /* VRTOverviewInfo() */
62 /************************************************************************/
63 class VRTOverviewInfo
64 {
65 CPL_DISALLOW_COPY_ASSIGN(VRTOverviewInfo)
66
67 public:
68 CPLString osFilename{};
69 int nBand = 0;
70 GDALRasterBand *poBand = nullptr;
71 int bTriedToOpen = FALSE;
72
73 VRTOverviewInfo() = default;
74 VRTOverviewInfo(VRTOverviewInfo&& oOther) noexcept:
75 osFilename(std::move(oOther.osFilename)),
76 nBand(oOther.nBand),
77 poBand(oOther.poBand),
78 bTriedToOpen(oOther.bTriedToOpen)
79 {
80 oOther.poBand = nullptr;
81 }
82
83 ~VRTOverviewInfo() {
84 CloseDataset();
85 }
86
87 bool CloseDataset()
88 {
89 if( poBand == nullptr )
90 return false;
91
92 GDALDataset* poDS = poBand->GetDataset();
93 // Nullify now, to prevent recursion in some cases !
94 poBand = nullptr;
95 if( poDS->GetShared() )
96 GDALClose( /* (GDALDatasetH) */ poDS );
97 else
98 poDS->Dereference();
99
100 return true;
101 }
102 };
103
104 /************************************************************************/
105 /* VRTSource */
106 /************************************************************************/
107
108 class CPL_DLL VRTSource
109 {
110 public:
111 virtual ~VRTSource();
112
113 virtual CPLErr RasterIO( GDALDataType eBandDataType,
114 int nXOff, int nYOff, int nXSize, int nYSize,
115 void *pData, int nBufXSize, int nBufYSize,
116 GDALDataType eBufType,
117 GSpacing nPixelSpace, GSpacing nLineSpace,
118 GDALRasterIOExtraArg* psExtraArg ) = 0;
119
120 virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ) = 0;
121 virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ) = 0;
122 virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK,
123 double* adfMinMax ) = 0;
124 virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
125 int bApproxOK,
126 double *pdfMin, double *pdfMax,
127 double *pdfMean, double *pdfStdDev,
128 GDALProgressFunc pfnProgress,
129 void *pProgressData ) = 0;
130 virtual CPLErr GetHistogram( int nXSize, int nYSize,
131 double dfMin, double dfMax,
132 int nBuckets, GUIntBig * panHistogram,
133 int bIncludeOutOfRange, int bApproxOK,
134 GDALProgressFunc pfnProgress,
135 void *pProgressData ) = 0;
136
137 virtual CPLErr XMLInit( CPLXMLNode *psTree, const char *, void*,
138 std::map<CPLString, GDALDataset*>& ) = 0;
139 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) = 0;
140
141 virtual void GetFileList(char*** ppapszFileList, int *pnSize,
142 int *pnMaxSize, CPLHashSet* hSetFiles);
143
144 virtual int IsSimpleSource() { return FALSE; }
145 virtual CPLErr FlushCache() { return CE_None; }
146 };
147
148 typedef VRTSource *(*VRTSourceParser)(CPLXMLNode *, const char *, void* pUniqueHandle,
149 std::map<CPLString, GDALDataset*>& oMapSharedSources);
150
151 VRTSource *VRTParseCoreSources( CPLXMLNode *psTree, const char *, void* pUniqueHandle,
152 std::map<CPLString, GDALDataset*>& oMapSharedSources);
153 VRTSource *VRTParseFilterSources( CPLXMLNode *psTree, const char *, void* pUniqueHandle,
154 std::map<CPLString, GDALDataset*>& oMapSharedSources );
155
156 /************************************************************************/
157 /* VRTDataset */
158 /************************************************************************/
159
160 class VRTRasterBand;
161
162 template<class T> struct VRTFlushCacheStruct
163 {
164 static void FlushCache(T& obj);
165 };
166
167 class VRTWarpedDataset;
168 class VRTPansharpenedDataset;
169 class VRTGroup;
170
171 class CPL_DLL VRTDataset CPL_NON_FINAL: public GDALDataset
172 {
173 friend class VRTRasterBand;
174 friend struct VRTFlushCacheStruct<VRTDataset>;
175 friend struct VRTFlushCacheStruct<VRTWarpedDataset>;
176 friend struct VRTFlushCacheStruct<VRTPansharpenedDataset>;
177 friend class VRTSourcedRasterBand;
178 friend VRTDatasetH CPL_STDCALL VRTCreate(int nXSize, int nYSize);
179
180 OGRSpatialReference* m_poSRS = nullptr;
181
182 int m_bGeoTransformSet = false;
183 double m_adfGeoTransform[6];
184
185 int m_nGCPCount = 0;
186 GDAL_GCP *m_pasGCPList = nullptr;
187 OGRSpatialReference *m_poGCP_SRS = nullptr;
188
189 bool m_bNeedsFlush = false;
190 bool m_bWritable = true;
191 bool m_bCanTakeRef = true;
192
193 char *m_pszVRTPath = nullptr;
194
195 VRTRasterBand *m_poMaskBand = nullptr;
196
197 int m_bCompatibleForDatasetIO = -1;
198 int CheckCompatibleForDatasetIO();
199 void ExpandProxyBands();
200
201 // Virtual (ie not materialized) overviews, created either implicitly
202 // when it is cheap to do it, or explicitly.
203 std::vector<GDALDataset*> m_apoOverviews{};
204 std::vector<GDALDataset*> m_apoOverviewsBak{};
205 CPLString m_osOverviewResampling{};
206 std::vector<int> m_anOverviewFactors{};
207
208 char **m_papszXMLVRTMetadata = nullptr;
209
210 std::map<CPLString, GDALDataset*> m_oMapSharedSources{};
211 std::shared_ptr<VRTGroup> m_poRootGroup{};
212
213 int m_nRecursionCounter = 0;
214
215 VRTRasterBand* InitBand(const char* pszSubclass, int nBand,
216 bool bAllowPansharpened);
217 static GDALDataset *OpenVRTProtocol( const char* pszSpec );
218 bool AddVirtualOverview(int nOvFactor,
219 const char* pszResampling);
220
221 CPL_DISALLOW_COPY_ASSIGN(VRTDataset)
222
223 protected:
224 virtual int CloseDependentDatasets() override;
225
226 public:
227 VRTDataset(int nXSize, int nYSize);
228 virtual ~VRTDataset();
229
230 void SetNeedsFlush() { m_bNeedsFlush = true; }
231 virtual void FlushCache() override;
232
233 void SetWritable(int bWritableIn) { m_bWritable = CPL_TO_BOOL(bWritableIn); }
234
235 virtual CPLErr CreateMaskBand( int nFlags ) override;
236 void SetMaskBand(VRTRasterBand* poMaskBand);
237
238 const OGRSpatialReference* GetSpatialRef() const override { return m_poSRS; }
239 CPLErr SetSpatialRef(const OGRSpatialReference* poSRS) override;
240
241 virtual CPLErr GetGeoTransform( double * ) override;
242 virtual CPLErr SetGeoTransform( double * ) override;
243
244 virtual CPLErr SetMetadata( char **papszMetadata,
245 const char *pszDomain = "" ) override;
246 virtual CPLErr SetMetadataItem( const char *pszName, const char *pszValue,
247 const char *pszDomain = "" ) override;
248
249 virtual char** GetMetadata( const char *pszDomain = "" ) override;
250
251 virtual int GetGCPCount() override;
252 const OGRSpatialReference* GetGCPSpatialRef() const override { return m_poGCP_SRS; }
253 virtual const GDAL_GCP *GetGCPs() override;
254 using GDALDataset::SetGCPs;
255 CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
256 const OGRSpatialReference* poSRS ) override;
257
258 virtual CPLErr AddBand( GDALDataType eType,
259 char **papszOptions=nullptr ) override;
260
261 virtual char **GetFileList() override;
262
263 virtual CPLErr IRasterIO( GDALRWFlag eRWFlag,
264 int nXOff, int nYOff, int nXSize, int nYSize,
265 void * pData, int nBufXSize, int nBufYSize,
266 GDALDataType eBufType,
267 int nBandCount, int *panBandMap,
268 GSpacing nPixelSpace, GSpacing nLineSpace,
269 GSpacing nBandSpace,
270 GDALRasterIOExtraArg* psExtraArg) override;
271
272 virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
273 int nBufXSize, int nBufYSize,
274 GDALDataType eDT,
275 int nBandCount, int *panBandList,
276 char **papszOptions ) override;
277
278 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath);
279 virtual CPLErr XMLInit( CPLXMLNode *, const char * );
280
281 virtual CPLErr IBuildOverviews( const char *, int, int *,
282 int, int *, GDALProgressFunc, void * ) override;
283
284 std::shared_ptr<GDALGroup> GetRootGroup() const override;
285
286 /* Used by PDF driver for example */
287 GDALDataset* GetSingleSimpleSource();
288 void BuildVirtualOverviews();
289
290 void UnsetPreservedRelativeFilenames();
291
292 static int Identify( GDALOpenInfo * );
293 static GDALDataset *Open( GDALOpenInfo * );
294 static GDALDataset *OpenXML( const char *, const char * = nullptr,
295 GDALAccess eAccess = GA_ReadOnly );
296 static GDALDataset *Create( const char * pszName,
297 int nXSize, int nYSize, int nBands,
298 GDALDataType eType, char ** papszOptions );
299 static GDALDataset *CreateMultiDimensional( const char * pszFilename,
300 CSLConstList papszRootGroupOptions,
301 CSLConstList papszOptions );
302 static CPLErr Delete( const char * pszFilename );
303 };
304
305 /************************************************************************/
306 /* VRTWarpedDataset */
307 /************************************************************************/
308
309 class GDALWarpOperation;
310 class VRTWarpedRasterBand;
311
312 class CPL_DLL VRTWarpedDataset final: public VRTDataset
313 {
314 int m_nBlockXSize;
315 int m_nBlockYSize;
316 GDALWarpOperation *m_poWarper;
317
318 int m_nOverviewCount;
319 VRTWarpedDataset **m_papoOverviews;
320 int m_nSrcOvrLevel;
321
322 void CreateImplicitOverviews();
323
324 struct VerticalShiftGrid
325 {
326 CPLString osVGrids{};
327 int bInverse = false;
328 double dfToMeterSrc = 0.0;
329 double dfToMeterDest = 0.0;
330 CPLStringList aosOptions{};
331 };
332 std::vector<VerticalShiftGrid> m_aoVerticalShiftGrids{};
333
334 friend class VRTWarpedRasterBand;
335
336 CPL_DISALLOW_COPY_ASSIGN(VRTWarpedDataset)
337
338 protected:
339 virtual int CloseDependentDatasets() override;
340
341 public:
342 VRTWarpedDataset( int nXSize, int nYSize );
343 virtual ~VRTWarpedDataset();
344
345 virtual void FlushCache() override;
346
347 CPLErr Initialize( /* GDALWarpOptions */ void * );
348
349 virtual CPLErr IBuildOverviews( const char *, int, int *,
350 int, int *, GDALProgressFunc, void * ) override;
351
352 virtual CPLErr SetMetadataItem( const char *pszName, const char *pszValue,
353 const char *pszDomain = "" ) override;
354
355 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) override;
356 virtual CPLErr XMLInit( CPLXMLNode *, const char * ) override;
357
358 virtual CPLErr AddBand( GDALDataType eType,
359 char **papszOptions=nullptr ) override;
360
361 virtual char **GetFileList() override;
362
363 CPLErr ProcessBlock( int iBlockX, int iBlockY );
364
365 void GetBlockSize( int *, int * ) const;
366
367 void SetApplyVerticalShiftGrid(const char* pszVGrids,
368 int bInverse,
369 double dfToMeterSrc,
370 double dfToMeterDest,
371 char** papszOptions );
372 };
373
374 /************************************************************************/
375 /* VRTPansharpenedDataset */
376 /************************************************************************/
377
378 class GDALPansharpenOperation;
379
380 typedef enum
381 {
382 GTAdjust_Union,
383 GTAdjust_Intersection,
384 GTAdjust_None,
385 GTAdjust_NoneWithoutWarning
386 } GTAdjustment;
387
388 class VRTPansharpenedDataset final: public VRTDataset
389 {
390 friend class VRTPansharpenedRasterBand;
391
392 int m_nBlockXSize;
393 int m_nBlockYSize;
394 GDALPansharpenOperation* m_poPansharpener;
395 VRTPansharpenedDataset* m_poMainDataset;
396 std::vector<VRTPansharpenedDataset*> m_apoOverviewDatasets{};
397 // Map from absolute to relative.
398 std::map<CPLString,CPLString> m_oMapToRelativeFilenames{};
399
400 int m_bLoadingOtherBands;
401
402 GByte *m_pabyLastBufferBandRasterIO;
403 int m_nLastBandRasterIOXOff;
404 int m_nLastBandRasterIOYOff;
405 int m_nLastBandRasterIOXSize;
406 int m_nLastBandRasterIOYSize;
407 GDALDataType m_eLastBandRasterIODataType;
408
409 GTAdjustment m_eGTAdjustment;
410 int m_bNoDataDisabled;
411
412 std::vector<GDALDataset*> m_apoDatasetsToClose{};
413
414 CPL_DISALLOW_COPY_ASSIGN(VRTPansharpenedDataset)
415
416 protected:
417 virtual int CloseDependentDatasets() override;
418
419 public:
420 VRTPansharpenedDataset( int nXSize, int nYSize );
421 virtual ~VRTPansharpenedDataset();
422
423 virtual void FlushCache() override;
424
425 virtual CPLErr XMLInit( CPLXMLNode *, const char * ) override;
426 virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ) override;
427
428 CPLErr XMLInit( CPLXMLNode *psTree, const char *pszVRTPath,
429 GDALRasterBandH hPanchroBandIn,
430 int nInputSpectralBandsIn,
431 GDALRasterBandH* pahInputSpectralBandsIn );
432
433 virtual CPLErr AddBand( GDALDataType eType,
434 char **papszOptions=nullptr ) override;
435
436 virtual char **GetFileList() override;
437
438 virtual CPLErr IRasterIO( GDALRWFlag eRWFlag,
439 int nXOff, int nYOff, int nXSize, int nYSize,
440 void * pData, int nBufXSize, int nBufYSize,
441 GDALDataType eBufType,
442 int nBandCount, int *panBandMap,
443 GSpacing nPixelSpace, GSpacing nLineSpace,
444 GSpacing nBandSpace,
445 GDALRasterIOExtraArg* psExtraArg) override;
446
447 void GetBlockSize( int *, int * ) const;
448
449 GDALPansharpenOperation* GetPansharpener() { return m_poPansharpener; }
450 };
451
452 /************************************************************************/
453 /* VRTRasterBand */
454 /* */
455 /* Provides support for all the various kinds of metadata but */
456 /* no raster access. That is handled by derived classes. */
457 /************************************************************************/
458
459 class CPL_DLL VRTRasterBand CPL_NON_FINAL: public GDALRasterBand
460 {
461 protected:
462 friend class VRTDataset;
463
464 int m_bIsMaskBand;
465
466 int m_bNoDataValueSet;
467 // If set to true, will not report the existence of nodata.
468 int m_bHideNoDataValue;
469 double m_dfNoDataValue;
470
471 std::unique_ptr<GDALColorTable> m_poColorTable{};
472
473 GDALColorInterp m_eColorInterp;
474
475 char *m_pszUnitType;
476 char **m_papszCategoryNames;
477
478 double m_dfOffset;
479 double m_dfScale;
480
481 CPLXMLNode *m_psSavedHistograms;
482
483 void Initialize( int nXSize, int nYSize );
484
485 std::vector<VRTOverviewInfo> m_aoOverviewInfos{};
486
487 VRTRasterBand *m_poMaskBand;
488
489 std::unique_ptr<GDALRasterAttributeTable> m_poRAT{};
490
491 CPL_DISALLOW_COPY_ASSIGN(VRTRasterBand)
492
493 public:
494
495 VRTRasterBand();
496 virtual ~VRTRasterBand();
497
498 virtual CPLErr XMLInit( CPLXMLNode *, const char *, void*,
499 std::map<CPLString, GDALDataset*>& );
500 virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath );
501
502 virtual CPLErr SetNoDataValue( double ) override;
503 virtual double GetNoDataValue( int *pbSuccess = nullptr ) override;
504 virtual CPLErr DeleteNoDataValue() override;
505
506 virtual CPLErr SetColorTable( GDALColorTable * ) override;
507 virtual GDALColorTable *GetColorTable() override;
508
509 virtual GDALRasterAttributeTable *GetDefaultRAT() override;
510 virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * poRAT ) override;
511
512 virtual CPLErr SetColorInterpretation( GDALColorInterp ) override;
513 virtual GDALColorInterp GetColorInterpretation() override;
514
515 virtual const char *GetUnitType() override;
516 CPLErr SetUnitType( const char * ) override;
517
518 virtual char **GetCategoryNames() override;
519 virtual CPLErr SetCategoryNames( char ** ) override;
520
521 virtual CPLErr SetMetadata( char **papszMD, const char *pszDomain = "" ) override;
522 virtual CPLErr SetMetadataItem( const char *pszName, const char *pszValue,
523 const char *pszDomain = "" ) override;
524
525 virtual double GetOffset( int *pbSuccess = nullptr ) override;
526 CPLErr SetOffset( double ) override;
527 virtual double GetScale( int *pbSuccess = nullptr ) override;
528 CPLErr SetScale( double ) override;
529
530 virtual int GetOverviewCount() override;
531 virtual GDALRasterBand *GetOverview(int) override;
532
533 virtual CPLErr GetHistogram( double dfMin, double dfMax,
534 int nBuckets, GUIntBig * panHistogram,
535 int bIncludeOutOfRange, int bApproxOK,
536 GDALProgressFunc, void *pProgressData ) override;
537
538 virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
539 int *pnBuckets, GUIntBig ** ppanHistogram,
540 int bForce,
541 GDALProgressFunc, void *pProgressData) override;
542
543 virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
544 int nBuckets, GUIntBig *panHistogram ) override;
545
546 CPLErr CopyCommonInfoFrom( GDALRasterBand * );
547
548 virtual void GetFileList(char*** ppapszFileList, int *pnSize,
549 int *pnMaxSize, CPLHashSet* hSetFiles);
550
551 virtual void SetDescription( const char * ) override;
552
553 virtual GDALRasterBand *GetMaskBand() override;
554 virtual int GetMaskFlags() override;
555
556 virtual CPLErr CreateMaskBand( int nFlagsIn ) override;
557
558 void SetMaskBand(VRTRasterBand* poMaskBand);
559
560 void SetIsMaskBand();
561
562 CPLErr UnsetNoDataValue();
563
564 virtual int CloseDependentDatasets();
565
566 virtual int IsSourcedRasterBand() { return FALSE; }
567 virtual int IsPansharpenRasterBand() { return FALSE; }
568 };
569
570 /************************************************************************/
571 /* VRTSourcedRasterBand */
572 /************************************************************************/
573
574 class VRTSimpleSource;
575
576 class CPL_DLL VRTSourcedRasterBand CPL_NON_FINAL: public VRTRasterBand
577 {
578 private:
579 int m_nRecursionCounter;
580 CPLString m_osLastLocationInfo{};
581 char **m_papszSourceList;
582
583 bool CanUseSourcesMinMaxImplementations();
584 void CheckSource( VRTSimpleSource *poSS );
585
586 CPL_DISALLOW_COPY_ASSIGN(VRTSourcedRasterBand)
587
588 public:
589 int nSources;
590 VRTSource **papoSources;
591 int bSkipBufferInitialization;
592
593 VRTSourcedRasterBand( GDALDataset *poDS, int nBand );
594 VRTSourcedRasterBand( GDALDataType eType,
595 int nXSize, int nYSize );
596 VRTSourcedRasterBand( GDALDataset *poDS, int nBand,
597 GDALDataType eType,
598 int nXSize, int nYSize );
599 virtual ~VRTSourcedRasterBand();
600
601 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
602 void *, int, int, GDALDataType,
603 GSpacing nPixelSpace, GSpacing nLineSpace,
604 GDALRasterIOExtraArg* psExtraArg) override;
605
606 virtual int IGetDataCoverageStatus( int nXOff, int nYOff,
607 int nXSize, int nYSize,
608 int nMaskFlagStop,
609 double* pdfDataPct) override;
610
611 virtual char **GetMetadataDomainList() override;
612 virtual const char *GetMetadataItem( const char * pszName,
613 const char * pszDomain = "" ) override;
614 virtual char **GetMetadata( const char * pszDomain = "" ) override;
615 virtual CPLErr SetMetadata( char ** papszMetadata,
616 const char * pszDomain = "" ) override;
617 virtual CPLErr SetMetadataItem( const char * pszName,
618 const char * pszValue,
619 const char * pszDomain = "" ) override;
620
621 virtual CPLErr XMLInit( CPLXMLNode *, const char *, void*,
622 std::map<CPLString, GDALDataset*>& ) override;
623 virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ) override;
624
625 virtual double GetMinimum( int *pbSuccess = nullptr ) override;
626 virtual double GetMaximum(int *pbSuccess = nullptr ) override;
627 virtual CPLErr ComputeRasterMinMax( int bApproxOK, double* adfMinMax ) override;
628 virtual CPLErr ComputeStatistics( int bApproxOK,
629 double *pdfMin, double *pdfMax,
630 double *pdfMean, double *pdfStdDev,
631 GDALProgressFunc pfnProgress,
632 void *pProgressData ) override;
633 virtual CPLErr GetHistogram( double dfMin, double dfMax,
634 int nBuckets, GUIntBig * panHistogram,
635 int bIncludeOutOfRange, int bApproxOK,
636 GDALProgressFunc pfnProgress,
637 void *pProgressData ) override;
638
639 CPLErr AddSource( VRTSource * );
640 CPLErr AddSimpleSource( GDALRasterBand *poSrcBand,
641 double dfSrcXOff=-1, double dfSrcYOff=-1,
642 double dfSrcXSize=-1, double dfSrcYSize=-1,
643 double dfDstXOff=-1, double dfDstYOff=-1,
644 double dfDstXSize=-1, double dfDstYSize=-1,
645 const char *pszResampling = "near",
646 double dfNoDataValue = VRT_NODATA_UNSET);
647 CPLErr AddComplexSource( GDALRasterBand *poSrcBand,
648 double dfSrcXOff=-1, double dfSrcYOff=-1,
649 double dfSrcXSize=-1, double dfSrcYSize=-1,
650 double dfDstXOff=-1, double dfDstYOff=-1,
651 double dfDstXSize=-1, double dfDstYSize=-1,
652 double dfScaleOff=0.0,
653 double dfScaleRatio=1.0,
654 double dfNoDataValue = VRT_NODATA_UNSET,
655 int nColorTableComponent = 0);
656
657 CPLErr AddMaskBandSource( GDALRasterBand *poSrcBand,
658 double dfSrcXOff=-1, double dfSrcYOff=-1,
659 double dfSrcXSize=-1,
660 double dfSrcYSize=-1,
661 double dfDstXOff=-1, double dfDstYOff=-1,
662 double dfDstXSize=-1,
663 double dfDstYSize=-1 );
664
665 CPLErr AddFuncSource( VRTImageReadFunc pfnReadFunc, void *hCBData,
666 double dfNoDataValue = VRT_NODATA_UNSET );
667
668 void ConfigureSource(VRTSimpleSource *poSimpleSource,
669 GDALRasterBand *poSrcBand,
670 int bAddAsMaskBand,
671 double dfSrcXOff, double dfSrcYOff,
672 double dfSrcXSize, double dfSrcYSize,
673 double dfDstXOff, double dfDstYOff,
674 double dfDstXSize, double dfDstYSize );
675
676 virtual CPLErr IReadBlock( int, int, void * ) override;
677
678 virtual void GetFileList(char*** ppapszFileList, int *pnSize,
679 int *pnMaxSize, CPLHashSet* hSetFiles) override;
680
681 virtual int CloseDependentDatasets() override;
682
683 virtual int IsSourcedRasterBand() override { return TRUE; }
684
685 virtual CPLErr FlushCache() override;
686 };
687
688 /************************************************************************/
689 /* VRTWarpedRasterBand */
690 /************************************************************************/
691
692 class CPL_DLL VRTWarpedRasterBand final: public VRTRasterBand
693 {
694 public:
695 VRTWarpedRasterBand( GDALDataset *poDS, int nBand,
696 GDALDataType eType = GDT_Unknown );
697 virtual ~VRTWarpedRasterBand();
698
699 virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ) override;
700
701 virtual CPLErr IReadBlock( int, int, void * ) override;
702 virtual CPLErr IWriteBlock( int, int, void * ) override;
703
704 virtual int GetOverviewCount() override;
705 virtual GDALRasterBand *GetOverview(int) override;
706 };
707 /************************************************************************/
708 /* VRTPansharpenedRasterBand */
709 /************************************************************************/
710
711 class VRTPansharpenedRasterBand final: public VRTRasterBand
712 {
713 int m_nIndexAsPansharpenedBand;
714
715 public:
716 VRTPansharpenedRasterBand(
717 GDALDataset *poDS, int nBand,
718 GDALDataType eDataType = GDT_Unknown );
719 virtual ~VRTPansharpenedRasterBand();
720
721 virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ) override;
722
723 virtual CPLErr IReadBlock( int, int, void * ) override;
724
725 virtual CPLErr IRasterIO( GDALRWFlag eRWFlag,
726 int nXOff, int nYOff, int nXSize, int nYSize,
727 void * pData, int nBufXSize, int nBufYSize,
728 GDALDataType eBufType,
729 GSpacing nPixelSpace, GSpacing nLineSpace,
730 GDALRasterIOExtraArg* psExtraArg) override;
731
732 virtual int GetOverviewCount() override;
733 virtual GDALRasterBand *GetOverview(int) override;
734
735 virtual int IsPansharpenRasterBand() override { return TRUE; }
736
737 void SetIndexAsPansharpenedBand( int nIdx )
738 { m_nIndexAsPansharpenedBand = nIdx; }
739 int GetIndexAsPansharpenedBand() const
740 { return m_nIndexAsPansharpenedBand; }
741 };
742
743 /************************************************************************/
744 /* VRTDerivedRasterBand */
745 /************************************************************************/
746
747 class VRTDerivedRasterBandPrivateData;
748
749 class CPL_DLL VRTDerivedRasterBand CPL_NON_FINAL: public VRTSourcedRasterBand
750 {
751 VRTDerivedRasterBandPrivateData* m_poPrivate;
752 bool InitializePython();
753
754 CPL_DISALLOW_COPY_ASSIGN(VRTDerivedRasterBand)
755
756 public:
757 char *pszFuncName;
758 GDALDataType eSourceTransferType;
759
760 VRTDerivedRasterBand( GDALDataset *poDS, int nBand );
761 VRTDerivedRasterBand( GDALDataset *poDS, int nBand,
762 GDALDataType eType, int nXSize, int nYSize );
763 virtual ~VRTDerivedRasterBand();
764
765 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
766 void *, int, int, GDALDataType,
767 GSpacing nPixelSpace, GSpacing nLineSpace,
768 GDALRasterIOExtraArg* psExtraArg ) override;
769
770 virtual int IGetDataCoverageStatus( int nXOff, int nYOff,
771 int nXSize, int nYSize,
772 int nMaskFlagStop,
773 double* pdfDataPct) override;
774
775 static CPLErr AddPixelFunction( const char *pszFuncName,
776 GDALDerivedPixelFunc pfnPixelFunc );
777 static GDALDerivedPixelFunc GetPixelFunction( const char *pszFuncName );
778
779 void SetPixelFunctionName( const char *pszFuncName );
780 void SetSourceTransferType( GDALDataType eDataType );
781 void SetPixelFunctionLanguage( const char* pszLanguage );
782
783 virtual CPLErr XMLInit( CPLXMLNode *, const char *, void*,
784 std::map<CPLString, GDALDataset*>& ) override;
785 virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ) override;
786
787 virtual double GetMinimum( int *pbSuccess = nullptr ) override;
788 virtual double GetMaximum(int *pbSuccess = nullptr ) override;
789 virtual CPLErr ComputeRasterMinMax( int bApproxOK, double* adfMinMax ) override;
790 virtual CPLErr ComputeStatistics( int bApproxOK,
791 double *pdfMin, double *pdfMax,
792 double *pdfMean, double *pdfStdDev,
793 GDALProgressFunc pfnProgress,
794 void *pProgressData ) override;
795 virtual CPLErr GetHistogram( double dfMin, double dfMax,
796 int nBuckets, GUIntBig * panHistogram,
797 int bIncludeOutOfRange, int bApproxOK,
798 GDALProgressFunc pfnProgress,
799 void *pProgressData ) override;
800
801 static void Cleanup();
802 };
803
804 /************************************************************************/
805 /* VRTRawRasterBand */
806 /************************************************************************/
807
808 class RawRasterBand;
809
810 class CPL_DLL VRTRawRasterBand CPL_NON_FINAL: public VRTRasterBand
811 {
812 RawRasterBand *m_poRawRaster;
813
814 char *m_pszSourceFilename;
815 int m_bRelativeToVRT;
816
817 CPL_DISALLOW_COPY_ASSIGN(VRTRawRasterBand)
818
819 public:
820 VRTRawRasterBand( GDALDataset *poDS, int nBand,
821 GDALDataType eType = GDT_Unknown );
822 virtual ~VRTRawRasterBand();
823
824 virtual CPLErr XMLInit( CPLXMLNode *, const char *, void*,
825 std::map<CPLString, GDALDataset*>& ) override;
826 virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ) override;
827
828 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
829 void *, int, int, GDALDataType,
830 GSpacing nPixelSpace, GSpacing nLineSpace,
831 GDALRasterIOExtraArg* psExtraArg ) override;
832
833 virtual CPLErr IReadBlock( int, int, void * ) override;
834 virtual CPLErr IWriteBlock( int, int, void * ) override;
835
836 CPLErr SetRawLink( const char *pszFilename,
837 const char *pszVRTPath,
838 int bRelativeToVRT,
839 vsi_l_offset nImageOffset,
840 int nPixelOffset, int nLineOffset,
841 const char *pszByteOrder );
842
843 void ClearRawLink();
844
845 CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag,
846 int *pnPixelSpace,
847 GIntBig *pnLineSpace,
848 char **papszOptions ) override;
849
850 virtual void GetFileList( char*** ppapszFileList, int *pnSize,
851 int *pnMaxSize, CPLHashSet* hSetFiles ) override;
852 };
853
854 /************************************************************************/
855 /* VRTDriver */
856 /************************************************************************/
857
858 class VRTDriver final: public GDALDriver
859 {
860 CPL_DISALLOW_COPY_ASSIGN(VRTDriver)
861
862 public:
863 VRTDriver();
864 virtual ~VRTDriver();
865
866 char **papszSourceParsers;
867
868 virtual char **GetMetadataDomainList() override;
869 virtual char **GetMetadata( const char * pszDomain = "" ) override;
870 virtual CPLErr SetMetadata( char ** papszMetadata,
871 const char * pszDomain = "" ) override;
872
873 VRTSource *ParseSource( CPLXMLNode *psSrc, const char *pszVRTPath,
874 void* pUniqueHandle,
875 std::map<CPLString, GDALDataset*>& oMapSharedSources );
876 void AddSourceParser( const char *pszElementName,
877 VRTSourceParser pfnParser );
878 };
879
880 /************************************************************************/
881 /* VRTSimpleSource */
882 /************************************************************************/
883
884 class CPL_DLL VRTSimpleSource CPL_NON_FINAL: public VRTSource
885 {
886 CPL_DISALLOW_COPY_ASSIGN(VRTSimpleSource)
887
888 protected:
889 friend class VRTSourcedRasterBand;
890 friend class VRTDataset;
891
892 GDALRasterBand *m_poRasterBand;
893
894 // When poRasterBand is a mask band, poMaskBandMainBand is the band
895 // from which the mask band is taken.
896 GDALRasterBand *m_poMaskBandMainBand;
897
898 double m_dfSrcXOff;
899 double m_dfSrcYOff;
900 double m_dfSrcXSize;
901 double m_dfSrcYSize;
902
903 double m_dfDstXOff;
904 double m_dfDstYOff;
905 double m_dfDstXSize;
906 double m_dfDstYSize;
907
908 int m_bNoDataSet;
909 double m_dfNoDataValue;
910 CPLString m_osResampling{};
911
912 int m_nMaxValue;
913
914 int m_bRelativeToVRTOri;
915 CPLString m_osSourceFileNameOri{};
916 int m_nExplicitSharedStatus; // -1 unknown, 0 = unshared, 1 = shared
917
918 bool m_bDropRefOnSrcBand;
919
920 int NeedMaxValAdjustment() const;
921
922 public:
923 VRTSimpleSource();
924 VRTSimpleSource( const VRTSimpleSource* poSrcSource,
925 double dfXDstRatio, double dfYDstRatio );
926 virtual ~VRTSimpleSource();
927
928 virtual CPLErr XMLInit( CPLXMLNode *psTree, const char *, void*,
929 std::map<CPLString, GDALDataset*>& ) override;
930 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) override;
931
932 void SetSrcBand( GDALRasterBand * );
933 void SetSrcMaskBand( GDALRasterBand * );
934 void SetSrcWindow( double, double, double, double );
935 void SetDstWindow( double, double, double, double );
936 void SetNoDataValue( double dfNoDataValue );
937 const CPLString& GetResampling() const { return m_osResampling; }
938 void SetResampling( const char* pszResampling );
939
940 int GetSrcDstWindow( int, int, int, int, int, int,
941 double *pdfReqXOff, double *pdfReqYOff,
942 double *pdfReqXSize, double *pdfReqYSize,
943 int *, int *, int *, int *,
944 int *, int *, int *, int * );
945
946 virtual CPLErr RasterIO( GDALDataType eBandDataType,
947 int nXOff, int nYOff, int nXSize, int nYSize,
948 void *pData, int nBufXSize, int nBufYSize,
949 GDALDataType eBufType,
950 GSpacing nPixelSpace, GSpacing nLineSpace,
951 GDALRasterIOExtraArg* psExtraArgIn ) override;
952
953 virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ) override;
954 virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ) override;
955 virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK,
956 double* adfMinMax ) override;
957 virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
958 int bApproxOK,
959 double *pdfMin, double *pdfMax,
960 double *pdfMean, double *pdfStdDev,
961 GDALProgressFunc pfnProgress,
962 void *pProgressData ) override;
963 virtual CPLErr GetHistogram( int nXSize, int nYSize,
964 double dfMin, double dfMax,
965 int nBuckets, GUIntBig * panHistogram,
966 int bIncludeOutOfRange, int bApproxOK,
967 GDALProgressFunc pfnProgress,
968 void *pProgressData ) override;
969
970 void DstToSrc( double dfX, double dfY,
971 double &dfXOut, double &dfYOut ) const;
972 void SrcToDst( double dfX, double dfY,
973 double &dfXOut, double &dfYOut ) const;
974
975 virtual void GetFileList( char*** ppapszFileList, int *pnSize,
976 int *pnMaxSize, CPLHashSet* hSetFiles ) override;
977
978 virtual int IsSimpleSource() override { return TRUE; }
979 virtual const char* GetType() { return "SimpleSource"; }
980 virtual CPLErr FlushCache() override;
981
982 GDALRasterBand* GetBand();
983 GDALRasterBand* GetMaskBandMainBand() { return m_poMaskBandMainBand; }
984 int IsSameExceptBandNumber( VRTSimpleSource* poOtherSource );
985 CPLErr DatasetRasterIO(
986 GDALDataType eBandDataType,
987 int nXOff, int nYOff, int nXSize, int nYSize,
988 void * pData, int nBufXSize, int nBufYSize,
989 GDALDataType eBufType,
990 int nBandCount, int *panBandMap,
991 GSpacing nPixelSpace, GSpacing nLineSpace,
992 GSpacing nBandSpace,
993 GDALRasterIOExtraArg* psExtraArg );
994
995 void UnsetPreservedRelativeFilenames();
996
997 void SetMaxValue( int nVal ) { m_nMaxValue = nVal; }
998 };
999
1000 /************************************************************************/
1001 /* VRTAveragedSource */
1002 /************************************************************************/
1003
1004 class VRTAveragedSource final: public VRTSimpleSource
1005 {
1006 CPL_DISALLOW_COPY_ASSIGN(VRTAveragedSource)
1007
1008 public:
1009 VRTAveragedSource();
1010 virtual CPLErr RasterIO( GDALDataType eBandDataType,
1011 int nXOff, int nYOff, int nXSize, int nYSize,
1012 void *pData, int nBufXSize, int nBufYSize,
1013 GDALDataType eBufType,
1014 GSpacing nPixelSpace, GSpacing nLineSpace,
1015 GDALRasterIOExtraArg* psExtraArgIn ) override;
1016
1017 virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ) override;
1018 virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ) override;
1019 virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK,
1020 double* adfMinMax ) override;
1021 virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
1022 int bApproxOK,
1023 double *pdfMin, double *pdfMax,
1024 double *pdfMean, double *pdfStdDev,
1025 GDALProgressFunc pfnProgress,
1026 void *pProgressData ) override;
1027 virtual CPLErr GetHistogram( int nXSize, int nYSize,
1028 double dfMin, double dfMax,
1029 int nBuckets, GUIntBig * panHistogram,
1030 int bIncludeOutOfRange, int bApproxOK,
1031 GDALProgressFunc pfnProgress,
1032 void *pProgressData ) override;
1033
1034 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) override;
1035 virtual const char* GetType() override { return "AveragedSource"; }
1036 };
1037
1038 /************************************************************************/
1039 /* VRTComplexSource */
1040 /************************************************************************/
1041
1042 typedef enum
1043 {
1044 VRT_SCALING_NONE,
1045 VRT_SCALING_LINEAR,
1046 VRT_SCALING_EXPONENTIAL,
1047 } VRTComplexSourceScaling;
1048
1049 class CPL_DLL VRTComplexSource CPL_NON_FINAL: public VRTSimpleSource
1050 {
1051 CPL_DISALLOW_COPY_ASSIGN(VRTComplexSource)
1052 bool AreValuesUnchanged() const;
1053
1054 protected:
1055 VRTComplexSourceScaling m_eScalingType;
1056 double m_dfScaleOff; // For linear scaling.
1057 double m_dfScaleRatio; // For linear scaling.
1058
1059 // For non-linear scaling with a power function.
1060 int m_bSrcMinMaxDefined;
1061 double m_dfSrcMin;
1062 double m_dfSrcMax;
1063 double m_dfDstMin;
1064 double m_dfDstMax;
1065 double m_dfExponent;
1066
1067 int m_nColorTableComponent;
1068
1069 template <class WorkingDT>
1070 CPLErr RasterIOInternal( int nReqXOff, int nReqYOff,
1071 int nReqXSize, int nReqYSize,
1072 void *pData, int nOutXSize, int nOutYSize,
1073 GDALDataType eBufType,
1074 GSpacing nPixelSpace, GSpacing nLineSpace,
1075 GDALRasterIOExtraArg* psExtraArg,
1076 GDALDataType eWrkDataType );
1077
1078 public:
1079 VRTComplexSource();
1080 VRTComplexSource(const VRTComplexSource* poSrcSource,
1081 double dfXDstRatio, double dfYDstRatio);
1082 virtual ~VRTComplexSource();
1083
1084 virtual CPLErr RasterIO( GDALDataType eBandDataType,
1085 int nXOff, int nYOff, int nXSize, int nYSize,
1086 void *pData, int nBufXSize, int nBufYSize,
1087 GDALDataType eBufType,
1088 GSpacing nPixelSpace, GSpacing nLineSpace,
1089 GDALRasterIOExtraArg* psExtraArgIn ) override;
1090
1091 virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ) override;
1092 virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ) override;
1093 virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK,
1094 double* adfMinMax ) override;
1095 virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
1096 int bApproxOK,
1097 double *pdfMin, double *pdfMax,
1098 double *pdfMean, double *pdfStdDev,
1099 GDALProgressFunc pfnProgress,
1100 void *pProgressData ) override;
1101 virtual CPLErr GetHistogram( int nXSize, int nYSize,
1102 double dfMin, double dfMax,
1103 int nBuckets, GUIntBig * panHistogram,
1104 int bIncludeOutOfRange, int bApproxOK,
1105 GDALProgressFunc pfnProgress,
1106 void *pProgressData ) override;
1107
1108 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) override;
1109 virtual CPLErr XMLInit( CPLXMLNode *, const char *, void*,
1110 std::map<CPLString, GDALDataset*>& ) override;
1111 virtual const char* GetType() override { return "ComplexSource"; }
1112
1113 double LookupValue( double dfInput );
1114
1115 void SetLinearScaling( double dfOffset, double dfScale );
1116 void SetPowerScaling( double dfExponent,
1117 double dfSrcMin,
1118 double dfSrcMax,
1119 double dfDstMin,
1120 double dfDstMax );
1121 void SetColorTableComponent( int nComponent );
1122
1123 double *m_padfLUTInputs;
1124 double *m_padfLUTOutputs;
1125 int m_nLUTItemCount;
1126 };
1127
1128 /************************************************************************/
1129 /* VRTFilteredSource */
1130 /************************************************************************/
1131
1132 class VRTFilteredSource CPL_NON_FINAL: public VRTComplexSource
1133 {
1134 private:
1135 int IsTypeSupported( GDALDataType eTestType ) const;
1136
1137 CPL_DISALLOW_COPY_ASSIGN(VRTFilteredSource)
1138
1139 protected:
1140 int m_nSupportedTypesCount;
1141 GDALDataType m_aeSupportedTypes[20];
1142
1143 int m_nExtraEdgePixels;
1144
1145 public:
1146 VRTFilteredSource();
1147 virtual ~VRTFilteredSource();
1148
1149 void SetExtraEdgePixels( int );
1150 void SetFilteringDataTypesSupported( int, GDALDataType * );
1151
1152 virtual CPLErr FilterData( int nXSize, int nYSize, GDALDataType eType,
1153 GByte *pabySrcData, GByte *pabyDstData ) = 0;
1154
1155 virtual CPLErr RasterIO( GDALDataType eBandDataType,
1156 int nXOff, int nYOff, int nXSize, int nYSize,
1157 void *pData, int nBufXSize, int nBufYSize,
1158 GDALDataType eBufType,
1159 GSpacing nPixelSpace, GSpacing nLineSpace,
1160 GDALRasterIOExtraArg* psExtraArg ) override;
1161 };
1162
1163 /************************************************************************/
1164 /* VRTKernelFilteredSource */
1165 /************************************************************************/
1166
1167 class VRTKernelFilteredSource CPL_NON_FINAL: public VRTFilteredSource
1168 {
1169 CPL_DISALLOW_COPY_ASSIGN(VRTKernelFilteredSource)
1170
1171 protected:
1172 int m_nKernelSize;
1173
1174 bool m_bSeparable;
1175
1176 double *m_padfKernelCoefs;
1177
1178 int m_bNormalized;
1179
1180 public:
1181 VRTKernelFilteredSource();
1182 virtual ~VRTKernelFilteredSource();
1183
1184 virtual CPLErr XMLInit( CPLXMLNode *psTree, const char *, void*,
1185 std::map<CPLString, GDALDataset*>& ) override;
1186 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) override;
1187
1188 virtual CPLErr FilterData( int nXSize, int nYSize, GDALDataType eType,
1189 GByte *pabySrcData, GByte *pabyDstData ) override;
1190
1191 CPLErr SetKernel( int nKernelSize, bool bSeparable, double *padfCoefs );
1192 void SetNormalized( int );
1193 };
1194
1195 /************************************************************************/
1196 /* VRTAverageFilteredSource */
1197 /************************************************************************/
1198
1199 class VRTAverageFilteredSource final: public VRTKernelFilteredSource
1200 {
1201 CPL_DISALLOW_COPY_ASSIGN(VRTAverageFilteredSource)
1202
1203 public:
1204 explicit VRTAverageFilteredSource( int nKernelSize );
1205 virtual ~VRTAverageFilteredSource();
1206
1207 virtual CPLErr XMLInit( CPLXMLNode *psTree, const char *, void*,
1208 std::map<CPLString, GDALDataset*>& ) override;
1209 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) override;
1210 };
1211
1212 /************************************************************************/
1213 /* VRTFuncSource */
1214 /************************************************************************/
1215 class VRTFuncSource final: public VRTSource
1216 {
1217 CPL_DISALLOW_COPY_ASSIGN(VRTFuncSource)
1218
1219 public:
1220 VRTFuncSource();
1221 virtual ~VRTFuncSource();
1222
1223 virtual CPLErr XMLInit( CPLXMLNode *, const char *, void*,
1224 std::map<CPLString, GDALDataset*>& ) override { return CE_Failure; }
1225 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) override;
1226
1227 virtual CPLErr RasterIO( GDALDataType eBandDataType,
1228 int nXOff, int nYOff, int nXSize, int nYSize,
1229 void *pData, int nBufXSize, int nBufYSize,
1230 GDALDataType eBufType,
1231 GSpacing nPixelSpace, GSpacing nLineSpace,
1232 GDALRasterIOExtraArg* psExtraArg ) override;
1233
1234 virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ) override;
1235 virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ) override;
1236 virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK,
1237 double* adfMinMax ) override;
1238 virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
1239 int bApproxOK,
1240 double *pdfMin, double *pdfMax,
1241 double *pdfMean, double *pdfStdDev,
1242 GDALProgressFunc pfnProgress,
1243 void *pProgressData ) override;
1244 virtual CPLErr GetHistogram( int nXSize, int nYSize,
1245 double dfMin, double dfMax,
1246 int nBuckets, GUIntBig * panHistogram,
1247 int bIncludeOutOfRange, int bApproxOK,
1248 GDALProgressFunc pfnProgress,
1249 void *pProgressData ) override;
1250
1251 VRTImageReadFunc pfnReadFunc;
1252 void *pCBData;
1253 GDALDataType eType;
1254
1255 float fNoDataValue;
1256 };
1257
1258 /************************************************************************/
1259 /* VRTGroup */
1260 /************************************************************************/
1261
1262 #ifdef TMPEXPORT
1263 #define TMP_CPL_DLL CPL_DLL
1264 #else
1265 #define TMP_CPL_DLL
1266 #endif
1267
1268 class VRTMDArray;
1269 class VRTAttribute;
1270 class VRTDimension;
1271
1272 class VRTGroup final: public GDALGroup
1273 {
1274 public:
1275 struct Ref
1276 {
1277 VRTGroup* m_ptr;
1278 explicit Ref(VRTGroup* ptr): m_ptr(ptr) {}
1279 Ref(const Ref&) = delete;
1280 Ref& operator=(const Ref&) = delete;
1281 };
1282
1283 private:
1284 std::shared_ptr<Ref> m_poSharedRefRootGroup{};
1285 std::weak_ptr<Ref> m_poWeakRefRootGroup{};
1286 std::shared_ptr<Ref> m_poRefSelf{};
1287
1288 std::string m_osFilename{};
1289 mutable bool m_bDirty = false;
1290 std::string m_osVRTPath{};
1291 std::map<std::string, std::shared_ptr<VRTGroup>> m_oMapGroups{};
1292 std::map<std::string, std::shared_ptr<VRTMDArray>> m_oMapMDArrays{};
1293 std::map<std::string, std::shared_ptr<VRTAttribute>> m_oMapAttributes{};
1294 std::map<std::string, std::shared_ptr<VRTDimension>> m_oMapDimensions{};
1295
1296 std::shared_ptr<VRTGroup> OpenGroupInternal(const std::string& osName) const;
1297 void SetRootGroupRef(const std::weak_ptr<Ref>& rgRef);
1298 std::weak_ptr<Ref> GetRootGroupRef() const;
1299
1300 public:
1301
1302 VRTGroup(const std::string& osParentName, const std::string& osName);
1303 ~VRTGroup();
1304
1305 bool XMLInit(const std::shared_ptr<VRTGroup>& poRoot,
1306 const std::shared_ptr<VRTGroup>& poThisGroup,
1307 const CPLXMLNode* psNode,
1308 const char* pszVRTPath);
1309
1310 std::vector<std::string> GetMDArrayNames(CSLConstList papszOptions) const override;
1311 std::shared_ptr<GDALMDArray> OpenMDArray(const std::string& osName,
1312 CSLConstList papszOptions = nullptr) const override;
1313
1314 std::vector<std::string> GetGroupNames(CSLConstList papszOptions) const override;
1315 std::shared_ptr<GDALGroup> OpenGroup(const std::string& osName,
1316 CSLConstList) const override
1317 {
1318 return OpenGroupInternal(osName);
1319 }
1320
1321 std::vector<std::shared_ptr<GDALDimension>> GetDimensions(CSLConstList) const override;
1322
1323 std::vector<std::shared_ptr<GDALAttribute>> GetAttributes(CSLConstList) const override;
1324
1325 std::shared_ptr<VRTDimension> GetDimension(const std::string& name) const {
1326 auto oIter = m_oMapDimensions.find(name);
1327 return oIter == m_oMapDimensions.end() ? nullptr : oIter->second;
1328 }
1329 std::shared_ptr<VRTDimension> GetDimensionFromFullName(const std::string& name,
1330 bool bEmitError) const;
1331
1332 std::shared_ptr<GDALGroup> CreateGroup(const std::string& osName,
1333 CSLConstList papszOptions = nullptr) override;
1334
1335 std::shared_ptr<GDALDimension> CreateDimension(const std::string& osName,
1336 const std::string& osType,
1337 const std::string& osDirection,
1338 GUInt64 nSize,
1339 CSLConstList papszOptions = nullptr) override;
1340
1341 std::shared_ptr<GDALAttribute> CreateAttribute(
1342 const std::string& osName,
1343 const std::vector<GUInt64>& anDimensions,
1344 const GDALExtendedDataType& oDataType,
1345 CSLConstList papszOptions = nullptr) override;
1346
1347 std::shared_ptr<GDALMDArray> CreateMDArray(const std::string& osName,
1348 const std::vector<std::shared_ptr<GDALDimension>>& aoDimensions,
1349 const GDALExtendedDataType& oDataType,
1350 CSLConstList papszOptions) override;
1351
1352 void SetIsRootGroup();
1353
1354 const std::shared_ptr<Ref>& GetRef() const { return m_poRefSelf; }
1355 VRTGroup* GetRootGroup() const;
1356
1357 const std::string& GetVRTPath() const { return m_osVRTPath; }
1358 void SetDirty();
1359 void SetFilename(const std::string& osFilename) { m_osFilename = osFilename; }
1360 void Serialize() const;
1361 CPLXMLNode* SerializeToXML( const char *pszVRTPathIn ) const;
1362 void Serialize(CPLXMLNode* psParent, const char *pszVRTPathIn) const;
1363 };
1364
1365 /************************************************************************/
1366 /* VRTDimension */
1367 /************************************************************************/
1368
1369 class VRTDimension final: public GDALDimension
1370 {
1371 std::weak_ptr<VRTGroup::Ref> m_poGroupRef;
1372 std::string m_osIndexingVariableName;
1373
1374 public:
1375 VRTDimension(const std::shared_ptr<VRTGroup::Ref>& poGroupRef,
1376 const std::string& osParentName,
1377 const std::string& osName,
1378 const std::string& osType,
1379 const std::string& osDirection,
1380 GUInt64 nSize,
1381 const std::string& osIndexingVariableName):
1382 GDALDimension(osParentName, osName, osType, osDirection, nSize),
1383 m_poGroupRef(poGroupRef),
1384 m_osIndexingVariableName(osIndexingVariableName)
1385 {}
1386
1387 VRTGroup* GetGroup() const;
1388
1389 static std::shared_ptr<VRTDimension> Create(const std::shared_ptr<VRTGroup>& poThisGroup,
1390 const std::string& osParentName,
1391 const CPLXMLNode* psNode);
1392
1393 std::shared_ptr<GDALMDArray> GetIndexingVariable() const override;
1394
1395 bool SetIndexingVariable(std::shared_ptr<GDALMDArray> poIndexingVariable) override;
1396
1397 void Serialize(CPLXMLNode* psParent) const;
1398 };
1399
1400 /************************************************************************/
1401 /* VRTAttribute */
1402 /************************************************************************/
1403
1404 class VRTAttribute final: public GDALAttribute
1405 {
1406 GDALExtendedDataType m_dt;
1407 std::vector<std::string> m_aosList{};
1408 std::vector<std::shared_ptr<GDALDimension>> m_dims{};
1409
1410 protected:
1411
1412 bool IRead(const GUInt64* arrayStartIdx,
1413 const size_t* count,
1414 const GInt64* arrayStep,
1415 const GPtrDiff_t* bufferStride,
1416 const GDALExtendedDataType& bufferDataType,
1417 void* pDstBuffer) const override;
1418
1419 bool IWrite(const GUInt64* arrayStartIdx,
1420 const size_t* count,
1421 const GInt64* arrayStep,
1422 const GPtrDiff_t* bufferStride,
1423 const GDALExtendedDataType& bufferDataType,
1424 const void* pSrcBuffer) override;
1425
1426
1427 public:
1428 VRTAttribute(const std::string& osParentName,
1429 const std::string& osName,
1430 const GDALExtendedDataType& dt,
1431 std::vector<std::string>&& aosList):
1432 GDALAbstractMDArray(osParentName, osName),
1433 GDALAttribute(osParentName, osName),
1434 m_dt(dt),
1435 m_aosList(std::move(aosList))
1436 {
1437 if( m_aosList.size() > 1 )
1438 {
1439 m_dims.emplace_back(std::make_shared<GDALDimension>(
1440 std::string(), "dim",
1441 std::string(), std::string(), m_aosList.size()));
1442 }
1443 }
1444
1445 VRTAttribute(const std::string& osParentName,
1446 const std::string& osName,
1447 GUInt64 nDim,
1448 const GDALExtendedDataType& dt):
1449 GDALAbstractMDArray(osParentName, osName),
1450 GDALAttribute(osParentName, osName),
1451 m_dt(dt)
1452 {
1453 if( nDim != 0 )
1454 {
1455 m_dims.emplace_back(std::make_shared<GDALDimension>(
1456 std::string(), "dim",
1457 std::string(), std::string(), nDim));
1458 }
1459 }
1460
1461 static bool CreationCommonChecks(const std::string& osName,
1462 const std::vector<GUInt64>& anDimensions,
1463 const std::map<std::string, std::shared_ptr<VRTAttribute>>& oMapAttributes);
1464
1465 static std::shared_ptr<VRTAttribute> Create(const std::string& osParentName,
1466 const CPLXMLNode* psNode);
1467
1468 const std::vector<std::shared_ptr<GDALDimension>>& GetDimensions() const override { return m_dims; }
1469
1470 const GDALExtendedDataType &GetDataType() const override { return m_dt; }
1471
1472 void Serialize(CPLXMLNode* psParent) const;
1473 };
1474
1475 /************************************************************************/
1476 /* VRTMDArraySource */
1477 /************************************************************************/
1478
1479 class VRTMDArraySource
1480 {
1481 public:
1482 virtual ~VRTMDArraySource() = default;
1483
1484 virtual bool Read(const GUInt64* arrayStartIdx,
1485 const size_t* count,
1486 const GInt64* arrayStep,
1487 const GPtrDiff_t* bufferStride,
1488 const GDALExtendedDataType& bufferDataType,
1489 void* pDstBuffer) const = 0;
1490
1491 virtual void Serialize(CPLXMLNode* psParent, const char* pszVRTPath) const = 0;
1492 };
1493
1494 /************************************************************************/
1495 /* VRTMDArray */
1496 /************************************************************************/
1497
1498 class VRTMDArray final: public GDALMDArray
1499 {
1500 protected:
1501 friend class VRTGroup; // for access to SetSelf()
1502
1503 std::weak_ptr<VRTGroup::Ref> m_poGroupRef;
1504 std::string m_osVRTPath{};
1505
1506 GDALExtendedDataType m_dt;
1507 std::vector<std::shared_ptr<GDALDimension>> m_dims;
1508 std::map<std::string, std::shared_ptr<VRTAttribute>> m_oMapAttributes{};
1509 std::vector<std::unique_ptr<VRTMDArraySource>> m_sources{};
1510 std::shared_ptr<OGRSpatialReference> m_poSRS{};
1511 std::vector<GByte> m_abyNoData{};
1512 std::string m_osUnit{};
1513 double m_dfScale = 1.0;
1514 double m_dfOffset = 0.0;
1515 bool m_bHasScale = false;
1516 bool m_bHasOffset = false;
1517
1518 bool IRead(const GUInt64* arrayStartIdx,
1519 const size_t* count,
1520 const GInt64* arrayStep,
1521 const GPtrDiff_t* bufferStride,
1522 const GDALExtendedDataType& bufferDataType,
1523 void* pDstBuffer) const override;
1524
1525 void SetDirty();
1526
1527 public:
1528 VRTMDArray(const std::shared_ptr<VRTGroup::Ref>& poGroupRef,
1529 const std::string& osParentName,
1530 const std::string& osName,
1531 const GDALExtendedDataType& dt,
1532 std::vector<std::shared_ptr<GDALDimension>>&& dims,
1533 std::map<std::string, std::shared_ptr<VRTAttribute>>&& oMapAttributes) :
1534 GDALAbstractMDArray(osParentName, osName),
1535 GDALMDArray(osParentName, osName),
1536 m_poGroupRef(poGroupRef),
1537 m_osVRTPath(poGroupRef->m_ptr->GetVRTPath()),
1538 m_dt(dt),
1539 m_dims(std::move(dims)),
1540 m_oMapAttributes(std::move(oMapAttributes))
1541 {
1542 }
1543
1544 VRTMDArray(const std::shared_ptr<VRTGroup::Ref>& poGroupRef,
1545 const std::string& osParentName,
1546 const std::string& osName,
1547 const std::vector<std::shared_ptr<GDALDimension>>& dims,
1548 const GDALExtendedDataType& dt) :
1549 GDALAbstractMDArray(osParentName, osName),
1550 GDALMDArray(osParentName, osName),
1551 m_poGroupRef(poGroupRef),
1552 m_osVRTPath(poGroupRef->m_ptr->GetVRTPath()),
1553 m_dt(dt),
1554 m_dims(dims)
1555 {
1556 }
1557
1558 bool IsWritable() const override { return false; }
1559
1560 static std::shared_ptr<VRTMDArray> Create(const std::shared_ptr<VRTGroup>& poThisGroup,
1561 const std::string& osParentName,
1562 const CPLXMLNode* psNode);
1563
1564 const std::vector<std::shared_ptr<GDALDimension>>& GetDimensions() const override { return m_dims; }
1565
1566 std::vector<std::shared_ptr<GDALAttribute>> GetAttributes(CSLConstList) const override;
1567
1568 const GDALExtendedDataType &GetDataType() const override { return m_dt; }
1569
1570 bool SetSpatialRef(const OGRSpatialReference* poSRS) override;
1571
1572 std::shared_ptr<OGRSpatialReference> GetSpatialRef() const override { return m_poSRS; }
1573
1574 const void* GetRawNoDataValue() const override;
1575
1576 bool SetRawNoDataValue(const void* pRawNoData) override;
1577
1578 const std::string& GetUnit() const override { return m_osUnit; }
1579
1580 bool SetUnit(const std::string& osUnit) override {
1581 m_osUnit = osUnit; return true; }
1582
1583 double GetOffset(bool* pbHasOffset) const override
1584 {
1585 if( pbHasOffset) *pbHasOffset = m_bHasOffset;
1586 return m_dfOffset;
1587 }
1588
1589 double GetScale(bool* pbHasScale) const override
1590 {
1591 if( pbHasScale) *pbHasScale = m_bHasScale;
1592 return m_dfScale;
1593 }
1594
1595 bool SetOffset(double dfOffset) override
1596 { SetDirty(); m_bHasOffset = true; m_dfOffset = dfOffset; return true; }
1597
1598 bool SetScale(double dfScale) override
1599 { SetDirty(); m_bHasScale = true; m_dfScale = dfScale; return true; }
1600
1601 void AddSource(std::unique_ptr<VRTMDArraySource>&& poSource);
1602
1603 std::shared_ptr<GDALAttribute> CreateAttribute(
1604 const std::string& osName,
1605 const std::vector<GUInt64>& anDimensions,
1606 const GDALExtendedDataType& oDataType,
1607 CSLConstList papszOptions = nullptr) override;
1608
1609 bool CopyFrom(GDALDataset* poSrcDS,
1610 const GDALMDArray* poSrcArray,
1611 bool bStrict,
1612 GUInt64& nCurCost,
1613 const GUInt64 nTotalCost,
1614 GDALProgressFunc pfnProgress,
1615 void * pProgressData) override;
1616
1617 void Serialize(CPLXMLNode* psParent, const char *pszVRTPathIn ) const;
1618
1619 VRTGroup* GetGroup() const;
1620
1621 const std::string& GetVRTPath() const { return m_osVRTPath; }
1622 };
1623
1624 /************************************************************************/
1625 /* VRTMDArraySourceInlinedValues */
1626 /************************************************************************/
1627
1628 class VRTMDArraySourceInlinedValues final: public VRTMDArraySource
1629 {
1630 const VRTMDArray* m_poDstArray = nullptr;
1631 bool m_bIsConstantValue;
1632 std::vector<GUInt64> m_anOffset{};
1633 std::vector<size_t> m_anCount{};
1634 std::vector<GByte> m_abyValues{};
1635 std::vector<size_t> m_anInlinedArrayStrideInBytes{};
1636 GDALExtendedDataType m_dt;
1637
1638 VRTMDArraySourceInlinedValues(const VRTMDArraySourceInlinedValues&) = delete;
1639 VRTMDArraySourceInlinedValues& operator=(const VRTMDArraySourceInlinedValues&) = delete;
1640
1641 public:
1642 VRTMDArraySourceInlinedValues(const VRTMDArray* poDstArray,
1643 bool bIsConstantValue,
1644 std::vector<GUInt64>&& anOffset,
1645 std::vector<size_t>&& anCount,
1646 std::vector<GByte>&& abyValues):
1647 m_poDstArray(poDstArray),
1648 m_bIsConstantValue(bIsConstantValue),
1649 m_anOffset(std::move(anOffset)),
1650 m_anCount(std::move(anCount)),
1651 m_abyValues(std::move(abyValues)),
1652 m_dt(poDstArray->GetDataType())
1653 {
1654 const auto nDims(poDstArray->GetDimensionCount());
1655 m_anInlinedArrayStrideInBytes.resize(nDims);
1656 if( !bIsConstantValue && nDims > 0 )
1657 {
1658 m_anInlinedArrayStrideInBytes.back() = poDstArray->GetDataType().GetSize();
1659 for(size_t i = nDims - 1; i > 0; )
1660 {
1661 --i;
1662 m_anInlinedArrayStrideInBytes[i] =
1663 m_anInlinedArrayStrideInBytes[i+1] * m_anCount[i+1];
1664 }
1665 }
1666 }
1667
1668 ~VRTMDArraySourceInlinedValues();
1669
1670 static std::unique_ptr<VRTMDArraySourceInlinedValues> Create(
1671 const VRTMDArray* poDstArray,
1672 const CPLXMLNode* psNode);
1673
1674 bool Read(const GUInt64* arrayStartIdx,
1675 const size_t* count,
1676 const GInt64* arrayStep,
1677 const GPtrDiff_t* bufferStride,
1678 const GDALExtendedDataType& bufferDataType,
1679 void* pDstBuffer) const override;
1680
1681 void Serialize(CPLXMLNode* psParent, const char* pszVRTPath) const override;
1682 };
1683
1684 /************************************************************************/
1685 /* VRTMDArraySourceRegularlySpaced */
1686 /************************************************************************/
1687
1688 class VRTMDArraySourceRegularlySpaced final: public VRTMDArraySource
1689 {
1690 double m_dfStart;
1691 double m_dfIncrement;
1692
1693 public:
1694 VRTMDArraySourceRegularlySpaced(
1695 double dfStart, double dfIncrement):
1696 m_dfStart(dfStart),
1697 m_dfIncrement(dfIncrement)
1698 {
1699 }
1700
1701 bool Read(const GUInt64* arrayStartIdx,
1702 const size_t* count,
1703 const GInt64* arrayStep,
1704 const GPtrDiff_t* bufferStride,
1705 const GDALExtendedDataType& bufferDataType,
1706 void* pDstBuffer) const override;
1707
1708 void Serialize(CPLXMLNode* psParent, const char* pszVRTPath) const override;
1709 };
1710
1711 /************************************************************************/
1712 /* VRTMDArraySourceFromArray */
1713 /************************************************************************/
1714
1715 class VRTMDArraySourceFromArray final: public VRTMDArraySource
1716 {
1717 const VRTMDArray* m_poDstArray = nullptr;
1718 bool m_bRelativeToVRTSet = false;
1719 bool m_bRelativeToVRT = false;
1720 std::string m_osFilename{};
1721 std::string m_osArray{};
1722 std::string m_osBand{};
1723 std::vector<int> m_anTransposedAxis{};
1724 std::string m_osViewExpr{};
1725 std::vector<GUInt64> m_anSrcOffset{};
1726 mutable std::vector<GUInt64> m_anCount{};
1727 std::vector<GUInt64> m_anStep{};
1728 std::vector<GUInt64> m_anDstOffset{};
1729
1730 VRTMDArraySourceFromArray(const VRTMDArraySourceFromArray&) = delete;
1731 VRTMDArraySourceFromArray& operator=(const VRTMDArraySourceFromArray&) = delete;
1732
1733 public:
1734 VRTMDArraySourceFromArray(const VRTMDArray* poDstArray,
1735 bool bRelativeToVRTSet,
1736 bool bRelativeToVRT,
1737 const std::string& osFilename,
1738 const std::string& osArray,
1739 const std::string& osBand,
1740 std::vector<int>&& anTransposedAxis,
1741 const std::string& osViewExpr,
1742 std::vector<GUInt64>&& anSrcOffset,
1743 std::vector<GUInt64>&& anCount,
1744 std::vector<GUInt64>&& anStep,
1745 std::vector<GUInt64>&& anDstOffset):
1746 m_poDstArray(poDstArray),
1747 m_bRelativeToVRTSet(bRelativeToVRTSet),
1748 m_bRelativeToVRT(bRelativeToVRT),
1749 m_osFilename(osFilename),
1750 m_osArray(osArray),
1751 m_osBand(osBand),
1752 m_anTransposedAxis(std::move(anTransposedAxis)),
1753 m_osViewExpr(osViewExpr),
1754 m_anSrcOffset(std::move(anSrcOffset)),
1755 m_anCount(std::move(anCount)),
1756 m_anStep(std::move(anStep)),
1757 m_anDstOffset(std::move(anDstOffset))
1758 {
1759 }
1760
1761 ~VRTMDArraySourceFromArray() override;
1762
1763 static std::unique_ptr<VRTMDArraySourceFromArray> Create(
1764 const VRTMDArray* poDstArray,
1765 const CPLXMLNode* psNode);
1766
1767 bool Read(const GUInt64* arrayStartIdx,
1768 const size_t* count,
1769 const GInt64* arrayStep,
1770 const GPtrDiff_t* bufferStride,
1771 const GDALExtendedDataType& bufferDataType,
1772 void* pDstBuffer) const override;
1773
1774 void Serialize(CPLXMLNode* psParent, const char* pszVRTPath) const override;
1775 };
1776
1777 #endif /* #ifndef DOXYGEN_SKIP */
1778
1779 #endif /* ndef VIRTUALDATASET_H_INCLUDED */
GDALRasterAttributeTable
The GDALRasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute ...
Definition: gdal_rat.h:47
GDALDataType
GDALDataType
Definition: gdal.h:60
CPLXMLNode
Document node structure.
Definition: cpl_minixml.h:69
cpl_minixml.h
Definitions for CPL mini XML Parser/Serializer.
VRTImageReadFunc
CPLErr(* VRTImageReadFunc)(void *hCBData, int nXOff, int nYOff, int nXSize, int nYSize, void *pData)
Type for a function that returns the pixel data in a provided window.
Definition: gdal_vrt.h:51
gdal_priv.h
C++ GDAL entry points.
GDALGroup
Class modeling a named container of GDALAttribute, GDALMDArray or other GDALGroup.
Definition: gdal_priv.h:1948
VRTCreate
VRTDatasetH VRTCreate(int, int)
Definition: vrtdataset.cpp:79
GDALRWFlag
GDALRWFlag
Definition: gdal.h:119
GByte
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:215
GDALRasterBandH
void * GDALRasterBandH
Opaque type used for the C bindings of the C++ GDALRasterBand class.
Definition: gdal.h:261
GDALPansharpenOperation
Pansharpening operation class.
Definition: gdalpansharpen.h:188
CPLString
Convenient string class based on std::string.
Definition: cpl_string.h:332
cpl_hash_set.h
Hash set implementation.
GDT_Unknown
Definition: gdal.h:61
GDALAttribute
Class modeling an attribute that has a name, a value and a type, and is typically used to describe a ...
Definition: gdal_priv.h:2219
GDALDerivedPixelFunc
CPLErr(* GDALDerivedPixelFunc)(void **papoSources, int nSources, void *pData, int nBufXSize, int nBufYSize, GDALDataType eSrcType, GDALDataType eBufType, int nPixelSpace, int nLineSpace)
Type of functions to pass to GDALAddDerivedBandPixelFunc.
Definition: gdal.h:881
CPLVirtualMem
struct CPLVirtualMem CPLVirtualMem
Opaque type that represents a virtual memory mapping.
Definition: cpl_virtualmem.h:62
VRT_NODATA_UNSET
#define VRT_NODATA_UNSET
Special value to indicate that nodata is not set.
Definition: gdal_vrt.h:45
GDALDimension
Class modeling a a dimension / axis used to index multidimensional arrays.
Definition: gdal_priv.h:2549
GSpacing
GIntBig GSpacing
Type to express pixel, line or band spacing.
Definition: gdal.h:276
GDALDataset::Dereference
int Dereference()
Subtract one from dataset reference count.
Definition: gdaldataset.cpp:1366
GUInt64
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition: cpl_port.h:269
GPtrDiff_t
GIntBig GPtrDiff_t
Integer type large enough to hold the difference between 2 addresses.
Definition: cpl_port.h:286
GDALDataset::SetGCPs
virtual CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList, const OGRSpatialReference *poGCP_SRS)
Assign GCPs.
Definition: gdaldataset.cpp:1783
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1216
GDALOpenInfo
Class for dataset open functions.
Definition: gdal_priv.h:268
GDALExtendedDataType
Class used to represent potentially complex data types.
Definition: gdal_priv.h:1784
CPLStringList
String list class designed around our use of C "char**" string lists.
Definition: cpl_string.h:441
GDALRasterIOExtraArg
Structure to pass extra arguments to RasterIO() method.
Definition: gdal.h:150
GDALWarpOperation
High level image warping class.
Definition: gdalwarper.h:451
GUIntBig
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition: cpl_port.h:251
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:157
GDALAbstractMDArray
Abstract class, implemented by GDALAttribute and GDALMDArray.
Definition: gdal_priv.h:2043
GDALClose
void GDALClose(GDALDatasetH)
Close GDAL dataset.
Definition: gdaldataset.cpp:3656
GDALMajorObject
Object with metadata.
Definition: gdal_priv.h:135
GDALRasterBand::GetDataset
GDALDataset * GetDataset()
Fetch the owning dataset handle.
Definition: gdalrasterband.cpp:2837
vsi_l_offset
GUIntBig vsi_l_offset
Type for a file offset.
Definition: cpl_vsi.h:140
GDALRasterBand
A single raster band (or channel).
Definition: gdal_priv.h:1111
GDALAccess
GDALAccess
Definition: gdal.h:113
VRTDatasetH
void * VRTDatasetH
Opaque type for a VRT dataset.
Definition: gdal_vrt.h:76
GDALDataset
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:339
GIntBig
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:248
GDALColorInterp
GDALColorInterp
Definition: gdal.h:193
GDALMDArray
Class modeling a multi-dimensional array.
Definition: gdal_priv.h:2336
gdal_vrt.h
Public (C callable) entry points for virtual GDAL dataset objects.
CPLHashSet
struct _CPLHashSet CPLHashSet
Opaque type for a hash set.
Definition: cpl_hash_set.h:52
GInt64
GIntBig GInt64
Signed 64 bit integer type.
Definition: cpl_port.h:267
GDALDataset::GetShared
int GetShared() const
Returns shared flag.
Definition: gdaldataset.cpp:1438
GA_ReadOnly
Definition: gdal.h:114
GDALDriver
Format specific driver.
Definition: gdal_priv.h:1467
CPL_NON_FINAL
#define CPL_NON_FINAL
Mark that a class is explicitly recognized as non-final.
Definition: cpl_port.h:1000
GDALColorTable
A color table / palette.
Definition: gdal_priv.h:1005
GDAL_GCP
Ground Control Point.
Definition: gdal.h:668
CPLErr
CPLErr
Error category.
Definition: cpl_error.h:52
CPL_DISALLOW_COPY_ASSIGN
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:1007