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
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
#ifndef GDALWARPER_H_INCLUDED
00067
#define GDALWARPER_H_INCLUDED
00068
00077
#include "gdal_alg.h"
00078
00079 CPL_C_START
00080
00082 typedef enum {
GRA_NearestNeighbour=0,
GRA_Bilinear=1,
GRA_Cubic=2,
GRA_CubicSpline=3,
00087 }
GDALResampleAlg;
00088
00089
typedef int
00090 (*GDALMaskFunc)(
void *pMaskFuncArg,
00091
int nBandCount,
GDALDataType eType,
00092
int nXOff,
int nYOff,
00093
int nXSize,
int nYSize,
00094 GByte **papabyImageData,
00095
int bMaskIsFloat,
void *pMask );
00096
00097 CPLErr GDALWarpNoDataMasker(
void *pMaskFuncArg,
int nBandCount,
00098 GDALDataType eType,
00099
int nXOff,
int nYOff,
int nXSize,
int nYSize,
00100 GByte **papabyImageData,
int bMaskIsFloat,
00101
void *pValidityMask );
00102
00103
00104
00105
00106
00108 typedef struct {
00109
00110
char **papszWarpOptions;
00111
00113 double dfWarpMemoryLimit;
00114
00116 GDALResampleAlg eResampleAlg;
00117
00120 GDALDataType eWorkingDataType;
00121
00123 GDALDatasetH hSrcDS;
00124
00126 GDALDatasetH hDstDS;
00127
00129 int nBandCount;
00130
00132 int *panSrcBands;
00133
00135 int *panDstBands;
00136
00138 double *padfSrcNoDataReal;
00141 double *padfSrcNoDataImag;
00142
00144 double *padfDstNoDataReal;
00147 double *padfDstNoDataImag;
00148
00151 GDALProgressFunc pfnProgress;
00152
00154 void *pProgressArg;
00155
00157 GDALTransformerFunc pfnTransformer;
00158
00160 void *pTransformerArg;
00161
00162 GDALMaskFunc *papfnSrcPerBandValidityMaskFunc;
00163
void **papSrcPerBandValidityMaskFuncArg;
00164
00165 GDALMaskFunc pfnSrcValidityMaskFunc;
00166
void *pSrcValidityMaskFuncArg;
00167
00168 GDALMaskFunc pfnSrcDensityMaskFunc;
00169
void *pSrcDensityMaskFuncArg;
00170
00171 GDALMaskFunc pfnDstDensityMaskFunc;
00172
void *pDstDensityMaskFuncArg;
00173
00174 GDALMaskFunc pfnDstValidityMaskFunc;
00175
void *pDstValidityMaskFuncArg;
00176
00177 CPLErr (*pfnPreWarpChunkProcessor)(
void *pKern,
void *pArg );
00178
void *pPreWarpProcessorArg;
00179
00180 CPLErr (*pfnPostWarpChunkProcessor)(
void *pKern,
void *pArg);
00181
void *pPostWarpProcessorArg;
00182
00183 }
GDALWarpOptions;
00184
00185
GDALWarpOptions CPL_DLL *GDALCreateWarpOptions();
00186
void CPL_DLL GDALDestroyWarpOptions(
GDALWarpOptions * );
00187
GDALWarpOptions CPL_DLL *GDALCloneWarpOptions(
const GDALWarpOptions * );
00188
00189
00190
00191
00192
00193 CPLErr CPL_DLL
00194 GDALReprojectImage( GDALDatasetH hSrcDS,
const char *pszSrcWKT,
00195 GDALDatasetH hDstDS,
const char *pszDstWKT,
00196 GDALResampleAlg eResampleAlg,
double dfWarpMemoryLimit,
00197
double dfMaxError,
00198
GDALProgressFunc pfnProgress,
void *pProgressArg,
00199
GDALWarpOptions *psOptions );
00200
00201 CPLErr CPL_DLL
00202 GDALCreateAndReprojectImage( GDALDatasetH hSrcDS,
const char *pszSrcWKT,
00203
const char *pszDstFilename,
const char *pszDstWKT,
00204 GDALDriverH hDstDriver,
char **papszCreateOptions,
00205 GDALResampleAlg eResampleAlg,
double dfWarpMemoryLimit,
00206
double dfMaxError,
00207
GDALProgressFunc pfnProgress,
void *pProgressArg,
00208
GDALWarpOptions *psOptions );
00209
00210 CPL_C_END
00211
00212
#ifdef __cplusplus
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224 class CPL_DLL GDALWarpKernel
00225 {
00226
public:
00227 GDALWarpKernel();
00228
virtual ~GDALWarpKernel();
00229
00230
char **papszWarpOptions;
00231
00232
GDALResampleAlg eResample;
00233
GDALDataType eWorkingDataType;
00234
int nBands;
00235
00236
int nSrcXSize;
00237
int nSrcYSize;
00238 GByte **papabySrcImage;
00239
00240 GUInt32 **papanBandSrcValid;
00241 GUInt32 *panUnifiedSrcValid;
00242
float *pafUnifiedSrcDensity;
00243
00244
int nDstXSize;
00245
int nDstYSize;
00246 GByte **papabyDstImage;
00247 GUInt32 *panDstValid;
00248
float *pafDstDensity;
00249
00250
int nSrcXOff;
00251
int nSrcYOff;
00252
00253
int nDstXOff;
00254
int nDstYOff;
00255
00256
GDALTransformerFunc pfnTransformer;
00257
void *pTransformerArg;
00258
00259
GDALProgressFunc pfnProgress;
00260
void *pProgress;
00261
00262
double dfProgressBase;
00263
double dfProgressScale;
00264
00265 CPLErr Validate();
00266 CPLErr PerformWarp();
00267 };
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279 class CPL_DLL GDALWarpOperation {
00280
private:
00281
GDALWarpOptions *psOptions;
00282
00283
double dfProgressBase;
00284
double dfProgressScale;
00285
00286
void WipeOptions();
00287
int ValidateOptions();
00288
00289 CPLErr ComputeSourceWindow(
int nDstXOff,
int nDstYOff,
00290
int nDstXSize,
int nDstYSize,
00291
int *pnSrcXOff,
int *pnSrcYOff,
00292
int *pnSrcXSize,
int *pnSrcYSize );
00293
00294 CPLErr CreateKernelMask( GDALWarpKernel *,
int iBand,
00295
const char *pszType );
00296
00297
void *hThread1Mutex;
00298
void *hThread2Mutex;
00299
void *hIOMutex;
00300
void *hWarpMutex;
00301
00302
int nChunkListCount;
00303
int nChunkListMax;
00304
int *panChunkList;
00305
00306
int bReportTimings;
00307
unsigned long nLastTimeReported;
00308
00309
void WipeChunkList();
00310 CPLErr CollectChunkList(
int nDstXOff,
int nDstYOff,
00311
int nDstXSize,
int nDstYSize );
00312
void ReportTiming(
const char * );
00313
00314
public:
00315 GDALWarpOperation();
00316
virtual ~GDALWarpOperation();
00317
00318 CPLErr Initialize(
const GDALWarpOptions *psNewOptions );
00319
00320
const GDALWarpOptions *GetOptions();
00321
00322 CPLErr ChunkAndWarpImage(
int nDstXOff,
int nDstYOff,
00323
int nDstXSize,
int nDstYSize );
00324 CPLErr ChunkAndWarpMulti(
int nDstXOff,
int nDstYOff,
00325
int nDstXSize,
int nDstYSize );
00326 CPLErr WarpRegion(
int nDstXOff,
int nDstYOff,
00327
int nDstXSize,
int nDstYSize,
00328
int nSrcXOff=0,
int nSrcYOff=0,
00329
int nSrcXSize=0,
int nSrcYSize=0 );
00330
00331 CPLErr WarpRegionToBuffer(
int nDstXOff,
int nDstYOff,
00332
int nDstXSize,
int nDstYSize,
00333
void *pDataBuf,
00334
GDALDataType eBufDataType,
00335
int nSrcXOff=0,
int nSrcYOff=0,
00336
int nSrcXSize=0,
int nSrcYSize=0 );
00337 };
00338
00339
#endif
00340
00341 CPL_C_START
00342
00343
typedef void * GDALWarpOperationH;
00344
00345 GDALWarpOperationH CPL_DLL
GDALCreateWarpOperation(
const GDALWarpOptions* );
00346
void CPL_DLL
GDALDestroyWarpOperation( GDALWarpOperationH );
00347 CPLErr CPL_DLL
GDALChunkAndWarpImage( GDALWarpOperationH,
int,
int,
int,
int );
00348 CPLErr CPL_DLL
GDALChunkAndWarpMulti( GDALWarpOperationH,
int,
int,
int,
int );
00349 CPLErr CPL_DLL
GDALWarpRegion( GDALWarpOperationH,
00350
int,
int,
int,
int,
int,
int,
int,
int );
00351 CPLErr CPL_DLL
GDALWarpRegionToBuffer( GDALWarpOperationH,
int,
int,
int,
int,
00352
void *, GDALDataType,
00353
int,
int,
int,
int );
00354
00355 CPL_C_END
00356
00357
#endif