/Proj4/PJ_vandg2.c

http://github.com/route-me/route-me · C · 48 lines · 47 code · 1 blank · 0 comment · 8 complexity · eb0c2b47697ace890fa151116e35b09d MD5 · raw file

  1. #ifndef lint
  2. static const char SCCSID[]="@(#)PJ_vandg2.c 4.1 94/02/15 GIE REL";
  3. #endif
  4. # define TOL 1e-10
  5. # define TWORPI 0.63661977236758134308
  6. #define PROJ_PARMS__ \
  7. int vdg3;
  8. #define PJ_LIB__
  9. #include "projects.h"
  10. PROJ_HEAD(vandg2, "van der Grinten II") "\n\tMisc Sph, no inv.";
  11. PROJ_HEAD(vandg3, "van der Grinten III") "\n\tMisc Sph, no inv.";
  12. FORWARD(s_forward); /* spheroid */
  13. double x1, at, bt, ct;
  14. bt = fabs(TWORPI * lp.phi);
  15. if ((ct = 1. - bt * bt) < 0.)
  16. ct = 0.;
  17. else
  18. ct = sqrt(ct);
  19. if (fabs(lp.lam) < TOL) {
  20. xy.x = 0.;
  21. xy.y = PI * (lp.phi < 0. ? -bt : bt) / (1. + ct);
  22. } else {
  23. at = 0.5 * fabs(PI / lp.lam - lp.lam / PI);
  24. if (P->vdg3) {
  25. x1 = bt / (1. + ct);
  26. xy.x = PI * (sqrt(at * at + 1. - x1 * x1) - at);
  27. xy.y = PI * x1;
  28. } else {
  29. x1 = (ct * sqrt(1. + at * at) - at * ct * ct) /
  30. (1. + at * at * bt * bt);
  31. xy.x = PI * x1;
  32. xy.y = PI * sqrt(1. - x1 * (x1 + 2. * at) + TOL);
  33. }
  34. if ( lp.lam < 0.) xy.x = -xy.x;
  35. if ( lp.phi < 0.) xy.y = -xy.y;
  36. }
  37. return (xy);
  38. }
  39. FREEUP; if (P) pj_dalloc(P); }
  40. ENTRY0(vandg2)
  41. P->vdg3 = 0;
  42. P->inv = 0; P->fwd = s_forward;
  43. ENDENTRY(P)
  44. ENTRY0(vandg3)
  45. P->vdg3 = 1;
  46. P->es = 0.; P->fwd = s_forward;
  47. ENDENTRY(P)