/[zanavi_public1]/navit/navit/tools/gpx2navit_txt/src/geod_set.c
ZANavi

Contents of /navit/navit/tools/gpx2navit_txt/src/geod_set.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations) (download)
Fri Oct 28 21:19:04 2011 UTC (12 years, 5 months ago) by zoff99
File MIME type: text/plain
File size: 3039 byte(s)
import files
1 /**
2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #ifndef lint
21 /*
22 * static const char SCCSID[]="@(#)geod_set.c 4.8 95/09/23 GIE REL";
23 */
24 #endif
25
26 #define _IN_GEOD_SET
27
28 #include <string.h>
29 #include "projects.h"
30 #include "geodesic.h"
31 #include "emess.h"
32 void geod_set(int argc, char **argv)
33 {
34 paralist *start = 0, *curr = NULL; /* added NULL */
35 double es;
36 char *name;
37 int i;
38
39 /*
40 * put arguments into internal linked list
41 */
42 if (argc <= 0)
43 emess(1, "no arguments in initialization list");
44 for (i = 0; i < argc; ++i)
45 if (i)
46 curr = curr->next = pj_mkparam(argv[i]);
47 else
48 start = curr = pj_mkparam(argv[i]);
49 /*
50 * set elliptical parameters
51 */
52 if (pj_ell_set(start, &geod_a, &es))
53 emess(1, "ellipse setup failure");
54 /*
55 * set units
56 */
57 if ((name = pj_param(start, "sunits").s)) { /* added parentheses */
58 char *s;
59
60 for (i = 0; (s = pj_units[i].id) && strcmp(name, s); ++i);
61 if (!s)
62 emess(1, "%s unknown unit conversion id", name);
63 fr_meter = 1. / (to_meter = atof(pj_units[i].to_meter));
64 } else
65 to_meter = fr_meter = 1.;
66 if ((ellipse = es != 0.)) { /* added parentheses */
67 onef = sqrt(1. - es);
68 geod_f = 1 - onef;
69 f2 = geod_f / 2;
70 f4 = geod_f / 4;
71 f64 = geod_f * geod_f / 64;
72 } else {
73 onef = 1.;
74 geod_f = f2 = f4 = f64 = 0.;
75 }
76 /*
77 * check if line or arc mode
78 */
79 if (pj_param(start, "tlat_1").i) {
80 double del_S;
81 #undef f
82 phi1 = pj_param(start, "rlat_1").f;
83 lam1 = pj_param(start, "rlon_1").f;
84 if (pj_param(start, "tlat_2").i) {
85 phi2 = pj_param(start, "rlat_2").f;
86 lam2 = pj_param(start, "rlon_2").f;
87 geod_inv();
88 geod_pre();
89 } else if ((geod_S = pj_param(start, "dS").f)) { /* added
90 * parentheses
91 */
92 al12 = pj_param(start, "rA").f;
93 geod_pre();
94 geod_for();
95 } else
96 emess(1, "incomplete geodesic/arc info");
97 if ((n_alpha = pj_param(start, "in_A").i) > 0) {
98 if (!(del_alpha = pj_param(start, "rdel_A").f))
99 emess(1, "del azimuth == 0");
100 } else if ((del_S = fabs(pj_param(start, "ddel_S").f))) { /* added
101 * parentheses
102 */
103 n_S = geod_S / del_S + .5;
104 } else if ((n_S = pj_param(start, "in_S").i) <= 0)
105 emess(1, "no interval divisor selected");
106 }
107 /*
108 * free up linked list
109 */
110 for (; start; start = curr) {
111 curr = start->next;
112 pj_dalloc(start);
113 }
114 }

   
Visit the ZANavi Wiki