/Proj4/geocent.h

http://github.com/route-me/route-me · C Header · 179 lines · 45 code · 19 blank · 115 comment · 0 complexity · 577e7275a0da25f194eb4ac434a74278 MD5 · raw file

  1. #ifndef GEOCENT_H
  2. #define GEOCENT_H
  3. /***************************************************************************/
  4. /* RSC IDENTIFIER: GEOCENTRIC
  5. *
  6. * ABSTRACT
  7. *
  8. * This component provides conversions between Geodetic coordinates (latitude,
  9. * longitude in radians and height in meters) and Geocentric coordinates
  10. * (X, Y, Z) in meters.
  11. *
  12. * ERROR HANDLING
  13. *
  14. * This component checks parameters for valid values. If an invalid value
  15. * is found, the error code is combined with the current error code using
  16. * the bitwise or. This combining allows multiple error codes to be
  17. * returned. The possible error codes are:
  18. *
  19. * GEOCENT_NO_ERROR : No errors occurred in function
  20. * GEOCENT_LAT_ERROR : Latitude out of valid range
  21. * (-90 to 90 degrees)
  22. * GEOCENT_LON_ERROR : Longitude out of valid range
  23. * (-180 to 360 degrees)
  24. * GEOCENT_A_ERROR : Semi-major axis less than or equal to zero
  25. * GEOCENT_B_ERROR : Semi-minor axis less than or equal to zero
  26. * GEOCENT_A_LESS_B_ERROR : Semi-major axis less than semi-minor axis
  27. *
  28. *
  29. * REUSE NOTES
  30. *
  31. * GEOCENTRIC is intended for reuse by any application that performs
  32. * coordinate conversions between geodetic coordinates and geocentric
  33. * coordinates.
  34. *
  35. *
  36. * REFERENCES
  37. *
  38. * An Improved Algorithm for Geocentric to Geodetic Coordinate Conversion,
  39. * Ralph Toms, February 1996 UCRL-JC-123138.
  40. *
  41. * Further information on GEOCENTRIC can be found in the Reuse Manual.
  42. *
  43. * GEOCENTRIC originated from : U.S. Army Topographic Engineering Center
  44. * Geospatial Information Division
  45. * 7701 Telegraph Road
  46. * Alexandria, VA 22310-3864
  47. *
  48. * LICENSES
  49. *
  50. * None apply to this component.
  51. *
  52. * RESTRICTIONS
  53. *
  54. * GEOCENTRIC has no restrictions.
  55. *
  56. * ENVIRONMENT
  57. *
  58. * GEOCENTRIC was tested and certified in the following environments:
  59. *
  60. * 1. Solaris 2.5 with GCC version 2.8.1
  61. * 2. Windows 95 with MS Visual C++ version 6
  62. *
  63. * MODIFICATIONS
  64. *
  65. * Date Description
  66. * ---- -----------
  67. *
  68. *
  69. */
  70. /***************************************************************************/
  71. /*
  72. * DEFINES
  73. */
  74. #define GEOCENT_NO_ERROR 0x0000
  75. #define GEOCENT_LAT_ERROR 0x0001
  76. #define GEOCENT_LON_ERROR 0x0002
  77. #define GEOCENT_A_ERROR 0x0004
  78. #define GEOCENT_B_ERROR 0x0008
  79. #define GEOCENT_A_LESS_B_ERROR 0x0010
  80. /***************************************************************************/
  81. /*
  82. * FUNCTION PROTOTYPES
  83. */
  84. /* ensure proper linkage to c++ programs */
  85. #ifdef __cplusplus
  86. extern "C" {
  87. #endif
  88. typedef struct
  89. {
  90. double Geocent_a; /* Semi-major axis of ellipsoid in meters */
  91. double Geocent_b; /* Semi-minor axis of ellipsoid */
  92. double Geocent_a2; /* Square of semi-major axis */
  93. double Geocent_b2; /* Square of semi-minor axis */
  94. double Geocent_e2; /* Eccentricity squared */
  95. double Geocent_ep2; /* 2nd eccentricity squared */
  96. } GeocentricInfo;
  97. void pj_Init_Geocentric( GeocentricInfo *gi );
  98. long pj_Set_Geocentric_Parameters( GeocentricInfo *gi,
  99. double a,
  100. double b);
  101. /*
  102. * The function Set_Geocentric_Parameters receives the ellipsoid parameters
  103. * as inputs and sets the corresponding state variables.
  104. *
  105. * a : Semi-major axis, in meters. (input)
  106. * b : Semi-minor axis, in meters. (input)
  107. */
  108. void pj_Get_Geocentric_Parameters ( GeocentricInfo *gi,
  109. double *a,
  110. double *b);
  111. /*
  112. * The function Get_Geocentric_Parameters returns the ellipsoid parameters
  113. * to be used in geocentric coordinate conversions.
  114. *
  115. * a : Semi-major axis, in meters. (output)
  116. * b : Semi-minor axis, in meters. (output)
  117. */
  118. long pj_Convert_Geodetic_To_Geocentric ( GeocentricInfo *gi,
  119. double Latitude,
  120. double Longitude,
  121. double Height,
  122. double *X,
  123. double *Y,
  124. double *Z);
  125. /*
  126. * The function Convert_Geodetic_To_Geocentric converts geodetic coordinates
  127. * (latitude, longitude, and height) to geocentric coordinates (X, Y, Z),
  128. * according to the current ellipsoid parameters.
  129. *
  130. * Latitude : Geodetic latitude in radians (input)
  131. * Longitude : Geodetic longitude in radians (input)
  132. * Height : Geodetic height, in meters (input)
  133. * X : Calculated Geocentric X coordinate, in meters. (output)
  134. * Y : Calculated Geocentric Y coordinate, in meters. (output)
  135. * Z : Calculated Geocentric Z coordinate, in meters. (output)
  136. *
  137. */
  138. void pj_Convert_Geocentric_To_Geodetic (GeocentricInfo *gi,
  139. double X,
  140. double Y,
  141. double Z,
  142. double *Latitude,
  143. double *Longitude,
  144. double *Height);
  145. /*
  146. * The function Convert_Geocentric_To_Geodetic converts geocentric
  147. * coordinates (X, Y, Z) to geodetic coordinates (latitude, longitude,
  148. * and height), according to the current ellipsoid parameters.
  149. *
  150. * X : Geocentric X coordinate, in meters. (input)
  151. * Y : Geocentric Y coordinate, in meters. (input)
  152. * Z : Geocentric Z coordinate, in meters. (input)
  153. * Latitude : Calculated latitude value in radians. (output)
  154. * Longitude : Calculated longitude value in radians. (output)
  155. * Height : Calculated height value, in meters. (output)
  156. */
  157. #ifdef __cplusplus
  158. }
  159. #endif
  160. #endif /* GEOCENT_H */