linqy的个人博客分享 http://blog.sciencenet.cn/u/linqy

博文

gdal数据类型的代码的核心定义文件

已有 3475 次阅读 2017-4-14 18:40 |个人分类:GDAL|系统分类:科研笔记

gdal中的数据类型由由自己的类型分很多中,为了方便大家的使用,下面来进行罗列一下使用方法

(参考网址: http://blog.csdn.net/liminlu0314/article/details/8227518)


[cpp]view plaincopyprint?

  1. /***************************************************************************

  2. *

  3. * Time: 2009-09-21

  4. * Project: 遥感平台

  5. * Purpose: 核心库文件

  6. * Author:  李民录

  7. * Copyright (c) 2009, liminlu0314@gmail.com

  8. * Describe:提供常用的数据类型定义等

  9. *

  10. ****************************************************************************/  

  11.  

  12. #ifndef IMGALG_H  

  13. #define IMGALG_H  

  14.  

  15. /**

  16. * file ImgCore.h

  17. * @brief 核心类型定义

  18. *

  19. * 导出接口(使用C语言方式),核心类型定义

  20. */  

  21.  

  22. /**

  23. * 忽略在MS Widows平台上的警告 lml 2010-10-19

  24. * warning C4100: “*”: 未引用的形参

  25. * warning C4190: “identifier1”有指定的 C 链接,但返回了与 C 不兼容的 UDT“identifier2”

  26. * warning C4251: 类“type”需要由类“type2”的客户端使用 dll 接口

  27. * warning C4275: 非 DLL 接口类键“identifier”作为 DLL 接口类键“identifier”的基使用

  28. * warning C4305: 从“type1”到“type2”截断

  29. * warning C4309: 截断常数值

  30. * warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失

  31. * warning C4996: 使用了非标准扩展: 限定名中使用了枚举

  32. */  

  33. #if defined(_MSC_VER) && (_MSC_VER >= 1400)  

  34. #pragma warning(disable: 4100 4190 4251 4275 4305 4309 4819 4996 )  

  35. #endif  

  36.  

  37. /**

  38. * @brief 是否使用Vld内存泄露监测工具

  39. */  

  40. #if _USEVLD  

  41. #if _DEBUG  //在debug模式下检测内存泄露  

  42. #include "vld.h"  

  43. #endif  

  44. #endif  

  45.  

  46. /**

  47. * @brief 是否使用LOG工具进行写日志

  48. */  

  49. #if _USELOG  

  50. #define USE_LOG4CPP  

  51. #endif  

  52.  

  53. #include <float.h>  

  54. #include <algorithm>  

  55. #include <deque>  

  56. #include <fstream>  

  57. #include <limits>  

  58. #include <map>  

  59. #include <stack>  

  60. #include <string>  

  61. #include <vector>  

  62. using namespace std;  

  63.  

  64. /**

  65. * @brief 导出符号定义

  66. */  

  67. #ifdef IMGALG_EXPORTS  

  68. #define IMGALG_API __declspec(dllexport)  

  69. #else  

  70. #define IMGALG_API __declspec(dllimport)  

  71. #endif  

  72.  

  73. /**

  74. * @brief 定义NULL

  75. */  

  76. #ifndef NULL  

  77. #  define NULL  0  

  78. #endif  

  79.  

  80. /**

  81. * @brief 定义FALSE

  82. */  

  83. #ifndef FALSE  

  84. #  define FALSE 0  

  85. #endif  

  86.  

  87. /**

  88. * @brief 定义TRUE

  89. */  

  90. #ifndef TRUE  

  91. #  define TRUE  1  

  92. #endif  

  93.  

  94. #ifndef MAX  

  95. /*! 求最大值 */  

  96. #  define MIN(a, b)      ((a<b) ? a : b)  

  97. /*! 求最小值 */  

  98. #  define MAX(a, b)      ((a>b) ? a : b)  

  99. #endif  

  100.  

  101. /**

  102. * @brief 定义ABS,求绝对值

  103. */  

  104. #ifndef ABS  

  105. #  define ABS(x)        ((x<0) ? (-1*(x)) : x)  

  106. #endif  

  107.  

  108. /**

  109. * @brief 定义PI=3.141592653...以及度和弧度转换

  110. */  

  111. #ifndef M_PI  

  112. /*! 定义圆周率PI */  

  113. # define M_PI  3.1415926535897932384626433832795  

  114. /*! 弧度转度 */  

  115. # define DEG_PER_RAD      ((double)(180.0/M_PI))  

  116. /*! 度转弧度 */  

  117. # define RAD_PER_DEG      ((double)(M_PI/180.0))  

  118. #endif  

  119.  

  120. /**

  121. * @brief 定义平方

  122. */  

  123. #ifndef M_SQUARE  

  124. # define M_SQUARE(x)  (x)*(x)  

  125. #endif  

  126.  

  127. /**

  128. * @brief 定义立方

  129. */  

  130. #ifndef M_CUBE  

  131. # define M_CUBE(x)  (x)*(x)*(x)  

  132. #endif  

  133.  

  134. /*! 判断浮点数是否NaN值 */  

  135. inline bool isnan(const float& v)  { return _isnan(v) ? true : false; }  

  136. /*! 判断double数是否NaN值 */  

  137. inline bool isnan(const double& v) { return _isnan(v) ? true : false; }  

  138. /*! 获取double的NaN值 */  

  139. inline double nan() { return numeric_limits<double>::quiet_NaN(); }  

  140.  

  141. /**

  142. * @brief float类型的极值

  143. */  

  144. #ifndef FLT_EQUALS  

  145. /*! 浮点数是否相等 */  

  146. #define FLT_EQUALS(x, y)  (fabs((double)x-y)<FLT_EPSILON)  

  147. /*! 浮点数是否相等(指定比较阈值) */  

  148. #define FLT_EQUALS_N(x, y, z)  (fabs((double)x-y)<z)  

  149. #endif  

  150.  

  151. #ifndef FLT_ZERO  

  152. /*! 浮点数是否为0 */  

  153. #define FLT_ZERO(x)  (fabs(x)<FLT_EPSILON)  

  154. #endif  

  155.  

  156. /**

  157. * @brief 释放数组

  158. */  

  159. #define RELEASE(x)  if(x!=NULL) {delete []x; x = NULL;}  

  160.  

  161. /**

  162. * @brief 将全局区域设为操作系统默认区域

  163. */  

  164. #define SET_LOCAL   { locale::global(locale("")); setlocale(LC_ALL,"Chinese-simplified"); }  

  165. /**

  166. * @brief 还原全局区域设定

  167. */  

  168. #define REVERT_LOCAL    locale::global(locale("C"))  

  169.  

  170.  

  171. #ifndef EQUAL  

  172. #if defined(WIN32) || defined(WIN32CE)  

  173. /*! 比较字符串是否相等 */  

  174. #  define EQUALN(a, b, n)           (_strnicmp(a, b, n) == 0)  

  175. /*! 比较字符串是否相等 */  

  176. #  define EQUAL(a, b)              (_stricmp(a, b) == 0)  

  177. #else  

  178. /*! 比较字符串是否相等 */  

  179. #  define EQUALN(a, b, n)           (strncasecmp(a, b, n) == 0)  

  180. /*! 比较字符串是否相等 */  

  181. #  define EQUAL(a, b)              (strcasecmp(a, b) == 0)  

  182. #endif  

  183. #endif  

  184.  

  185. /*! byte */  

  186. typedef unsigned char   byte;  

  187. /*! 8U */  

  188. typedef unsigned char   DT_8U;  

  189. /*! 16U */  

  190. typedef unsigned short  DT_16U;  

  191. /*! 16S */  

  192. typedef short           DT_16S;  

  193. /*! 32U */  

  194. typedef unsigned int    DT_32U;  

  195. /*! 32S */  

  196. typedef int             DT_32S;  

  197. /*! 32F */  

  198. typedef float           DT_32F;  

  199. /*! 64F */  

  200. typedef double          DT_64F;  

  201.  

  202. /*! 成功执行 */  

  203. const int RE_SUCCESS        = 0;  

  204. /*! 文件不存在 */  

  205. const int RE_FILENOTEXIST   = 1;  

  206. /*! 文件格式不被支持 */  

  207. const int RE_FILENOTSUPPORT = 2;  

  208. /*! 图像数据类型不正确 */  

  209. const int RE_FILETYPEERROR  = 3;  

  210. /*! 创建图像失败 */  

  211. const int RE_CREATEFAILED   = 4;  

  212. /*! 输入参数错误 */  

  213. const int RE_PARAMERROR     = 5;  

  214. /*! 其他错误 */  

  215. const int RE_FAILED         = 6;  

  216. /*! 图像不存在公共区域 */  

  217. const int RE_NOSAMEEXTENT   = 7;  

  218. /*! 用户取消操作 */  

  219. const int RE_USERCANCEL     = 8;  

  220. /*! 文件已经被使用 */  

  221. const int RE_FILEISUESED    = 9;  

  222. /*! 不支持的像素深度 */  

  223. const int RE_DEPTHNOTSUPPORT    = 10;  

  224. /*! 波段数量不符合要求 */  

  225. const int RE_BANDCOUNTERROR     = 11;  

  226. /*! 文件不存在投影 */  

  227. const int RE_NOPROJECTION       = 12;  

  228. /*! 投影不一致 */  

  229. const int RE_PROJECTIONDIFF     = 13;  

  230.  

  231. #endif  




https://blog.sciencenet.cn/blog-3134052-1048930.html


下一篇:GDAL中GDALDataType中值与其在C++中数据类型对应
收藏 IP: 124.207.244.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-6-1 13:38

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部