/Proj4/PJ_sts.c

http://github.com/route-me/route-me · C · 57 lines · 55 code · 2 blank · 0 comment · 4 complexity · 85e5f25c865abb56e6dad6f51a9da6a0 MD5 · raw file

  1. #ifndef lint
  2. static const char SCCSID[]="@(#)PJ_sts.c 4.1 94/02/15 GIE REL";
  3. #endif
  4. #define PROJ_PARMS__ \
  5. double C_x, C_y, C_p; \
  6. int tan_mode;
  7. #define PJ_LIB__
  8. # include "projects.h"
  9. PROJ_HEAD(kav5, "Kavraisky V") "\n\tPCyl., Sph.";
  10. PROJ_HEAD(qua_aut, "Quartic Authalic") "\n\tPCyl., Sph.";
  11. PROJ_HEAD(mbt_s, "McBryde-Thomas Flat-Polar Sine (No. 1)") "\n\tPCyl., Sph.";
  12. PROJ_HEAD(fouc, "Foucaut") "\n\tPCyl., Sph.";
  13. FORWARD(s_forward); /* spheroid */
  14. double c;
  15. xy.x = P->C_x * lp.lam * cos(lp.phi);
  16. xy.y = P->C_y;
  17. lp.phi *= P->C_p;
  18. c = cos(lp.phi);
  19. if (P->tan_mode) {
  20. xy.x *= c * c;
  21. xy.y *= tan(lp.phi);
  22. } else {
  23. xy.x /= c;
  24. xy.y *= sin(lp.phi);
  25. }
  26. return (xy);
  27. }
  28. INVERSE(s_inverse); /* spheroid */
  29. double c;
  30. xy.y /= P->C_y;
  31. c = cos(lp.phi = P->tan_mode ? atan(xy.y) : aasin(xy.y));
  32. lp.phi /= P->C_p;
  33. lp.lam = xy.x / (P->C_x * cos(lp.phi /= P->C_p));
  34. if (P->tan_mode)
  35. lp.lam /= c * c;
  36. else
  37. lp.lam *= c;
  38. return (lp);
  39. }
  40. FREEUP; if (P) pj_dalloc(P); }
  41. static PJ *
  42. setup(PJ *P, double p, double q, int mode) {
  43. P->es = 0.;
  44. P->inv = s_inverse;
  45. P->fwd = s_forward;
  46. P->C_x = q / p;
  47. P->C_y = p;
  48. P->C_p = 1/ q;
  49. P->tan_mode = mode;
  50. return P;
  51. }
  52. ENTRY0(kav5) ENDENTRY(setup(P, 1.50488, 1.35439, 0))
  53. ENTRY0(qua_aut) ENDENTRY(setup(P, 2., 2., 0))
  54. ENTRY0(mbt_s) ENDENTRY(setup(P, 1.48875, 1.36509, 0))
  55. ENTRY0(fouc) ENDENTRY(setup(P, 2., 2., 1))