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 GDALWARPER_H_INCLUDED
00031 #define GDALWARPER_H_INCLUDED
00032
00041 #include "gdal_alg.h"
00042 #include "cpl_minixml.h"
00043
00044 CPL_C_START
00045
00047 typedef enum { GRA_NearestNeighbour=0, GRA_Bilinear=1, GRA_Cubic=2, GRA_CubicSpline=3, GRA_Lanczos=4
00053 } GDALResampleAlg;
00054
00055 typedef int
00056 (*GDALMaskFunc)( void *pMaskFuncArg,
00057 int nBandCount, GDALDataType eType,
00058 int nXOff, int nYOff,
00059 int nXSize, int nYSize,
00060 GByte **papabyImageData,
00061 int bMaskIsFloat, void *pMask );
00062
00063 CPLErr CPL_DLL
00064 GDALWarpNoDataMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
00065 int nXOff, int nYOff, int nXSize, int nYSize,
00066 GByte **papabyImageData, int bMaskIsFloat,
00067 void *pValidityMask );
00068
00069 CPLErr CPL_DLL
00070 GDALWarpDstAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
00071 int nXOff, int nYOff, int nXSize, int nYSize,
00072 GByte ** ,
00073 int bMaskIsFloat, void *pValidityMask );
00074 CPLErr CPL_DLL
00075 GDALWarpSrcAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
00076 int nXOff, int nYOff, int nXSize, int nYSize,
00077 GByte ** ,
00078 int bMaskIsFloat, void *pValidityMask );
00079
00080 CPLErr CPL_DLL
00081 GDALWarpCutlineMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
00082 int nXOff, int nYOff, int nXSize, int nYSize,
00083 GByte ** ,
00084 int bMaskIsFloat, void *pValidityMask );
00085
00086
00087
00088
00089
00091 typedef struct {
00092
00093 char **papszWarpOptions;
00094
00096 double dfWarpMemoryLimit;
00097
00099 GDALResampleAlg eResampleAlg;
00100
00103 GDALDataType eWorkingDataType;
00104
00106 GDALDatasetH hSrcDS;
00107
00109 GDALDatasetH hDstDS;
00110
00112 int nBandCount;
00113
00115 int *panSrcBands;
00116
00118 int *panDstBands;
00119
00121 int nSrcAlphaBand;
00122
00124 int nDstAlphaBand;
00125
00127 double *padfSrcNoDataReal;
00130 double *padfSrcNoDataImag;
00131
00133 double *padfDstNoDataReal;
00136 double *padfDstNoDataImag;
00137
00140 GDALProgressFunc pfnProgress;
00141
00143 void *pProgressArg;
00144
00146 GDALTransformerFunc pfnTransformer;
00147
00149 void *pTransformerArg;
00150
00151 GDALMaskFunc *papfnSrcPerBandValidityMaskFunc;
00152 void **papSrcPerBandValidityMaskFuncArg;
00153
00154 GDALMaskFunc pfnSrcValidityMaskFunc;
00155 void *pSrcValidityMaskFuncArg;
00156
00157 GDALMaskFunc pfnSrcDensityMaskFunc;
00158 void *pSrcDensityMaskFuncArg;
00159
00160 GDALMaskFunc pfnDstDensityMaskFunc;
00161 void *pDstDensityMaskFuncArg;
00162
00163 GDALMaskFunc pfnDstValidityMaskFunc;
00164 void *pDstValidityMaskFuncArg;
00165
00166 CPLErr (*pfnPreWarpChunkProcessor)( void *pKern, void *pArg );
00167 void *pPreWarpProcessorArg;
00168
00169 CPLErr (*pfnPostWarpChunkProcessor)( void *pKern, void *pArg);
00170 void *pPostWarpProcessorArg;
00171
00172 void *hCutline;
00173 double dfCutlineBlendDist;
00174
00175 } GDALWarpOptions;
00176
00177 GDALWarpOptions CPL_DLL * CPL_STDCALL GDALCreateWarpOptions(void);
00178 void CPL_DLL CPL_STDCALL GDALDestroyWarpOptions( GDALWarpOptions * );
00179 GDALWarpOptions CPL_DLL * CPL_STDCALL
00180 GDALCloneWarpOptions( const GDALWarpOptions * );
00181
00182 CPLXMLNode CPL_DLL * CPL_STDCALL
00183 GDALSerializeWarpOptions( const GDALWarpOptions * );
00184 GDALWarpOptions CPL_DLL * CPL_STDCALL
00185 GDALDeserializeWarpOptions( CPLXMLNode * );
00186
00187
00188
00189
00190
00191 CPLErr CPL_DLL CPL_STDCALL
00192 GDALReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT,
00193 GDALDatasetH hDstDS, const char *pszDstWKT,
00194 GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit,
00195 double dfMaxError,
00196 GDALProgressFunc pfnProgress, void *pProgressArg,
00197 GDALWarpOptions *psOptions );
00198
00199 CPLErr CPL_DLL CPL_STDCALL
00200 GDALCreateAndReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT,
00201 const char *pszDstFilename, const char *pszDstWKT,
00202 GDALDriverH hDstDriver, char **papszCreateOptions,
00203 GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit,
00204 double dfMaxError,
00205 GDALProgressFunc pfnProgress, void *pProgressArg,
00206 GDALWarpOptions *psOptions );
00207
00208
00209
00210
00211
00212 GDALDatasetH CPL_DLL CPL_STDCALL
00213 GDALAutoCreateWarpedVRT( GDALDatasetH hSrcDS,
00214 const char *pszSrcWKT, const char *pszDstWKT,
00215 GDALResampleAlg eResampleAlg,
00216 double dfMaxError, const GDALWarpOptions *psOptions );
00217
00218 GDALDatasetH CPL_DLL CPL_STDCALL
00219 GDALCreateWarpedVRT( GDALDatasetH hSrcDS,
00220 int nPixels, int nLines, double *padfGeoTransform,
00221 GDALWarpOptions *psOptions );
00222
00223 CPLErr CPL_DLL CPL_STDCALL
00224 GDALInitializeWarpedVRT( GDALDatasetH hDS,
00225 GDALWarpOptions *psWO );
00226
00227 CPL_C_END
00228
00229 #ifdef __cplusplus
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241 class CPL_DLL GDALWarpKernel
00242 {
00243 public:
00244 char **papszWarpOptions;
00245
00246 GDALResampleAlg eResample;
00247 GDALDataType eWorkingDataType;
00248 int nBands;
00249
00250 int nSrcXSize;
00251 int nSrcYSize;
00252 GByte **papabySrcImage;
00253
00254 GUInt32 **papanBandSrcValid;
00255 GUInt32 *panUnifiedSrcValid;
00256 float *pafUnifiedSrcDensity;
00257
00258 int nDstXSize;
00259 int nDstYSize;
00260 GByte **papabyDstImage;
00261 GUInt32 *panDstValid;
00262 float *pafDstDensity;
00263
00264 double dfXScale;
00265 double dfYScale;
00266 double dfXFilter;
00267 double dfYFilter;
00268 int nXRadius;
00269 int nYRadius;
00270 int nFiltInitX;
00271 int nFiltInitY;
00272
00273 int nSrcXOff;
00274 int nSrcYOff;
00275
00276 int nDstXOff;
00277 int nDstYOff;
00278
00279 GDALTransformerFunc pfnTransformer;
00280 void *pTransformerArg;
00281
00282 GDALProgressFunc pfnProgress;
00283 void *pProgress;
00284
00285 double dfProgressBase;
00286 double dfProgressScale;
00287
00288 GDALWarpKernel();
00289 virtual ~GDALWarpKernel();
00290
00291 CPLErr Validate();
00292 CPLErr PerformWarp();
00293 };
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305 class CPL_DLL GDALWarpOperation {
00306 private:
00307 GDALWarpOptions *psOptions;
00308
00309 double dfProgressBase;
00310 double dfProgressScale;
00311
00312 void WipeOptions();
00313 int ValidateOptions();
00314
00315 CPLErr ComputeSourceWindow( int nDstXOff, int nDstYOff,
00316 int nDstXSize, int nDstYSize,
00317 int *pnSrcXOff, int *pnSrcYOff,
00318 int *pnSrcXSize, int *pnSrcYSize );
00319
00320 CPLErr CreateKernelMask( GDALWarpKernel *, int iBand,
00321 const char *pszType );
00322
00323 void *hThread1Mutex;
00324 void *hThread2Mutex;
00325 void *hIOMutex;
00326 void *hWarpMutex;
00327
00328 int nChunkListCount;
00329 int nChunkListMax;
00330 int *panChunkList;
00331
00332 int bReportTimings;
00333 unsigned long nLastTimeReported;
00334
00335 void WipeChunkList();
00336 CPLErr CollectChunkList( int nDstXOff, int nDstYOff,
00337 int nDstXSize, int nDstYSize );
00338 void ReportTiming( const char * );
00339
00340 public:
00341 GDALWarpOperation();
00342 virtual ~GDALWarpOperation();
00343
00344 CPLErr Initialize( const GDALWarpOptions *psNewOptions );
00345
00346 const GDALWarpOptions *GetOptions();
00347
00348 CPLErr ChunkAndWarpImage( int nDstXOff, int nDstYOff,
00349 int nDstXSize, int nDstYSize );
00350 CPLErr ChunkAndWarpMulti( int nDstXOff, int nDstYOff,
00351 int nDstXSize, int nDstYSize );
00352 CPLErr WarpRegion( int nDstXOff, int nDstYOff,
00353 int nDstXSize, int nDstYSize,
00354 int nSrcXOff=0, int nSrcYOff=0,
00355 int nSrcXSize=0, int nSrcYSize=0 );
00356
00357 CPLErr WarpRegionToBuffer( int nDstXOff, int nDstYOff,
00358 int nDstXSize, int nDstYSize,
00359 void *pDataBuf,
00360 GDALDataType eBufDataType,
00361 int nSrcXOff=0, int nSrcYOff=0,
00362 int nSrcXSize=0, int nSrcYSize=0 );
00363 };
00364
00365 #endif
00366
00367 CPL_C_START
00368
00369 typedef void * GDALWarpOperationH;
00370
00371 GDALWarpOperationH CPL_DLL GDALCreateWarpOperation(const GDALWarpOptions* );
00372 void CPL_DLL GDALDestroyWarpOperation( GDALWarpOperationH );
00373 CPLErr CPL_DLL GDALChunkAndWarpImage( GDALWarpOperationH, int, int, int, int );
00374 CPLErr CPL_DLL GDALChunkAndWarpMulti( GDALWarpOperationH, int, int, int, int );
00375 CPLErr CPL_DLL GDALWarpRegion( GDALWarpOperationH,
00376 int, int, int, int, int, int, int, int );
00377 CPLErr CPL_DLL GDALWarpRegionToBuffer( GDALWarpOperationH, int, int, int, int,
00378 void *, GDALDataType,
00379 int, int, int, int );
00380
00381 CPL_C_END
00382
00383 #endif