1
0
Fork 0

Initial revision.

This commit is contained in:
curt 1999-03-10 01:02:54 +00:00
parent 7794e0bf68
commit d2d25cbc93
3 changed files with 202 additions and 0 deletions

51
DemChop/Makefile.am Normal file
View file

@ -0,0 +1,51 @@
#---------------------------------------------------------------------------
# Makefile
#
# Written by Curtis Olson, started March 1999.
#
# Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# $Id$
# (Log is kept at end of this file)
#---------------------------------------------------------------------------
bin_PROGRAMS = demchop
demchop_SOURCES = \
demchop.cxx point2d.hxx
demchop_LDADD = \
$(top_builddir)/Tools/Lib/DEM/libDEM.a \
$(top_builddir)/Lib/Bucket/libBucket.a \
$(top_builddir)/Lib/Misc/libMisc.a \
$(top_builddir)/Lib/zlib/libz.a \
$(base_LIBS)
INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib -I$(top_builddir)/Tools/Lib
# We can't build this with "-O2" (optimization) since this causes a seg fault
# I haven't found a way to strip this out of the CXXFLAGS, so I'm just
# setting it to "-g"
CXXFLAGS = -g
#---------------------------------------------------------------------------
# $Log$
# Revision 1.1 1999/03/10 01:02:54 curt
# Initial revision.
#

107
DemChop/demchop.cxx Normal file
View file

@ -0,0 +1,107 @@
// demchop.cxx -- chop up a dem file into it's corresponding pieces and stuff
// them into the workspace directory
//
// Written by Curtis Olson, started March 1999.
//
// Copyright (C) 1997 Curtis L. Olson - curt@flightgear.org
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// $Id$
// (Log is kept at end of this file)
#include <Include/compiler.h>
#include STL_STRING
#include <Debug/logstream.hxx>
#include <Bucket/newbucket.hxx>
#include <DEM/dem.hxx>
FG_USING_STD(string);
int main(int argc, char **argv) {
/*
fgDEM dem;
FGBucket p;
string fg_root;
string filename;
double error;
int i, j;
*/
fglog().setLogLevels( FG_ALL, FG_DEBUG );
if ( argc != 4 ) {
FG_LOG( FG_GENERAL, FG_ALERT,
"Usage " << argv[0] << " <dem_file> <work_dir>" );
exit(-1);
}
string dem_name = argv[1];
string work_dir = argv[2];
string command = "mkdir -p " + work_dir;
system( command.c_str() );
fgDEM dem(dem_name);
dem.parse();
dem.close();
point2d min, max;
min.x = dem.get_originx() / 3600.0;
min.y = dem.get_originy() / 3600.0;
FGBucket b_min( min.x, min.y );
max.x = min.x + ( dem.get_cols() * dem.get_col_step() ) / 3600.0;
max.y = min.y + ( dem.get_rows() * dem.get_row_step() ) / 3600.0;
FGBucket b_max( max.x, max.y );
if ( b_min == b_max ) {
dem.write_area( b_min );
} else {
FGBucket b_cur;
int dx, dy, i, j;
fgBucketDiff(b_min, b_max, &dx, &dy);
cout << "DEM file spans tile boundaries" << endl;
cout << " dx = " << dx << " dy = " << dy << endl;
if ( (dx > 20) || (dy > 20) ) {
cout << "somethings really wrong!!!!" << endl;
exit(-1);
}
for ( j = 0; j <= dy; j++ ) {
for ( i = 0; i <= dx; i++ ) {
b_cur = fgBucketOffset(min.x, min.y, i, j);
if ( b_cur == b ) {
dem.write_area( b_cur );
} else {
dem.write_area( b_cur );
}
}
}
}
return 0;
}
// $Log$
// Revision 1.1 1999/03/10 01:02:54 curt
// Initial revision.
//

44
DemChop/point2d.cxx Normal file
View file

@ -0,0 +1,44 @@
// point2d.cxx -- 2d coordinate routines
//
// Written by Curtis Olson, started September 1998.
//
// Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// $Id$
// (Log is kept at end of this file)
//
#include <math.h>
#include "point2d.hxx"
// convert a point from cartesian to polar coordinates
point2d cart_to_polar_2d(point2d in) {
point2d result;
result.dist = sqrt( in.x * in.x + in.y * in.y );
result.theta = atan2(in.y, in.x);
return(result);
}
// $Log$
// Revision 1.1 1999/03/10 01:02:54 curt
// Initial revision.
//