Revision 64

View differences:

1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/CrsJniProj.cbp
1
<?xml version="1.0"?>
2
<!DOCTYPE CodeBlocks_project_file>
3
<CodeBlocks_project_file>
4
	<FileVersion major="1" minor="1"/>
5
	<Project>
6
		<Option title="crsjniproj"/>
7
		<Option makefile="Makefile"/>
8
		<Option makefile_is_custom="0"/>
9
		<Option default_target="-1"/>
10
		<Option compiler="0"/>
11
		<Build>
12
			<Target title="default">
13
				<Option output="dist\crsjniproj.dll"/>
14
				<Option working_dir="."/>
15
				<Option object_output="dist"/>
16
				<Option deps_output=".deps"/>
17
				<Option type="3"/>
18
				<Option compiler="0"/>
19
				<Option createDefFile="1"/>
20
			</Target>
21
		</Build>
22
		<Compiler>
23
			<Add option="-DBUILDING_DLL=1"/>
24
			<Add directory="include"/>
25
			<Add directory="C:\j2sdk1.4.2_11\include\win32"/>
26
			<Add directory="C:\j2sdk1.4.2_11\include"/>
27
		</Compiler>
28
		<Unit filename="src\crsJniProj.c">
29
			<Option compilerVar="CC"/>
30
			<Option target="default"/>
31
		</Unit>
32
	</Project>
33
</CodeBlocks_project_file>
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/aasincos.c
1
/* arc sin, cosine, tan2 and sqrt that will NOT fail */
2
#ifndef lint
3
static const char SCCSID[]="@(#)aasincos.c	4.6	93/12/12	GIE	REL";
4
#endif
5
#include <projects.h>
6
#define ONE_TOL	 1.00000000000001
7
#define TOL	0.000000001
8
#define ATOL 1e-50
9
	double
10
aasin(double v) {
11
	double av;
12

  
13
	if ((av = fabs(v)) >= 1.) {
14
		if (av > ONE_TOL)
15
			pj_errno = -19;
16
		return (v < 0. ? -HALFPI : HALFPI);
17
	}
18
	return asin(v);
19
}
20
	double
21
aacos(double v) {
22
	double av;
23

  
24
	if ((av = fabs(v)) >= 1.) {
25
		if (av > ONE_TOL)
26
			pj_errno = -19;
27
		return (v < 0. ? PI : 0.);
28
	}
29
	return acos(v);
30
}
31
	double
32
asqrt(double v) { return ((v <= 0) ? 0. : sqrt(v)); }
33
	double
34
aatan2(double n, double d) {
35
	return ((fabs(n) < ATOL && fabs(d) < ATOL) ? 0. : atan2(n,d));
36
}
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/pj_deriv.c
1
/* dervative of (*P->fwd) projection */
2
#ifndef lint
3
static const char SCCSID[]="@(#)pj_deriv.c	4.4	93/06/12	GIE	REL";
4
#endif
5
#define PJ_LIB__
6
#include "projects.h"
7
	int
8
pj_deriv(LP lp, double h, PJ *P, struct DERIVS *der) {
9
	XY t;
10

  
11
	lp.lam += h;
12
	lp.phi += h;
13
	if (fabs(lp.phi) > HALFPI) return 1;
14
	h += h;
15
	t = (*P->fwd)(lp, P);
16
	if (t.x == HUGE_VAL) return 1;
17
	der->x_l = t.x; der->y_p = t.y; der->x_p = -t.x; der->y_l = -t.y;
18
	lp.phi -= h;
19
	if (fabs(lp.phi) > HALFPI) return 1;
20
	t = (*P->fwd)(lp, P);
21
	if (t.x == HUGE_VAL) return 1;
22
	der->x_l += t.x; der->y_p -= t.y; der->x_p += t.x; der->y_l -= t.y;
23
	lp.lam -= h;
24
	t = (*P->fwd)(lp, P);
25
	if (t.x == HUGE_VAL) return 1;
26
	der->x_l -= t.x; der->y_p -= t.y; der->x_p += t.x; der->y_l += t.y;
27
	lp.phi += h;
28
	t = (*P->fwd)(lp, P);
29
	if (t.x == HUGE_VAL) return 1;
30
	der->x_l -= t.x; der->y_p += t.y; der->x_p -= t.x; der->y_l += t.y;
31
	der->x_l /= (h += h);
32
	der->y_p /= h;
33
	der->x_p /= h;
34
	der->y_l /= h;
35
	return 0;
36
}
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/PJ_urmfps.c
1
#ifndef lint
2
static const char SCCSID[]="@(#)PJ_urmfps.c	4.1	94/02/15	GIE	REL";
3
#endif
4
#define PROJ_PARMS__ \
5
	double	n, C_y;
6
#define PJ_LIB__
7
#include	<projects.h>
8
PROJ_HEAD(urmfps, "Urmaev Flat-Polar Sinusoidal") "\n\tPCyl, Sph.\n\tn=";
9
PROJ_HEAD(wag1, "Wagner I (Kavraisky VI)") "\n\tPCyl, Sph.";
10
#define C_x 0.8773826753
11
#define Cy 1.139753528477
12
FORWARD(s_forward); /* sphere */
13
	lp.phi = aasin(P->n * sin(lp.phi));
14
	xy.x = C_x * lp.lam * cos(lp.phi);
15
	xy.y = P->C_y * lp.phi;
16
	return (xy);
17
}
18
INVERSE(s_inverse); /* sphere */
19
	xy.y /= P->C_y;
20
	lp.phi = aasin(sin(xy.y) / P->n);
21
	lp.lam = xy.x / (C_x * cos(xy.y));
22
	return (lp);
23
}
24
FREEUP; if (P) pj_dalloc(P); }
25
	static PJ *
26
setup(PJ *P) {
27
	P->C_y = Cy / P->n;
28
	P->es = 0.;
29
	P->inv = s_inverse;
30
	P->fwd = s_forward;
31
	return P;
32
}
33
ENTRY0(urmfps)
34
	if (pj_param(P->params, "tn").i) {
35
		P->n = pj_param(P->params, "dn").f;
36
		if (P->n <= 0. || P->n > 1.)
37
			E_ERROR(-40)
38
	} else
39
		E_ERROR(-40)
40
ENDENTRY(setup(P))
41
ENTRY0(wag1)
42
	P->n = 0.8660254037844386467637231707;
43
ENDENTRY(setup(P))
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/pj_pr_list.c
1
/* print projection's list of parameters */
2
#ifndef lint
3
static const char SCCSID[]="@(#)pj_pr_list.c	4.6   94/03/19 GIE REL";
4
#endif
5
#include <projects.h>
6
#include <stdio.h>
7
#include <string.h>
8
#define LINE_LEN 72
9
	static int
10
pr_list(PJ *P, int not_used) {
11
	paralist *t;
12
	int l, n = 1, flag = 0;
13

  
14
	(void)putchar('#');
15
	for (t = P->params; t; t = t->next)
16
		if ((!not_used && t->used) || (not_used && !t->used)) {
17
			l = strlen(t->param) + 1;
18
			if (n + l > LINE_LEN) {
19
				(void)fputs("\n#", stdout);
20
				n = 2;
21
			}
22
			(void)putchar(' ');
23
			if (*(t->param) != '+')
24
				(void)putchar('+');
25
			(void)fputs(t->param, stdout);
26
			n += l;
27
		} else
28
			flag = 1;
29
	if (n > 1)
30
		(void)putchar('\n');
31
	return flag;
32
}
33
	void /* print link list of projection parameters */
34
pj_pr_list(PJ *P) {
35
	char const *s;
36

  
37
	(void)putchar('#');
38
	for (s = P->descr; *s ; ++s) {
39
		(void)putchar(*s);
40
		if (*s == '\n')
41
			(void)putchar('#');
42
	}
43
	(void)putchar('\n');
44
	if (pr_list(P, 0)) {
45
		(void)fputs("#--- following specified but NOT used\n", stdout);
46
		(void)pr_list(P, 1);
47
	}
48
}
49

  
50
/************************************************************************/
51
/*                             pj_get_def()                             */
52
/*                                                                      */
53
/*      Returns the PROJ.4 command string that would produce this       */
54
/*      definition expanded as much as possible.  For instance,         */
55
/*      +init= calls and +datum= defintions would be expanded.          */
56
/************************************************************************/
57

  
58
char *pj_get_def( PJ *P, int options )
59

  
60
{
61
    paralist *t;
62
    int l;
63
    char *definition;
64
    int  def_max = 10;
65

  
66
    definition = (char *) pj_malloc(def_max);
67
    definition[0] = '\0';
68

  
69
    for (t = P->params; t; t = t->next)
70
    {
71
        /* skip unused parameters ... mostly appended defaults and stuff */
72
        if (!t->used)
73
            continue;
74

  
75
        /* grow the resulting string if needed */
76
        l = strlen(t->param) + 1;
77
        if( strlen(definition) + l + 5 > def_max )
78
        {
79
            char *def2;
80

  
81
            def_max = def_max * 2 + l + 5;
82
            def2 = (char *) pj_malloc(def_max);
83
            strcpy( def2, definition );
84
            pj_dalloc( definition );
85
            definition = def2;
86
        }
87

  
88
        /* append this parameter */
89
        strcat( definition, " +" );
90
        strcat( definition, t->param );
91
    }
92

  
93
    return definition;
94
}
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/PJ_putp5.c
1
#ifndef lint
2
static const char SCCSID[]="@(#)PJ_putp5.c	4.1	94/02/15	GIE	REL";
3
#endif
4
#define PROJ_PARMS__ \
5
	double	A, B;
6
#define PJ_LIB__
7
# include	<projects.h>
8
PROJ_HEAD(putp5, "Putnins P5") "\n\tPCyl., Sph.";
9
PROJ_HEAD(putp5p, "Putnins P5'") "\n\tPCyl., Sph.";
10
#define C	1.01346
11
#define D	1.2158542
12
FORWARD(s_forward); /* spheroid */
13
	xy.x = C * lp.lam * (P->A - P->B * sqrt(1. + D * lp.phi * lp.phi));
14
	xy.y = C * lp.phi;
15
	return (xy);
16
}
17
INVERSE(s_inverse); /* spheroid */
18
	lp.phi = xy.y / C;
19
	lp.lam = xy.x / (C * (P->A - P->B * sqrt(1. + D * lp.phi * lp.phi)));
20
	return (lp);
21
}
22
FREEUP; if (P) pj_dalloc(P); }
23
	static PJ *
24
setup(PJ *P) {
25
	P->es = 0.; P->inv = s_inverse; P->fwd = s_forward;
26
	return P;
27
}
28
ENTRY0(putp5) P->A = 2.; P->B = 1.; ENDENTRY(setup(P))
29
ENTRY0(putp5p) P->A = 1.5; P->B = 0.5; ENDENTRY(setup(P))
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/pj_ellps.c
1
/* definition of standard geoids */
2
#ifndef lint
3
static const char SCCSID[]="@(#)pj_ellps.c	4.6	95/08/25	GIE	REL";
4
#endif
5
#define PJ_ELLPS__
6
#include "projects.h"
7

  
8
C_NAMESPACE struct PJ_ELLPS
9
pj_ellps[] = {
10
"MERIT",	"a=6378137.0", "rf=298.257", "MERIT 1983",
11
"SGS85",	"a=6378136.0", "rf=298.257",  "Soviet Geodetic System 85",
12
"GRS80",	"a=6378137.0", "rf=298.257222101", "GRS 1980(IUGG, 1980)",
13
"IAU76",	"a=6378140.0", "rf=298.257", "IAU 1976",
14
"airy",		"a=6377563.396", "b=6356256.910", "Airy 1830",
15
"APL4.9",	"a=6378137.0.",  "rf=298.25", "Appl. Physics. 1965",
16
"NWL9D",	"a=6378145.0.",  "rf=298.25", "Naval Weapons Lab., 1965",
17
"mod_airy",	"a=6377340.189", "b=6356034.446", "Modified Airy",
18
"andrae",	"a=6377104.43",  "rf=300.0", 	"Andrae 1876 (Den., Iclnd.)",
19
"aust_SA",	"a=6378160.0", "rf=298.25", "Australian Natl & S. Amer. 1969",
20
"GRS67",	"a=6378160.0", "rf=298.2471674270", "GRS 67(IUGG 1967)",
21
"bessel",	"a=6377397.155", "rf=299.1528128", "Bessel 1841",
22
"bess_nam",	"a=6377483.865", "rf=299.1528128", "Bessel 1841 (Namibia)",
23
"clrk66",	"a=6378206.4", "b=6356583.8", "Clarke 1866",
24
"clrk80",	"a=6378249.145", "rf=293.4663", "Clarke 1880 mod.",
25
"CPM",  	"a=6375738.7", "rf=334.29", "Comm. des Poids et Mesures 1799",
26
"delmbr",	"a=6376428.",  "rf=311.5", "Delambre 1810 (Belgium)",
27
"engelis",	"a=6378136.05", "rf=298.2566", "Engelis 1985",
28
"evrst30",  "a=6377276.345", "rf=300.8017",  "Everest 1830",
29
"evrst48",  "a=6377304.063", "rf=300.8017",  "Everest 1948",
30
"evrst56",  "a=6377301.243", "rf=300.8017",  "Everest 1956",
31
"evrst69",  "a=6377295.664", "rf=300.8017",  "Everest 1969",
32
"evrstSS",  "a=6377298.556", "rf=300.8017",  "Everest (Sabah & Sarawak)",
33
"fschr60",  "a=6378166.",   "rf=298.3", "Fischer (Mercury Datum) 1960",
34
"fschr60m", "a=6378155.",   "rf=298.3", "Modified Fischer 1960",
35
"fschr68",  "a=6378150.",   "rf=298.3", "Fischer 1968",
36
"helmert",  "a=6378200.",   "rf=298.3", "Helmert 1906",
37
"hough",	"a=6378270.0", "rf=297.", "Hough",
38
"intl",		"a=6378388.0", "rf=297.", "International 1909 (Hayford)",
39
"krass",	"a=6378245.0", "rf=298.3", "Krassovsky, 1942",
40
"kaula",	"a=6378163.",  "rf=298.24", "Kaula 1961",
41
"lerch",	"a=6378139.",  "rf=298.257", "Lerch 1979",
42
"mprts",	"a=6397300.",  "rf=191.", "Maupertius 1738",
43
"new_intl",	"a=6378157.5", "b=6356772.2", "New International 1967",
44
"plessis",	"a=6376523.",  "b=6355863.", "Plessis 1817 (France)",
45
"SEasia",	"a=6378155.0", "b=6356773.3205", "Southeast Asia",
46
"walbeck",	"a=6376896.0", "b=6355834.8467", "Walbeck",
47
"WGS60",    "a=6378165.0",  "rf=298.3", "WGS 60",
48
"WGS66",	"a=6378145.0", "rf=298.25", "WGS 66",
49
"WGS72",	"a=6378135.0", "rf=298.26", "WGS 72",
50
"WGS84",    "a=6378137.0",  "rf=298.257223563", "WGS 84",
51
"sphere",   "a=6370997.0",  "b=6370997.0", "Normal Sphere (r=6370997)",
52
0,0,0,0
53
};
54

  
55
struct PJ_ELLPS *pj_get_ellps_ref()
56

  
57
{
58
    return pj_ellps;
59
}
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/PJ_stere.c
1
#ifndef lint
2
static const char SCCSID[]="@(#)PJ_stere.c	4.1	94/02/15	GIE	REL";
3
#endif
4
#define PROJ_PARMS__ \
5
	double phits; \
6
	double sinX1; \
7
	double cosX1; \
8
	double akm1; \
9
	int	mode;
10
#define PJ_LIB__
11
#include	<projects.h>
12
PROJ_HEAD(stere, "Stereographic") "\n\tAzi, Sph&Ell\n\tlat_ts=";
13
PROJ_HEAD(ups, "Universal Polar Stereographic") "\n\tAzi, Sph&Ell\n\tsouth";
14
#define sinph0	P->sinX1
15
#define cosph0	P->cosX1
16
#define EPS10	1.e-10
17
#define TOL	1.e-8
18
#define NITER	8
19
#define CONV	1.e-10
20
#define S_POLE	0
21
#define N_POLE	1
22
#define OBLIQ	2
23
#define EQUIT	3
24
	static double
25
ssfn_(double phit, double sinphi, double eccen) {
26
	sinphi *= eccen;
27
	return (tan (.5 * (HALFPI + phit)) *
28
	   pow((1. - sinphi) / (1. + sinphi), .5 * eccen));
29
}
30
FORWARD(e_forward); /* ellipsoid */
31
	double coslam, sinlam, sinX=0.0, cosX=0.0, X, A, sinphi;
32

  
33
	coslam = cos(lp.lam);
34
	sinlam = sin(lp.lam);
35
	sinphi = sin(lp.phi);
36
	if (P->mode == OBLIQ || P->mode == EQUIT) {
37
		sinX = sin(X = 2. * atan(ssfn_(lp.phi, sinphi, P->e)) - HALFPI);
38
		cosX = cos(X);
39
	}
40
	switch (P->mode) {
41
	case OBLIQ:
42
		A = P->akm1 / (P->cosX1 * (1. + P->sinX1 * sinX +
43
		   P->cosX1 * cosX * coslam));
44
		xy.y = A * (P->cosX1 * sinX - P->sinX1 * cosX * coslam);
45
		goto xmul;
46
	case EQUIT:
47
		A = 2. * P->akm1 / (1. + cosX * coslam);
48
		xy.y = A * sinX;
49
xmul:
50
		xy.x = A * cosX;
51
		break;
52
	case S_POLE:
53
		lp.phi = -lp.phi;
54
		coslam = - coslam;
55
		sinphi = -sinphi;
56
	case N_POLE:
57
		xy.x = P->akm1 * pj_tsfn(lp.phi, sinphi, P->e);
58
		xy.y = - xy.x * coslam;
59
		break;
60
	}
61
	xy.x = xy.x * sinlam;
62
	return (xy);
63
}
64
FORWARD(s_forward); /* spheroid */
65
	double  sinphi, cosphi, coslam, sinlam;
66

  
67
	sinphi = sin(lp.phi);
68
	cosphi = cos(lp.phi);
69
	coslam = cos(lp.lam);
70
	sinlam = sin(lp.lam);
71
	switch (P->mode) {
72
	case EQUIT:
73
		xy.y = 1. + cosphi * coslam;
74
		goto oblcon;
75
	case OBLIQ:
76
		xy.y = 1. + sinph0 * sinphi + cosph0 * cosphi * coslam;
77
oblcon:
78
		if (xy.y <= EPS10) F_ERROR;
79
		xy.x = (xy.y = P->akm1 / xy.y) * cosphi * sinlam;
80
		xy.y *= (P->mode == EQUIT) ? sinphi :
81
		   cosph0 * sinphi - sinph0 * cosphi * coslam;
82
		break;
83
	case N_POLE:
84
		coslam = - coslam;
85
		lp.phi = - lp.phi;
86
	case S_POLE:
87
		if (fabs(lp.phi - HALFPI) < TOL) F_ERROR;
88
		xy.x = sinlam * ( xy.y = P->akm1 * tan(FORTPI + .5 * lp.phi) );
89
		xy.y *= coslam;
90
		break;
91
	}
92
	return (xy);
93
}
94
INVERSE(e_inverse); /* ellipsoid */
95
	double cosphi, sinphi, tp=0.0, phi_l=0.0, rho, halfe=0.0, halfpi=0.0;
96
	int i;
97

  
98
	rho = hypot(xy.x, xy.y);
99
	switch (P->mode) {
100
	case OBLIQ:
101
	case EQUIT:
102
		cosphi = cos( tp = 2. * atan2(rho * P->cosX1 , P->akm1) );
103
		sinphi = sin(tp);
104
                if( rho == 0.0 )
105
		    phi_l = asin(cosphi * P->sinX1);
106
                else
107
		    phi_l = asin(cosphi * P->sinX1 + (xy.y * sinphi * P->cosX1 / rho));
108

  
109
		tp = tan(.5 * (HALFPI + phi_l));
110
		xy.x *= sinphi;
111
		xy.y = rho * P->cosX1 * cosphi - xy.y * P->sinX1* sinphi;
112
		halfpi = HALFPI;
113
		halfe = .5 * P->e;
114
		break;
115
	case N_POLE:
116
		xy.y = -xy.y;
117
	case S_POLE:
118
		phi_l = HALFPI - 2. * atan(tp = - rho / P->akm1);
119
		halfpi = -HALFPI;
120
		halfe = -.5 * P->e;
121
		break;
122
	}
123
	for (i = NITER; i--; phi_l = lp.phi) {
124
		sinphi = P->e * sin(phi_l);
125
		lp.phi = 2. * atan(tp * pow((1.+sinphi)/(1.-sinphi),
126
		   halfe)) - halfpi;
127
		if (fabs(phi_l - lp.phi) < CONV) {
128
			if (P->mode == S_POLE)
129
				lp.phi = -lp.phi;
130
			lp.lam = (xy.x == 0. && xy.y == 0.) ? 0. : atan2(xy.x, xy.y);
131
			return (lp);
132
		}
133
	}
134
	I_ERROR;
135
}
136
INVERSE(s_inverse); /* spheroid */
137
	double  c, rh, sinc, cosc;
138

  
139
	sinc = sin(c = 2. * atan((rh = hypot(xy.x, xy.y)) / P->akm1));
140
	cosc = cos(c);
141
	lp.lam = 0.;
142
	switch (P->mode) {
143
	case EQUIT:
144
		if (fabs(rh) <= EPS10)
145
			lp.phi = 0.;
146
		else
147
			lp.phi = asin(xy.y * sinc / rh);
148
		if (cosc != 0. || xy.x != 0.)
149
			lp.lam = atan2(xy.x * sinc, cosc * rh);
150
		break;
151
	case OBLIQ:
152
		if (fabs(rh) <= EPS10)
153
			lp.phi = P->phi0;
154
		else
155
			lp.phi = asin(cosc * sinph0 + xy.y * sinc * cosph0 / rh);
156
		if ((c = cosc - sinph0 * sin(lp.phi)) != 0. || xy.x != 0.)
157
			lp.lam = atan2(xy.x * sinc * cosph0, c * rh);
158
		break;
159
	case N_POLE:
160
		xy.y = -xy.y;
161
	case S_POLE:
162
		if (fabs(rh) <= EPS10)
163
			lp.phi = P->phi0;
164
		else
165
			lp.phi = asin(P->mode == S_POLE ? - cosc : cosc);
166
		lp.lam = (xy.x == 0. && xy.y == 0.) ? 0. : atan2(xy.x, xy.y);
167
		break;
168
	}
169
	return (lp);
170
}
171
FREEUP; if (P) pj_dalloc(P); }
172
	static PJ *
173
setup(PJ *P) { /* general initialization */
174
	double t;
175

  
176
	if (fabs((t = fabs(P->phi0)) - HALFPI) < EPS10)
177
		P->mode = P->phi0 < 0. ? S_POLE : N_POLE;
178
	else
179
		P->mode = t > EPS10 ? OBLIQ : EQUIT;
180
	P->phits = fabs(P->phits);
181
	if (P->es) {
182
		double X;
183

  
184
		switch (P->mode) {
185
		case N_POLE:
186
		case S_POLE:
187
			if (fabs(P->phits - HALFPI) < EPS10)
188
				P->akm1 = 2. * P->k0 /
189
				   sqrt(pow(1+P->e,1+P->e)*pow(1-P->e,1-P->e));
190
			else {
191
				P->akm1 = cos(P->phits) /
192
				   pj_tsfn(P->phits, t = sin(P->phits), P->e);
193
				t *= P->e;
194
				P->akm1 /= sqrt(1. - t * t);
195
			}
196
			break;
197
		case EQUIT:
198
			P->akm1 = 2. * P->k0;
199
			break;
200
		case OBLIQ:
201
			t = sin(P->phi0);
202
			X = 2. * atan(ssfn_(P->phi0, t, P->e)) - HALFPI;
203
			t *= P->e;
204
			P->akm1 = 2. * P->k0 * cos(P->phi0) / sqrt(1. - t * t);
205
			P->sinX1 = sin(X);
206
			P->cosX1 = cos(X);
207
			break;
208
		}
209
		P->inv = e_inverse;
210
		P->fwd = e_forward;
211
	} else {
212
		switch (P->mode) {
213
		case OBLIQ:
214
			sinph0 = sin(P->phi0);
215
			cosph0 = cos(P->phi0);
216
		case EQUIT:
217
			P->akm1 = 2. * P->k0;
218
			break;
219
		case S_POLE:
220
		case N_POLE:
221
			P->akm1 = fabs(P->phits - HALFPI) >= EPS10 ?
222
			   cos(P->phits) / tan(FORTPI - .5 * P->phits) :
223
			   2. * P->k0 ;
224
			break;
225
		}
226
		P->inv = s_inverse;
227
		P->fwd = s_forward;
228
	}
229
	return P;
230
}
231
ENTRY0(stere)
232
	P->phits = pj_param(P->params, "tlat_ts").i ?
233
		P->phits = pj_param(P->params, "rlat_ts").f : HALFPI;
234
ENDENTRY(setup(P))
235
ENTRY0(ups)
236
	/* International Ellipsoid */
237
	P->phi0 = pj_param(P->params, "bsouth").i ? - HALFPI: HALFPI;
238
	if (!P->es) E_ERROR(-34);
239
	P->k0 = .994;
240
	P->x0 = 2000000.;
241
	P->y0 = 2000000.;
242
	P->phits = HALFPI;
243
	P->lam0 = 0.;
244
ENDENTRY(setup(P))
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/PJ_sterea.c
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
*/
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/PJ_eck1.c
1
#ifndef lint
2
static const char SCCSID[]="@(#)PJ_eck1.c	4.1 94/02/15     GIE     REL";
3
#endif
4
#define PJ_LIB__
5
#include	<projects.h>
6
PROJ_HEAD(eck1, "Eckert I") "\n\tPCyl., Sph.";
7
#define FC	.92131773192356127802
8
#define RP	.31830988618379067154
9
FORWARD(s_forward); /* spheroid */
10
	xy.x = FC * lp.lam * (1. - RP * fabs(lp.phi));
11
	xy.y = FC * lp.phi;
12
	return (xy);
13
}
14
INVERSE(s_inverse); /* spheroid */
15
	lp.phi = xy.y / FC;
16
	lp.lam = xy.x / (FC * (1. - RP * fabs(lp.phi)));
17
	return (lp);
18
}
19
FREEUP; if (P) pj_dalloc(P); }
20
ENTRY0(eck1)
21
	P->es = 0.; P->inv = s_inverse; P->fwd = s_forward;
22
ENDENTRY(P)
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/PJ_labrd.c
1
#ifndef lint
2
static const char SCCSID[]="@(#)PJ_labrd.c	4.1	94/02/15	GIE	REL";
3
#endif
4
#define PROJ_PARMS__ \
5
	double	Az, kRg, p0s, A, C, Ca, Cb, Cc, Cd; \
6
	int		rot;
7
#define PJ_LIB__
8
#include	<projects.h>
9
PROJ_HEAD(labrd, "Laborde") "\n\tCyl, Sph\n\tSpecial for Madagascar";
10
#define EPS	1.e-10
11
FORWARD(e_forward);
12
	double V1, V2, ps, sinps, cosps, sinps2, cosps2, I1, I2, I3, I4, I5, I6,
13
		x2, y2, t;
14

  
15
	V1 = P->A * log( tan(FORTPI + .5 * lp.phi) );
16
	t = P->e * sin(lp.phi);
17
	V2 = .5 * P->e * P->A * log ((1. + t)/(1. - t));
18
	ps = 2. * (atan(exp(V1 - V2 + P->C)) - FORTPI);
19
	I1 = ps - P->p0s;
20
	cosps = cos(ps);	cosps2 = cosps * cosps;
21
	sinps = sin(ps);	sinps2 = sinps * sinps;
22
	I4 = P->A * cosps;
23
	I2 = .5 * P->A * I4 * sinps;
24
	I3 = I2 * P->A * P->A * (5. * cosps2 - sinps2) / 12.;
25
	I6 = I4 * P->A * P->A;
26
	I5 = I6 * (cosps2 - sinps2) / 6.;
27
	I6 *= P->A * P->A *
28
		(5. * cosps2 * cosps2 + sinps2 * (sinps2 - 18. * cosps2)) / 120.;
29
	t = lp.lam * lp.lam;
30
	xy.x = P->kRg * lp.lam * (I4 + t * (I5 + t * I6));
31
	xy.y = P->kRg * (I1 + t * (I2 + t * I3));
32
	x2 = xy.x * xy.x;
33
	y2 = xy.y * xy.y;
34
	V1 = 3. * xy.x * y2 - xy.x * x2;
35
	V2 = xy.y * y2 - 3. * x2 * xy.y;
36
	xy.x += P->Ca * V1 + P->Cb * V2;
37
	xy.y += P->Ca * V2 - P->Cb * V1;
38
	return (xy);
39
}
40
INVERSE(e_inverse); /* ellipsoid & spheroid */
41
	double x2, y2, V1, V2, V3, V4, t, t2, ps, pe, tpe, s,
42
		I7, I8, I9, I10, I11, d, Re;
43
	int i;
44

  
45
	x2 = xy.x * xy.x;
46
	y2 = xy.y * xy.y;
47
	V1 = 3. * xy.x * y2 - xy.x * x2;
48
	V2 = xy.y * y2 - 3. * x2 * xy.y;
49
	V3 = xy.x * (5. * y2 * y2 + x2 * (-10. * y2 + x2 ));
50
	V4 = xy.y * (5. * x2 * x2 + y2 * (-10. * x2 + y2 ));
51
	xy.x += - P->Ca * V1 - P->Cb * V2 + P->Cc * V3 + P->Cd * V4;
52
	xy.y +=   P->Cb * V1 - P->Ca * V2 - P->Cd * V3 + P->Cc * V4;
53
	ps = P->p0s + xy.y / P->kRg;
54
	pe = ps + P->phi0 - P->p0s;
55
	for ( i = 20; i; --i) {
56
		V1 = P->A * log(tan(FORTPI + .5 * pe));
57
		tpe = P->e * sin(pe);
58
		V2 = .5 * P->e * P->A * log((1. + tpe)/(1. - tpe));
59
		t = ps - 2. * (atan(exp(V1 - V2 + P->C)) - FORTPI);
60
		pe += t;
61
		if (fabs(t) < EPS)
62
			break;
63
	}
64
/*
65
	if (!i) {
66
	} else {
67
	}
68
*/
69
	t = P->e * sin(pe);
70
	t = 1. - t * t;
71
	Re = P->one_es / ( t * sqrt(t) );
72
	t = tan(ps);
73
	t2 = t * t;
74
	s = P->kRg * P->kRg;
75
	d = Re * P->k0 * P->kRg;
76
	I7 = t / (2. * d);
77
	I8 = t * (5. + 3. * t2) / (24. * d * s);
78
	d = cos(ps) * P->kRg * P->A;
79
	I9 = 1. / d;
80
	d *= s;
81
	I10 = (1. + 2. * t2) / (6. * d);
82
	I11 = (5. + t2 * (28. + 24. * t2)) / (120. * d * s);
83
	x2 = xy.x * xy.x;
84
	lp.phi = pe + x2 * (-I7 + I8 * x2);
85
	lp.lam = xy.x * (I9 + x2 * (-I10 + x2 * I11));
86
	return (lp);
87
}
88
FREEUP; if (P) pj_dalloc(P); }
89
ENTRY0(labrd)
90
	double Az, sinp, R, N, t;
91

  
92
	P->rot	= pj_param(P->params, "bno_rot").i == 0;
93
	Az = pj_param(P->params, "razi").f;
94
	sinp = sin(P->phi0);
95
	t = 1. - P->es * sinp * sinp;
96
	N = 1. / sqrt(t);
97
	R = P->one_es * N / t;
98
	P->kRg = P->k0 * sqrt( N * R );
99
	P->p0s = atan( sqrt(R / N) * tan(P->phi0) );
100
	P->A = sinp / sin(P->p0s);
101
	t = P->e * sinp;
102
	P->C = .5 * P->e * P->A * log((1. + t)/(1. - t)) +
103
		- P->A * log( tan(FORTPI + .5 * P->phi0))
104
		+ log( tan(FORTPI + .5 * P->p0s));
105
	t = Az + Az;
106
	P->Ca = (1. - cos(t)) * ( P->Cb = 1. / (12. * P->kRg * P->kRg) );
107
	P->Cb *= sin(t);
108
	P->Cc = 3. * (P->Ca * P->Ca - P->Cb * P->Cb);
109
	P->Cd = 6. * P->Ca * P->Cb;
110
	P->inv = e_inverse;
111
	P->fwd = e_forward;
112
ENDENTRY(P)
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/pj_geocent.c
1
/******************************************************************************
2
 * $Id: pj_geocent.c,v 1.1 2002/12/14 20:13:21 warmerda Exp $
3
 *
4
 * Project:  PROJ.4
5
 * Purpose:  Stub projection for geocentric.  The transformation isn't
6
 *           really done here since this code is 2D.  The real transformation
7
 *           is handled by pj_transform.c.
8
 * Author:   Frank Warmerdam, warmerdam@pobox.com
9
 *
10
 ******************************************************************************
11
 * Copyright (c) 2002, Frank Warmerdam
12
 *
13
 * Permission is hereby granted, free of charge, to any person obtaining a
14
 * copy of this software and associated documentation files (the "Software"),
15
 * to deal in the Software without restriction, including without limitation
16
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17
 * and/or sell copies of the Software, and to permit persons to whom the
18
 * Software is furnished to do so, subject to the following conditions:
19
 *
20
 * The above copyright notice and this permission notice shall be included
21
 * in all copies or substantial portions of the Software.
22
 *
23
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29
 * DEALINGS IN THE SOFTWARE.
30
 ******************************************************************************
31
 *
32
 * $Log: pj_geocent.c,v $
33
 * Revision 1.1  2002/12/14 20:13:21  warmerda
34
 * New
35
 *
36
 */
37

  
38
#define PJ_LIB__
39
#include <projects.h>
40

  
41
PJ_CVSID("$Id: pj_geocent.c,v 1.1 2002/12/14 20:13:21 warmerda Exp $");
42

  
43
PROJ_HEAD(geocent, "Geocentric")  "\n\t";
44

  
45
FORWARD(forward);
46
        xy.x = lp.lam;
47
        xy.y = lp.phi;
48
        return xy;
49
}
50
INVERSE(inverse);
51
        lp.phi = xy.y;
52
        lp.lam = xy.x;
53
        return lp;
54
}
55
FREEUP; if (P) pj_dalloc(P); }
56

  
57
ENTRY0(geocent)
58
    P->is_geocent = 1; 
59
    P->x0 = 0.0;
60
    P->y0 = 0.0;
61
    P->inv = inverse; P->fwd = forward;
62
ENDENTRY(P)
63

  
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/pj_errno.c
1
/* For full ANSI compliance of global variable */
2
#ifndef lint
3
static const char SCCSID[]="@(#)pj_errno.c	4.3	95/06/03	GIE	REL";
4
#endif
5

  
6
#include <projects.h>
7

  
8
C_NAMESPACE int pj_errno = 0;
9

  
10
/************************************************************************/
11
/*                          pj_get_errno_ref()                          */
12
/************************************************************************/
13

  
14
int *pj_get_errno_ref()
15

  
16
{
17
    return &pj_errno;
18
}
19

  
20
/* end */
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/PJ_eck5.c
1
#ifndef lint
2
static const char SCCSID[]="@(#)PJ_eck5.c	4.1 94/02/15     GIE     REL";
3
#endif
4
#define PJ_LIB__
5
# include	<projects.h>
6
PROJ_HEAD(eck5, "Eckert V") "\n\tPCyl, Sph.";
7
#define XF	0.44101277172455148219
8
#define RXF	2.26750802723822639137
9
#define YF	0.88202554344910296438
10
#define RYF	1.13375401361911319568
11
FORWARD(s_forward); /* spheroid */
12
	xy.x = XF * (1. + cos(lp.phi)) * lp.lam;
13
	xy.y = YF * lp.phi;
14
	return (xy);
15
}
16
INVERSE(s_inverse); /* spheroid */
17
	lp.lam = RXF * xy.x / (1. + cos( lp.phi = RYF * xy.y));
18
	return (lp);
19
}
20
FREEUP; if (P) pj_dalloc(P); }
21
ENTRY0(eck5); P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/pj_ell_set.c
1
/* set ellipsoid parameters a and es */
2
#ifndef lint
3
static const char SCCSID[]="@(#)pj_ell_set.c	4.5	93/06/12	GIE	REL";
4
#endif
5
#include <projects.h>
6
#include <string.h>
7
#define SIXTH .1666666666666666667 /* 1/6 */
8
#define RA4 .04722222222222222222 /* 17/360 */
9
#define RA6 .02215608465608465608 /* 67/3024 */
10
#define RV4 .06944444444444444444 /* 5/72 */
11
#define RV6 .04243827160493827160 /* 55/1296 */
12
	int /* initialize geographic shape parameters */
13
pj_ell_set(paralist *pl, double *a, double *es) {
14
	int i;
15
	double b=0.0, e;
16
	char *name;
17
	paralist *start = 0, *curr;
18

  
19
		/* check for varying forms of ellipsoid input */
20
	*a = *es = 0.;
21
	/* R takes precedence */
22
	if (pj_param(pl, "tR").i)
23
		*a = pj_param(pl, "dR").f;
24
	else { /* probable elliptical figure */
25

  
26
		/* check if ellps present and temporarily append its values to pl */
27
		if (name = pj_param(pl, "sellps").s) {
28
			char *s;
29

  
30
			for (start = pl; start && start->next ; start = start->next) ;
31
			curr = start;
32
			for (i = 0; (s = pj_ellps[i].id) && strcmp(name, s) ; ++i) ;
33
			if (!s) { pj_errno = -9; return 1; }
34
			curr = curr->next = pj_mkparam(pj_ellps[i].major);
35
			curr = curr->next = pj_mkparam(pj_ellps[i].ell);
36
		}
37
		*a = pj_param(pl, "da").f;
38
		if (pj_param(pl, "tes").i) /* eccentricity squared */
39
			*es = pj_param(pl, "des").f;
40
		else if (pj_param(pl, "te").i) { /* eccentricity */
41
			e = pj_param(pl, "de").f;
42
			*es = e * e;
43
		} else if (pj_param(pl, "trf").i) { /* recip flattening */
44
			*es = pj_param(pl, "drf").f;
45
			if (!*es) {
46
				pj_errno = -10;
47
				goto bomb;
48
			}
49
			*es = 1./ *es;
50
			*es = *es * (2. - *es);
51
		} else if (pj_param(pl, "tf").i) { /* flattening */
52
			*es = pj_param(pl, "df").f;
53
			*es = *es * (2. - *es);
54
		} else if (pj_param(pl, "tb").i) { /* minor axis */
55
			b = pj_param(pl, "db").f;
56
			*es = 1. - (b * b) / (*a * *a);
57
		}     /* else *es == 0. and sphere of radius *a */
58
		if (!b)
59
			b = *a * sqrt(1. - *es);
60
		/* following options turn ellipsoid into equivalent sphere */
61
		if (pj_param(pl, "bR_A").i) { /* sphere--area of ellipsoid */
62
			*a *= 1. - *es * (SIXTH + *es * (RA4 + *es * RA6));
63
			*es = 0.;
64
		} else if (pj_param(pl, "bR_V").i) { /* sphere--vol. of ellipsoid */
65
			*a *= 1. - *es * (SIXTH + *es * (RV4 + *es * RV6));
66
			*es = 0.;
67
		} else if (pj_param(pl, "bR_a").i) { /* sphere--arithmetic mean */
68
			*a = .5 * (*a + b);
69
			*es = 0.;
70
		} else if (pj_param(pl, "bR_g").i) { /* sphere--geometric mean */
71
			*a = sqrt(*a * b);
72
			*es = 0.;
73
		} else if (pj_param(pl, "bR_h").i) { /* sphere--harmonic mean */
74
			*a = 2. * *a * b / (*a + b);
75
			*es = 0.;
76
		} else if ((i = pj_param(pl, "tR_lat_a").i) || /* sphere--arith. */
77
			pj_param(pl, "tR_lat_g").i) { /* or geom. mean at latitude */
78
			double tmp;
79

  
80
			tmp = sin(pj_param(pl, i ? "rR_lat_a" : "rR_lat_g").f);
81
			if (fabs(tmp) > HALFPI) {
82
				pj_errno = -11;
83
				goto bomb;
84
			}
85
			tmp = 1. - *es * tmp * tmp;
86
			*a *= i ? .5 * (1. - *es + tmp) / ( tmp * sqrt(tmp)) :
87
				sqrt(1. - *es) / tmp;
88
			*es = 0.;
89
		}
90
bomb:
91
		if (start) { /* clean up temporary extension of list */
92
			pj_dalloc(start->next->next);
93
			pj_dalloc(start->next);
94
			start->next = 0;
95
		}
96
		if (pj_errno)
97
			return 1;
98
	}
99
	/* some remaining checks */
100
	if (*es < 0.)
101
		{ pj_errno = -12; return 1; }
102
	if (*a <= 0.)
103
		{ pj_errno = -13; return 1; }
104
	return 0;
105
}
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/PJ_wink2.c
1
#ifndef lint
2
static const char SCCSID[]="@(#)PJ_wink2.c	4.1 94/02/15     GIE     REL";
3
#endif
4
#define PROJ_PARMS__ \
5
	double	cosphi1;
6
#define PJ_LIB__
7
# include	<projects.h>
8
PROJ_HEAD(wink2, "Winkel II") "\n\tPCyl., Sph., no inv.\n\tlat_1=";
9
#define MAX_ITER    10
10
#define LOOP_TOL    1e-7
11
#define TWO_D_PI 0.636619772367581343
12
FORWARD(s_forward); /* spheroid */
13
	double k, V;
14
	int i;
15

  
16
	xy.y = lp.phi * TWO_D_PI;
17
	k = PI * sin(lp.phi);
18
	lp.phi *= 1.8;
19
	for (i = MAX_ITER; i ; --i) {
20
		lp.phi -= V = (lp.phi + sin(lp.phi) - k) /
21
			(1. + cos(lp.phi));
22
		if (fabs(V) < LOOP_TOL)
23
			break;
24
	}
25
	if (!i)
26
		lp.phi = (lp.phi < 0.) ? -HALFPI : HALFPI;
27
	else
28
		lp.phi *= 0.5;
29
	xy.x = 0.5 * lp.lam * (cos(lp.phi) + P->cosphi1);
30
	xy.y = FORTPI * (sin(lp.phi) + xy.y);
31
	return (xy);
32
}
33
FREEUP; if (P) pj_dalloc(P); }
34
ENTRY0(wink2)
35
	P->cosphi1 = cos(pj_param(P->params, "rlat_1").f);
36
	P->es = 0.; P->inv = 0; P->fwd = s_forward;
37
ENDENTRY(P)
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/vector1.c
1
/* make storage for one and two dimensional matricies */
2
#ifndef lint
3
static const char SCCSID[]="@(#)vector1.c	4.4	94/03/22	GIE	REL";
4
#endif
5
#include <stdlib.h>
6
#include <projects.h>
7
	void * /* one dimension array */
8
vector1(int nvals, int size) { return((void *)pj_malloc(size * nvals)); }
9
	void /* free 2D array */
10
freev2(void **v, int nrows) {
11
	if (v) {
12
		for (v += nrows; nrows > 0; --nrows)
13
			pj_dalloc(*--v);
14
		pj_dalloc(v);
15
	}
16
}
17
	void ** /* two dimension array */
18
vector2(int nrows, int ncols, int size) {
19
	void **s;
20

  
21
	if (s = (void **)pj_malloc(sizeof(void *) * nrows)) {
22
		int rsize, i;
23

  
24
		rsize = size * ncols;
25
		for (i = 0; i < nrows; ++i)
26
			if (!(s[i] = pj_malloc(rsize))) {
27
				freev2(s, i);
28
				return (void **)0;
29
			}
30
	}
31
	return s;
32
}
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/PJ_nell.c
1
#ifndef lint
2
static const char SCCSID[]="@(#)PJ_nell.c	4.1	94/02/15	GIE	REL";
3
#endif
4
#define PJ_LIB__
5
#include	<projects.h>
6
PROJ_HEAD(nell, "Nell") "\n\tPCyl., Sph.";
7
#define MAX_ITER	10
8
#define LOOP_TOL	1e-7
9
FORWARD(s_forward); /* spheroid */
10
	double k, V;
11
	int i;
12

  
13
	k = 2. * sin(lp.phi);
14
	V = lp.phi * lp.phi;
15
	lp.phi *= 1.00371 + V * (-0.0935382 + V * -0.011412);
16
	for (i = MAX_ITER; i ; --i) {
17
		lp.phi -= V = (lp.phi + sin(lp.phi) - k) /
18
			(1. + cos(lp.phi));
19
		if (fabs(V) < LOOP_TOL)
20
			break;
21
	}
22
	xy.x = 0.5 * lp.lam * (1. + cos(lp.phi));
23
	xy.y = lp.phi;
24
	return (xy);
25
}
26
INVERSE(s_inverse); /* spheroid */
27
	double th, s;
28

  
29
	lp.lam = 2. * xy.x / (1. + cos(xy.y));
30
	lp.phi = aasin(0.5 * (xy.y + sin(xy.y)));
31
	return (lp);
32
}
33
FREEUP; if (P) pj_dalloc(P); }
34
ENTRY0(nell) P->es = 0; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/PJ_ortho.c
1
#ifndef lint
2
static const char SCCSID[]="@(#)PJ_ortho.c	4.1	94/02/15	GIE	REL";
3
#endif
4
#define PROJ_PARMS__ \
5
	double	sinph0; \
6
	double	cosph0; \
7
	int		mode;
8
#define PJ_LIB__
9
#include	<projects.h>
10
PROJ_HEAD(ortho, "Orthographic") "\n\tAzi, Sph.";
11
#define EPS10 1.e-10
12
#define N_POLE	0
13
#define S_POLE 1
14
#define EQUIT	2
15
#define OBLIQ	3
16
FORWARD(s_forward); /* spheroid */
17
	double  coslam, cosphi, sinphi;
18

  
19
	cosphi = cos(lp.phi);
20
	coslam = cos(lp.lam);
21
	switch (P->mode) {
22
	case EQUIT:
23
		if (cosphi * coslam < - EPS10) F_ERROR;
24
		xy.y = sin(lp.phi);
25
		break;
26
	case OBLIQ:
27
		if (P->sinph0 * (sinphi = sin(lp.phi)) +
28
		   P->cosph0 * cosphi * coslam < - EPS10) F_ERROR;
29
		xy.y = P->cosph0 * sinphi - P->sinph0 * cosphi * coslam;
30
		break;
31
	case N_POLE:
32
		coslam = - coslam;
33
	case S_POLE:
34
		if (fabs(lp.phi - P->phi0) - EPS10 > HALFPI) F_ERROR;
35
		xy.y = cosphi * coslam;
36
		break;
37
	}
38
	xy.x = cosphi * sin(lp.lam);
39
	return (xy);
40
}
41

  
42
INVERSE(s_inverse); /* spheroid */
43
    double  rh, cosc, sinc;
44

  
45
    if ((sinc = (rh = hypot(xy.x, xy.y))) > 1.) {
46
        if ((sinc - 1.) > EPS10) I_ERROR;
47
        sinc = 1.;
48
    }
49
    cosc = sqrt(1. - sinc * sinc); /* in this range OK */
50
    if (fabs(rh) <= EPS10) {
51
        lp.phi = P->phi0;
52
        lp.lam = 0.0;
53
    } else {
54
        switch (P->mode) {
55
        case N_POLE:
56
            xy.y = -xy.y;
57
            lp.phi = acos(sinc);
58
            break;
59
        case S_POLE:
60
            lp.phi = - acos(sinc);
61
            break;
62
        case EQUIT:
63
            lp.phi = xy.y * sinc / rh;
64
            xy.x *= sinc;
65
            xy.y = cosc * rh;
66
            goto sinchk;
67
        case OBLIQ:
68
            lp.phi = cosc * P->sinph0 + xy.y * sinc * P->cosph0 /rh;
69
            xy.y = (cosc - P->sinph0 * lp.phi) * rh;
70
            xy.x *= sinc * P->cosph0;
71
        sinchk:
72
            if (fabs(lp.phi) >= 1.)
73
                lp.phi = lp.phi < 0. ? -HALFPI : HALFPI;
74
            else
75
                lp.phi = asin(lp.phi);
76
            break;
77
        }
78
        lp.lam = (xy.y == 0. && (P->mode == OBLIQ || P->mode == EQUIT))
79
             ? (xy.x == 0. ? 0. : xy.x < 0. ? -HALFPI : HALFPI)
80
                           : atan2(xy.x, xy.y);
81
    }
82
    return (lp);
83
}
84

  
85
FREEUP; if (P) pj_dalloc(P); }
86
ENTRY0(ortho)
87
	if (fabs(fabs(P->phi0) - HALFPI) <= EPS10)
88
		P->mode = P->phi0 < 0. ? S_POLE : N_POLE;
89
	else if (fabs(P->phi0) > EPS10) {
90
		P->mode = OBLIQ;
91
		P->sinph0 = sin(P->phi0);
92
		P->cosph0 = cos(P->phi0);
93
	} else
94
		P->mode = EQUIT;
95
	P->inv = s_inverse;
96
	P->fwd = s_forward;
97
	P->es = 0.;
98
ENDENTRY(P)
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/bchgen.c
1
/* generate double bivariate Chebychev polynomial */
2
#ifndef lint
3
static const char SCCSID[]="@(#)bchgen.c	4.5	94/03/22	GIE	REL";
4
#endif
5
#include <projects.h>
6
	int
7
bchgen(projUV a, projUV b, int nu, int nv, projUV **f, projUV(*func)(projUV)) {
8
	int i, j, k;
9
	projUV arg, *t, bma, bpa, *c;
10
	double d, fac;
11

  
12
	bma.u = 0.5 * (b.u - a.u); bma.v = 0.5 * (b.v - a.v);
13
	bpa.u = 0.5 * (b.u + a.u); bpa.v = 0.5 * (b.v + a.v);
14
	for ( i = 0; i < nu; ++i) {
15
		arg.u = cos(PI * (i + 0.5) / nu) * bma.u + bpa.u;
16
		for ( j = 0; j < nv; ++j) {
17
			arg.v = cos(PI * (j + 0.5) / nv) * bma.v + bpa.v;
18
			f[i][j] = (*func)(arg);
19
			if ((f[i][j]).u == HUGE_VAL)
20
				return(1);
21
		}
22
	}
23
	if (!(c = (projUV *) vector1(nu, sizeof(projUV)))) return 1;
24
	fac = 2. / nu;
25
	for ( j = 0; j < nv ; ++j) {
26
		for ( i = 0; i < nu; ++i) {
27
			arg.u = arg.v = 0.;
28
			for (k = 0; k < nu; ++k) {
29
				d = cos(PI * i * (k + .5) / nu);
30
				arg.u += f[k][j].u * d;
31
				arg.v += f[k][j].v * d;
32
			}
33
			arg.u *= fac;
34
			arg.v *= fac;
35
			c[i] = arg;
36
		}
37
		for (i = 0; i < nu; ++i)
38
			f[i][j] = c[i];
39
	}
40
	pj_dalloc(c);
41
	if (!(c = (projUV*) vector1(nv, sizeof(projUV)))) return 1;
42
	fac = 2. / nv;
43
	for ( i = 0; i < nu; ++i) {
44
		t = f[i];
45
		for (j = 0; j < nv; ++j) {
46
			arg.u = arg.v = 0.;
47
			for (k = 0; k < nv; ++k) {
48
				d = cos(PI * j * (k + .5) / nv);
49
				arg.u += t[k].u * d;
50
				arg.v += t[k].v * d;
51
			}
52
			arg.u *= fac;
53
			arg.v *= fac;
54
			c[j] = arg;
55
		}
56
		f[i] = c;
57
		c = t;
58
	}
59
	pj_dalloc(c);
60
	return(0);
61
}
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/pj_zpoly1.c
1
/* evaluate complex polynomial */
2
#ifndef lint
3
static const char SCCSID[]="@(#)pj_zpoly1.c	4.3	93/06/12	GIE	REL";
4
#endif
5
#include <projects.h>
6
/* note: coefficients are always from C_1 to C_n
7
**	i.e. C_0 == (0., 0)
8
**	n should always be >= 1 though no checks are made
9
*/
10
	COMPLEX
11
pj_zpoly1(COMPLEX z, COMPLEX *C, int n) {
12
	COMPLEX a;
13
	double t;
14

  
15
	a = *(C += n);
16
	while (n-- > 0) {
17
		a.r = (--C)->r + z.r * (t = a.r) - z.i * a.i;
18
		a.i = C->i + z.r * a.i + z.i * t;
19
	}
20
	a.r = z.r * (t = a.r) - z.i * a.i;
21
	a.i = z.r * a.i + z.i * t;
22
	return a;
23
}
24
/* evaluate complex polynomial and derivative */
25
	COMPLEX
26
pj_zpolyd1(COMPLEX z, COMPLEX *C, int n, COMPLEX *der) {
27
	COMPLEX a, b;
28
	double t;
29
	int first = 1;
30

  
31
	a = *(C += n);
32
	while (n-- > 0) {
33
		if (first) {
34
			first = 0;
35
			b = a;
36
		} else {
37
			b.r = a.r + z.r * (t = b.r) - z.i * b.i;
38
			b.i = a.i + z.r * b.i + z.i * t;
39
		}
40
		a.r = (--C)->r + z.r * (t = a.r) - z.i * a.i;
41
		a.i = C->i + z.r * a.i + z.i * t;
42
	}
43
	b.r = a.r + z.r * (t = b.r) - z.i * b.i;
44
	b.i = a.i + z.r * b.i + z.i * t;
45
	a.r = z.r * (t = a.r) - z.i * a.i;
46
	a.i = z.r * a.i + z.i * t;
47
	*der = b;
48
	return a;
49
}
1.10/tags/gvSIG_3D_Animation_1_10_build_15/libraries/libjni-proj4/src/PJ_vandg.c
1
#ifndef lint
2
static const char SCCSID[]="@(#)PJ_vandg.c	4.1	94/02/15	GIE	REL";
3
#endif
4
#define PJ_LIB__
5
# include	<projects.h>
6
PROJ_HEAD(vandg, "van der Grinten (I)") "\n\tMisc Sph";
7
# define TOL		1.e-10
8
# define THIRD		.33333333333333333333
9
# define TWO_THRD	.66666666666666666666
10
# define C2_27		.07407407407407407407
11
# define PI4_3		4.18879020478639098458
12
# define PISQ		9.86960440108935861869
13
# define TPISQ		19.73920880217871723738
14
# define HPISQ		4.93480220054467930934
15
FORWARD(s_forward); /* spheroid */
16
	double  al, al2, g, g2, p2;
17

  
18
	p2 = fabs(lp.phi / HALFPI);
19
	if ((p2 - TOL) > 1.) F_ERROR;
20
	if (p2 > 1.)
21
		p2 = 1.;
22
	if (fabs(lp.phi) <= TOL) {
23
		xy.x = lp.lam;
24
		xy.y = 0.;
25
	} else if (fabs(lp.lam) <= TOL || fabs(p2 - 1.) < TOL) {
26
		xy.x = 0.;
27
		xy.y = PI * tan(.5 * asin(p2));
28
		if (lp.phi < 0.) xy.y = -xy.y;
29
	} else {
30
		al = .5 * fabs(PI / lp.lam - lp.lam / PI);
31
		al2 = al * al;
32
		g = sqrt(1. - p2 * p2);
33
		g = g / (p2 + g - 1.);
34
		g2 = g * g;
35
		p2 = g * (2. / p2 - 1.);
36
		p2 = p2 * p2;
37
		xy.x = g - p2; g = p2 + al2;
38
		xy.x = PI * (al * xy.x + sqrt(al2 * xy.x * xy.x - g * (g2 - p2))) / g;
39
		if (lp.lam < 0.) xy.x = -xy.x;
40
		xy.y = fabs(xy.x / PI);
41
		xy.y = 1. - xy.y * (xy.y + 2. * al);
42
		if (xy.y < -TOL) F_ERROR;
43
		if (xy.y < 0.)	xy.y = 0.;
44
		else		xy.y = sqrt(xy.y) * (lp.phi < 0. ? -PI : PI);
45
	}
46
	return (xy);
47
}
48
INVERSE(s_inverse); /* spheroid */
49
	double t, c0, c1, c2, c3, al, r2, r, m, d, ay, x2, y2;
50

  
51
	x2 = xy.x * xy.x;
52
	if ((ay = fabs(xy.y)) < TOL) {
53
		lp.phi = 0.;
54
		t = x2 * x2 + TPISQ * (x2 + HPISQ);
55
		lp.lam = fabs(xy.x) <= TOL ? 0. :
56
		   .5 * (x2 - PISQ + sqrt(t)) / xy.x;
57
		return (lp);
58
	}
59
	y2 = xy.y * xy.y;
60
	r = x2 + y2;	r2 = r * r;
61
	c1 = - PI * ay * (r + PISQ);
62
	c3 = r2 + TWOPI * (ay * r + PI * (y2 + PI * (ay + HALFPI)));
63
	c2 = c1 + PISQ * (r - 3. *  y2);
64
	c0 = PI * ay;
65
	c2 /= c3;
66
	al = c1 / c3 - THIRD * c2 * c2;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff