From: curt Date: Wed, 10 Mar 1999 01:02:54 +0000 (+0000) Subject: Initial revision. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d2d25cbc9314c1157f9b7af4468b5ae2b40f5c69;p=flightgear.git Initial revision. --- diff --git a/DemChop/Makefile.am b/DemChop/Makefile.am new file mode 100644 index 000000000..ff5474731 --- /dev/null +++ b/DemChop/Makefile.am @@ -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. +# diff --git a/DemChop/demchop.cxx b/DemChop/demchop.cxx new file mode 100644 index 000000000..b311c7fcc --- /dev/null +++ b/DemChop/demchop.cxx @@ -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 STL_STRING + +#include +#include +#include + +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] << " " ); + 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. +// diff --git a/DemChop/point2d.cxx b/DemChop/point2d.cxx new file mode 100644 index 000000000..817015f8a --- /dev/null +++ b/DemChop/point2d.cxx @@ -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 + +#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. +//