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