gprojects.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. #else
  25. #include <proj_api.h>
  26. #define PJ_FWD 1
  27. #define PJ_INV -1
  28. /* PROJ_VERSION_MAJOR is not set in the old PROJ API */
  29. #define PROJ_VERSION_MAJOR 4
  30. #endif
  31. #ifdef HAVE_OGR
  32. # include <ogr_srs_api.h>
  33. # if PROJ_VERSION_MAJOR >= 6 && GDAL_VERSION_MAJOR < 3
  34. # error "PROJ 6+ requires GDAL 3+"
  35. # endif
  36. #endif
  37. /* Data Files */
  38. #define ELLIPSOIDTABLE "/etc/proj/ellipse.table"
  39. #define DATUMTABLE "/etc/proj/datum.table"
  40. #define DATUMTRANSFORMTABLE "/etc/proj/datumtransform.table"
  41. /* GRASS relative location of datum conversion lookup tables */
  42. #define GRIDDIR "/etc/proj/nad"
  43. /* TODO: rename pj_ to gpj_ to avoid symbol clash with PROJ lib */
  44. struct pj_info
  45. {
  46. #ifdef HAVE_PROJ_H
  47. PJ *pj;
  48. #else
  49. projPJ pj;
  50. #endif
  51. double meters;
  52. int zone;
  53. char proj[100];
  54. char *def;
  55. char *srid;
  56. };
  57. struct gpj_datum
  58. {
  59. char *name, *longname, *ellps;
  60. double dx, dy, dz;
  61. };
  62. /* no longer needed with PROJ6+ */
  63. struct gpj_datum_transform_list
  64. {
  65. int count; /**< Transform Number (ordered list) */
  66. char *params; /**< PROJ.4-style datum transform parameters */
  67. char *where_used; /**< Comment text describing where (geographically)
  68. * the transform is valid */
  69. char *comment; /**< Additional Comments */
  70. struct gpj_datum_transform_list *next; /**< Pointer to next set of
  71. * transform parameters in linked list */
  72. };
  73. struct gpj_ellps
  74. {
  75. char *name, *longname;
  76. double a, es, rf;
  77. };
  78. #ifndef HAVE_PROJ_H
  79. /* PROJ.4's private datastructures copied from projects.h as removed
  80. from upstream; pending better solution. see:
  81. http://trac.osgeo.org/proj/ticket/98 */
  82. /* In PROJ 5, the 'struct FACTORS' is back in as 'struct P5_FACTORS',
  83. * and old 'struct LP' is now back in as 'PJ_UV' */
  84. typedef struct { double u, v; } LP;
  85. struct DERIVS {
  86. double x_l, x_p; /* derivatives of x for lambda-phi */
  87. double y_l, y_p; /* derivatives of y for lambda-phi */
  88. };
  89. struct FACTORS {
  90. struct DERIVS der;
  91. double h, k; /* meridinal, parallel scales */
  92. double omega, thetap; /* angular distortion, theta prime */
  93. double conv; /* convergence */
  94. double s; /* areal scale factor */
  95. double a, b; /* max-min scale error */
  96. int code; /* info as to analytics, see following */
  97. };
  98. /* end of copy */
  99. #endif
  100. #include <grass/defs/gprojects.h>
  101. #endif