00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef GDAL_PROXY_H_INCLUDED
00031 #define GDAL_PROXY_H_INCLUDED
00032
00033 #include "gdal.h"
00034
00035 #ifdef __cplusplus
00036
00037 #include "gdal_priv.h"
00038 #include "cpl_hash_set.h"
00039
00040
00041
00042
00043
00044 class CPL_DLL GDALProxyDataset : public GDALDataset
00045 {
00046 protected:
00047 virtual GDALDataset *RefUnderlyingDataset() = 0;
00048 virtual void UnrefUnderlyingDataset(GDALDataset* poUnderlyingDataset);
00049
00050 virtual CPLErr IBuildOverviews( const char *, int, int *,
00051 int, int *, GDALProgressFunc, void * );
00052 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00053 void *, int, int, GDALDataType,
00054 int, int *, GSpacing, GSpacing, GSpacing,
00055 GDALRasterIOExtraArg* psExtraArg );
00056 public:
00057
00058 virtual char **GetMetadataDomainList();
00059 virtual char **GetMetadata( const char * pszDomain );
00060 virtual CPLErr SetMetadata( char ** papszMetadata,
00061 const char * pszDomain );
00062 virtual const char *GetMetadataItem( const char * pszName,
00063 const char * pszDomain );
00064 virtual CPLErr SetMetadataItem( const char * pszName,
00065 const char * pszValue,
00066 const char * pszDomain );
00067
00068 virtual void FlushCache(void);
00069
00070 virtual const char *GetProjectionRef(void);
00071 virtual CPLErr SetProjection( const char * );
00072
00073 virtual CPLErr GetGeoTransform( double * );
00074 virtual CPLErr SetGeoTransform( double * );
00075
00076 virtual void *GetInternalHandle( const char * );
00077 virtual GDALDriver *GetDriver(void);
00078 virtual char **GetFileList(void);
00079
00080 virtual int GetGCPCount();
00081 virtual const char *GetGCPProjection();
00082 virtual const GDAL_GCP *GetGCPs();
00083 virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
00084 const char *pszGCPProjection );
00085
00086 virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
00087 int nBufXSize, int nBufYSize,
00088 GDALDataType eDT,
00089 int nBandCount, int *panBandList,
00090 char **papszOptions );
00091
00092 virtual CPLErr CreateMaskBand( int nFlags );
00093
00094 };
00095
00096
00097
00098
00099
00100 class CPL_DLL GDALProxyRasterBand : public GDALRasterBand
00101 {
00102 protected:
00103 virtual GDALRasterBand* RefUnderlyingRasterBand() = 0;
00104 virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand);
00105
00106 virtual CPLErr IReadBlock( int, int, void * );
00107 virtual CPLErr IWriteBlock( int, int, void * );
00108 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00109 void *, int, int, GDALDataType,
00110 GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg );
00111
00112 public:
00113
00114 virtual char **GetMetadataDomainList();
00115 virtual char **GetMetadata( const char * pszDomain );
00116 virtual CPLErr SetMetadata( char ** papszMetadata,
00117 const char * pszDomain );
00118 virtual const char *GetMetadataItem( const char * pszName,
00119 const char * pszDomain );
00120 virtual CPLErr SetMetadataItem( const char * pszName,
00121 const char * pszValue,
00122 const char * pszDomain );
00123 virtual CPLErr FlushCache();
00124 virtual char **GetCategoryNames();
00125 virtual double GetNoDataValue( int *pbSuccess = NULL );
00126 virtual double GetMinimum( int *pbSuccess = NULL );
00127 virtual double GetMaximum(int *pbSuccess = NULL );
00128 virtual double GetOffset( int *pbSuccess = NULL );
00129 virtual double GetScale( int *pbSuccess = NULL );
00130 virtual const char *GetUnitType();
00131 virtual GDALColorInterp GetColorInterpretation();
00132 virtual GDALColorTable *GetColorTable();
00133 virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
00134
00135 virtual CPLErr SetCategoryNames( char ** );
00136 virtual CPLErr SetNoDataValue( double );
00137 virtual CPLErr SetColorTable( GDALColorTable * );
00138 virtual CPLErr SetColorInterpretation( GDALColorInterp );
00139 virtual CPLErr SetOffset( double );
00140 virtual CPLErr SetScale( double );
00141 virtual CPLErr SetUnitType( const char * );
00142
00143 virtual CPLErr GetStatistics( int bApproxOK, int bForce,
00144 double *pdfMin, double *pdfMax,
00145 double *pdfMean, double *padfStdDev );
00146 virtual CPLErr ComputeStatistics( int bApproxOK,
00147 double *pdfMin, double *pdfMax,
00148 double *pdfMean, double *pdfStdDev,
00149 GDALProgressFunc, void *pProgressData );
00150 virtual CPLErr SetStatistics( double dfMin, double dfMax,
00151 double dfMean, double dfStdDev );
00152 virtual CPLErr ComputeRasterMinMax( int, double* );
00153
00154 virtual int HasArbitraryOverviews();
00155 virtual int GetOverviewCount();
00156 virtual GDALRasterBand *GetOverview(int);
00157 virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig );
00158 virtual CPLErr BuildOverviews( const char *, int, int *,
00159 GDALProgressFunc, void * );
00160
00161 virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
00162 int nBufXSize, int nBufYSize,
00163 GDALDataType eDT, char **papszOptions );
00164
00165 virtual CPLErr GetHistogram( double dfMin, double dfMax,
00166 int nBuckets, GUIntBig * panHistogram,
00167 int bIncludeOutOfRange, int bApproxOK,
00168 GDALProgressFunc, void *pProgressData );
00169
00170 virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
00171 int *pnBuckets, GUIntBig ** ppanHistogram,
00172 int bForce,
00173 GDALProgressFunc, void *pProgressData);
00174 virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
00175 int nBuckets, GUIntBig *panHistogram );
00176
00177 virtual GDALRasterAttributeTable *GetDefaultRAT();
00178 virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * );
00179
00180 virtual GDALRasterBand *GetMaskBand();
00181 virtual int GetMaskFlags();
00182 virtual CPLErr CreateMaskBand( int nFlags );
00183
00184 virtual CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag,
00185 int *pnPixelSpace,
00186 GIntBig *pnLineSpace,
00187 char **papszOptions );
00188 };
00189
00190
00191
00192
00193
00194
00195 typedef struct _GDALProxyPoolCacheEntry GDALProxyPoolCacheEntry;
00196 class GDALProxyPoolRasterBand;
00197
00198 class CPL_DLL GDALProxyPoolDataset : public GDALProxyDataset
00199 {
00200 private:
00201 GIntBig responsiblePID;
00202
00203 char *pszProjectionRef;
00204 double adfGeoTransform[6];
00205 int bHasSrcProjection;
00206 int bHasSrcGeoTransform;
00207 char *pszGCPProjection;
00208 int nGCPCount;
00209 GDAL_GCP *pasGCPList;
00210 CPLHashSet *metadataSet;
00211 CPLHashSet *metadataItemSet;
00212
00213 GDALProxyPoolCacheEntry* cacheEntry;
00214
00215 protected:
00216 virtual GDALDataset *RefUnderlyingDataset();
00217 virtual void UnrefUnderlyingDataset(GDALDataset* poUnderlyingDataset);
00218
00219 friend class GDALProxyPoolRasterBand;
00220
00221 public:
00222 GDALProxyPoolDataset(const char* pszSourceDatasetDescription,
00223 int nRasterXSize, int nRasterYSize,
00224 GDALAccess eAccess = GA_ReadOnly,
00225 int bShared = FALSE,
00226 const char * pszProjectionRef = NULL,
00227 double * padfGeoTransform = NULL);
00228 ~GDALProxyPoolDataset();
00229
00230 void SetOpenOptions(char** papszOpenOptions);
00231 void AddSrcBandDescription( GDALDataType eDataType, int nBlockXSize, int nBlockYSize);
00232
00233 virtual const char *GetProjectionRef(void);
00234 virtual CPLErr SetProjection( const char * );
00235
00236 virtual CPLErr GetGeoTransform( double * );
00237 virtual CPLErr SetGeoTransform( double * );
00238
00239
00240
00241
00242 virtual char **GetMetadata( const char * pszDomain );
00243 virtual const char *GetMetadataItem( const char * pszName,
00244 const char * pszDomain );
00245
00246 virtual void *GetInternalHandle( const char * pszRequest );
00247
00248 virtual const char *GetGCPProjection();
00249 virtual const GDAL_GCP *GetGCPs();
00250 };
00251
00252
00253
00254
00255
00256 class GDALProxyPoolOverviewRasterBand;
00257 class GDALProxyPoolMaskBand;
00258
00259 class CPL_DLL GDALProxyPoolRasterBand : public GDALProxyRasterBand
00260 {
00261 private:
00262 CPLHashSet *metadataSet;
00263 CPLHashSet *metadataItemSet;
00264 char *pszUnitType;
00265 char **papszCategoryNames;
00266 GDALColorTable *poColorTable;
00267
00268 int nSizeProxyOverviewRasterBand;
00269 GDALProxyPoolOverviewRasterBand **papoProxyOverviewRasterBand;
00270 GDALProxyPoolMaskBand *poProxyMaskBand;
00271
00272 void Init();
00273
00274 protected:
00275 virtual GDALRasterBand* RefUnderlyingRasterBand();
00276 virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand);
00277
00278 friend class GDALProxyPoolOverviewRasterBand;
00279 friend class GDALProxyPoolMaskBand;
00280
00281 public:
00282 GDALProxyPoolRasterBand(GDALProxyPoolDataset* poDS, int nBand,
00283 GDALDataType eDataType,
00284 int nBlockXSize, int nBlockYSize);
00285 GDALProxyPoolRasterBand(GDALProxyPoolDataset* poDS,
00286 GDALRasterBand* poUnderlyingRasterBand);
00287 ~GDALProxyPoolRasterBand();
00288
00289 void AddSrcMaskBandDescription( GDALDataType eDataType, int nBlockXSize, int nBlockYSize);
00290
00291
00292
00293
00294 virtual char **GetMetadata( const char * pszDomain );
00295 virtual const char *GetMetadataItem( const char * pszName,
00296 const char * pszDomain );
00297 virtual char **GetCategoryNames();
00298 virtual const char *GetUnitType();
00299 virtual GDALColorTable *GetColorTable();
00300 virtual GDALRasterBand *GetOverview(int);
00301 virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig nDesiredSamples);
00302 virtual GDALRasterBand *GetMaskBand();
00303
00304 };
00305
00306
00307
00308
00309
00310 class GDALProxyPoolOverviewRasterBand : public GDALProxyPoolRasterBand
00311 {
00312 private:
00313 GDALProxyPoolRasterBand *poMainBand;
00314 int nOverviewBand;
00315
00316 GDALRasterBand *poUnderlyingMainRasterBand;
00317 int nRefCountUnderlyingMainRasterBand;
00318
00319 protected:
00320 virtual GDALRasterBand* RefUnderlyingRasterBand();
00321 virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand);
00322
00323 public:
00324 GDALProxyPoolOverviewRasterBand(GDALProxyPoolDataset* poDS,
00325 GDALRasterBand* poUnderlyingOverviewBand,
00326 GDALProxyPoolRasterBand* poMainBand,
00327 int nOverviewBand);
00328 ~GDALProxyPoolOverviewRasterBand();
00329 };
00330
00331
00332
00333
00334
00335 class GDALProxyPoolMaskBand : public GDALProxyPoolRasterBand
00336 {
00337 private:
00338 GDALProxyPoolRasterBand *poMainBand;
00339
00340 GDALRasterBand *poUnderlyingMainRasterBand;
00341 int nRefCountUnderlyingMainRasterBand;
00342
00343 protected:
00344 virtual GDALRasterBand* RefUnderlyingRasterBand();
00345 virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand);
00346
00347 public:
00348 GDALProxyPoolMaskBand(GDALProxyPoolDataset* poDS,
00349 GDALRasterBand* poUnderlyingMaskBand,
00350 GDALProxyPoolRasterBand* poMainBand);
00351 GDALProxyPoolMaskBand(GDALProxyPoolDataset* poDS,
00352 GDALProxyPoolRasterBand* poMainBand,
00353 GDALDataType eDataType,
00354 int nBlockXSize, int nBlockYSize);
00355 ~GDALProxyPoolMaskBand();
00356 };
00357
00358 #endif
00359
00360
00361
00362
00363
00364
00365
00366 CPL_C_START
00367
00368 typedef struct GDALProxyPoolDatasetHS *GDALProxyPoolDatasetH;
00369
00370 GDALProxyPoolDatasetH CPL_DLL GDALProxyPoolDatasetCreate(const char* pszSourceDatasetDescription,
00371 int nRasterXSize, int nRasterYSize,
00372 GDALAccess eAccess, int bShared,
00373 const char * pszProjectionRef,
00374 double * padfGeoTransform);
00375
00376 void CPL_DLL GDALProxyPoolDatasetDelete(GDALProxyPoolDatasetH hProxyPoolDataset);
00377
00378 void CPL_DLL GDALProxyPoolDatasetAddSrcBandDescription( GDALProxyPoolDatasetH hProxyPoolDataset,
00379 GDALDataType eDataType,
00380 int nBlockXSize, int nBlockYSize);
00381
00382 CPL_C_END
00383
00384 #endif