1 // demchop.cxx -- chop up a dem file into it's corresponding pieces and stuff
2 // them into the workspace directory
4 // Written by Curtis Olson, started March 1999.
6 // Copyright (C) 1997 Curtis L. Olson - curt@flightgear.org
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 // (Log is kept at end of this file)
26 #include <Include/compiler.h>
30 #include <Debug/logstream.hxx>
31 #include <Bucket/newbucket.hxx>
32 #include <DEM/dem.hxx>
34 #include "point2d.hxx"
39 int main(int argc, char **argv) {
49 fglog().setLogLevels( FG_ALL, FG_DEBUG );
52 FG_LOG( FG_GENERAL, FG_ALERT,
53 "Usage " << argv[0] << " <dem_file> <work_dir>" );
57 string dem_name = argv[1];
58 string work_dir = argv[2];
59 string command = "mkdir -p " + work_dir;
60 system( command.c_str() );
67 min.x = dem.get_originx() / 3600.0 + FG_HALF_BUCKET_SPAN;
68 min.y = dem.get_originy() / 3600.0 + FG_HALF_BUCKET_SPAN;
69 FGBucket b_min( min.x, min.y );
71 max.x = (dem.get_originx() + dem.get_cols() * dem.get_col_step()) / 3600.0
72 - FG_HALF_BUCKET_SPAN;
73 max.y = (dem.get_originy() + dem.get_rows() * dem.get_row_step()) / 3600.0
74 - FG_HALF_BUCKET_SPAN;
75 FGBucket b_max( max.x, max.y );
77 if ( b_min == b_max ) {
78 dem.write_area( work_dir, b_min, true );
83 fgBucketDiff(b_min, b_max, &dx, &dy);
84 cout << "DEM file spans tile boundaries" << endl;
85 cout << " dx = " << dx << " dy = " << dy << endl;
87 if ( (dx > 20) || (dy > 20) ) {
88 cout << "somethings really wrong!!!!" << endl;
92 for ( j = 0; j <= dy; j++ ) {
93 for ( i = 0; i <= dx; i++ ) {
94 b_cur = fgBucketOffset(min.x, min.y, i, j);
95 dem.write_area( work_dir, b_cur, true );
105 // Revision 1.3 1999/03/12 22:53:46 curt
106 // First working version!
108 // Revision 1.2 1999/03/10 16:09:44 curt
109 // Hacking towards the first working version.
111 // Revision 1.1 1999/03/10 01:02:54 curt