gdal_alg_priv.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /******************************************************************************
  2. * $Id: gdal_alg_priv.h 28826 2015-03-30 17:51:14Z 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 mines-paris dot org>
  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. #ifndef GDAL_ALG_PRIV_H_INCLUDED
  32. #define GDAL_ALG_PRIV_H_INCLUDED
  33. #include "gdal_alg.h"
  34. CPL_C_START
  35. /** Source of the burn value */
  36. typedef enum {
  37. /*! Use value from padfBurnValue */ GBV_UserBurnValue = 0,
  38. /*! Use value from the Z coordinate */ GBV_Z = 1,
  39. /*! Use value form the M value */ GBV_M = 2
  40. } GDALBurnValueSrc;
  41. typedef enum {
  42. GRMA_Replace = 0,
  43. GRMA_Add = 1,
  44. } GDALRasterMergeAlg;
  45. typedef struct {
  46. unsigned char * pabyChunkBuf;
  47. int nXSize;
  48. int nYSize;
  49. int nBands;
  50. GDALDataType eType;
  51. double *padfBurnValue;
  52. GDALBurnValueSrc eBurnValueSource;
  53. GDALRasterMergeAlg eMergeAlg;
  54. } GDALRasterizeInfo;
  55. /************************************************************************/
  56. /* Low level rasterizer API. */
  57. /************************************************************************/
  58. typedef void (*llScanlineFunc)( void *, int, int, int, double );
  59. typedef void (*llPointFunc)( void *, int, int, double );
  60. void GDALdllImagePoint( int nRasterXSize, int nRasterYSize,
  61. int nPartCount, int *panPartSize,
  62. double *padfX, double *padfY, double *padfVariant,
  63. llPointFunc pfnPointFunc, void *pCBData );
  64. void GDALdllImageLine( int nRasterXSize, int nRasterYSize,
  65. int nPartCount, int *panPartSize,
  66. double *padfX, double *padfY, double *padfVariant,
  67. llPointFunc pfnPointFunc, void *pCBData );
  68. void GDALdllImageLineAllTouched(int nRasterXSize, int nRasterYSize,
  69. int nPartCount, int *panPartSize,
  70. double *padfX, double *padfY,
  71. double *padfVariant,
  72. llPointFunc pfnPointFunc, void *pCBData );
  73. void GDALdllImageFilledPolygon(int nRasterXSize, int nRasterYSize,
  74. int nPartCount, int *panPartSize,
  75. double *padfX, double *padfY,
  76. double *padfVariant,
  77. llScanlineFunc pfnScanlineFunc, void *pCBData );
  78. CPL_C_END
  79. /************************************************************************/
  80. /* Polygon Enumerator */
  81. /************************************************************************/
  82. #define GP_NODATA_MARKER -51502112
  83. class GDALRasterPolygonEnumerator
  84. {
  85. private:
  86. void MergePolygon( int nSrcId, int nDstId );
  87. int NewPolygon( GInt32 nValue );
  88. public: // these are intended to be readonly.
  89. GInt32 *panPolyIdMap;
  90. GInt32 *panPolyValue;
  91. int nNextPolygonId;
  92. int nPolyAlloc;
  93. int nConnectedness;
  94. public:
  95. GDALRasterPolygonEnumerator( int nConnectedness=4 );
  96. ~GDALRasterPolygonEnumerator();
  97. void ProcessLine( GInt32 *panLastLineVal, GInt32 *panThisLineVal,
  98. GInt32 *panLastLineId, GInt32 *panThisLineId,
  99. int nXSize );
  100. void CompleteMerges();
  101. void Clear();
  102. };
  103. #ifdef OGR_ENABLED
  104. /************************************************************************/
  105. /* Polygon Enumerator */
  106. /* */
  107. /* Buffers has float values instead og GInt32 */
  108. /************************************************************************/
  109. class GDALRasterFPolygonEnumerator
  110. {
  111. private:
  112. void MergePolygon( int nSrcId, int nDstId );
  113. int NewPolygon( float fValue );
  114. public: // these are intended to be readonly.
  115. GInt32 *panPolyIdMap;
  116. float *pafPolyValue;
  117. int nNextPolygonId;
  118. int nPolyAlloc;
  119. int nConnectedness;
  120. public:
  121. GDALRasterFPolygonEnumerator( int nConnectedness=4 );
  122. ~GDALRasterFPolygonEnumerator();
  123. void ProcessLine( float *pafLastLineVal, float *pafThisLineVal,
  124. GInt32 *panLastLineId, GInt32 *panThisLineId,
  125. int nXSize );
  126. void CompleteMerges();
  127. void Clear();
  128. };
  129. #endif
  130. typedef void* (*GDALTransformDeserializeFunc)( CPLXMLNode *psTree );
  131. void* GDALRegisterTransformDeserializer(const char* pszTransformName,
  132. GDALTransformerFunc pfnTransformerFunc,
  133. GDALTransformDeserializeFunc pfnDeserializeFunc);
  134. void GDALUnregisterTransformDeserializer(void* pData);
  135. void GDALCleanupTransformDeserializerMutex();
  136. /* Transformer cloning */
  137. void* GDALCreateTPSTransformerInt( int nGCPCount, const GDAL_GCP *pasGCPList,
  138. int bReversed, char** papszOptions );
  139. void CPL_DLL * GDALCloneTransformer( void *pTranformerArg );
  140. /************************************************************************/
  141. /* Color table related */
  142. /************************************************************************/
  143. int
  144. GDALComputeMedianCutPCTInternal( GDALRasterBandH hRed,
  145. GDALRasterBandH hGreen,
  146. GDALRasterBandH hBlue,
  147. GByte* pabyRedBand,
  148. GByte* pabyGreenBand,
  149. GByte* pabyBlueBand,
  150. int (*pfnIncludePixel)(int,int,void*),
  151. int nColors,
  152. int nBits,
  153. int* panHistogram,
  154. GDALColorTableH hColorTable,
  155. GDALProgressFunc pfnProgress,
  156. void * pProgressArg );
  157. int GDALDitherRGB2PCTInternal( GDALRasterBandH hRed,
  158. GDALRasterBandH hGreen,
  159. GDALRasterBandH hBlue,
  160. GDALRasterBandH hTarget,
  161. GDALColorTableH hColorTable,
  162. int nBits,
  163. GInt16* pasDynamicColorMap,
  164. int bDither,
  165. GDALProgressFunc pfnProgress,
  166. void * pProgressArg );
  167. #define PRIME_FOR_65536 98317
  168. #define MEDIAN_CUT_AND_DITHER_BUFFER_SIZE_65536 (6 * sizeof(int) * PRIME_FOR_65536)
  169. /************************************************************************/
  170. /* Float comparison function. */
  171. /************************************************************************/
  172. /**
  173. * Units in the Last Place. This specifies how big an error we are willing to
  174. * accept in terms of the value of the least significant digit of the floating
  175. * point number’s representation. MAX_ULPS can also be interpreted in terms of
  176. * how many representable floats we are willing to accept between A and B.
  177. */
  178. #define MAX_ULPS 10
  179. GBool GDALFloatEquals(float A, float B);
  180. #endif /* ndef GDAL_ALG_PRIV_H_INCLUDED */