/Proj4/PJ_boggs.c

http://github.com/route-me/route-me · C · 35 lines · 34 code · 1 blank · 0 comment · 5 complexity · 28f799b7d226ce44f46aec18807f1565 MD5 · raw file

  1. #ifndef lint
  2. static const char SCCSID[]="@(#)PJ_boggs.c 4.1 94/02/15 GIE REL";
  3. #endif
  4. #define PJ_LIB__
  5. # include "projects.h"
  6. PROJ_HEAD(boggs, "Boggs Eumorphic") "\n\tPCyl., no inv., Sph.";
  7. # define NITER 20
  8. # define EPS 1e-7
  9. # define ONETOL 1.000001
  10. # define FXC 2.00276
  11. # define FXC2 1.11072
  12. # define FYC 0.49931
  13. # define FYC2 1.41421356237309504880
  14. FORWARD(s_forward); /* spheroid */
  15. double theta, th1, c;
  16. int i;
  17. theta = lp.phi;
  18. if (fabs(fabs(lp.phi) - HALFPI) < EPS)
  19. xy.x = 0.;
  20. else {
  21. c = sin(theta) * PI;
  22. for (i = NITER; i; --i) {
  23. theta -= th1 = (theta + sin(theta) - c) /
  24. (1. + cos(theta));
  25. if (fabs(th1) < EPS) break;
  26. }
  27. theta *= 0.5;
  28. xy.x = FXC * lp.lam / (1. / cos(lp.phi) + FXC2 / cos(theta));
  29. }
  30. xy.y = FYC * (lp.phi + FYC2 * sin(theta));
  31. return (xy);
  32. }
  33. FREEUP; if (P) pj_dalloc(P); }
  34. ENTRY0(boggs) P->es = 0.; P->fwd = s_forward; ENDENTRY(P)