PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/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
37#define PROJ_PARMS__ \
38	double	cosphi1; \
39	int		mode;
40#define PJ_LIB__
41#include "projects.h"
42
43PJ_CVSID("$Id: PJ_aitoff.c,v 1.3 2002/12/14 19:32:27 warmerda Exp $");
44
45PROJ_HEAD(aitoff, "Aitoff") "\n\tMisc Sph";
46PROJ_HEAD(wintri, "Winkel Tripel") "\n\tMisc Sph\n\tlat_1";
47
48FORWARD(s_forward); /* spheroid */
49	double c, d;
50
51	if((d = acos(cos(lp.phi) * cos(c = 0.5 * lp.lam)))) {/* basic Aitoff */
52		xy.x = 2. * d * cos(lp.phi) * sin(c) * (xy.y = 1. / sin(d));
53		xy.y *= d * sin(lp.phi);
54	} else
55		xy.x = xy.y = 0.;
56	if (P->mode) { /* Winkel Tripel */
57		xy.x = (xy.x + lp.lam * P->cosphi1) * 0.5;
58		xy.y = (xy.y + lp.phi) * 0.5;
59	}
60	return (xy);
61}
62FREEUP; if (P) pj_dalloc(P); }
63	static PJ *
64setup(PJ *P) {
65	P->inv = 0;
66	P->fwd = s_forward;
67	P->es = 0.;
68	return P;
69}
70ENTRY0(aitoff)
71	P->mode = 0;
72ENDENTRY(setup(P))
73ENTRY0(wintri)
74	P->mode = 1;
75	if (pj_param(P->params, "tlat_1").i)
76        {
77		if ((P->cosphi1 = cos(pj_param(P->params, "rlat_1").f)) == 0.)
78			E_ERROR(-22)
79        }
80	else /* 50d28' or acos(2/pi) */
81		P->cosphi1 = 0.636619772367581343;
82ENDENTRY(setup(P))