GDAL
gdal_alg_priv.h
1 /******************************************************************************
2  * $Id: gdal_alg_priv.h 225923a5caa782d1543b7c0d7248b92dcc0bc8bf 2020-04-06 12:59:27 +0200 Even Rouault $
3  *
4  * Project: GDAL Image Processing Algorithms
5  * Purpose: Prototypes and definitions for various GDAL based algorithms:
6  * private declarations.
7  * Author: Andrey Kiselev, dron@ak4719.spb.edu
8  *
9  ******************************************************************************
10  * Copyright (c) 2008, Andrey Kiselev <dron@ak4719.spb.edu>
11  * Copyright (c) 2010-2013, Even Rouault <even dot rouault at spatialys.com>
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a
14  * copy of this software and associated documentation files (the "Software"),
15  * to deal in the Software without restriction, including without limitation
16  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17  * and/or sell copies of the Software, and to permit persons to whom the
18  * Software is furnished to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be included
21  * in all copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29  * DEALINGS IN THE SOFTWARE.
30  ****************************************************************************/
31 
32 #ifndef GDAL_ALG_PRIV_H_INCLUDED
33 #define GDAL_ALG_PRIV_H_INCLUDED
34 
35 #ifndef DOXYGEN_SKIP
36 
37 #include "gdal_alg.h"
38 #include "ogr_spatialref.h"
39 
41 
43 typedef enum { GBV_UserBurnValue = 0, GBV_Z = 1, GBV_M = 2
47 } GDALBurnValueSrc;
48 
49 typedef enum {
50  GRMA_Replace = 0,
51  GRMA_Add = 1,
52 } GDALRasterMergeAlg;
53 
54 typedef struct {
55  unsigned char * pabyChunkBuf;
56  int nXSize;
57  int nYSize;
58  int nBands;
59  GDALDataType eType;
60  int nPixelSpace;
61  GSpacing nLineSpace;
62  GSpacing nBandSpace;
63  const double *padfBurnValue;
64  GDALBurnValueSrc eBurnValueSource;
65  GDALRasterMergeAlg eMergeAlg;
66 } GDALRasterizeInfo;
67 
68 typedef enum {
69  GRO_Raster = 0,
70  GRO_Vector = 1,
71  GRO_Auto = 2,
72 } GDALRasterizeOptim;
73 
74 
75 /************************************************************************/
76 /* Low level rasterizer API. */
77 /************************************************************************/
78 
79 typedef void (*llScanlineFunc)( void *, int, int, int, double );
80 typedef void (*llPointFunc)( void *, int, int, double );
81 
82 void GDALdllImagePoint( int nRasterXSize, int nRasterYSize,
83  int nPartCount, const int *panPartSize,
84  const double *padfX, const double *padfY,
85  const double *padfVariant,
86  llPointFunc pfnPointFunc, void *pCBData );
87 
88 void GDALdllImageLine( int nRasterXSize, int nRasterYSize,
89  int nPartCount, const int *panPartSize,
90  const double *padfX, const double *padfY,
91  const double *padfVariant,
92  llPointFunc pfnPointFunc, void *pCBData );
93 
94 void GDALdllImageLineAllTouched( int nRasterXSize, int nRasterYSize,
95  int nPartCount, const int *panPartSize,
96  const double *padfX, const double *padfY,
97  const double *padfVariant,
98  llPointFunc pfnPointFunc, void *pCBData,
99  int bAvoidBurningSamePoints );
100 
101 void GDALdllImageFilledPolygon( int nRasterXSize, int nRasterYSize,
102  int nPartCount, const int *panPartSize,
103  const double *padfX, const double *padfY,
104  const double *padfVariant,
105  llScanlineFunc pfnScanlineFunc, void *pCBData );
106 
107 CPL_C_END
108 
109 /************************************************************************/
110 /* Polygon Enumerator */
111 /************************************************************************/
112 
113 #define GP_NODATA_MARKER -51502112
114 
115 template<class DataType, class EqualityTest> class GDALRasterPolygonEnumeratorT
116 
117 {
118 private:
119  void MergePolygon( int nSrcId, int nDstId );
120  int NewPolygon( DataType nValue );
121 
122  CPL_DISALLOW_COPY_ASSIGN(GDALRasterPolygonEnumeratorT)
123 
124 public: // these are intended to be readonly.
125 
126  GInt32 *panPolyIdMap = nullptr;
127  DataType *panPolyValue = nullptr;
128 
129  int nNextPolygonId = 0;
130  int nPolyAlloc = 0;
131 
132  int nConnectedness = 0;
133 
134 public:
135  explicit GDALRasterPolygonEnumeratorT( int nConnectedness=4 );
136  ~GDALRasterPolygonEnumeratorT();
137 
138  void ProcessLine( DataType *panLastLineVal, DataType *panThisLineVal,
139  GInt32 *panLastLineId, GInt32 *panThisLineId,
140  int nXSize );
141 
142  void CompleteMerges();
143 
144  void Clear();
145 };
146 
147 struct IntEqualityTest
148 {
149  bool operator()(GInt32 a, GInt32 b) const { return a == b; }
150 };
151 
152 typedef GDALRasterPolygonEnumeratorT<GInt32, IntEqualityTest> GDALRasterPolygonEnumerator;
153 
154 typedef void* (*GDALTransformDeserializeFunc)( CPLXMLNode *psTree );
155 
156 void CPL_DLL *GDALRegisterTransformDeserializer(const char* pszTransformName,
157  GDALTransformerFunc pfnTransformerFunc,
158  GDALTransformDeserializeFunc pfnDeserializeFunc);
159 void CPL_DLL GDALUnregisterTransformDeserializer(void* pData);
160 
161 void GDALCleanupTransformDeserializerMutex();
162 
163 /* Transformer cloning */
164 
165 void* GDALCreateTPSTransformerInt( int nGCPCount, const GDAL_GCP *pasGCPList,
166  int bReversed, char** papszOptions );
167 
168 void CPL_DLL * GDALCloneTransformer( void *pTransformerArg );
169 
170 /************************************************************************/
171 /* Color table related */
172 /************************************************************************/
173 
174 // Definitions exists for T = GUInt32 and T = GUIntBig.
175 template<class T> int
176 GDALComputeMedianCutPCTInternal( GDALRasterBandH hRed,
177  GDALRasterBandH hGreen,
178  GDALRasterBandH hBlue,
179  GByte* pabyRedBand,
180  GByte* pabyGreenBand,
181  GByte* pabyBlueBand,
182  int (*pfnIncludePixel)(int,int,void*),
183  int nColors,
184  int nBits,
185  T* panHistogram,
186  GDALColorTableH hColorTable,
187  GDALProgressFunc pfnProgress,
188  void * pProgressArg );
189 
190 int GDALDitherRGB2PCTInternal( GDALRasterBandH hRed,
191  GDALRasterBandH hGreen,
192  GDALRasterBandH hBlue,
193  GDALRasterBandH hTarget,
194  GDALColorTableH hColorTable,
195  int nBits,
196  GInt16* pasDynamicColorMap,
197  int bDither,
198  GDALProgressFunc pfnProgress,
199  void * pProgressArg );
200 
201 #define PRIME_FOR_65536 98317
202 
203 // See HashHistogram structure in gdalmediancut.cpp and ColorIndex structure in
204 // gdaldither.cpp 6 * sizeof(int) should be the size of the largest of both
205 // structures.
206 #define MEDIAN_CUT_AND_DITHER_BUFFER_SIZE_65536 (6 * sizeof(int) * PRIME_FOR_65536)
207 
208 /************************************************************************/
209 /* Float comparison function. */
210 /************************************************************************/
211 
218 #define MAX_ULPS 10
219 
220 GBool GDALFloatEquals(float A, float B);
221 
222 struct FloatEqualityTest
223 {
224  bool operator()(float a, float b) { return GDALFloatEquals(a,b) == TRUE; }
225 };
226 
227 bool GDALComputeAreaOfInterest(OGRSpatialReference* poSRS,
228  double adfGT[6],
229  int nXSize,
230  int nYSize,
231  double& dfWestLongitudeDeg,
232  double& dfSouthLatitudeDeg,
233  double& dfEastLongitudeDeg,
234  double& dfNorthLatitudeDeg );
235 
236 bool GDALComputeAreaOfInterest(OGRSpatialReference* poSRS,
237  double dfX1,
238  double dfY1,
239  double dfX2,
240  double dfY2,
241  double& dfWestLongitudeDeg,
242  double& dfSouthLatitudeDeg,
243  double& dfEastLongitudeDeg,
244  double& dfNorthLatitudeDeg );
245 
246 
247 #endif /* #ifndef DOXYGEN_SKIP */
248 
249 #endif /* ndef GDAL_ALG_PRIV_H_INCLUDED */
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:158
short GInt16
Int16 type.
Definition: cpl_port.h:211
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:339
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:337
int GBool
Type for boolean values (alias to int)
Definition: cpl_port.h:223
#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:1003
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:215
int GInt32
Int32 type.
Definition: cpl_port.h:205
GIntBig GSpacing
Type to express pixel, line or band spacing.
Definition: gdal.h:276
GDALDataType
Definition: gdal.h:60
void * GDALRasterBandH
Opaque type used for the C bindings of the C++ GDALRasterBand class.
Definition: gdal.h:261
void * GDALColorTableH
Opaque type used for the C bindings of the C++ GDALColorTable class.
Definition: gdal.h:267
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:114
Coordinate systems services.
Document node structure.
Definition: cpl_minixml.h:70
Ground Control Point.
Definition: gdal.h:664