/Proj4/PJ_cea.c

http://github.com/route-me/route-me · C · 64 lines · 62 code · 2 blank · 0 comment · 9 complexity · abf061afab73939b2af8fdde43ada069 MD5 · raw file

  1. #ifndef lint
  2. static const char SCCSID[]="@(#)PJ_cea.c 4.1 94/02/15 GIE REL";
  3. #endif
  4. #define PROJ_PARMS__ \
  5. double qp; \
  6. double *apa;
  7. #define PJ_LIB__
  8. # include "projects.h"
  9. PROJ_HEAD(cea, "Equal Area Cylindrical") "\n\tCyl, Sph&Ell\n\tlat_ts=";
  10. # define EPS 1e-10
  11. FORWARD(e_forward); /* spheroid */
  12. xy.x = P->k0 * lp.lam;
  13. xy.y = .5 * pj_qsfn(sin(lp.phi), P->e, P->one_es) / P->k0;
  14. return (xy);
  15. }
  16. FORWARD(s_forward); /* spheroid */
  17. xy.x = P->k0 * lp.lam;
  18. xy.y = sin(lp.phi) / P->k0;
  19. return (xy);
  20. }
  21. INVERSE(e_inverse); /* spheroid */
  22. lp.phi = pj_authlat(asin( 2. * xy.y * P->k0 / P->qp), P->apa);
  23. lp.lam = xy.x / P->k0;
  24. return (lp);
  25. }
  26. INVERSE(s_inverse); /* spheroid */
  27. double t;
  28. if ((t = fabs(xy.y *= P->k0)) - EPS <= 1.) {
  29. if (t >= 1.)
  30. lp.phi = xy.y < 0. ? -HALFPI : HALFPI;
  31. else
  32. lp.phi = asin(xy.y);
  33. lp.lam = xy.x / P->k0;
  34. } else I_ERROR;
  35. return (lp);
  36. }
  37. FREEUP;
  38. if (P) {
  39. if (P->apa)
  40. pj_dalloc(P->apa);
  41. pj_dalloc(P);
  42. }
  43. }
  44. ENTRY1(cea, apa)
  45. double t;
  46. if (pj_param(P->params, "tlat_ts").i &&
  47. (P->k0 = cos(t = pj_param(P->params, "rlat_ts").f)) < 0.) E_ERROR(-24)
  48. else
  49. t = 0.;
  50. if (P->es) {
  51. t = sin(t);
  52. P->k0 /= sqrt(1. - P->es * t * t);
  53. P->e = sqrt(P->es);
  54. if (!(P->apa = pj_authset(P->es))) E_ERROR_0;
  55. P->qp = pj_qsfn(1., P->e, P->one_es);
  56. P->inv = e_inverse;
  57. P->fwd = e_forward;
  58. } else {
  59. P->inv = s_inverse;
  60. P->fwd = s_forward;
  61. }
  62. ENDENTRY(P)