15#ifndef GDALWARPER_H_INCLUDED
16#define GDALWARPER_H_INCLUDED
28#include "cpl_multiproc.h"
72typedef int (*GDALMaskFunc)(
void *pMaskFuncArg,
int nBandCount,
74 int nXSize,
int nYSize,
GByte **papabyImageData,
75 int bMaskIsFloat,
void *pMask);
77CPLErr CPL_DLL GDALWarpNoDataMasker(
void *pMaskFuncArg,
int nBandCount,
79 int nXSize,
int nYSize,
80 GByte **papabyImageData,
int bMaskIsFloat,
81 void *pValidityMask,
int *pbOutAllValid);
83CPLErr CPL_DLL GDALWarpDstAlphaMasker(
void *pMaskFuncArg,
int nBandCount,
85 int nXSize,
int nYSize,
87 int bMaskIsFloat,
void *pValidityMask);
88CPLErr CPL_DLL GDALWarpSrcAlphaMasker(
void *pMaskFuncArg,
int nBandCount,
90 int nXSize,
int nYSize,
92 int bMaskIsFloat,
void *pValidityMask,
95CPLErr CPL_DLL GDALWarpSrcMaskMasker(
void *pMaskFuncArg,
int nBandCount,
97 int nXSize,
int nYSize,
99 int bMaskIsFloat,
void *pValidityMask);
101CPLErr CPL_DLL GDALWarpCutlineMasker(
void *pMaskFuncArg,
int nBandCount,
103 int nXSize,
int nYSize,
105 int bMaskIsFloat,
void *pValidityMask);
108#define GCMVF_PARTIAL_INTERSECTION 0
109#define GCMVF_NO_INTERSECTION 1
110#define GCMVF_CHUNK_FULLY_WITHIN_CUTLINE 2
111CPLErr CPL_DLL GDALWarpCutlineMaskerEx(
void *pMaskFuncArg,
int nBandCount,
113 int nXSize,
int nYSize,
115 int bMaskIsFloat,
void *pValidityMask,
116 int *pnValidityFlag);
225 CPLErr (*pfnPreWarpChunkProcessor)(
void *pKern,
void *pArg);
230 CPLErr (*pfnPostWarpChunkProcessor)(
void *pKern,
void *pArg);
285 double dfWarpMemoryLimit,
double dfMaxError, GDALProgressFunc pfnProgress,
289 GDALDatasetH hSrcDS,
const char *pszSrcWKT,
const char *pszDstFilename,
290 const char *pszDstWKT,
GDALDriverH hDstDriver,
char **papszCreateOptions,
291 GDALResampleAlg eResampleAlg,
double dfWarpMemoryLimit,
double dfMaxError,
292 GDALProgressFunc pfnProgress,
void *pProgressArg,
305 GDALDatasetH hSrcDS,
const char *pszSrcWKT,
const char *pszDstWKT,
318#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
335#define WARP_EXTRA_ELTS 1
447 bool bApplyVerticalShift =
false;
449 double dfMultFactorVerticalShift = 1.0;
454 std::vector<std::vector<double>> m_aadfExcludedValues{};
458 bool bWarnedAboutDstNoDataReplacement =
false;
470void *GWKThreadsCreate(
char **papszWarpOptions,
472 void *pTransformerArg);
473void GWKThreadsEnd(
void *psThreadDataIn);
487typedef struct _GDALWarpChunk GDALWarpChunk;
489struct GDALTransformerUniquePtrReleaser
491 void operator()(
void *p)
493 GDALDestroyTransformer(p);
501 std::unique_ptr<void, GDALTransformerUniquePtrReleaser>;
513 int ValidateOptions();
515 bool ComputeSourceWindowTransformPoints(
516 int nDstXOff,
int nDstYOff,
int nDstXSize,
int nDstYSize,
bool bUseGrid,
517 bool bAll,
int nStepCount,
bool bTryWithCheckWithInvertProj,
518 double &dfMinXOut,
double &dfMinYOut,
double &dfMaxXOut,
519 double &dfMaxYOut,
int &nSamplePoints,
int &nFailedCount);
521 void ComputeSourceWindowStartingFromSource(
int nDstXOff,
int nDstYOff,
522 int nDstXSize,
int nDstYSize,
526 double *padfSrcMaxY);
529 const char *pszType);
531 CPLMutex *hIOMutex =
nullptr;
532 CPLMutex *hWarpMutex =
nullptr;
534 int nChunkListCount = 0;
535 int nChunkListMax = 0;
536 GDALWarpChunk *pasChunkList =
nullptr;
538 bool bReportTimings =
false;
539 unsigned long nLastTimeReported = 0;
541 void *psThreadData =
nullptr;
545 std::vector<std::pair<double, double>> aDstXYSpecialPoints{};
547 bool m_bIsTranslationOnPixelBoundaries =
false;
549 void WipeChunkList();
550 CPLErr CollectChunkListInternal(
int nDstXOff,
int nDstYOff,
int nDstXSize,
552 void CollectChunkList(
int nDstXOff,
int nDstYOff,
int nDstXSize,
554 void ReportTiming(
const char *);
564 void *CreateDestinationBuffer(
int nDstXSize,
int nDstYSize,
565 int *pbWasInitialized =
nullptr);
566 CPLErr InitializeDestinationBuffer(
void *pDstBuffer,
int nDstXSize,
568 int *pbWasInitialized =
nullptr)
const;
569 static void DestroyDestinationBuffer(
void *pDstBuffer);
573 CPLErr ChunkAndWarpImage(
int nDstXOff,
int nDstYOff,
int nDstXSize,
575 CPLErr ChunkAndWarpMulti(
int nDstXOff,
int nDstYOff,
int nDstXSize,
577 CPLErr WarpRegion(
int nDstXOff,
int nDstYOff,
int nDstXSize,
int nDstYSize,
578 int nSrcXOff = 0,
int nSrcYOff = 0,
int nSrcXSize = 0,
579 int nSrcYSize = 0,
double dfProgressBase = 0.0,
580 double dfProgressScale = 1.0);
581 CPLErr WarpRegion(
int nDstXOff,
int nDstYOff,
int nDstXSize,
int nDstYSize,
582 int nSrcXOff,
int nSrcYOff,
int nSrcXSize,
int nSrcYSize,
583 double dfSrcXExtraSize,
double dfSrcYExtraSize,
584 double dfProgressBase,
double dfProgressScale);
585 CPLErr WarpRegionToBuffer(
int nDstXOff,
int nDstYOff,
int nDstXSize,
586 int nDstYSize,
void *pDataBuf,
588 int nSrcYOff = 0,
int nSrcXSize = 0,
589 int nSrcYSize = 0,
double dfProgressBase = 0.0,
590 double dfProgressScale = 1.0);
591 CPLErr WarpRegionToBuffer(
int nDstXOff,
int nDstYOff,
int nDstXSize,
592 int nDstYSize,
void *pDataBuf,
594 int nSrcYOff,
int nSrcXSize,
int nSrcYSize,
595 double dfSrcXExtraSize,
double dfSrcYExtraSize,
596 double dfProgressBase,
double dfProgressScale);
599 friend class VRTWarpedDataset;
600 CPLErr ComputeSourceWindow(
int nDstXOff,
int nDstYOff,
int nDstXSize,
601 int nDstYSize,
int *pnSrcXOff,
int *pnSrcYOff,
602 int *pnSrcXSize,
int *pnSrcYSize,
603 double *pdfSrcXExtraSize,
604 double *pdfSrcYExtraSize,
605 double *pdfSrcFillRatio);
607 double GetWorkingMemoryForWindow(
int nSrcXSize,
int nSrcYSize,
608 int nDstXSize,
int nDstYSize)
const;
634typedef double (*FilterFuncType)(
double dfX);
638typedef double (*FilterFunc4ValuesType)(
double *padfVals);
639FilterFunc4ValuesType GWKGetFilterFunc4Values(
GDALResampleAlg eResampleAlg);
This class represents the lowest level of abstraction of warping.
Definition gdalwarper.h:345
int nXRadius
X size of window to filter.
Definition gdalwarper.h:403
int nSrcYSize
Height of the source image.
Definition gdalwarper.h:362
char ** papszWarpOptions
Warp options.
Definition gdalwarper.h:350
int nFiltInitX
X filtering offset.
Definition gdalwarper.h:407
double dfXScale
X resampling scale, i.e.
Definition gdalwarper.h:395
double dfYFilter
Y size of filter kernel.
Definition gdalwarper.h:401
int nDstXSize
Width of the destination image.
Definition gdalwarper.h:384
double dfSrcXExtraSize
Extra pixels (included in nSrcXSize) reserved for filter window.
Definition gdalwarper.h:365
double * padfDstNoDataReal
Array of nBands value for destination nodata.
Definition gdalwarper.h:441
int nDstXOff
X offset of the destination buffer regarding the top-left corner of the image.
Definition gdalwarper.h:420
GDALResampleAlg eResample
Resample algorithm.
Definition gdalwarper.h:353
GDALTransformerFunc pfnTransformer
Pixel transformation function.
Definition gdalwarper.h:426
GUInt32 * panUnifiedSrcValid
Unified validity mask of size (nSrcXSize * nSrcYSize + WARP_EXTRA_ELTS) / 8.
Definition gdalwarper.h:378
int nDstYSize
Height of the destination image.
Definition gdalwarper.h:386
int nBands
Number of input and output bands (excluding alpha bands)
Definition gdalwarper.h:357
double dfProgressBase
Base/offset value for progress computation.
Definition gdalwarper.h:436
GDALDataType eWorkingDataType
Working data type.
Definition gdalwarper.h:355
double dfSrcYExtraSize
Extra pixels (included in nSrcYSize) reserved for filter window.
Definition gdalwarper.h:368
int nSrcXOff
X offset of the source buffer regarding the top-left corner of the image.
Definition gdalwarper.h:413
int nSrcYOff
Y offset of the source buffer regarding the top-left corner of the image.
Definition gdalwarper.h:416
int nDstYOff
Y offset of the destination buffer regarding the top-left corner of the image.
Definition gdalwarper.h:423
int nFiltInitY
Y filtering offset.
Definition gdalwarper.h:409
GDALProgressFunc pfnProgress
Progress function.
Definition gdalwarper.h:431
GUInt32 ** papanBandSrcValid
Array of nBands validity mask of size (nSrcXSize * nSrcYSize + WARP_EXTRA_ELTS) / 8.
Definition gdalwarper.h:375
void * pProgress
User data provided to pfnProgress.
Definition gdalwarper.h:433
float * pafUnifiedSrcDensity
Unified source density of size nSrcXSize * nSrcYSize + WARP_EXTRA_ELTS.
Definition gdalwarper.h:381
int nYRadius
Y size of window to filter.
Definition gdalwarper.h:405
float * pafDstDensity
Destination density of size nDstXSize * nDstYSize.
Definition gdalwarper.h:392
double dfXFilter
X size of filter kernel.
Definition gdalwarper.h:399
double dfYScale
Y resampling scale, i.e.
Definition gdalwarper.h:397
GByte ** papabyDstImage
Array of nBands destination images of size nDstXSize * nDstYSize.
Definition gdalwarper.h:388
double dfProgressScale
Scale value for progress computation.
Definition gdalwarper.h:438
int nSrcXSize
Width of the source image.
Definition gdalwarper.h:360
void * pTransformerArg
User data provided to pfnTransformer.
Definition gdalwarper.h:428
GByte ** papabySrcImage
Array of nBands source images of size nSrcXSize * nSrcYSize.
Definition gdalwarper.h:371
GUInt32 * panDstValid
Validify mask of size (nDstXSize * nDstYSize) / 8.
Definition gdalwarper.h:390
High level image warping class.
Definition gdalwarper.h:504
CPLErr
Error category / error level.
Definition cpl_error.h:45
Definitions for CPL mini XML Parser/Serializer.
#define CPL_C_END
Macro to end a block of C symbols.
Definition cpl_port.h:279
#define CPL_C_START
Macro to start a block of C symbols.
Definition cpl_port.h:275
unsigned int GUInt32
Unsigned int32 type.
Definition cpl_port.h:157
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition cpl_port.h:1101
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1252
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:165
GDALDataType
Definition gdal.h:48
Public (C callable) GDAL algorithm entry points, and definitions.
int(* GDALTransformerFunc)(void *pTransformerArg, int bDstToSrc, int nPointCount, double *x, double *y, double *z, int *panSuccess)
Definition gdal_alg.h:79
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition gdal_fwd.h:42
void * GDALDriverH
Opaque type used for the C bindings of the C++ GDALDriver class.
Definition gdal_fwd.h:51
CPLErr GDALWarpRegion(GDALWarpOperationH, int, int, int, int, int, int, int, int)
Definition gdalwarpoperation.cpp:1843
void GDALDestroyWarpOperation(GDALWarpOperationH)
Definition gdalwarpoperation.cpp:945
GDALWarpOperationH GDALCreateWarpOperation(const GDALWarpOptions *)
Definition gdalwarpoperation.cpp:925
GWKTieStrategy
Definition gdalwarper.h:122
void GDALWarpInitDstNoDataImag(GDALWarpOptions *, double dNoDataImag)
Initialize padfDstNoDataImag with specified value.
Definition gdalwarper.cpp:1726
GDALResampleAlg
Definition gdalwarper.h:36
@ GRA_CubicSpline
Definition gdalwarper.h:41
@ GRA_Q1
Definition gdalwarper.h:57
@ GRA_Sum
Definition gdalwarper.h:62
@ GRA_Max
Definition gdalwarper.h:50
@ GRA_Cubic
Definition gdalwarper.h:40
@ GRA_Min
Definition gdalwarper.h:52
@ GRA_RMS
Definition gdalwarper.h:65
@ GRA_Lanczos
Definition gdalwarper.h:42
@ GRA_Mode
Definition gdalwarper.h:48
@ GRA_NearestNeighbour
Definition gdalwarper.h:37
@ GRA_Q3
Definition gdalwarper.h:59
@ GRA_Med
Definition gdalwarper.h:54
@ GRA_Average
Definition gdalwarper.h:45
@ GRA_Bilinear
Definition gdalwarper.h:39
void GDALDestroyWarpOptions(GDALWarpOptions *)
Destroy a warp options structure.
Definition gdalwarper.cpp:1560
void * GDALWarpOperationH
Opaque type representing a GDALWarpOperation object.
Definition gdalwarper.h:616
CPLErr GDALWarpRegionToBuffer(GDALWarpOperationH, int, int, int, int, void *, GDALDataType, int, int, int, int)
Definition gdalwarpoperation.cpp:2481
CPLErr GDALCreateAndReprojectImage(GDALDatasetH hSrcDS, const char *pszSrcWKT, const char *pszDstFilename, const char *pszDstWKT, GDALDriverH hDstDriver, char **papszCreateOptions, GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit, double dfMaxError, GDALProgressFunc pfnProgress, void *pProgressArg, GDALWarpOptions *psOptions)
Reproject an image and create the target reprojected image.
Definition gdalwarper.cpp:221
GDALDatasetH GDALCreateWarpedVRT(GDALDatasetH hSrcDS, int nPixels, int nLines, const double *padfGeoTransform, GDALWarpOptions *psOptions)
Create virtual warped dataset.
Definition vrtwarped.cpp:372
CPLErr GDALChunkAndWarpImage(GDALWarpOperationH, int, int, int, int)
Definition gdalwarpoperation.cpp:1111
GDALDatasetH GDALAutoCreateWarpedVRTEx(GDALDatasetH hSrcDS, const char *pszSrcWKT, const char *pszDstWKT, GDALResampleAlg eResampleAlg, double dfMaxError, const GDALWarpOptions *psOptions, CSLConstList papszTransformerOptions)
Create virtual warped dataset automatically.
Definition vrtwarped.cpp:139
std::unique_ptr< void, GDALTransformerUniquePtrReleaser > GDALTransformerArgUniquePtr
Unique pointer for the argument of a GDALTransformerFunc.
Definition gdalwarper.h:501
void GDALWarpInitDefaultBandMapping(GDALWarpOptions *, int nBandCount)
Init src and dst band mappings such that Bands[i] = i+1 for nBandCount Does nothing if psOptionsIn->n...
Definition gdalwarper.cpp:1898
GDALDatasetH GDALAutoCreateWarpedVRT(GDALDatasetH hSrcDS, const char *pszSrcWKT, const char *pszDstWKT, GDALResampleAlg eResampleAlg, double dfMaxError, const GDALWarpOptions *psOptions)
Create virtual warped dataset automatically.
Definition vrtwarped.cpp:118
void GDALWarpInitSrcNoDataImag(GDALWarpOptions *, double dNoDataImag)
Initialize padfSrcNoDataImag with specified value.
Definition gdalwarper.cpp:1745
CPLErr GDALInitializeWarpedVRT(GDALDatasetH hDS, GDALWarpOptions *psWO)
Set warp info on virtual warped dataset.
Definition vrtwarped.cpp:1340
void GDALWarpInitSrcNoDataReal(GDALWarpOptions *, double dNoDataReal)
Initialize padfSrcNoDataReal with specified value.
Definition gdalwarper.cpp:1688
void GDALWarpInitDstNoDataReal(GDALWarpOptions *, double dNoDataReal)
Initialize padfDstNoDataReal with specified value.
Definition gdalwarper.cpp:1669
CPLErr GDALReprojectImage(GDALDatasetH hSrcDS, const char *pszSrcWKT, GDALDatasetH hDstDS, const char *pszDstWKT, GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit, double dfMaxError, GDALProgressFunc pfnProgress, void *pProgressArg, GDALWarpOptions *psOptions)
Reproject image.
Definition gdalwarper.cpp:84
CPLErr GDALChunkAndWarpMulti(GDALWarpOperationH, int, int, int, int)
Definition gdalwarpoperation.cpp:1361
const char * GDALWarpGetOptionList(void)
Return a XML string describing options accepted by GDALWarpOptions::papszWarpOptions.
Definition gdalwarper.cpp:1086
GDALWarpOptions * GDALCreateWarpOptions(void)
Create a warp options structure.
Definition gdalwarper.cpp:1540
void GDALWarpInitNoDataReal(GDALWarpOptions *, double dNoDataReal)
Initialize padfSrcNoDataReal and padfDstNoDataReal with specified value.
Definition gdalwarper.cpp:1708
bool GDALGetWarpResampleAlg(const char *pszResampling, GDALResampleAlg &eResampleAlg, bool bThrow=false)
Return a GDALResampleAlg from a string.
Definition gdalwarper.cpp:2468
GDALWarpOptions * GDALCloneWarpOptions(const GDALWarpOptions *)
Clone a warp options structure.
Definition gdalwarper.cpp:1605
void GDALWarpResolveWorkingDataType(GDALWarpOptions *)
If the working data type is unknown, this method will determine a valid working data type to support ...
Definition gdalwarper.cpp:1765
Document node structure.
Definition cpl_minixml.h:54
Warp control options for use with GDALWarpOperation::Initialize()
Definition gdalwarper.h:134
int nSrcAlphaBand
Definition gdalwarper.h:165
GDALDatasetH hDstDS
Definition gdalwarper.h:153
char ** papszWarpOptions
A string list of additional options controlling the warp operation in name=value format.
Definition gdalwarper.h:136
double * padfDstNoDataImag
Definition gdalwarper.h:184
GDALMaskFunc pfnDstValidityMaskFunc
Unused.
Definition gdalwarper.h:220
double * padfSrcNoDataReal
Definition gdalwarper.h:172
void * pTransformerArg
Definition gdalwarper.h:197
GDALDataType eWorkingDataType
Definition gdalwarper.h:146
void * pSrcValidityMaskFuncArg
Unused.
Definition gdalwarper.h:207
void * pDstDensityMaskFuncArg
Unused.
Definition gdalwarper.h:217
int * panDstBands
Definition gdalwarper.h:162
double dfCutlineBlendDist
Definition gdalwarper.h:239
GDALProgressFunc pfnProgress
Definition gdalwarper.h:188
GDALMaskFunc pfnSrcDensityMaskFunc
Unused.
Definition gdalwarper.h:210
GDALDatasetH hSrcDS
Definition gdalwarper.h:149
GDALMaskFunc pfnDstDensityMaskFunc
Unused.
Definition gdalwarper.h:215
void * pPreWarpProcessorArg
Unused.
Definition gdalwarper.h:227
void * pProgressArg
Definition gdalwarper.h:191
int nDstAlphaBand
Definition gdalwarper.h:168
int * panSrcBands
Definition gdalwarper.h:159
GDALTransformerFunc pfnTransformer
Definition gdalwarper.h:194
int nBandCount
Definition gdalwarper.h:156
double dfWarpMemoryLimit
Definition gdalwarper.h:139
void * pSrcDensityMaskFuncArg
Unused.
Definition gdalwarper.h:212
GDALMaskFunc * papfnSrcPerBandValidityMaskFunc
Unused.
Definition gdalwarper.h:200
GDALResampleAlg eResampleAlg
Definition gdalwarper.h:142
GDALMaskFunc pfnSrcValidityMaskFunc
Unused.
Definition gdalwarper.h:205
void * hCutline
Definition gdalwarper.h:235
void * pDstValidityMaskFuncArg
Unused.
Definition gdalwarper.h:222
GWKTieStrategy eTieStrategy
Tie-breaking method.
Definition gdalwarper.h:242
void ** papSrcPerBandValidityMaskFuncArg
Unused.
Definition gdalwarper.h:202
double * padfDstNoDataReal
Definition gdalwarper.h:180
double * padfSrcNoDataImag
Definition gdalwarper.h:176
void * pPostWarpProcessorArg
Unused.
Definition gdalwarper.h:232