]> git.mxchange.org Git - flightgear.git/blob - Areas/main.cxx
Removed forced -g compile flag.
[flightgear.git] / Areas / main.cxx
1 // main.c -- main loop
2 //
3 // Written by Curtis Olson, started March 1998.
4 //
5 // Copyright (C) 1998  Curtis L. Olson  - curt@me.umn.edu
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22 // (Log is kept at end of this file)
23 //
24
25
26 #ifdef HAVE_CONFIG_H
27 #include <config.h>
28 #endif
29
30 #ifdef HAVE_STDLIB_H
31 #include <stdlib.h>
32 #endif
33
34 #include <stdio.h>
35 #include <string.h>
36
37 #include "area.hxx"
38
39 #include <Bucket/bucketutils.h>
40 #include <Include/fg_constants.h>
41
42
43 int main( int argc, char **argv ) {
44     fgBUCKET b;
45     point2d nodes[4];
46     FILE *fd;
47     char base[256], path[256], command[256], file[256], exfile[256];
48     double lon, lat, elevation, heading;
49     double length, width;
50     long int index;
51     int i, count;
52
53     if ( argc != 2 ) {
54         printf("Usage %s <work dir>\n", argv[0]);
55         exit(0);
56     }
57
58     // P13 (Globe, AZ)
59     // lon = -110.6642442;
60     // lat = 33.3528903;
61     // heading = 102.0 * DEG_TO_RAD;
62     // length = 1769;
63     // width = 23;
64
65     // KANE
66     lon = -93.2113889;
67     lat = 45.145;
68     elevation = 912 * FEET_TO_METER;
69     heading = 270.0 * DEG_TO_RAD;
70     length = 1220;
71     width = 23;
72
73     gen_runway_area( lon * DEG_TO_RAD, lat * DEG_TO_RAD, 
74                      heading, length, width, nodes, &count );
75
76     fgBucketFind(lon, lat, &b);
77     printf( "Bucket = lon,lat = %d,%d  x,y index = %d,%d\n", 
78             b.lon, b.lat, b.x, b.y);
79
80     index = fgBucketGenIndex(&b);
81     fgBucketGenBasePath(&b, base);
82     sprintf(path, "%s/Scenery/%s", argv[1], base);
83     sprintf(command, "mkdir -p %s\n", path);
84     system(command);
85     
86     sprintf(exfile, "%s/%ld.node.ex", path, index);
87     sprintf(file, "%s/%ld.poly", path, index);
88     printf( "extra node file = %s\n", exfile);
89     printf( "poly file = %s\n", file);
90
91     // output extra nodes
92     if ( (fd = fopen(exfile, "w")) == NULL ) {
93         printf("Cannot open file: %s\n", exfile);
94         exit(-1);
95     }
96
97     fprintf(fd, "%d 2 0 0\n", count);
98     for ( i = 0; i < count; i++ ) {
99         fprintf( fd, "%d %.2f %.2f %.2f\n", i + 1, 
100                  nodes[i].lon * RAD_TO_ARCSEC, nodes[i].lat * RAD_TO_ARCSEC, 
101                  elevation);
102     }
103     fclose(fd);
104
105     // output poly
106     if ( (fd = fopen(file, "w")) == NULL ) {
107         printf("Cannot open file: %s\n", file);
108         exit(-1);
109     }
110
111     // output empty node list
112     fprintf(fd, "0 2 0 0\n");
113
114     // output segments
115     fprintf(fd, "%d 0\n", count);
116     for ( i = 0; i < count - 1; i++ ) {
117         fprintf( fd, "%d %d %d\n", i + 1, i + 1, i + 2 );
118     }
119     fprintf( fd, "%d %d %d\n", count, count, 1 );
120
121     // output hole center
122     fprintf( fd, "1\n");
123     fprintf( fd, "1 %.2f %.2f\n", lon * 3600.0, lat * 3600);
124
125     fclose(fd);
126 }
127
128
129 // $Log: main.c,v
130 //