Menu

[r8323]: / trunk / toolkits / basemap / src / PJ_airy.c  Maximize  Restore  History

Download this file

125 lines (118 with data), 3.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/******************************************************************************
* $Id: PJ_airy.c 1504 2009-01-06 02:11:57Z warmerdam $
*
* Project: PROJ.4
* Purpose: Implementation of the airy (Airy) projection.
* Author: Gerald Evenden
*
******************************************************************************
* Copyright (c) 1995, Gerald Evenden
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*****************************************************************************/
#define PROJ_PARMS__ \
double p_halfpi; \
double sinph0; \
double cosph0; \
double Cb; \
int mode; \
int no_cut; /* do not cut at hemisphere limit */
#define PJ_LIB__
#include <projects.h>
PJ_CVSID("$Id: PJ_airy.c 1504 2009-01-06 02:11:57Z warmerdam $");
PROJ_HEAD(airy, "Airy") "\n\tMisc Sph, no inv.\n\tno_cut lat_b=";
# define EPS 1.e-10
# define N_POLE 0
# define S_POLE 1
# define EQUIT 2
# define OBLIQ 3
FORWARD(s_forward); /* spheroid */
double sinlam, coslam, cosphi, sinphi, t, s, Krho, cosz;
sinlam = sin(lp.lam);
coslam = cos(lp.lam);
switch (P->mode) {
case EQUIT:
case OBLIQ:
sinphi = sin(lp.phi);
cosphi = cos(lp.phi);
cosz = cosphi * coslam;
if (P->mode == OBLIQ)
cosz = P->sinph0 * sinphi + P->cosph0 * cosz;
if (!P->no_cut && cosz < -EPS)
F_ERROR;
if (fabs(s = 1. - cosz) > EPS) {
t = 0.5 * (1. + cosz);
Krho = -log(t)/s - P->Cb / t;
} else
Krho = 0.5 - P->Cb;
xy.x = Krho * cosphi * sinlam;
if (P->mode == OBLIQ)
xy.y = Krho * (P->cosph0 * sinphi -
P->sinph0 * cosphi * coslam);
else
xy.y = Krho * sinphi;
break;
case S_POLE:
case N_POLE:
lp.phi = fabs(P->p_halfpi - lp.phi);
if (!P->no_cut && (lp.phi - EPS) > HALFPI)
F_ERROR;
if ((lp.phi *= 0.5) > EPS) {
t = tan(lp.phi);
Krho = -2.*(log(cos(lp.phi)) / t + t * P->Cb);
xy.x = Krho * sinlam;
xy.y = Krho * coslam;
if (P->mode == N_POLE)
xy.y = -xy.y;
} else
xy.x = xy.y = 0.;
}
return (xy);
}
FREEUP; if (P) pj_dalloc(P); }
ENTRY0(airy)
double beta;
P->no_cut = pj_param(P->params, "bno_cut").i;
beta = 0.5 * (HALFPI - pj_param(P->params, "rlat_b").f);
if (fabs(beta) < EPS)
P->Cb = -0.5;
else {
P->Cb = 1./tan(beta);
P->Cb *= P->Cb * log(cos(beta));
}
if (fabs(fabs(P->phi0) - HALFPI) < EPS)
if (P->phi0 < 0.) {
P->p_halfpi = -HALFPI;
P->mode = S_POLE;
} else {
P->p_halfpi = HALFPI;
P->mode = N_POLE;
}
else {
if (fabs(P->phi0) < EPS)
P->mode = EQUIT;
else {
P->mode = OBLIQ;
P->sinph0 = sin(P->phi0);
P->cosph0 = cos(P->phi0);
}
}
P->fwd = s_forward;
P->es = 0.;
ENDENTRY(P)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.