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