- Main Page
- Classes
- Files
- Related Pages

- File List
- File Members

# gdalwarper.h

Go to the documentation of this file.

    00001 /******************************************************************************
    00002  * $Id: gdalwarper.h 11407 2007-05-03 17:30:09Z dron $
    00003  *
    00004  * Project:  GDAL High Performance Warper
    00005  * Purpose:  Prototypes, and definitions for warping related work.
    00006  * Author:   Frank Warmerdam, warmerdam@pobox.com
    00007  *
    00008  ******************************************************************************
    00009  * Copyright (c) 2003, Frank Warmerdam
    00010  *
    00011  * Permission is hereby granted, free of charge, to any person obtaining a
    00012  * copy of this software and associated documentation files (the "Software"),
    00013  * to deal in the Software without restriction, including without limitation
    00014  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
    00015  * and/or sell copies of the Software, and to permit persons to whom the
    00016  * Software is furnished to do so, subject to the following conditions:
    00017  *
    00018  * The above copyright notice and this permission notice shall be included
    00019  * in all copies or substantial portions of the Software.
    00020  *
    00021  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
    00022  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00023  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    00024  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00025  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    00026  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    00027  * DEALINGS IN THE SOFTWARE.
    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 ** /*ppImageData */,
    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 ** /*ppImageData */,
    00078                         int bMaskIsFloat, void *pValidityMask );
    00079
    00080 /************************************************************************/
    00081 /*                           GDALWarpOptions                            */
    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 /*                         GDALReprojectImage()                         */
    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 /*                           VRTWarpedDataset                           */
    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 /*                            GDALWarpKernel                            */
    00224 /*                                                                      */
    00225 /*      This class represents the lowest level of abstraction.  It      */
    00226 /*      is holds the imagery for one "chunk" of a warp, and the         */
    00227 /*      pre-prepared masks.  All IO is done before and after it's       */
    00228 /*      operation.  This class is not normally used by the              */
    00229 /*      application.                                                    */
    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;   // Resampling scale, i.e.
    00256     double              dfYScale;   // nDstSize/nSrcSize.
    00257     double              dfXFilter;  // Size of filter kernel.
    00258     double              dfYFilter;
    00259     int                 nXRadius;   // Size of window to filter.
    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 /*                         GDALWarpOperation()                          */
    00286 /*                                                                      */
    00287 /*      This object is application created, or created by a higher      */
    00288 /*      level convenience function.  It is responsible for              */
    00289 /*      subdividing the operation into chunks, loading and saving       */
    00290 /*      imagery, and establishing the varios validity and density       */
    00291 /*      masks.  Actual resampling is done by the GDALWarpKernel.        */
    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 /* def __cplusplus */
    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 /* ndef GDAL_ALG_H_INCLUDED */

Generated for GDAL by 1.5.1.