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
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 #ifndef GDALWARPER_H_INCLUDED
00088 #define GDALWARPER_H_INCLUDED
00089
00098 #include "gdal_alg.h"
00099 #include "cpl_minixml.h"
00100
00101 CPL_C_START
00102
00104 typedef enum { GRA_NearestNeighbour=0, GRA_Bilinear=1, GRA_Cubic=2, GRA_CubicSpline=3,
00109 } GDALResampleAlg;
00110
00111 typedef int
00112 (*GDALMaskFunc)( void *pMaskFuncArg,
00113 int nBandCount, GDALDataType eType,
00114 int nXOff, int nYOff,
00115 int nXSize, int nYSize,
00116 GByte **papabyImageData,
00117 int bMaskIsFloat, void *pMask );
00118
00119 CPLErr CPL_DLL
00120 GDALWarpNoDataMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
00121 int nXOff, int nYOff, int nXSize, int nYSize,
00122 GByte **papabyImageData, int bMaskIsFloat,
00123 void *pValidityMask );
00124
00125 CPLErr CPL_DLL
00126 GDALWarpDstAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
00127 int nXOff, int nYOff, int nXSize, int nYSize,
00128 GByte ** ,
00129 int bMaskIsFloat, void *pValidityMask );
00130 CPLErr CPL_DLL
00131 GDALWarpSrcAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
00132 int nXOff, int nYOff, int nXSize, int nYSize,
00133 GByte ** ,
00134 int bMaskIsFloat, void *pValidityMask );
00135
00136
00137
00138
00139
00141 typedef struct {
00142
00143 char **papszWarpOptions;
00144
00146 double dfWarpMemoryLimit;
00147
00149 GDALResampleAlg eResampleAlg;
00150
00153 GDALDataType eWorkingDataType;
00154
00156 GDALDatasetH hSrcDS;
00157
00159 GDALDatasetH hDstDS;
00160
00162 int nBandCount;
00163
00165 int *panSrcBands;
00166
00168 int *panDstBands;
00169
00171 int nSrcAlphaBand;
00172
00174 int nDstAlphaBand;
00175
00177 double *padfSrcNoDataReal;
00180 double *padfSrcNoDataImag;
00181
00183 double *padfDstNoDataReal;
00186 double *padfDstNoDataImag;
00187
00190 GDALProgressFunc pfnProgress;
00191
00193 void *pProgressArg;
00194
00196 GDALTransformerFunc pfnTransformer;
00197
00199 void *pTransformerArg;
00200
00201 GDALMaskFunc *papfnSrcPerBandValidityMaskFunc;
00202 void **papSrcPerBandValidityMaskFuncArg;
00203
00204 GDALMaskFunc pfnSrcValidityMaskFunc;
00205 void *pSrcValidityMaskFuncArg;
00206
00207 GDALMaskFunc pfnSrcDensityMaskFunc;
00208 void *pSrcDensityMaskFuncArg;
00209
00210 GDALMaskFunc pfnDstDensityMaskFunc;
00211 void *pDstDensityMaskFuncArg;
00212
00213 GDALMaskFunc pfnDstValidityMaskFunc;
00214 void *pDstValidityMaskFuncArg;
00215
00216 CPLErr (*pfnPreWarpChunkProcessor)( void *pKern, void *pArg );
00217 void *pPreWarpProcessorArg;
00218
00219 CPLErr (*pfnPostWarpChunkProcessor)( void *pKern, void *pArg);
00220 void *pPostWarpProcessorArg;
00221
00222 } GDALWarpOptions;
00223
00224 GDALWarpOptions CPL_DLL * CPL_STDCALL GDALCreateWarpOptions(void);
00225 void CPL_DLL CPL_STDCALL GDALDestroyWarpOptions( GDALWarpOptions * );
00226 GDALWarpOptions CPL_DLL * CPL_STDCALL
00227 GDALCloneWarpOptions( const GDALWarpOptions * );
00228
00229 CPLXMLNode CPL_DLL * CPL_STDCALL
00230 GDALSerializeWarpOptions( const GDALWarpOptions * );
00231 GDALWarpOptions CPL_DLL * CPL_STDCALL
00232 GDALDeserializeWarpOptions( CPLXMLNode * );
00233
00234
00235
00236
00237
00238 CPLErr CPL_DLL CPL_STDCALL
00239 GDALReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT,
00240 GDALDatasetH hDstDS, const char *pszDstWKT,
00241 GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit,
00242 double dfMaxError,
00243 GDALProgressFunc pfnProgress, void *pProgressArg,
00244 GDALWarpOptions *psOptions );
00245
00246 CPLErr CPL_DLL CPL_STDCALL
00247 GDALCreateAndReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT,
00248 const char *pszDstFilename, const char *pszDstWKT,
00249 GDALDriverH hDstDriver, char **papszCreateOptions,
00250 GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit,
00251 double dfMaxError,
00252 GDALProgressFunc pfnProgress, void *pProgressArg,
00253 GDALWarpOptions *psOptions );
00254
00255
00256
00257
00258
00259 GDALDatasetH CPL_DLL CPL_STDCALL
00260 GDALAutoCreateWarpedVRT( GDALDatasetH hSrcDS,
00261 const char *pszSrcWKT, const char *pszDstWKT,
00262 GDALResampleAlg eResampleAlg,
00263 double dfMaxError, const GDALWarpOptions *psOptions );
00264
00265 GDALDatasetH CPL_DLL CPL_STDCALL
00266 GDALCreateWarpedVRT( GDALDatasetH hSrcDS,
00267 int nPixels, int nLines, double *padfGeoTransform,
00268 GDALWarpOptions *psOptions );
00269
00270 CPLErr CPL_DLL CPL_STDCALL
00271 GDALInitializeWarpedVRT( GDALDatasetH hDS,
00272 GDALWarpOptions *psWO );
00273
00274 CPL_C_END
00275
00276 #ifdef __cplusplus
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288 class CPL_DLL GDALWarpKernel
00289 {
00290 public:
00291 GDALWarpKernel();
00292 virtual ~GDALWarpKernel();
00293
00294 char **papszWarpOptions;
00295
00296 GDALResampleAlg eResample;
00297 GDALDataType eWorkingDataType;
00298 int nBands;
00299
00300 int nSrcXSize;
00301 int nSrcYSize;
00302 GByte **papabySrcImage;
00303
00304 GUInt32 **papanBandSrcValid;
00305 GUInt32 *panUnifiedSrcValid;
00306 float *pafUnifiedSrcDensity;
00307
00308 int nDstXSize;
00309 int nDstYSize;
00310 GByte **papabyDstImage;
00311 GUInt32 *panDstValid;
00312 float *pafDstDensity;
00313
00314 int nSrcXOff;
00315 int nSrcYOff;
00316
00317 int nDstXOff;
00318 int nDstYOff;
00319
00320 GDALTransformerFunc pfnTransformer;
00321 void *pTransformerArg;
00322
00323 GDALProgressFunc pfnProgress;
00324 void *pProgress;
00325
00326 double dfProgressBase;
00327 double dfProgressScale;
00328
00329 CPLErr Validate();
00330 CPLErr PerformWarp();
00331 };
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343 class CPL_DLL GDALWarpOperation {
00344 private:
00345 GDALWarpOptions *psOptions;
00346
00347 double dfProgressBase;
00348 double dfProgressScale;
00349
00350 void WipeOptions();
00351 int ValidateOptions();
00352
00353 CPLErr ComputeSourceWindow( int nDstXOff, int nDstYOff,
00354 int nDstXSize, int nDstYSize,
00355 int *pnSrcXOff, int *pnSrcYOff,
00356 int *pnSrcXSize, int *pnSrcYSize );
00357
00358 CPLErr CreateKernelMask( GDALWarpKernel *, int iBand,
00359 const char *pszType );
00360
00361 void *hThread1Mutex;
00362 void *hThread2Mutex;
00363 void *hIOMutex;
00364 void *hWarpMutex;
00365
00366 int nChunkListCount;
00367 int nChunkListMax;
00368 int *panChunkList;
00369
00370 int bReportTimings;
00371 unsigned long nLastTimeReported;
00372
00373 void WipeChunkList();
00374 CPLErr CollectChunkList( int nDstXOff, int nDstYOff,
00375 int nDstXSize, int nDstYSize );
00376 void ReportTiming( const char * );
00377
00378 public:
00379 GDALWarpOperation();
00380 virtual ~GDALWarpOperation();
00381
00382 CPLErr Initialize( const GDALWarpOptions *psNewOptions );
00383
00384 const GDALWarpOptions *GetOptions();
00385
00386 CPLErr ChunkAndWarpImage( int nDstXOff, int nDstYOff,
00387 int nDstXSize, int nDstYSize );
00388 CPLErr ChunkAndWarpMulti( int nDstXOff, int nDstYOff,
00389 int nDstXSize, int nDstYSize );
00390 CPLErr WarpRegion( int nDstXOff, int nDstYOff,
00391 int nDstXSize, int nDstYSize,
00392 int nSrcXOff=0, int nSrcYOff=0,
00393 int nSrcXSize=0, int nSrcYSize=0 );
00394
00395 CPLErr WarpRegionToBuffer( int nDstXOff, int nDstYOff,
00396 int nDstXSize, int nDstYSize,
00397 void *pDataBuf,
00398 GDALDataType eBufDataType,
00399 int nSrcXOff=0, int nSrcYOff=0,
00400 int nSrcXSize=0, int nSrcYSize=0 );
00401 };
00402
00403 #endif
00404
00405 CPL_C_START
00406
00407 typedef void * GDALWarpOperationH;
00408
00409 GDALWarpOperationH CPL_DLL GDALCreateWarpOperation(const GDALWarpOptions* );
00410 void CPL_DLL GDALDestroyWarpOperation( GDALWarpOperationH );
00411 CPLErr CPL_DLL GDALChunkAndWarpImage( GDALWarpOperationH, int, int, int, int );
00412 CPLErr CPL_DLL GDALChunkAndWarpMulti( GDALWarpOperationH, int, int, int, int );
00413 CPLErr CPL_DLL GDALWarpRegion( GDALWarpOperationH,
00414 int, int, int, int, int, int, int, int );
00415 CPLErr CPL_DLL GDALWarpRegionToBuffer( GDALWarpOperationH, int, int, int, int,
00416 void *, GDALDataType,
00417 int, int, int, int );
00418
00419 CPL_C_END
00420
00421 #endif