3 // Written by Curtis Olson, started March 1998.
5 // Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
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.
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.
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.
22 // (Log is kept at end of this file)
39 #include <Bucket/bucketutils.h>
40 #include <Include/fg_constants.h>
43 int main( int argc, char **argv ) {
47 char base[256], path[256], command[256], file[256], exfile[256];
48 double lon, lat, elevation, heading;
54 printf("Usage %s <work dir>\n", argv[0]);
59 // lon = -110.6642442;
61 // heading = 102.0 * DEG_TO_RAD;
68 elevation = 912 * FEET_TO_METER;
69 heading = 270.0 * DEG_TO_RAD;
73 gen_runway_area( lon * DEG_TO_RAD, lat * DEG_TO_RAD,
74 heading, length, width, nodes, &count );
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);
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);
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);
92 if ( (fd = fopen(exfile, "w")) == NULL ) {
93 printf("Cannot open file: %s\n", exfile);
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,
106 if ( (fd = fopen(file, "w")) == NULL ) {
107 printf("Cannot open file: %s\n", file);
111 // output empty node list
112 fprintf(fd, "0 2 0 0\n");
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 );
119 fprintf( fd, "%d %d %d\n", count, count, 1 );
121 // output hole center
123 fprintf( fd, "1 %.2f %.2f\n", lon * 3600.0, lat * 3600);