/Proj4/PJ_ocea.c

http://github.com/route-me/route-me · C · 71 lines · 65 code · 3 blank · 3 comment · 4 complexity · 9845d1090fd8992c0d2fa94d056c08dc MD5 · raw file

  1. #ifndef lint
  2. static const char SCCSID[]="@(#)PJ_ocea.c 4.1 94/02/15 GIE REL";
  3. #endif
  4. #define PROJ_PARMS__ \
  5. double rok; \
  6. double rtk; \
  7. double sinphi; \
  8. double cosphi; \
  9. double singam; \
  10. double cosgam;
  11. #define PJ_LIB__
  12. #include "projects.h"
  13. PROJ_HEAD(ocea, "Oblique Cylindrical Equal Area") "\n\tCyl, Sph"
  14. "lonc= alpha= or\n\tlat_1= lat_2= lon_1= lon_2=";
  15. FORWARD(s_forward); /* spheroid */
  16. double t;
  17. xy.y = sin(lp.lam);
  18. /*
  19. xy.x = atan2((tan(lp.phi) * P->cosphi + P->sinphi * xy.y) , cos(lp.lam));
  20. */
  21. t = cos(lp.lam);
  22. xy.x = atan((tan(lp.phi) * P->cosphi + P->sinphi * xy.y) / t);
  23. if (t < 0.)
  24. xy.x += PI;
  25. xy.x *= P->rtk;
  26. xy.y = P->rok * (P->sinphi * sin(lp.phi) - P->cosphi * cos(lp.phi) * xy.y);
  27. return (xy);
  28. }
  29. INVERSE(s_inverse); /* spheroid */
  30. double t, s;
  31. xy.y /= P->rok;
  32. xy.x /= P->rtk;
  33. t = sqrt(1. - xy.y * xy.y);
  34. lp.phi = asin(xy.y * P->sinphi + t * P->cosphi * (s = sin(xy.x)));
  35. lp.lam = atan2(t * P->sinphi * s - xy.y * P->cosphi,
  36. t * cos(xy.x));
  37. return (lp);
  38. }
  39. FREEUP; if (P) pj_dalloc(P); }
  40. ENTRY0(ocea)
  41. double phi_0=0.0, phi_1, phi_2, lam_1, lam_2, lonz, alpha;
  42. P->rok = P->a / P->k0;
  43. P->rtk = P->a * P->k0;
  44. if ( pj_param(P->params, "talpha").i) {
  45. alpha = pj_param(P->params, "ralpha").f;
  46. lonz = pj_param(P->params, "rlonc").f;
  47. P->singam = atan(-cos(alpha)/(-sin(phi_0) * sin(alpha))) + lonz;
  48. P->sinphi = asin(cos(phi_0) * sin(alpha));
  49. } else {
  50. phi_1 = pj_param(P->params, "rlat_1").f;
  51. phi_2 = pj_param(P->params, "rlat_2").f;
  52. lam_1 = pj_param(P->params, "rlon_1").f;
  53. lam_2 = pj_param(P->params, "rlon_2").f;
  54. P->singam = atan2(cos(phi_1) * sin(phi_2) * cos(lam_1) -
  55. sin(phi_1) * cos(phi_2) * cos(lam_2),
  56. sin(phi_1) * cos(phi_2) * sin(lam_2) -
  57. cos(phi_1) * sin(phi_2) * sin(lam_1) );
  58. P->sinphi = atan(-cos(P->singam - lam_1) / tan(phi_1));
  59. }
  60. P->lam0 = P->singam + HALFPI;
  61. P->cosphi = cos(P->sinphi);
  62. P->sinphi = sin(P->sinphi);
  63. P->cosgam = cos(P->singam);
  64. P->singam = sin(P->singam);
  65. P->inv = s_inverse;
  66. P->fwd = s_forward;
  67. P->es = 0.;
  68. ENDENTRY(P)