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