Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libjni-proj4 / src / PJ_sterea.c @ 7098

History | View | Annotate | Download (2.8 KB)

1
/*
2
** libproj -- library of cartographic projections
3
**
4
** Copyright (c) 2003   Gerald I. Evenden
5
*/
6
static const char
7
LIBPROJ_ID[] = "$Id: PJ_sterea.c,v 1.1 2004/10/20 17:04:00 fwarmerdam Exp $";
8
/*
9
** Permission is hereby granted, free of charge, to any person obtaining
10
** a copy of this software and associated documentation files (the
11
** "Software"), to deal in the Software without restriction, including
12
** without limitation the rights to use, copy, modify, merge, publish,
13
** distribute, sublicense, and/or sell copies of the Software, and to
14
** permit persons to whom the Software is furnished to do so, subject to
15
** the following conditions:
16
**
17
** The above copyright notice and this permission notice shall be
18
** included in all copies or substantial portions of the Software.
19
**
20
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
*/
28
#define PROJ_PARMS__ \
29
        double phic0; \
30
        double cosc0, sinc0; \
31
        double R2; \
32
        void *en;
33

    
34
#define PJ_LIB__
35
#include        <projects.h>
36

    
37
PROJ_HEAD(sterea, "Oblique Stereographic Alternative")
38
        "\n\tAzimuthal, Sph&Ell";
39
# define DEL_TOL        1.e-14
40
# define MAX_ITER        10
41

    
42
FORWARD(e_forward); /* ellipsoid */
43
        double cosc, sinc, cosl, k;
44

    
45
        lp = pj_gauss(lp, P->en);
46
        sinc = sin(lp.phi);
47
        cosc = cos(lp.phi);
48
        cosl = cos(lp.lam);
49
        k = P->k0 * P->R2 / (1. + P->sinc0 * sinc + P->cosc0 * cosc * cosl);
50
        xy.x = k * cosc * sin(lp.lam);
51
        xy.y = k * (P->cosc0 * sinc - P->sinc0 * cosc * cosl);
52
        return (xy);
53
}
54
INVERSE(e_inverse); /* ellipsoid */
55
        double rho, c, sinc, cosc;
56

    
57
        xy.x /= P->k0;
58
        xy.y /= P->k0;
59
        if((rho = hypot(xy.x, xy.y))) {
60
                c = 2. * atan2(rho, P->R2);
61
                sinc = sin(c);
62
                cosc = cos(c);
63
                lp.phi = asin(cosc * P->sinc0 + xy.y * sinc * P->cosc0 / rho);
64
                lp.lam = atan2(xy.x * sinc, rho * P->cosc0 * cosc -
65
                        xy.y * P->sinc0 * sinc);
66
        } else {
67
                lp.phi = P->phic0;
68
                lp.lam = 0.;
69
        }
70
        return(pj_inv_gauss(lp, P->en));
71
}
72
FREEUP; if (P) { if (P->en) free(P->en); free(P); } }
73
ENTRY0(sterea)
74
        double R;
75

    
76
        if (!(P->en = pj_gauss_ini(P->e, P->phi0, &(P->phic0), &R))) E_ERROR_0;
77
        P->sinc0 = sin(P->phic0);
78
        P->cosc0 = cos(P->phic0);
79
        P->R2 = 2. * R;
80
        P->inv = e_inverse;
81
        P->fwd = e_forward;
82
ENDENTRY(P)
83
/*
84
** $Log: PJ_sterea.c,v $
85
** Revision 1.1  2004/10/20 17:04:00  fwarmerdam
86
** New
87
**
88
** Revision 2.3  2004/04/07 17:18:32  gie
89
** corrected comment stamp
90
**
91
** Revision 2.2  2003/08/05 00:15:09  gie
92
** corrected 0 rho on inverse.
93
**
94
** Revision 2.1  2003/03/28 01:46:02  gie
95
** Initial
96
**
97
*/