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 #ifndef GDALWARPER_H_INCLUDED
00032 #define GDALWARPER_H_INCLUDED
00033
00042 #include "gdal_alg.h"
00043 #include "cpl_minixml.h"
00044 #include "cpl_multiproc.h"
00045
00046 CPL_C_START
00047
00048
00050 typedef enum { GRA_NearestNeighbour=0, GRA_Bilinear=1, GRA_Cubic=2, GRA_CubicSpline=3, GRA_Lanczos=4, GRA_Average=5, GRA_Mode=6,
00058
00064 } GDALResampleAlg;
00065
00067 typedef enum { GWKAOM_Average=1, GWKAOM_Fmode=2, GWKAOM_Imode=3, GWKAOM_Max=4, GWKAOM_Min=5, GWKAOM_Quant=6
00074 } GWKAverageOrModeAlg;
00075
00076 typedef int
00077 (*GDALMaskFunc)( void *pMaskFuncArg,
00078 int nBandCount, GDALDataType eType,
00079 int nXOff, int nYOff,
00080 int nXSize, int nYSize,
00081 GByte **papabyImageData,
00082 int bMaskIsFloat, void *pMask );
00083
00084 CPLErr CPL_DLL
00085 GDALWarpNoDataMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
00086 int nXOff, int nYOff, int nXSize, int nYSize,
00087 GByte **papabyImageData, int bMaskIsFloat,
00088 void *pValidityMask, int* pbOutAllValid );
00089
00090 CPLErr CPL_DLL
00091 GDALWarpDstAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
00092 int nXOff, int nYOff, int nXSize, int nYSize,
00093 GByte ** ,
00094 int bMaskIsFloat, void *pValidityMask );
00095 CPLErr CPL_DLL
00096 GDALWarpSrcAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
00097 int nXOff, int nYOff, int nXSize, int nYSize,
00098 GByte ** ,
00099 int bMaskIsFloat, void *pValidityMask, int* pbOutAllOpaque );
00100
00101 CPLErr CPL_DLL
00102 GDALWarpSrcMaskMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
00103 int nXOff, int nYOff, int nXSize, int nYSize,
00104 GByte ** ,
00105 int bMaskIsFloat, void *pValidityMask );
00106
00107 CPLErr CPL_DLL
00108 GDALWarpCutlineMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
00109 int nXOff, int nYOff, int nXSize, int nYSize,
00110 GByte ** ,
00111 int bMaskIsFloat, void *pValidityMask );
00112
00113
00114
00115
00116
00118 typedef struct {
00119
00120 char **papszWarpOptions;
00121
00123 double dfWarpMemoryLimit;
00124
00126 GDALResampleAlg eResampleAlg;
00127
00130 GDALDataType eWorkingDataType;
00131
00133 GDALDatasetH hSrcDS;
00134
00136 GDALDatasetH hDstDS;
00137
00139 int nBandCount;
00140
00142 int *panSrcBands;
00143
00145 int *panDstBands;
00146
00148 int nSrcAlphaBand;
00149
00151 int nDstAlphaBand;
00152
00154 double *padfSrcNoDataReal;
00157 double *padfSrcNoDataImag;
00158
00160 double *padfDstNoDataReal;
00163 double *padfDstNoDataImag;
00164
00167 GDALProgressFunc pfnProgress;
00168
00170 void *pProgressArg;
00171
00173 GDALTransformerFunc pfnTransformer;
00174
00176 void *pTransformerArg;
00177
00178 GDALMaskFunc *papfnSrcPerBandValidityMaskFunc;
00179 void **papSrcPerBandValidityMaskFuncArg;
00180
00181 GDALMaskFunc pfnSrcValidityMaskFunc;
00182 void *pSrcValidityMaskFuncArg;
00183
00184 GDALMaskFunc pfnSrcDensityMaskFunc;
00185 void *pSrcDensityMaskFuncArg;
00186
00187 GDALMaskFunc pfnDstDensityMaskFunc;
00188 void *pDstDensityMaskFuncArg;
00189
00190 GDALMaskFunc pfnDstValidityMaskFunc;
00191 void *pDstValidityMaskFuncArg;
00192
00193 CPLErr (*pfnPreWarpChunkProcessor)( void *pKern, void *pArg );
00194 void *pPreWarpProcessorArg;
00195
00196 CPLErr (*pfnPostWarpChunkProcessor)( void *pKern, void *pArg);
00197 void *pPostWarpProcessorArg;
00198
00200 void *hCutline;
00201
00203 double dfCutlineBlendDist;
00204
00205 } GDALWarpOptions;
00206
00207 GDALWarpOptions CPL_DLL * CPL_STDCALL GDALCreateWarpOptions(void);
00208 void CPL_DLL CPL_STDCALL GDALDestroyWarpOptions( GDALWarpOptions * );
00209 GDALWarpOptions CPL_DLL * CPL_STDCALL
00210 GDALCloneWarpOptions( const GDALWarpOptions * );
00211
00212 CPLXMLNode CPL_DLL * CPL_STDCALL
00213 GDALSerializeWarpOptions( const GDALWarpOptions * );
00214 GDALWarpOptions CPL_DLL * CPL_STDCALL
00215 GDALDeserializeWarpOptions( CPLXMLNode * );
00216
00217
00218
00219
00220
00221 CPLErr CPL_DLL CPL_STDCALL
00222 GDALReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT,
00223 GDALDatasetH hDstDS, const char *pszDstWKT,
00224 GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit,
00225 double dfMaxError,
00226 GDALProgressFunc pfnProgress, void *pProgressArg,
00227 GDALWarpOptions *psOptions );
00228
00229 CPLErr CPL_DLL CPL_STDCALL
00230 GDALCreateAndReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT,
00231 const char *pszDstFilename, const char *pszDstWKT,
00232 GDALDriverH hDstDriver, char **papszCreateOptions,
00233 GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit,
00234 double dfMaxError,
00235 GDALProgressFunc pfnProgress, void *pProgressArg,
00236 GDALWarpOptions *psOptions );
00237
00238
00239
00240
00241
00242 GDALDatasetH CPL_DLL CPL_STDCALL
00243 GDALAutoCreateWarpedVRT( GDALDatasetH hSrcDS,
00244 const char *pszSrcWKT, const char *pszDstWKT,
00245 GDALResampleAlg eResampleAlg,
00246 double dfMaxError, const GDALWarpOptions *psOptions );
00247
00248 GDALDatasetH CPL_DLL CPL_STDCALL
00249 GDALCreateWarpedVRT( GDALDatasetH hSrcDS,
00250 int nPixels, int nLines, double *padfGeoTransform,
00251 GDALWarpOptions *psOptions );
00252
00253 CPLErr CPL_DLL CPL_STDCALL
00254 GDALInitializeWarpedVRT( GDALDatasetH hDS,
00255 GDALWarpOptions *psWO );
00256
00257 CPL_C_END
00258
00259 #ifdef __cplusplus
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276 #define WARP_EXTRA_ELTS 1
00277
00278 class CPL_DLL GDALWarpKernel
00279 {
00280 public:
00281 char **papszWarpOptions;
00282
00283 GDALResampleAlg eResample;
00284 GDALDataType eWorkingDataType;
00285 int nBands;
00286
00287 int nSrcXSize;
00288 int nSrcYSize;
00289 int nSrcXExtraSize;
00290 int nSrcYExtraSize;
00291 GByte **papabySrcImage;
00292
00293 GUInt32 **papanBandSrcValid;
00294 GUInt32 *panUnifiedSrcValid;
00295 float *pafUnifiedSrcDensity;
00296
00297 int nDstXSize;
00298 int nDstYSize;
00299 GByte **papabyDstImage;
00300 GUInt32 *panDstValid;
00301 float *pafDstDensity;
00302
00303 double dfXScale;
00304 double dfYScale;
00305 double dfXFilter;
00306 double dfYFilter;
00307 int nXRadius;
00308 int nYRadius;
00309 int nFiltInitX;
00310 int nFiltInitY;
00311
00312 int nSrcXOff;
00313 int nSrcYOff;
00314
00315 int nDstXOff;
00316 int nDstYOff;
00317
00318 GDALTransformerFunc pfnTransformer;
00319 void *pTransformerArg;
00320
00321 GDALProgressFunc pfnProgress;
00322 void *pProgress;
00323
00324 double dfProgressBase;
00325 double dfProgressScale;
00326
00327 double *padfDstNoDataReal;
00328
00329 GDALWarpKernel();
00330 virtual ~GDALWarpKernel();
00331
00332 CPLErr Validate();
00333 CPLErr PerformWarp();
00334 };
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346 typedef struct _GDALWarpChunk GDALWarpChunk;
00347
00348 class CPL_DLL GDALWarpOperation {
00349 private:
00350 GDALWarpOptions *psOptions;
00351
00352 void WipeOptions();
00353 int ValidateOptions();
00354
00355 CPLErr ComputeSourceWindow( int nDstXOff, int nDstYOff,
00356 int nDstXSize, int nDstYSize,
00357 int *pnSrcXOff, int *pnSrcYOff,
00358 int *pnSrcXSize, int *pnSrcYSize,
00359 int *pnSrcXExtraSize, int *pnSrcYExtraSize,
00360 double* pdfSrcFillRatio );
00361
00362 CPLErr CreateKernelMask( GDALWarpKernel *, int iBand,
00363 const char *pszType );
00364
00365 CPLMutex *hIOMutex;
00366 CPLMutex *hWarpMutex;
00367
00368 int nChunkListCount;
00369 int nChunkListMax;
00370 GDALWarpChunk *pasChunkList;
00371
00372 int bReportTimings;
00373 unsigned long nLastTimeReported;
00374
00375 void WipeChunkList();
00376 CPLErr CollectChunkList( int nDstXOff, int nDstYOff,
00377 int nDstXSize, int nDstYSize );
00378 void ReportTiming( const char * );
00379
00380 public:
00381 GDALWarpOperation();
00382 virtual ~GDALWarpOperation();
00383
00384 CPLErr Initialize( const GDALWarpOptions *psNewOptions );
00385
00386 const GDALWarpOptions *GetOptions();
00387
00388 CPLErr ChunkAndWarpImage( int nDstXOff, int nDstYOff,
00389 int nDstXSize, int nDstYSize );
00390 CPLErr ChunkAndWarpMulti( int nDstXOff, int nDstYOff,
00391 int nDstXSize, int nDstYSize );
00392 CPLErr WarpRegion( int nDstXOff, int nDstYOff,
00393 int nDstXSize, int nDstYSize,
00394 int nSrcXOff=0, int nSrcYOff=0,
00395 int nSrcXSize=0, int nSrcYSize=0,
00396 double dfProgressBase=0.0, double dfProgressScale=1.0);
00397 CPLErr WarpRegion( int nDstXOff, int nDstYOff,
00398 int nDstXSize, int nDstYSize,
00399 int nSrcXOff, int nSrcYOff,
00400 int nSrcXSize, int nSrcYSize,
00401 int nSrcXExtraSize, int nSrcYExtraSize,
00402 double dfProgressBase, double dfProgressScale);
00403 CPLErr WarpRegionToBuffer( int nDstXOff, int nDstYOff,
00404 int nDstXSize, int nDstYSize,
00405 void *pDataBuf,
00406 GDALDataType eBufDataType,
00407 int nSrcXOff=0, int nSrcYOff=0,
00408 int nSrcXSize=0, int nSrcYSize=0,
00409 double dfProgressBase=0.0, double dfProgressScale=1.0);
00410 CPLErr WarpRegionToBuffer( int nDstXOff, int nDstYOff,
00411 int nDstXSize, int nDstYSize,
00412 void *pDataBuf,
00413 GDALDataType eBufDataType,
00414 int nSrcXOff, int nSrcYOff,
00415 int nSrcXSize, int nSrcYSize,
00416 int nSrcXExtraSize, int nSrcYExtraSize,
00417 double dfProgressBase, double dfProgressScale);
00418 };
00419
00420 #endif
00421
00422 CPL_C_START
00423
00424 typedef void * GDALWarpOperationH;
00425
00426 GDALWarpOperationH CPL_DLL GDALCreateWarpOperation(const GDALWarpOptions* );
00427 void CPL_DLL GDALDestroyWarpOperation( GDALWarpOperationH );
00428 CPLErr CPL_DLL GDALChunkAndWarpImage( GDALWarpOperationH, int, int, int, int );
00429 CPLErr CPL_DLL GDALChunkAndWarpMulti( GDALWarpOperationH, int, int, int, int );
00430 CPLErr CPL_DLL GDALWarpRegion( GDALWarpOperationH,
00431 int, int, int, int, int, int, int, int );
00432 CPLErr CPL_DLL GDALWarpRegionToBuffer( GDALWarpOperationH, int, int, int, int,
00433 void *, GDALDataType,
00434 int, int, int, int );
00435
00436
00437
00438
00439
00440 int GWKGetFilterRadius(GDALResampleAlg eResampleAlg);
00441
00442 typedef double (*FilterFuncType)(double dfX);
00443 FilterFuncType GWKGetFilterFunc(GDALResampleAlg eResampleAlg);
00444
00445 typedef double (*FilterFunc4ValuesType)(double* padfVals);
00446 FilterFunc4ValuesType GWKGetFilterFunc4Values(GDALResampleAlg eResampleAlg);
00447
00448 CPL_C_END
00449
00450 #endif