gooderp18绿色标准版
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

248 行
9.6KB

  1. /******************************************************************************
  2. * $Id: gdal_alg_priv.h e40d0a17ddb8ca683d53dd68777a74094f8f1bde 2019-03-12 13:31:28 +0100 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 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. #ifndef DOXYGEN_SKIP
  34. #include "gdal_alg.h"
  35. #include "ogr_spatialref.h"
  36. CPL_C_START
  37. /** Source of the burn value */
  38. typedef enum {
  39. /*! Use value from padfBurnValue */ GBV_UserBurnValue = 0,
  40. /*! Use value from the Z coordinate */ GBV_Z = 1,
  41. /*! Use value form the M value */ GBV_M = 2
  42. } GDALBurnValueSrc;
  43. typedef enum {
  44. GRMA_Replace = 0,
  45. GRMA_Add = 1,
  46. } GDALRasterMergeAlg;
  47. typedef struct {
  48. unsigned char * pabyChunkBuf;
  49. int nXSize;
  50. int nYSize;
  51. int nBands;
  52. GDALDataType eType;
  53. int nPixelSpace;
  54. GSpacing nLineSpace;
  55. GSpacing nBandSpace;
  56. double *padfBurnValue;
  57. GDALBurnValueSrc eBurnValueSource;
  58. GDALRasterMergeAlg eMergeAlg;
  59. } GDALRasterizeInfo;
  60. typedef enum {
  61. GRO_Raster = 0,
  62. GRO_Vector = 1,
  63. GRO_Auto = 2,
  64. } GDALRasterizeOptim;
  65. /************************************************************************/
  66. /* Low level rasterizer API. */
  67. /************************************************************************/
  68. typedef void (*llScanlineFunc)( void *, int, int, int, double );
  69. typedef void (*llPointFunc)( void *, int, int, double );
  70. void GDALdllImagePoint( int nRasterXSize, int nRasterYSize,
  71. int nPartCount, int *panPartSize,
  72. double *padfX, double *padfY, double *padfVariant,
  73. llPointFunc pfnPointFunc, void *pCBData );
  74. void GDALdllImageLine( int nRasterXSize, int nRasterYSize,
  75. int nPartCount, int *panPartSize,
  76. double *padfX, double *padfY, double *padfVariant,
  77. llPointFunc pfnPointFunc, void *pCBData );
  78. void GDALdllImageLineAllTouched( int nRasterXSize, int nRasterYSize,
  79. int nPartCount, int *panPartSize,
  80. double *padfX, double *padfY,
  81. double *padfVariant,
  82. llPointFunc pfnPointFunc, void *pCBData,
  83. int bAvoidBurningSamePoints );
  84. void GDALdllImageFilledPolygon( int nRasterXSize, int nRasterYSize,
  85. int nPartCount, int *panPartSize,
  86. double *padfX, double *padfY,
  87. double *padfVariant,
  88. llScanlineFunc pfnScanlineFunc, void *pCBData );
  89. CPL_C_END
  90. /************************************************************************/
  91. /* Polygon Enumerator */
  92. /************************************************************************/
  93. #define GP_NODATA_MARKER -51502112
  94. template<class DataType, class EqualityTest> class GDALRasterPolygonEnumeratorT
  95. {
  96. private:
  97. void MergePolygon( int nSrcId, int nDstId );
  98. int NewPolygon( DataType nValue );
  99. CPL_DISALLOW_COPY_ASSIGN(GDALRasterPolygonEnumeratorT)
  100. public: // these are intended to be readonly.
  101. GInt32 *panPolyIdMap = nullptr;
  102. DataType *panPolyValue = nullptr;
  103. int nNextPolygonId = 0;
  104. int nPolyAlloc = 0;
  105. int nConnectedness = 0;
  106. public:
  107. explicit GDALRasterPolygonEnumeratorT( int nConnectedness=4 );
  108. ~GDALRasterPolygonEnumeratorT();
  109. void ProcessLine( DataType *panLastLineVal, DataType *panThisLineVal,
  110. GInt32 *panLastLineId, GInt32 *panThisLineId,
  111. int nXSize );
  112. void CompleteMerges();
  113. void Clear();
  114. };
  115. struct IntEqualityTest
  116. {
  117. bool operator()(GInt32 a, GInt32 b) const { return a == b; }
  118. };
  119. typedef GDALRasterPolygonEnumeratorT<GInt32, IntEqualityTest> GDALRasterPolygonEnumerator;
  120. typedef void* (*GDALTransformDeserializeFunc)( CPLXMLNode *psTree );
  121. void CPL_DLL *GDALRegisterTransformDeserializer(const char* pszTransformName,
  122. GDALTransformerFunc pfnTransformerFunc,
  123. GDALTransformDeserializeFunc pfnDeserializeFunc);
  124. void CPL_DLL GDALUnregisterTransformDeserializer(void* pData);
  125. void GDALCleanupTransformDeserializerMutex();
  126. /* Transformer cloning */
  127. void* GDALCreateTPSTransformerInt( int nGCPCount, const GDAL_GCP *pasGCPList,
  128. int bReversed, char** papszOptions );
  129. void CPL_DLL * GDALCloneTransformer( void *pTransformerArg );
  130. /************************************************************************/
  131. /* Color table related */
  132. /************************************************************************/
  133. // Definitions exists for T = GUInt32 and T = GUIntBig.
  134. template<class T> int
  135. GDALComputeMedianCutPCTInternal( GDALRasterBandH hRed,
  136. GDALRasterBandH hGreen,
  137. GDALRasterBandH hBlue,
  138. GByte* pabyRedBand,
  139. GByte* pabyGreenBand,
  140. GByte* pabyBlueBand,
  141. int (*pfnIncludePixel)(int,int,void*),
  142. int nColors,
  143. int nBits,
  144. T* panHistogram,
  145. GDALColorTableH hColorTable,
  146. GDALProgressFunc pfnProgress,
  147. void * pProgressArg );
  148. int GDALDitherRGB2PCTInternal( GDALRasterBandH hRed,
  149. GDALRasterBandH hGreen,
  150. GDALRasterBandH hBlue,
  151. GDALRasterBandH hTarget,
  152. GDALColorTableH hColorTable,
  153. int nBits,
  154. GInt16* pasDynamicColorMap,
  155. int bDither,
  156. GDALProgressFunc pfnProgress,
  157. void * pProgressArg );
  158. #define PRIME_FOR_65536 98317
  159. // See HashHistogram structure in gdalmediancut.cpp and ColorIndex structure in
  160. // gdaldither.cpp 6 * sizeof(int) should be the size of the largest of both
  161. // structures.
  162. #define MEDIAN_CUT_AND_DITHER_BUFFER_SIZE_65536 (6 * sizeof(int) * PRIME_FOR_65536)
  163. /************************************************************************/
  164. /* Float comparison function. */
  165. /************************************************************************/
  166. /**
  167. * Units in the Last Place. This specifies how big an error we are willing to
  168. * accept in terms of the value of the least significant digit of the floating
  169. * point number’s representation. MAX_ULPS can also be interpreted in terms of
  170. * how many representable floats we are willing to accept between A and B.
  171. */
  172. #define MAX_ULPS 10
  173. GBool GDALFloatEquals(float A, float B);
  174. struct FloatEqualityTest
  175. {
  176. bool operator()(float a, float b) { return GDALFloatEquals(a,b) == TRUE; }
  177. };
  178. bool GDALComputeAreaOfInterest(OGRSpatialReference* poSRS,
  179. double adfGT[6],
  180. int nXSize,
  181. int nYSize,
  182. double& dfWestLongitudeDeg,
  183. double& dfSouthLatitudeDeg,
  184. double& dfEastLongitudeDeg,
  185. double& dfNorthLatitudeDeg );
  186. bool GDALComputeAreaOfInterest(OGRSpatialReference* poSRS,
  187. double dfX1,
  188. double dfY1,
  189. double dfX2,
  190. double dfY2,
  191. double& dfWestLongitudeDeg,
  192. double& dfSouthLatitudeDeg,
  193. double& dfEastLongitudeDeg,
  194. double& dfNorthLatitudeDeg );
  195. #endif /* #ifndef DOXYGEN_SKIP */
  196. #endif /* ndef GDAL_ALG_PRIV_H_INCLUDED */
上海开阖软件有限公司 沪ICP备12045867号-1