]> git.mxchange.org Git - flightgear.git/blob - Tools/Prep/DemRaw2ascii/main.c
Fixed a small bug which cropped up with the new gpc hole interface.
[flightgear.git] / Tools / Prep / 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  */
23
24
25 #include <stdio.h>
26 #include <string.h>
27
28 #include "rawdem.h"
29
30
31 int main(int argc, char **argv) {
32     fgRAWDEM raw;
33     char basename[256], output_dir[256], hdr_file[256], dem_file[256];
34     int i, start_lat, end_lat;
35
36     if ( argc != 3 ) {
37         printf("Usage: %s <input_file_basename> <output_dir>\n", argv[0]);
38         exit(-1);
39     }
40
41     /* get basename */
42     strcpy(basename, argv[1]);
43
44     /* get output dir */
45     strcpy(output_dir, argv[2]);
46
47     /* generate header file name */
48     strcpy(hdr_file, basename);
49     strcat(hdr_file, ".HDR");
50
51     /* generate input file name (raw dem) */
52     strcpy(dem_file, basename);
53     strcat(dem_file, ".DEM");
54     
55     printf("Header file = %s  Input file = %s\n", hdr_file, dem_file);
56     printf("Output Directory = %s\n", output_dir);
57
58     /* scan the header file and extract important values */
59     rawReadDemHdr(&raw, hdr_file);
60
61     /* open up the raw data file */
62     rawOpenDemFile(&raw, dem_file);
63
64     end_lat = raw.rooty / 3600;
65     start_lat = end_lat - ((raw.nrows * raw.ydim) / 3600);
66     printf("Latitude ranges from %d to %d\n", start_lat, end_lat);
67
68     for ( i = start_lat + 1; i <= end_lat; i++ ) {
69         rawProcessStrip(&raw, i, output_dir);
70     }
71
72     /* close the raw data file */
73     rawCloseDemFile(&raw);
74
75     return(0);
76 }
77
78