Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

gdalwarper.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  * $Id: gdalwarper.h,v 1.18 2006/11/07 16:24:08 hobu Exp $
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  * $Log: gdalwarper.h,v $
00031  * Revision 1.18  2006/11/07 16:24:08  hobu
00032  * silence errors about no prototype defined for a few functions with void parameters
00033  *
00034  * Revision 1.17  2005/04/04 15:24:16  fwarmerdam
00035  * added CPL_STDCALL to some functions
00036  *
00037  * Revision 1.16  2004/11/14 04:16:30  fwarmerdam
00038  * fixup src alpha support
00039  *
00040  * Revision 1.15  2004/10/07 15:50:18  fwarmerdam
00041  * added preliminary alpha band support
00042  *
00043  * Revision 1.14  2004/08/11 20:11:47  warmerda
00044  * added GDALInitializeWarpedVRT
00045  *
00046  * Revision 1.13  2004/08/11 19:01:25  warmerda
00047  * Added prototypes for GDALAutoCreateWarpedVRT and GDALCreateWarpedVRT
00048  *
00049  * Revision 1.12  2004/08/09 14:38:27  warmerda
00050  * added serialize/deserialize support for warpoptions and transformers
00051  *
00052  * Revision 1.11  2003/11/22 19:13:31  dron
00053  * Added C bindings for GDALWarpOperation functions.
00054  *
00055  * Revision 1.10  2003/07/04 11:50:57  dron
00056  * GRA_CubicSpline added to the list of resampling algorithms.
00057  *
00058  * Revision 1.9  2003/06/12 11:21:33  dron
00059  * Few additional comments.
00060  *
00061  * Revision 1.8  2003/05/27 20:49:25  warmerda
00062  * added REPORT_TIMINGS support
00063  *
00064  * Revision 1.7  2003/05/07 19:13:06  warmerda
00065  * added pre and post warp chunk processor
00066  *
00067  * Revision 1.6  2003/04/23 05:18:57  warmerda
00068  * added multithread support
00069  *
00070  * Revision 1.5  2003/03/02 05:25:59  warmerda
00071  * added some source nodata support
00072  *
00073  * Revision 1.4  2003/02/22 02:04:11  warmerda
00074  * added dfMaxError to reproject function
00075  *
00076  * Revision 1.3  2003/02/21 15:41:37  warmerda
00077  * added progressbase/scale for operation
00078  *
00079  * Revision 1.2  2003/02/20 21:53:06  warmerda
00080  * partial implementation
00081  *
00082  * Revision 1.1  2003/02/18 17:25:50  warmerda
00083  * New
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 ** /*ppImageData */,
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 ** /*ppImageData */,
00134                         int bMaskIsFloat, void *pValidityMask );
00135 
00136 /************************************************************************/
00137 /*                           GDALWarpOptions                            */
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 /*                         GDALReprojectImage()                         */
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 /*                           VRTWarpedDataset                           */
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 /*                            GDALWarpKernel                            */
00280 /*                                                                      */
00281 /*      This class represents the lowest level of abstraction.  It      */
00282 /*      is holds the imagery for one "chunk" of a warp, and the         */
00283 /*      pre-prepared masks.  All IO is done before and after it's       */
00284 /*      operation.  This class is not normally used by the              */
00285 /*      application.                                                    */
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 /*                         GDALWarpOperation()                          */
00335 /*                                                                      */
00336 /*      This object is application created, or created by a higher      */
00337 /*      level convenience function.  It is responsible for              */
00338 /*      subdividing the operation into chunks, loading and saving       */
00339 /*      imagery, and establishing the varios validity and density       */
00340 /*      masks.  Actual resampling is done by the GDALWarpKernel.        */
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 /* def __cplusplus */
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 /* ndef GDAL_ALG_H_INCLUDED */

Generated for GDAL by doxygen 1.4.4.