]> git.mxchange.org Git - flightgear.git/blob - DEM/dem.h
Reorganized into a class lib called fgDEM.
[flightgear.git] / DEM / dem.h
1 // -*- Mode: C++ -*-
2 //
3 // dem.h -- DEM management class
4 //
5 // Written by Curtis Olson, started March 1998.
6 //
7 // Copyright (C) 1998  Curtis L. Olson  - curt@me.umn.edu
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of the
12 // License, or (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 // General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 //
23 // $Id$
24 // (Log is kept at end of this file)
25
26
27 #ifndef _DEM_H
28 #define _DEM_H
29
30
31 #include <stdio.h>
32
33 #include <Scenery/bucketutils.h>
34
35
36 #define EPSILON 0.000001
37 #define DEM_SIZE 1200
38 #define DEM_SIZE_1 1201
39
40
41 class fgDEM {
42     // file pointer for input
43     FILE *fd;
44
45     // coordinates (in arc seconds) of south west corner
46     double originx, originy;
47     
48     // number of columns and rows
49     int cols, rows;
50     
51     // Distance between column and row data points (in arc seconds)
52     double col_step, row_step;
53     
54     // the actual mesh data allocated here
55     // float dem_data[DEM_SIZE_1][DEM_SIZE_1];
56     // float output_data[DEM_SIZE_1][DEM_SIZE_1];
57
58     // Current "A" Record Information
59     char dem_description[80], dem_quadrangle[80];
60     double dem_x1, dem_y1, dem_x2, dem_y2, dem_x3, dem_y3, dem_x4, dem_y4;
61     double dem_z1, dem_z2;
62     int dem_resolution, dem_num_profiles;
63   
64     // Current "B" Record Information
65     int prof_col, prof_row;
66     int prof_num_cols, prof_num_rows;
67     double prof_x1, prof_y1;
68     int prof_data;
69
70     // temporary values for the class to use
71     char option_name[32];
72     int do_data;
73     int cur_col, cur_row;
74
75 public:
76
77     // Constructor (opens a DEM file)
78     fgDEM( void );
79
80     // open a DEM file (use "-" if input is coming from stdin)
81     int open ( char *file );
82
83     // close a DEM file
84     int close ( void );
85
86     // parse a DEM file
87     int parse( float dem_data[DEM_SIZE_1][DEM_SIZE_1] );
88
89     // read and parse DEM "A" record
90     void read_a_record( );
91
92     // read and parse DEM "B" record
93     void read_b_record( float dem_data[DEM_SIZE_1][DEM_SIZE_1] );
94
95     // Informational methods
96     double info_originx( void ) { return(originx); }
97     double info_originy( void ) { return(originy); }
98
99     // return the current altitude based on mesh data.  We should
100     // rewrite this to interpolate exact values, but for now this is
101     // good enough
102     double interpolate_altitude( float dem_data[DEM_SIZE_1][DEM_SIZE_1], 
103                                  double lon, double lat);
104
105     // Use least squares to fit a simpler data set to dem data
106     void fit( float dem_data[DEM_SIZE_1][DEM_SIZE_1], 
107               float output_data[DEM_SIZE_1][DEM_SIZE_1], 
108               char *fg_root, double error, struct fgBUCKET *p );
109
110     // Initialize output mesh structure
111     void outputmesh_init( float output_data[DEM_SIZE_1][DEM_SIZE_1] );
112
113     // Get the value of a mesh node
114     double outputmesh_get_pt( float output_data[DEM_SIZE_1][DEM_SIZE_1],
115                               int i, int j );
116
117     // Set the value of a mesh node
118     void outputmesh_set_pt( float output_data[DEM_SIZE_1][DEM_SIZE_1],
119                             int i, int j, double value );
120
121     // Write out a node file that can be used by the "triangle" program
122     void outputmesh_output_nodes( float output_data[DEM_SIZE_1][DEM_SIZE_1],
123                                   char *fg_root, struct fgBUCKET *p );
124
125     // Destructor
126     ~fgDEM( void );
127 };
128
129
130 #endif // _DEM_H
131
132
133 // $Log$
134 // Revision 1.1  1998/03/19 02:54:47  curt
135 // Reorganized into a class lib called fgDEM.
136 //
137 // Revision 1.1  1998/03/19 01:46:29  curt
138 // Initial revision.
139 //