From 9b63deeb03b59d265aac7e685fd334e66226be3c Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 8 Oct 2002 15:28:53 +0000 Subject: [PATCH] Updated dem libs to support z units == 1 (feet). This is not tested since I do not have data in feet to work with. --- autogen.sh | 56 +++++++++++++++++++++++++++++++++++++++++---- configure.ac | 2 ++ src/Lib/DEM/dem.cxx | 23 ++++++++++++++----- src/Lib/DEM/dem.hxx | 3 ++- 4 files changed, 73 insertions(+), 11 deletions(-) diff --git a/autogen.sh b/autogen.sh index 22d20ab6..e09c31b9 100644 --- a/autogen.sh +++ b/autogen.sh @@ -1,17 +1,65 @@ #!/bin/sh -echo "Running aclocal" -aclocal +OSTYPE=`uname -s` +MACHINE=`uname -m` +AUTO_MAKE_VERSION=`automake --version | head -1 | awk '{print $4}' | sed -e 's/\.\([0-9]*\).*/\1/'` +if test $AUTO_MAKE_VERSION -lt 15; then + echo "" + echo "You need to upgrade to automake version 1.5 or greater." + echo "Most distributions have packages available to install or you can" + echo "find the source for the most recent version at" + echo "ftp://ftp.gnu.org/gnu/automake" + exit 1 +fi + +echo "Host info: $OSTYPE $MACHINE" +echo -n " automake: `automake --version | head -1 | awk '{print $4}'`" +echo " ($AUTO_MAKE_VERSION)" +echo "" + +ACLOCAL_OPTS="" +if [ $AUTO_MAKE_VERSION -ge 14 ]; then + if [ $OSTYPE = "IRIX" -o $OSTYPE = "IRIX64" ]; then echo " -I ." + ACLOCAL_OPTS="-I ." + fi +fi +echo "Running aclocal $ACLOCAL_OPTS" +aclocal $ACLOCAL_OPTS echo "Running autoheader" autoheader +if [ ! -e src/Include/config.h.in ]; then + echo "ERROR: autoheader didn't create simgear/simgear_config.h.in!" + exit 1 +fi -echo "Running automake" -automake --add-missing +echo -n "Running automake" +if [ $OSTYPE = "IRIX" -o $OSTYPE = "IRIX64" ]; then + echo " --add-missing --include-deps" + automake --add-missing --include-deps +else + echo " --add-missing" + automake --add-missing +fi echo "Running autoconf" autoconf +if [ ! -e configure ]; then + echo "ERROR: configure was not created!" + exit 1 +fi + +# fixup Makefiles for Irix +if test "$OSTYPE" = "IRIX" -o "$OSTYPE" = "IRIX64"; then + echo "Fixing Makefiles for Irix" + for n in `find . -name Makefile.in`; do \ + mv -f $n $n.ar-new; \ + sed 's/$(AR) cru/$(AR) -o/g' $n.ar-new > $n; \ + rm -f $n.ar-new; \ + done; +fi + echo "" echo "======================================" diff --git a/configure.ac b/configure.ac index 5c425628..f5faa6b4 100644 --- a/configure.ac +++ b/configure.ac @@ -184,6 +184,7 @@ AC_CHECK_LIB(plibul, ulInit,,,) AM_CONDITIONAL(HAVE_XWINDOWS, test "x$ac_cv_lib_X11_XCreateWindow" = "xyes" ) +AC_LANG_PUSH(C++) dnl Check for "plib" without which we cannot go on AC_CHECK_HEADER(plib/pu.h) if test "x$ac_cv_header_plib_pu_h" != "xyes"; then @@ -196,6 +197,7 @@ if test "x$ac_cv_header_plib_pu_h" != "xyes"; then echo "configure aborted." exit fi +AC_LANG_POP dnl Check if Generic Polygon Clipping library is installed dnl (from http://www.cs.man.ac.uk/aig/staff/alan/software/) diff --git a/src/Lib/DEM/dem.cxx b/src/Lib/DEM/dem.cxx index a5364aea..74f3d769 100644 --- a/src/Lib/DEM/dem.cxx +++ b/src/Lib/DEM/dem.cxx @@ -77,7 +77,9 @@ SG_USING_STD(endl); #endif //0 -FGDem::FGDem( void ) { +FGDem::FGDem( void ) : + z_units(2) // meters +{ // cout << "class FGDem CONstructor called." << endl; dem_data = new float[DEM_SIZE_1][DEM_SIZE_1]; output_data = new float[DEM_SIZE_1][DEM_SIZE_1]; @@ -240,8 +242,8 @@ FGDem::read_a_record() { // Units code; 2 represents meters as the unit of measure for // elevation coordinates throughout the file. - inum = next_int(); - if ( inum != 2 ) { + z_units = inum = next_int(); + if ( z_units != 1 && z_units != 2 ) { cout << " Unknown (Z) units code = " << inum << "!\n"; exit(-1); } @@ -271,6 +273,11 @@ FGDem::read_a_record() { // Minimum/maximum elevations in meters dem_z1 = next_exp(); dem_z2 = next_exp(); + if ( z_units == 1 ) { + // convert to meters + dem_z1 *= SG_FEET_TO_METER; + dem_z2 *= SG_FEET_TO_METER; + } cout << " Elevation range " << dem_z1 << " to " << dem_z2 << "\n"; // Counterclockwise angle from the primary axis of ground @@ -314,7 +321,6 @@ void FGDem::read_b_record( ) { string token; int i; - int last; // row / column id of this profile prof_row = next_int(); @@ -341,9 +347,14 @@ FGDem::read_b_record( ) { token = next_token(); // One (usually) dimensional array (1,prof_num_rows) of elevations - last = 0; + float last = 0.0; for ( i = 0; i < prof_num_rows; i++ ) { - prof_data = next_int(); + prof_data = (float)next_int(); + + if ( z_units == 1 ) { + // convert to meters + prof_data *= SG_FEET_TO_METER; + } // a bit of sanity checking that is unfortunately necessary if ( prof_data > 10000 ) { // meters diff --git a/src/Lib/DEM/dem.hxx b/src/Lib/DEM/dem.hxx index 802df82b..5d7091fb 100644 --- a/src/Lib/DEM/dem.hxx +++ b/src/Lib/DEM/dem.hxx @@ -73,12 +73,13 @@ private: int prof_col, prof_row; int prof_num_cols, prof_num_rows; double prof_x1, prof_y1; - int prof_data; + float prof_data; // temporary values for the class to use char option_name[32]; int do_data; int cur_col, cur_row; + int z_units; // 1 = feet, 2 = meters // return next token from input stream string next_token();