gprojects.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. ******************************************************************************
  3. *
  4. * MODULE: gproj library
  5. * AUTHOR(S): Original Author unknown, probably Soil Conservation Service
  6. * Paul Kelly
  7. * PURPOSE: Include file for GRASS modules that use the PROJ.4
  8. * wrapper functions
  9. * COPYRIGHT: (C) 2003 by the GRASS Development Team
  10. *
  11. * This program is free software under the GNU General Public
  12. * License (>=v2). Read the file COPYING that comes with GRASS
  13. * for details.
  14. *
  15. *****************************************************************************/
  16. #ifndef GRASS_GPROJECTS_H
  17. #define GRASS_GPROJECTS_H
  18. #include <grass/config.h>
  19. /* TODO: clean up support for PROJ 5+ */
  20. #ifdef HAVE_PROJ_H
  21. #include <proj.h>
  22. #define RAD_TO_DEG 57.295779513082321
  23. #define DEG_TO_RAD .017453292519943296
  24. /* adapted from gdal_version.h */
  25. #ifndef PROJ_COMPUTE_VERSION
  26. #define PROJ_COMPUTE_VERSION(maj,min,rev) ((maj)*1000000+(min)*10000+(rev)*100)
  27. #endif
  28. /* just in case PROJ introduces PROJ_VERSION_NUM in a future version */
  29. #ifdef PROJ_VERSION_NUM
  30. #undef PROJ_VERSION_NUM
  31. #endif
  32. #define PROJ_VERSION_NUM (PROJ_COMPUTE_VERSION(PROJ_VERSION_MAJOR,PROJ_VERSION_MINOR,PROJ_VERSION_PATCH))
  33. #ifndef PJ_WKT2_LATEST
  34. /* update if new PROJ versions support new WKT2 standards */
  35. #if PROJ_VERSION_NUM < 6030000
  36. #define PJ_WKT2_LATEST PJ_WKT2_2018
  37. #else
  38. #define PJ_WKT2_LATEST PJ_WKT2_2019
  39. #endif
  40. #endif
  41. #else
  42. #include <proj_api.h>
  43. #define PJ_FWD 1
  44. #define PJ_INV -1
  45. /* PROJ_VERSION_MAJOR is not set in the old PROJ API */
  46. #define PROJ_VERSION_MAJOR 4
  47. #endif
  48. #ifdef HAVE_OGR
  49. # include <ogr_srs_api.h>
  50. # if PROJ_VERSION_MAJOR >= 6 && GDAL_VERSION_MAJOR < 3
  51. # error "PROJ 6+ requires GDAL 3+"
  52. # endif
  53. #endif
  54. /* Data Files */
  55. #define ELLIPSOIDTABLE "/etc/proj/ellipse.table"
  56. #define DATUMTABLE "/etc/proj/datum.table"
  57. #define DATUMTRANSFORMTABLE "/etc/proj/datumtransform.table"
  58. /* GRASS relative location of datum conversion lookup tables */
  59. #define GRIDDIR "/etc/proj/nad"
  60. /* TODO: rename pj_ to gpj_ to avoid symbol clash with PROJ lib */
  61. struct pj_info
  62. {
  63. #ifdef HAVE_PROJ_H
  64. PJ *pj;
  65. #else
  66. projPJ pj;
  67. #endif
  68. double meters;
  69. int zone;
  70. char proj[100];
  71. char *def;
  72. char *srid;
  73. char *wkt;
  74. };
  75. struct gpj_datum
  76. {
  77. char *name, *longname, *ellps;
  78. double dx, dy, dz;
  79. };
  80. /* no longer needed with PROJ6+ */
  81. struct gpj_datum_transform_list
  82. {
  83. int count; /**< Transform Number (ordered list) */
  84. char *params; /**< PROJ.4-style datum transform parameters */
  85. char *where_used; /**< Comment text describing where (geographically)
  86. * the transform is valid */
  87. char *comment; /**< Additional Comments */
  88. struct gpj_datum_transform_list *next; /**< Pointer to next set of
  89. * transform parameters in linked list */
  90. };
  91. struct gpj_ellps
  92. {
  93. char *name, *longname;
  94. double a, es, rf;
  95. };
  96. #ifndef HAVE_PROJ_H
  97. /* PROJ.4's private datastructures copied from projects.h as removed
  98. from upstream; pending better solution. see:
  99. http://trac.osgeo.org/proj/ticket/98 */
  100. /* In PROJ 5, the 'struct FACTORS' is back in as 'struct P5_FACTORS',
  101. * and old 'struct LP' is now back in as 'PJ_UV' */
  102. typedef struct { double u, v; } LP;
  103. struct DERIVS {
  104. double x_l, x_p; /* derivatives of x for lambda-phi */
  105. double y_l, y_p; /* derivatives of y for lambda-phi */
  106. };
  107. struct FACTORS {
  108. struct DERIVS der;
  109. double h, k; /* meridinal, parallel scales */
  110. double omega, thetap; /* angular distortion, theta prime */
  111. double conv; /* convergence */
  112. double s; /* areal scale factor */
  113. double a, b; /* max-min scale error */
  114. int code; /* info as to analytics, see following */
  115. };
  116. /* end of copy */
  117. #endif
  118. #include <grass/defs/gprojects.h>
  119. #endif