/Proj4/PJ_rpoly.c

http://github.com/route-me/route-me · C · 38 lines · 37 code · 1 blank · 0 comment · 5 complexity · c398879e18ed273adab56b90c1d5883a MD5 · raw file

  1. #ifndef lint
  2. static const char SCCSID[]="@(#)PJ_rpoly.c 4.1 94/02/15 GIE REL";
  3. #endif
  4. #define PROJ_PARMS__ \
  5. double phi1; \
  6. double fxa; \
  7. double fxb; \
  8. int mode;
  9. #define EPS 1e-9
  10. #define PJ_LIB__
  11. #include "projects.h"
  12. PROJ_HEAD(rpoly, "Rectangular Polyconic")
  13. "\n\tConic, Sph., no inv.\n\tlat_ts=";
  14. FORWARD(s_forward); /* spheroid */
  15. double fa;
  16. if (P->mode)
  17. fa = tan(lp.lam * P->fxb) * P->fxa;
  18. else
  19. fa = 0.5 * lp.lam;
  20. if (fabs(lp.phi) < EPS) {
  21. xy.x = fa + fa;
  22. xy.y = - P->phi0;
  23. } else {
  24. xy.y = 1. / tan(lp.phi);
  25. xy.x = sin(fa = 2. * atan(fa * sin(lp.phi))) * xy.y;
  26. xy.y = lp.phi - P->phi0 + (1. - cos(fa)) * xy.y;
  27. }
  28. return (xy);
  29. }
  30. FREEUP; if (P) pj_dalloc(P); }
  31. ENTRY0(rpoly)
  32. if ((P->mode = (P->phi1 = fabs(pj_param(P->params, "rlat_ts").f)) > EPS)) {
  33. P->fxb = 0.5 * sin(P->phi1);
  34. P->fxa = 0.5 / P->fxb;
  35. }
  36. P->es = 0.; P->fwd = s_forward;
  37. ENDENTRY(P)