/Proj4/PJ_aitoff.c

http://github.com/route-me/route-me · C · 82 lines · 42 code · 5 blank · 35 comment · 7 complexity · a92d6f64aef790b457624c681de9868f MD5 · raw file

  1. /******************************************************************************
  2. * $Id: PJ_aitoff.c,v 1.3 2002/12/14 19:32:27 warmerda Exp $
  3. *
  4. * Project: PROJ.4
  5. * Purpose: Implementation of the aitoff (Aitoff) and wintri (Winkel Tripel)
  6. * projections.
  7. * Author: Gerald Evenden
  8. *
  9. ******************************************************************************
  10. * Copyright (c) 1995, Gerald Evenden
  11. *
  12. * Permission is hereby granted, free of charge, to any person obtaining a
  13. * copy of this software and associated documentation files (the "Software"),
  14. * to deal in the Software without restriction, including without limitation
  15. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  16. * and/or sell copies of the Software, and to permit persons to whom the
  17. * Software is furnished to do so, subject to the following conditions:
  18. *
  19. * The above copyright notice and this permission notice shall be included
  20. * in all copies or substantial portions of the Software.
  21. *
  22. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  23. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  25. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  27. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  28. * DEALINGS IN THE SOFTWARE.
  29. ******************************************************************************
  30. *
  31. * $Log: PJ_aitoff.c,v $
  32. * Revision 1.3 2002/12/14 19:32:27 warmerda
  33. * updated header
  34. *
  35. */
  36. #define PROJ_PARMS__ \
  37. double cosphi1; \
  38. int mode;
  39. #define PJ_LIB__
  40. #include "projects.h"
  41. PJ_CVSID("$Id: PJ_aitoff.c,v 1.3 2002/12/14 19:32:27 warmerda Exp $");
  42. PROJ_HEAD(aitoff, "Aitoff") "\n\tMisc Sph";
  43. PROJ_HEAD(wintri, "Winkel Tripel") "\n\tMisc Sph\n\tlat_1";
  44. FORWARD(s_forward); /* spheroid */
  45. double c, d;
  46. if((d = acos(cos(lp.phi) * cos(c = 0.5 * lp.lam)))) {/* basic Aitoff */
  47. xy.x = 2. * d * cos(lp.phi) * sin(c) * (xy.y = 1. / sin(d));
  48. xy.y *= d * sin(lp.phi);
  49. } else
  50. xy.x = xy.y = 0.;
  51. if (P->mode) { /* Winkel Tripel */
  52. xy.x = (xy.x + lp.lam * P->cosphi1) * 0.5;
  53. xy.y = (xy.y + lp.phi) * 0.5;
  54. }
  55. return (xy);
  56. }
  57. FREEUP; if (P) pj_dalloc(P); }
  58. static PJ *
  59. setup(PJ *P) {
  60. P->inv = 0;
  61. P->fwd = s_forward;
  62. P->es = 0.;
  63. return P;
  64. }
  65. ENTRY0(aitoff)
  66. P->mode = 0;
  67. ENDENTRY(setup(P))
  68. ENTRY0(wintri)
  69. P->mode = 1;
  70. if (pj_param(P->params, "tlat_1").i)
  71. {
  72. if ((P->cosphi1 = cos(pj_param(P->params, "rlat_1").f)) == 0.)
  73. E_ERROR(-22)
  74. }
  75. else /* 50d28' or acos(2/pi) */
  76. P->cosphi1 = 0.636619772367581343;
  77. ENDENTRY(setup(P))