]> git.mxchange.org Git - flightgear.git/blob - DEM/dem.hxx
ae6ae2f7931349cf3183b5858924d52683295da3
[flightgear.git] / DEM / dem.hxx
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 <Bucket/bucketutils.h>
34
35
36 #define DEM_SIZE 1200
37 #define DEM_SIZE_1 1201
38
39
40 class fgDEM {
41     // file pointer for input
42     FILE *fd;
43
44     // coordinates (in arc seconds) of south west corner
45     double originx, originy;
46     
47     // number of columns and rows
48     int cols, rows;
49     
50     // Distance between column and row data points (in arc seconds)
51     double col_step, row_step;
52     
53     // pointers to the actual mesh data allocated here
54     float (*dem_data)[DEM_SIZE_1];
55     float (*output_data)[DEM_SIZE_1];
56
57     // Current "A" Record Information
58     char dem_description[80], dem_quadrangle[80];
59     double dem_x1, dem_y1, dem_x2, dem_y2, dem_x3, dem_y3, dem_x4, dem_y4;
60     double dem_z1, dem_z2;
61     int dem_resolution, dem_num_profiles;
62   
63     // Current "B" Record Information
64     int prof_col, prof_row;
65     int prof_num_cols, prof_num_rows;
66     double prof_x1, prof_y1;
67     int prof_data;
68
69     // temporary values for the class to use
70     char option_name[32];
71     int do_data;
72     int cur_col, cur_row;
73
74 public:
75
76     // Constructor (opens a DEM file)
77     fgDEM( void );
78
79     // open a DEM file (use "-" if input is coming from stdin)
80     int open ( char *file );
81
82     // close a DEM file
83     int close ( void );
84
85     // parse a DEM file
86     int parse( void );
87
88     // read and parse DEM "A" record
89     void read_a_record( void );
90
91     // read and parse DEM "B" record
92     void read_b_record( void );
93
94     // Informational methods
95     double info_originx( void ) { return(originx); }
96     double info_originy( void ) { return(originy); }
97
98     // return the current altitude based on mesh data.  We should
99     // rewrite this to interpolate exact values, but for now this is
100     // good enough
101     double interpolate_altitude( double lon, double lat );
102
103     // Use least squares to fit a simpler data set to dem data
104     void fit( char *fg_root, double error, struct fgBUCKET *p );
105
106     // Initialize output mesh structure
107     void outputmesh_init( void );
108
109     // Get the value of a mesh node
110     double outputmesh_get_pt( int i, int j );
111
112     // Set the value of a mesh node
113     void outputmesh_set_pt( int i, int j, double value );
114
115     // Write out a node file that can be used by the "triangle" program
116     void outputmesh_output_nodes( char *fg_root, struct fgBUCKET *p );
117
118     // Destructor
119     ~fgDEM( void );
120 };
121
122
123 #endif // _DEM_H
124
125
126 // $Log$
127 // Revision 1.2  1998/04/14 02:43:28  curt
128 // Used "new" to auto-allocate large DEM parsing arrays in class constructor.
129 //
130 // Revision 1.1  1998/04/08 22:57:23  curt
131 // Adopted Gnu automake/autoconf system.
132 //
133 // Revision 1.2  1998/03/23 20:35:42  curt
134 // Updated to use FG_EPSILON
135 //
136 // Revision 1.1  1998/03/19 02:54:47  curt
137 // Reorganized into a class lib called fgDEM.
138 //
139 // Revision 1.1  1998/03/19 01:46:29  curt
140 // Initial revision.
141 //