]> git.mxchange.org Git - flightgear.git/blob - DemRaw2ascii/main.c
Let's not pass copies of huge structures on the stack ... ye might see a
[flightgear.git] / DemRaw2ascii / main.c
1 /* main.c -- main loop
2  *
3  * Written by Curtis Olson, started February 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 #include <stdio.h>
27 #include <string.h>
28
29 #include "rawdem.h"
30
31
32 int main(int argc, char **argv) {
33     fgRAWDEM raw;
34     char basename[256], output_dir[256], hdr_file[256], dem_file[256];
35     int i, start_lat, end_lat;
36
37     if ( argc != 3 ) {
38         printf("Usage: %s <input_file_basename> <output_dir>\n", argv[0]);
39         exit(-1);
40     }
41
42     /* get basename */
43     strcpy(basename, argv[1]);
44
45     /* get output dir */
46     strcpy(output_dir, argv[2]);
47
48     /* generate header file name */
49     strcpy(hdr_file, basename);
50     strcat(hdr_file, ".HDR");
51
52     /* generate input file name (raw dem) */
53     strcpy(dem_file, basename);
54     strcat(dem_file, ".DEM");
55     
56     printf("Header file = %s  Input file = %s\n", hdr_file, dem_file);
57     printf("Output Directory = %s\n", output_dir);
58
59     /* scan the header file and extract important values */
60     rawReadDemHdr(&raw, hdr_file);
61
62     /* open up the raw data file */
63     rawOpenDemFile(&raw, dem_file);
64
65     end_lat = raw.rooty / 3600;
66     start_lat = end_lat - ((raw.nrows * raw.ydim) / 3600);
67     printf("Latitude ranges from %d to %d\n", start_lat, end_lat);
68
69     for ( i = start_lat + 1; i <= end_lat; i++ ) {
70         rawProcessStrip(&raw, i, output_dir);
71     }
72
73     /* close the raw data file */
74     rawCloseDemFile(&raw);
75
76     return(0);
77 }
78
79
80 /* $Log$
81 /* Revision 1.3  1998/03/03 21:54:50  curt
82 /* Changes to process 30 arcsec binary DEM files.
83 /*
84  * Revision 1.2  1998/03/03 13:10:28  curt
85  * Close to a working version.
86  *
87  * Revision 1.1  1998/03/02 23:31:01  curt
88  * Initial revision.
89  *
90  */