summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2017-08-10 20:33:14 -0400
committerSolomon Peachy <pizza@shaftnet.org>2017-08-10 20:33:14 -0400
commit8a331e00256cac4d78830c2bfce6b2713723e4c8 (patch)
tree15f431b156589158a991a998462352ca8edd9310 /src
downloadgpligc-8a331e00256cac4d78830c2bfce6b2713723e4c8.tar.gz
gpligc-8a331e00256cac4d78830c2bfce6b2713723e4c8.tar.bz2
gpligc-8a331e00256cac4d78830c2bfce6b2713723e4c8.zip
initial commit -- gpligc 1.10.1
Diffstat (limited to 'src')
-rw-r--r--src/.ogierc292
-rw-r--r--src/GLexplorer.cpp5909
-rw-r--r--src/GLexplorer.h75
-rw-r--r--src/Makefile.am27
-rw-r--r--src/Makefile.in780
-rw-r--r--src/airspc.cpp1490
-rw-r--r--src/airspc.h64
-rw-r--r--src/cmdline.c4232
-rw-r--r--src/cmdline.h704
-rw-r--r--src/createworlddem.cpp466
-rw-r--r--src/ego.cpp256
-rw-r--r--src/ego.h92
-rw-r--r--src/etopo1merger.cpp384
-rw-r--r--src/etopo2merger.cpp383
-rw-r--r--src/flightdata.cpp1581
-rw-r--r--src/flightdata.h236
-rw-r--r--src/landscape.cpp1266
-rw-r--r--src/landscape.h116
-rw-r--r--src/map.cpp374
-rw-r--r--src/map.h77
-rw-r--r--src/merger.cpp469
-rw-r--r--src/oconfig.cpp1565
-rw-r--r--src/oconfig.h428
-rw-r--r--src/oglexfunc.cpp1534
-rw-r--r--src/oglexfunc.h78
-rw-r--r--src/optimizer.cpp967
-rw-r--r--src/points.cpp572
-rw-r--r--src/points.h80
-rw-r--r--src/projection.cpp198
-rw-r--r--src/projection.h53
-rw-r--r--src/value.h110
-rw-r--r--src/write_jpeg.c344
32 files changed, 25202 insertions, 0 deletions
diff --git a/src/.ogierc b/src/.ogierc
new file mode 100644
index 0000000..a480309
--- /dev/null
+++ b/src/.ogierc
@@ -0,0 +1,292 @@
+# This is an exmaple configuration file for
+# OGIE
+
+# lines beginning with #, space or empty lines are ignored
+
+##########################################################################
+# GENERAL OPTIONS
+
+# SAVE_PATH string A Path, were to store screenshots
+# BASENAME string A basename for screenshots
+# JPEG_QUALITY int (0-100)
+# IMAGE_FORMAT (rgb or jpg)
+
+#start with mouse function
+#false is mouse control on!
+MOUSE false
+
+#more output (only for debugging reasons)
+VERBOSE false
+
+
+###########################################################################
+# Digital Elevation Model File Setup
+
+#This block can be used for Europe
+#(if you have GTOPO30 W020N90.DEM)
+#but set full path to file
+#DEM_FILE PREFIX/share/gpligc/data/dem/W020N90.DEM
+#DEM_ROWS 6000
+#DEM_COLUMNS 4800
+#DEM_LAT_MIN 40
+#DEM_LAT_MAX 90
+#DEM_LON_MIN -20
+#DEM_LON_MAX 20
+
+#if you have created a WORLD.DEM from the 33 GTOPO30 Tiles
+# or even the WORLD3.DEM (see manual)
+#DEM_FILE PREFIX/share/gpligc/data/dem/WORLD.DEM
+#DEM_ROWS 21600
+#DEM_COLUMNS 43200
+#DEM_LAT_MIN -90
+#DEM_LAT_MAX 90
+#DEM_LON_MIN -180
+#DEM_LON_MAX 180
+
+#if you have downloaded the TOPO30
+#(See documentation)
+#DEM_FILE PREFIX/share/gpligc/data/dem/topo30
+#DEM_ROWS 21600
+#DEM_COLUMNS 43200
+#DEM_LAT_MIN -90
+#DEM_LAT_MAX 90
+#DEM_LON_MIN 0
+#DEM_LON_MAX 360
+
+
+#resolution of DEM Model
+#0.008333333333 is 30 arc-sec
+#which will work for GTOPO30 and GLOBE
+DEM_GRID_LAT 0.008333333333
+DEM_GRID_LON 0.008333333333
+
+
+###########################################################################
+# OPTIONS FOR DRAWING THE TERRAIN
+
+# sealevels
+#SEALEVEL 0
+#SEALEVEL2 -22222
+#SEALEVEL3 -22222
+
+#default colormaps
+#1=max's special "LSD"-Map
+#2=max's "Atlas colormap"
+#3=hannes' "grayscale-moon-map"
+#4=dark green -> red
+#5=magenta -> light blue
+#6=extended LSD-Map
+COLORMAP 2
+COLORMAP_SEA 5
+
+LANDSCAPE true
+WIRE false
+#MAXTRIANGLES float
+#AUTOREDUCE on
+#QUADS off
+
+#Gouraud-Shading (true) or flat shading (false)
+SHADE true
+
+#terrain border (in km)
+BORDER 30.0
+
+
+#############################################################################
+# GENERAL DRAWING OPTIONS
+
+# haze
+HAZE false
+HAZE_DENSITY 0.01
+
+#start fullscreen
+FULLSCREEN false
+#initial window size
+#if FULLSCREEN isnt enabled
+WINDOW_WIDTH 1024
+WINDOW_HEIGHT 768
+
+#Angle of view
+ANGLE_OF_VIEW 80
+
+PROJECTION 4
+#1=Cylindrical (platt)
+#2=MERCATOR
+#3=Cylindrical
+#4=pseudo cylindrical
+
+#default z-axis(height) scaling
+SCALE_Z 3.0
+
+# BACKGROUND_COLOR_1_R 1.0
+# BACKGROUND_COLOR_1_G 0.2 (floats 0-1)
+# BACKGROUND_COLOR_1_B 0.2
+# BACKGROUND_COLOR_2_R 0.0
+# BACKGROUND_COLOR_2_G 0.0
+# BACKGROUND_COLOR_2_B 0.0
+# BACKGROUND_STYLE 1 (1=one color (color 1), 2=vertical gradient
+# (color1=top), 3=horiz gradient (color1=left)
+
+
+#############################################################################
+# OPTIONS FOR DISPLAY OF INFORMATION
+
+# info text
+INFO true
+# INFOFONT_SIZE 40 (int 20-100) window_height / INFOFONT_SIZE
+# INFOFONT_LINEWIDTH 1.0 (float 0.5-3.0)
+# INFO_STYLE 1 (1= new style [thanks to antonio ospite], 2=old style)
+
+
+#############################################################################
+# Units:
+# Use your favourite units. Calculate the conversion factor (from defaults)
+# Defaults (speed=km/h, vspeed=m/s, alt=m)
+
+#SPEED_UNIT_FAC 0.539957
+#SPEED_UNIT_NAME knots
+#SPEED_UNIT_FAC 0.621504
+#SPEED_UNIT_NAME mph
+#VSPEED_UNIT_FAC 1.94384
+#VSPEED_UNIT_NAME knots
+#VSPEED_UNIT_FAC 196.8
+#VSPEED_UNIT_NAME ft/min
+#ALT_UNIT_FAC 3.28
+#ALT_UNIT_NAME ft
+#TIME_ZONE 0
+#TIME_ZONE_NAME UTC
+
+
+#############################################################################
+# OPTIONS FOR DISPLAY OF FLIGHTS
+
+# FLIGHTSTRIPCOLUP_R 1.0
+# FLIGHTSTRIPCOLUP_G 0.0
+# FLIGHTSTRIPCOLUP_B 0.0
+# FLIGHTSTRIPCOLDOWN_R 0.0
+# FLIGHTSTRIPCOLDOWN_G 0.0
+# FLIGHTSTRIPCOLDOWN_B 0.0
+# FLIGHTSTRIP_LINEWIDTH 2.0 (float 1-7)
+# FLIGHTSTRIP_MODE 1 (0=classic,1=alt,2=speed,3=vario)
+# FLIGHTSTRIP_COLORMAP 1 (1-7)
+
+# A range of the flight will be displayed.
+MARKER_RANGE false
+
+# The displayed range can be defined here.
+MARKER_BACK 50
+MARKER_AHEAD 0
+
+# Viewpoint will follow Marker
+FOLLOW true
+
+# use GPS (true) or Barometric (false) altitude
+GPSALT false
+
+# draw marker
+MARKER true
+MARKER_SIZE 1.0
+# MARKERCOL_R 1.0
+# MARKERCOL_G 0.0
+# MARKERCOL_B 0.0
+
+# draw curtain
+CURTAIN true
+
+# SPINNING float
+# MOVIE bool
+
+# MOVIE_REPEAT
+# MOVIE_REPEAT_FACTOR
+# MOVIE_REPEAT_FPS_LIMIT
+
+
+#######################################################################
+# OPTIONS FOR DRAWING AIRSPACES
+
+#OPEN_AIR_FILE PREFIX/share/gpligc/data/airspace/airspace.txt
+AIRSPACE false
+#AIRSPACE_LIMIT int
+#AIRSPACE_WIRE 0
+#AIRSPACE_D 1
+#AIRSPACE_C 1
+#AIRSPACE_CTR 1
+#AIRSPACE_R 1
+#AIRSPACE_P 1
+#AIRSPACE_Q 1
+
+
+###########################################################################
+# OPTIONS FOR STEREOGRAPHIC DISPLAY
+# stereographic view
+# only one of the following three may be true
+STEREO false
+STEREO_RG false
+STEREO_RB false
+# swap stereographic images
+INVERSE_STEREO false
+# eye distance for stereographic images (km)
+EYE_DIST 0.1
+
+############################################################################
+# OPTIONS FOR DRAWING POINT INFORMATION (LIFTS/WAYPOINTS)
+
+#LIFTS_COLOR_R 1.0
+#LIFTS_COLOR_G 0.0
+#LIFTS_COLOR_B 0.0
+
+#WP_COLOR_R 0.0
+#WP_COLOR_G 0.0
+#WP_COLOR_B 0.0
+
+# for suitable file format see manual!
+#WAYPOINTS_FILE PREFIX/share/gpligc/data/waypoint/wpfile.gwpt
+#WAYPOINTS false
+
+#TEXT_COLOR_R 0.0
+#TEXT_COLOR_G 0.0
+#TEXT_COLOR_B 0.0
+
+#TEXT_LINEWIDTH 2.0
+
+
+############################################################################
+# OPTIONS FOR DRAWING OF THE MAPS
+
+# MAPS_UNLIGHTED
+# use MAPS
+MAP false
+# use DEM-Altitude-color with textured maps
+MODULATE true
+
+
+#######################################################################
+# Texture map Setup
+
+#Texture map compression
+#with compression texture loading will need more time
+#but rendering is faster and will need fewer videomemory
+#but not supported by some openGL implementations
+
+COMPRESSION false
+
+#MAP_SET_NAME Osterholz
+
+#MAP_SHIFT_LAT 0.0
+#MAP_SHIFT_LON 0.0
+
+#MAP_FILE PREFIX/share/gpligc/data/map/bremen/bremen512x1024.jpg
+#MAP_TOP 53.5
+#MAP_RIGHT 9.3333333333
+#MAP_LEFT 8.6666666667
+#MAP_BOTTOM 52.8333333333
+
+#MAP_CUT
+
+#MAP_SET_NAME Innsbruck
+
+#MAP_FILE PREFIX/share/gpligc/data/map/innsbruck/n48e012.jpg
+#MAP_TOP 48
+#MAP_RIGHT 13
+#MAP_LEFT 12
+#MAP_BOTTOM 47
diff --git a/src/GLexplorer.cpp b/src/GLexplorer.cpp
new file mode 100644
index 0000000..5046770
--- /dev/null
+++ b/src/GLexplorer.cpp
@@ -0,0 +1,5909 @@
+/*
+ * (c) 2002-2016 Hannes Krueger
+ * This file is part of the GPLIGC/ogie package
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+/*
+if compiled with -DWITH_OSMESA, the mesa offscreen rendering is included
+ -> changed to autoconf -> HAVE_LIBOSMESA
+if compiled with -DONLY_OSMESA, only osmesa will work. all interactive
+features will be disabled, and therefore no GLUT or X11 is needed.
+ --> however for text some glut functions are used....
+*/
+
+// all platforms include gl.h (except OSX)
+#ifndef __OSX__
+#include <GL/gl.h>
+// glut not needed for ONLY_OSMESA
+// actually ONLY_OSMESA shouldnt be used any longer
+// #ifndef ONLY_OSMESA
+#include <GL/glut.h>
+#include <GL/glu.h>
+// #endif
+
+#else
+
+// OSX here....
+// #ifndef ONLY_OSMESA
+#include <GLUT/glut.h>
+// #endif
+#include <OpenGL/gl.h>
+#define __MACOSX__
+#endif
+
+
+#ifdef FREEGLUT
+#include <GL/freeglut_ext.h>
+#endif
+
+#ifndef GLUT_VERSION
+// this is the value from GL/freeglut_ext.h. If we dont have freeglut, we need to define it here
+#define GLUT_VERSION 0x01FC
+#endif
+
+
+#include "oconfig.h"
+#include "config.h"
+
+#ifdef HAVE_LIBOSMESA
+//#include <GL/glu.h>
+#include <GL/osmesa.h>
+//#include "osmesa.h"
+#endif
+
+#ifndef __WIN32__
+#ifndef __OSX__
+// #ifndef ONLY_OSMESA
+#include <GL/glx.h>
+// #endif
+#endif
+#endif
+
+// just for version info
+#ifdef HAVE_LIBGPS
+#include "libgpsmm.h"
+#endif
+
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <unistd.h>
+
+#include <jpeglib.h>
+
+// do we need this ?
+#ifndef __WIN32__
+#include <csignal>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#endif
+
+#include <sys/time.h>
+
+#include <string>
+#include <vector>
+
+#include "GLexplorer.h"
+#include "flightdata.h"
+#include "ego.h"
+#include "landscape.h"
+
+#include "cmdline.h"
+#include "map.h"
+#include "oglexfunc.h"
+#include "airspc.h"
+#include "projection.h"
+//#include "sysinfo.h"
+#include "points.h"
+
+
+// windows hasn't GLX and Mesa
+#ifdef __WIN32__
+#define NOGLX
+//#include <strings.h>
+//#undef WITH_OSMESA
+#endif
+
+// #ifdef __OSX__
+// #define NOGLX
+// #undef WITH_OSMESA
+// #endif
+
+// configure hasn't found glXCreatePbuffer
+#ifndef HAVE_GLXPBUFFER
+#define NOGLX
+#endif
+
+// no unix, no GLX, Mesa
+#ifndef __unix__
+#define NOGLX
+//#undef WITH_MESA
+#endif
+
+#ifndef M_PI
+#define M_PI 3.141592654
+#endif
+
+
+using namespace std;
+
+//const string rcsid_GLexplorer_cpp =
+// "$Id: GLexplorer.cpp 3 2014-07-31 09:59:20Z kruegerh $";
+//const string rcsid_GLexplorer_h = GLEXPLORER_H;
+
+//Global stuff
+Flightdata fd; //flightdata object
+ //needs to be global! (see keyPressed callback function...)
+
+Airspace air; //airspaces....
+
+Projection proj; //projection
+
+Points lifts;
+Points waypoints;
+
+gengetopt_args_info args_info;
+gpligc_ipc_block ipc_block;
+
+Ego ego(0, 0, 0, 0, 0, 0); //initialize ego
+GLuint flightdata_displ_list; //the display_lists
+GLuint landscape_displ_list; //
+GLuint airspace_displ_list;
+//GLuint lifts_displ_list;
+
+Config conf; //configuration stuff (initialized with compiled-in defaults, see constructor)
+ // defaults can be overridden by 1. configfile and 2.cmdline
+
+int lastmx = 0; //last mouseposition
+int lastmy = 0;
+
+int rightbuttonstate = GLUT_UP;
+int middlebuttonstate = GLUT_UP;
+int leftbuttonstate = GLUT_UP;
+//bool cntrlstate = false;
+
+
+bool MENUPOPPED = false; //menu hasnt popped or disappeared soon.
+bool MENUCHANGED = false; //menu has to be changed!
+bool MENUSTATE = false;
+
+bool HELP = false; //flag for help-display
+bool INFO = false; // flag for info-display
+
+bool MOUSEWARPED = false; // Mouse warped indicator. Will be set when the mouse pointer
+ // is forcefully re-centered by the program.
+
+/*
+bool SHIFTKEY = false;
+bool CNTRLKEY = false;
+bool ALTKEY = false;
+*/
+
+int window = -3992; // GLUT window number (3992 to check if its changed (=window created))
+
+vector<float>fps(10); // used to smooth framerate
+
+
+int movie_repeat_counter=0;
+
+
+#ifndef __WIN32__
+#ifndef ONLY_OSMESA
+// GPLIGC communication... if SIGUSR1 received, reread shared mem block
+void SIGUSR1Handler(int sig)
+{
+ if (sig == SIGUSR1) {
+ int shm_id;
+ key_t key;
+ key = ftok(conf.getIGCFileName().c_str(), 76);
+ //cout << "key : " << key << endl;
+ shm_id = shmget(key, sizeof(gpligc_ipc_block), 0);
+
+ if (shm_id != -1) {
+ char *data;
+ char *data_dest;
+ data_dest = (char *) &ipc_block;
+ data = (char *) shmat(shm_id, (void *) 0, 0);
+
+ //copy shm segment to the ipc_block struct... (low-level)
+ for (int _z = 0;
+ _z < (int) sizeof(gpligc_ipc_block); _z++) {
+ data_dest[_z] = data[_z];
+ }
+ shmdt(data);
+
+ //cout << "Inhalt: " << ipc_block.marker_pos << endl;
+ fd.setmarkerpos(ipc_block.marker_pos);
+ if (conf.FOLLOW.get()) {
+ update_locked_pos();
+ }
+ if (conf.MARKER_RANGE.get()) {
+ GenFlightList();
+ }
+ }
+
+ /*
+ if (conf.VERBOSE.get()) {
+ cout << "SIGUSR1 received... Size of shared mem block:"
+ << sizeof(gpligc_ipc_block) << " shmid:"<< shm_id <<endl;
+ }
+ */
+ glutPostRedisplay();
+ }
+}
+
+void update_shmem(void) {
+
+ ipc_block.marker_pos = fd.getmarker();
+
+ //cout << "openGLIGCexplorer: " << fd.getmarker();
+
+ int shm_id;
+ key_t key;
+ key = ftok(conf.getIGCFileName().c_str(), 76);
+ //cout << "key : " << key << endl;
+ shm_id = shmget(key, sizeof(gpligc_ipc_block), 0);
+
+ if (shm_id != -1) {
+ char *data;
+ char *data_src;
+ data_src = (char *) &ipc_block;
+ data = (char *) shmat(shm_id, (void *) 0, 0);
+
+ //copy the ipc_block struct to shm-segment... (low-level)
+ for (int _z = 0;
+ _z < (int) sizeof(gpligc_ipc_block); _z++) {
+ data[_z] = data_src[_z];
+ }
+ shmdt(data);
+ }
+
+ //cout << "update_shmem called... sending SIGUSR2 to GPLIGC" << endl;
+
+ // this is now deactivated....
+
+ //if (args_info.parent_pid_given) {
+ // kill(args_info.parent_pid_arg, SIGUSR2);
+ //}
+
+}
+#endif
+#endif
+
+
+
+#ifndef ONLY_OSMESA
+int menIdMain, menIdMapSet, menIdStereo, menIdColormap, menIdColormap_sea,
+ menIdFSColormap, menIdFSMode, menIdAirspaceType;
+
+void menuMain(int val)
+{
+
+ // this is needed for glutChangeToMenuEntry (which is done in current menu),
+ // if this is called from keypressed function and current menu is other than menuMain
+// glutSetMenu(menIdMain); // we dont changeToMenuEntry any more, here
+
+ MENUPOPPED=true;
+
+ switch (val) {
+
+ case 1:
+ conf.MAP.toggle();
+ GenLandscapeList();
+ GenFlightList(); //?
+ glutPostRedisplay();
+
+ MENUCHANGED= true;
+// if (conf.MAP.get()) {
+// glutChangeToMenuEntry(1, "Maps off", 1);
+// } else {
+// glutChangeToMenuEntry(1, "Maps on", 1);
+// }
+
+
+ break;
+
+ case 2:
+ conf.MODULATE.toggle();
+
+ if (conf.MAP.get()) {
+ GenLandscapeList();
+ glutPostRedisplay();
+ }
+ MENUCHANGED= true;
+
+// if (conf.MODULATE.get()) {
+// glutChangeToMenuEntry(2, "Colored maps off", 2);
+// } else {
+// glutChangeToMenuEntry(2, "Colored maps on", 2);
+// }
+
+
+ break;
+
+ case 11:
+ if (conf.DEM.get()) {
+ conf.LANDSCAPE.toggle();
+ GenFlightList();
+ GenLandscapeList();
+ glutPostRedisplay();
+ }
+ MENUCHANGED= true;
+
+// if (conf.LANDSCAPE.get()) {
+// glutChangeToMenuEntry(5, "Terrain off", 11);
+// } else {
+// glutChangeToMenuEntry(5, "Terrain on", 11);
+// }
+
+ break;
+
+ case 12:
+ conf.FOG.toggle();
+ //GenFlightList();
+ InitGL(conf.getwidth(), conf.getheight());
+ glutPostRedisplay();
+ MENUCHANGED= true;
+
+// if (conf.FOG.get()) {
+// glutChangeToMenuEntry(8, "Haze off", 12);
+// } else {
+// glutChangeToMenuEntry(8, "Haze on", 12);
+// }
+
+
+ break;
+
+ case 13:
+
+ if (conf.getAirspaceFileName() != "not available") {
+ conf.AIRSPACE.toggle();
+ GenAirspaceList();
+ glutPostRedisplay();
+ }
+ MENUCHANGED= true;
+
+// if (conf.AIRSPACE.get()) {
+// glutChangeToMenuEntry(9, "Airspace off", 13);
+// } else {
+// glutChangeToMenuEntry(9, "Airspace on", 13);
+// }
+
+
+ break;
+
+
+ case 21:
+ if (conf.FLIGHT.get()) {
+ conf.CURTAIN.toggle();
+ GenFlightList();
+ glutPostRedisplay();
+ }
+ MENUCHANGED= true;
+
+// if (conf.CURTAIN.get()) {
+// glutChangeToMenuEntry(14, "Curtain off", 21);
+// } else {
+// glutChangeToMenuEntry(14, "Curtain on", 21);
+// }
+
+
+ break;
+
+ case 31:
+ if (conf.FLIGHT.get()) {
+
+ conf.MARKER.toggle();
+ glutPostRedisplay();
+ }
+ MENUCHANGED= true;
+
+
+// if (conf.MARKER.get()) {
+// glutChangeToMenuEntry(16, "Marker off", 31);
+// } else {
+// glutChangeToMenuEntry(16, "Marker on", 31);
+// }
+
+
+ break;
+
+ case 32:
+ conf.INFO.toggle();
+
+
+ glutPostRedisplay();
+ MENUCHANGED= true;
+
+// if (conf.INFO.get()) {
+// glutChangeToMenuEntry(17, "Info off", 32);
+// } else {
+// glutChangeToMenuEntry(17, "Info on", 32);
+// }
+
+
+ break;
+
+
+ case 33:
+ if (conf.FLIGHT.get()) {
+ if (conf.FOLLOW.get()) {
+ ego.setdx(0);
+ ego.setdy(0);
+ ego.setdz(0);
+ } else {
+ update_diff_pos();
+ }
+
+ conf.FOLLOW.toggle();
+ }
+ MENUCHANGED= true;
+
+// if (conf.FOLLOW.get()) {
+// glutChangeToMenuEntry(18, "Follow mode off", 33);
+// } else {
+// glutChangeToMenuEntry(18, "Follow mode on", 33);
+// }
+
+
+ break;
+
+ case 34:
+ if (conf.FLIGHT.get()) {
+ conf.MARKER_RANGE.toggle();
+ GenFlightList();
+ glutPostRedisplay();
+ }
+ MENUCHANGED= true;
+
+// if (conf.MARKER_RANGE.get()) {
+// glutChangeToMenuEntry(19, "Range off", 34);
+// } else {
+// // glutChangeToMenuEntry(19, "Range on", 34);
+// }
+
+
+ break;
+
+
+
+ case 35:
+ // makes no sense without flight
+ //if (conf.FLIGHT.get()) {
+ conf.FLYING.toggle();
+ //}
+
+ if (conf.FLYING.get() || conf.JOYSTICK.get() || conf.GPSD.get()) {
+ glutIdleFunc(&IdleFunc);
+ } else {
+ glutIdleFunc(NULL);
+ }
+
+ glutPostRedisplay();
+ MENUCHANGED= true;
+
+// if (conf.FLYING.get()) {
+// glutChangeToMenuEntry(20, "Movie off", 35);
+// } else {
+// glutChangeToMenuEntry(20, "Movie on", 35);
+// }
+
+
+ break;
+
+ case 36:
+ conf.JOYSTICK.toggle();
+
+ if (conf.FLYING.get() || conf.JOYSTICK.get() || conf.GPSD.get() ) {
+ glutIdleFunc(&IdleFunc);
+ } else {
+ glutIdleFunc(NULL);
+ }
+ MENUCHANGED= true;
+
+ if (conf.JOYSTICK.get()) {
+ glutJoystickFunc(joystick,0);
+// glutChangeToMenuEntry(21,"Joystick off", 36);
+ } else {
+ glutJoystickFunc(NULL,0);
+// glutChangeToMenuEntry(21,"Joystick on", 36);
+ }
+
+ break;
+
+
+
+
+
+ case 41:
+ conf.ORTHOVIEW.toggle();
+ GenFlightList();
+ InitGL(conf.getwidth(), conf.getheight()); //???
+ glutPostRedisplay();
+ MENUCHANGED= true;
+
+// if (conf.ORTHOVIEW.get()) {
+// glutChangeToMenuEntry(23, "3D perspectivic view",
+// 41);
+// } else {
+// glutChangeToMenuEntry(23, "2D orthographic view",
+// 41);
+// }
+
+
+ break;
+
+
+ case 97:
+ HELP = true; INFO=false;
+ glutPostRedisplay();
+ break;
+
+ case 98:
+ INFO = true; HELP=false;
+ glutPostRedisplay();
+ break;
+
+ case 99:
+ Ende(0);
+ break;
+
+ }
+
+}
+
+// recreate/update menus!
+void menuRecreate()
+{
+ if (conf.DEBUG.get())
+ cout << " re-creating menus"<< endl;
+ glutSetMenu(menIdAirspaceType);
+
+ if (conf.AIRSPACE_P.get()) {
+ glutChangeToMenuEntry(1, "Prohibited D off", 1);
+
+ } else {
+ glutChangeToMenuEntry(1, "Prohibited P on", 1);
+ }
+
+ if (conf.AIRSPACE_R.get()) {
+ glutChangeToMenuEntry(2, "Restricted R off", 2); //2
+ } else {
+ glutChangeToMenuEntry(2, "Restricted R on", 2);
+ }
+
+ if (conf.AIRSPACE_Q.get()) {
+ glutChangeToMenuEntry(3, "Danger Q off", 3); //3
+ } else {
+ glutChangeToMenuEntry(3, "Danger Q on", 3);
+ }
+
+ if (conf.AIRSPACE_C.get()) {
+ glutChangeToMenuEntry(4, "Class C off", 4); //4
+ } else {
+ glutChangeToMenuEntry(4, "Class C on", 4);
+ }
+
+ if (conf.AIRSPACE_D.get()) {
+ glutChangeToMenuEntry(5, "Class D off", 5); //5
+ } else {
+ glutChangeToMenuEntry(5, "Class D on", 5);
+ }
+
+ if (conf.AIRSPACE_CTR.get()) {
+ glutChangeToMenuEntry(6, "CTR off", 6); //6
+ } else {
+ glutChangeToMenuEntry(6, "CTR on", 6);
+ }
+
+ // recreate/change main menu!
+ glutSetMenu(menIdMain);
+ if (conf.MAP.get()) {
+ glutChangeToMenuEntry(1, "Maps off", 1);
+ } else {
+ glutChangeToMenuEntry(1, "Maps on", 1);
+ }
+ if (conf.MODULATE.get()) {
+ glutChangeToMenuEntry(2, "Colored maps off", 2);
+ } else {
+ glutChangeToMenuEntry(2, "Colored maps on", 2);
+ }
+ if (conf.LANDSCAPE.get()) {
+ glutChangeToMenuEntry(5, "Terrain off", 11);
+ } else {
+ glutChangeToMenuEntry(5, "Terrain on", 11);
+ }
+ if (conf.FOG.get()) {
+ glutChangeToMenuEntry(8, "Haze off", 12);
+ } else {
+ glutChangeToMenuEntry(8, "Haze on", 12);
+ }
+ if (conf.AIRSPACE.get()) {
+ glutChangeToMenuEntry(9, "Airspace off", 13);
+ } else {
+ glutChangeToMenuEntry(9, "Airspace on", 13);
+ }
+ if (conf.CURTAIN.get()) {
+ glutChangeToMenuEntry(14, "Curtain off", 21);
+ } else {
+ glutChangeToMenuEntry(14, "Curtain on", 21);
+ }
+ if (conf.MARKER.get()) {
+ glutChangeToMenuEntry(16, "Marker off", 31);
+ } else {
+ glutChangeToMenuEntry(16, "Marker on", 31);
+ }
+ if (conf.INFO.get()) {
+ glutChangeToMenuEntry(17, "Info off", 32);
+ } else {
+ glutChangeToMenuEntry(17, "Info on", 32);
+ }
+ if (conf.FOLLOW.get()) {
+ glutChangeToMenuEntry(18, "Follow mode off", 33);
+ } else {
+ glutChangeToMenuEntry(18, "Follow mode on", 33);
+ }
+ if (conf.MARKER_RANGE.get()) {
+ glutChangeToMenuEntry(19, "Range off", 34);
+ } else {
+ glutChangeToMenuEntry(19, "Range on", 34);
+ }
+ if (conf.FLYING.get()) {
+ glutChangeToMenuEntry(20, "Movie off", 35);
+ } else {
+ glutChangeToMenuEntry(20, "Movie on", 35);
+ }
+ if (conf.JOYSTICK.get()) {
+// glutJoystickFunc(joystick,0);
+ glutChangeToMenuEntry(21,"Joystick off", 36);
+ } else {
+// glutJoystickFunc(NULL,0);
+ glutChangeToMenuEntry(21,"Joystick on", 36);
+ }
+ if (conf.ORTHOVIEW.get()) {
+ glutChangeToMenuEntry(23, "3D perspectivic view",
+ 41);
+ } else {
+ glutChangeToMenuEntry(23, "2D orthographic view",
+ 41);
+ }
+
+ MENUCHANGED=false;
+
+}
+
+void menuMapSet(int val)
+{
+ MENUPOPPED=true;
+ if (val == 9999) return;
+
+ conf.ActiveMapSet.set(val);
+
+ if (conf.MAP.get()) {
+ GenLandscapeList();
+ glutPostRedisplay();
+
+ }
+
+}
+
+void menuStereo(int val)
+{
+ MENUPOPPED=true;
+ // nothing to do in Hardware stereo mode
+ // HW stereo can be enabled at start time and cannot be changed then
+ if (conf.STEREO_HW.get()) {
+ return;
+ }
+
+ bool REBUILD = false;
+
+ switch (val) {
+
+ // turn off stereo modes
+ case 1:
+
+ // rebuilding terrain list is necessary if we had colored anaglyph before
+ // because everything is drawn in B&W then
+ if ((conf.STEREO_RG.get() || conf.STEREO_RB.get())
+ && !conf.BW.get()) {
+ REBUILD = true;
+ }
+ conf.STEREO.off();
+ conf.STEREO_RG.off();
+ conf.STEREO_RB.off();
+ InitGL(conf.getwidth(), conf.getheight());
+ if (REBUILD) {
+ GenLandscapeList();
+ GenFlightList();
+ GenAirspaceList();
+ }
+ glutPostRedisplay();
+ break;
+
+ case 2:
+ if (conf.STEREO.get()) {
+ return;
+ }
+ if ((conf.STEREO_RG.get() || conf.STEREO_RB.get())
+ && !conf.BW.get()) {
+ REBUILD = true;
+ }
+ conf.STEREO.on();
+ conf.STEREO_RG.off();
+ conf.STEREO_RB.off();
+ InitGL(conf.getwidth(), conf.getheight());
+ if (REBUILD) {
+ GenLandscapeList();
+ GenFlightList();
+ GenAirspaceList();
+ }
+ glutPostRedisplay();
+ break;
+
+ case 3:
+ if (conf.STEREO_RG.get()) {
+ return;
+ }
+ if (!(conf.STEREO_RB.get() || conf.BW.get())) {
+ REBUILD = true;
+ }
+ conf.STEREO.off();
+ conf.STEREO_RG.on();
+ conf.STEREO_RB.off();
+ InitGL(conf.getwidth(), conf.getheight());
+ if (REBUILD) {
+ GenLandscapeList();
+ GenFlightList();
+ GenAirspaceList();
+ }
+ glutPostRedisplay();
+ break;
+
+ case 4:
+ if (conf.STEREO_RB.get()) {
+ return;
+ }
+ if (!(conf.STEREO_RG.get() || conf.BW.get())) {
+ REBUILD = true;
+ }
+ conf.STEREO.off();
+ conf.STEREO_RG.off();
+ conf.STEREO_RB.on();
+ InitGL(conf.getwidth(), conf.getheight());
+ if (REBUILD) {
+ GenLandscapeList();
+ GenFlightList();
+ GenAirspaceList();
+ }
+ glutPostRedisplay();
+ break;
+
+ case 5:
+ conf.SWAP_STEREO.toggle();
+ glutPostRedisplay();
+ break;
+ }
+}
+
+
+void menuColormap(int val)
+{
+ MENUPOPPED=true;
+ if (conf.colmapnumber.get() == val) {
+ return;
+ }
+ conf.colmapnumber.set(val);
+
+ if ((conf.LANDSCAPE.get() && conf.MAP.get() && conf.MODULATE.get())
+ || (conf.LANDSCAPE.get() && !conf.MAP.get()
+ && !conf.WIRE.get())) {
+
+ GenLandscapeList();
+ glutPostRedisplay();
+ }
+}
+
+void menuColormap_sea(int val)
+{
+ MENUPOPPED=true;
+ if (conf.colmap2number.get() == val) {
+ return;
+ }
+ conf.colmap2number.set(val);
+
+ if ((conf.LANDSCAPE.get() && conf.MAP.get() && conf.MODULATE.get())
+ || (conf.LANDSCAPE.get() && !conf.MAP.get()
+ && !conf.WIRE.get())) {
+
+ GenLandscapeList();
+ glutPostRedisplay();
+ }
+}
+
+void menuFSColormap(int val)
+{
+ MENUPOPPED=true;
+ if (conf.flightstrip_colmap.get() == val) {
+ return;
+ }
+ conf.flightstrip_colmap.set(val);
+ GenFlightList();
+ glutPostRedisplay();
+}
+
+void menuFSMode(int val)
+{
+ MENUPOPPED=true;
+ if (conf.flightstrip_mode.get() == val) {
+ return;
+ }
+ conf.flightstrip_mode.set(val);
+ GenFlightList();
+ glutPostRedisplay();
+}
+
+void menuAirspaceType(int val)
+{
+ MENUPOPPED=true;
+ switch (val) {
+
+ case 1:
+ conf.AIRSPACE_P.toggle();
+ MENUCHANGED = true;
+ break;
+
+ case 2:
+ conf.AIRSPACE_R.toggle();
+ MENUCHANGED = true;
+ break;
+
+ case 3:
+ conf.AIRSPACE_Q.toggle();
+ MENUCHANGED = true;
+ break;
+
+ case 4:
+ conf.AIRSPACE_C.toggle();
+ MENUCHANGED = true;
+ break;
+
+ case 5:
+ conf.AIRSPACE_D.toggle();
+ MENUCHANGED = true;
+ break;
+
+ case 6:
+ conf.AIRSPACE_CTR.toggle();
+ MENUCHANGED = true;
+ break;
+ }
+
+ GenAirspaceList();
+ glutPostRedisplay();
+}
+
+void GenMenu(void)
+{
+ // create Map-Set-Submenu
+ //if (conf.getMapSetName().size() > 0) {
+ //cout << "XXX" << conf.getMapSetName().size() << endl;
+
+ // freeglut 3.0!
+// glutSetMenuFont(menIdMain, GLUT_BITMAP_TIMES_ROMAN_10);
+
+ menIdMapSet = glutCreateMenu(menuMapSet);
+ vector < string > MapSets;
+ MapSets = conf.getMapSetName();
+
+ if (MapSets.size() == 0) {
+ glutAddMenuEntry("no map sets found", 9999);
+ }
+
+ for (int i = 0; i < (int) MapSets.size(); i++) {
+ //cout << "set:" << i <<" "<< MapSets[i] << endl;
+ glutAddMenuEntry(MapSets[i].c_str(), i + 1);
+ }
+ //}
+
+ // create Stereo menu
+ menIdStereo = glutCreateMenu(menuStereo);
+ glutAddMenuEntry("Stereo off", 1);
+ glutAddMenuEntry("Double image", 2);
+ glutAddMenuEntry("Red Green", 3);
+ glutAddMenuEntry("Red Blue", 4);
+ glutAddMenuEntry("Swap Images", 5);
+
+ //create Colormapmenu
+ menIdColormap = glutCreateMenu(menuColormap);
+ glutAddMenuEntry("Max's colormap", 1);
+ glutAddMenuEntry("Atlas colormap", 2);
+ glutAddMenuEntry("Graymap", 3);
+ glutAddMenuEntry("Atlas 2 colormap", 4);
+ glutAddMenuEntry("Violett - blue", 5);
+ glutAddMenuEntry("Killer Rainbow map", 6);
+ glutAddMenuEntry("White", 7);
+
+
+ //create Colormapmenu sea
+ menIdColormap_sea = glutCreateMenu(menuColormap_sea);
+ glutAddMenuEntry("Max's colormap", 1);
+ glutAddMenuEntry("Atlas colormap", 2);
+ glutAddMenuEntry("Graymap", 3);
+ glutAddMenuEntry("Atlas 2 colormap", 4);
+ glutAddMenuEntry("Violett - blue", 5);
+ glutAddMenuEntry("Killer Rainbow map", 6);
+ glutAddMenuEntry("White", 7);
+
+ //create Colormapmenu FS
+ menIdFSColormap = glutCreateMenu(menuFSColormap);
+ glutAddMenuEntry("Max's colormap", 1);
+ glutAddMenuEntry("Atlas colormap", 2);
+ glutAddMenuEntry("Graymap", 3);
+ glutAddMenuEntry("Atlas 2 colormap", 4);
+ glutAddMenuEntry("Violett - blue", 5);
+ glutAddMenuEntry("Killer Rainbow map", 6);
+ glutAddMenuEntry("White", 7);
+
+ //create FS Mode menu
+ menIdFSMode = glutCreateMenu(menuFSMode);
+ glutAddMenuEntry("classic", 0);
+ glutAddMenuEntry("altitude", 1);
+ glutAddMenuEntry("speed", 2);
+ glutAddMenuEntry("vario", 3);
+
+
+ //create Airspace type menu
+ menIdAirspaceType=glutCreateMenu(menuAirspaceType);
+ if (conf.AIRSPACE_P.get()) {
+ glutAddMenuEntry("Prohibited P off", 1); //1
+ } else {
+ glutAddMenuEntry("Prohibited P on", 1);
+ }
+
+ if (conf.AIRSPACE_R.get()) {
+ glutAddMenuEntry("Restricted R off", 2); //2
+ } else {
+ glutAddMenuEntry("Restricted R on", 2);
+ }
+
+ if (conf.AIRSPACE_Q.get()) {
+ glutAddMenuEntry("Danger Q off", 3); //3
+ } else {
+ glutAddMenuEntry("Danger Q on", 3);
+ }
+
+ if (conf.AIRSPACE_C.get()) {
+ glutAddMenuEntry("Class C off", 4); //4
+ } else {
+ glutAddMenuEntry("Class C on", 4);
+ }
+
+ if (conf.AIRSPACE_D.get()) {
+ glutAddMenuEntry("Class D off", 5); //5
+ } else {
+ glutAddMenuEntry("Class D on", 5);
+ }
+
+ if (conf.AIRSPACE_CTR.get()) {
+ glutAddMenuEntry("CTR off", 6); //6
+ } else {
+ glutAddMenuEntry("CTR on", 6);
+ }
+
+
+ // create Main Menu
+ menIdMain = glutCreateMenu(menuMain);
+
+ if (conf.MAP.get()) {
+ glutAddMenuEntry("Maps off", 1); //1
+ } else {
+ glutAddMenuEntry("Maps on", 1);
+ }
+
+ if (conf.MODULATE.get()) {
+ glutAddMenuEntry("Colored maps off", 2); //2
+ } else {
+ glutAddMenuEntry("Colored maps on", 2);
+ }
+
+ glutAddSubMenu("Map Sets", menIdMapSet); //3
+
+
+ //-----------
+ glutAddMenuEntry(" ", 0); //4
+
+
+ if (conf.LANDSCAPE.get()) {
+ glutAddMenuEntry("Terrain off", 11); //5
+ } else {
+ glutAddMenuEntry("Terrain on", 11);
+ }
+
+ glutAddSubMenu("Terrain Colorramps", menIdColormap); //6
+ glutAddSubMenu("Sea Colorramps", menIdColormap_sea); //7
+
+ if (conf.FOG.get()) {
+ glutAddMenuEntry("Haze off", 12); //8
+ } else {
+ glutAddMenuEntry("Haze on", 12);
+ }
+
+ if (conf.AIRSPACE.get()) {
+ glutAddMenuEntry("Airspace off", 13); //9
+ } else {
+ glutAddMenuEntry("Airspace on", 13);
+ }
+
+ glutAddSubMenu("Airspace types", menIdAirspaceType); // 10
+
+ //------------
+ glutAddMenuEntry(" ", 0); //11
+
+ glutAddSubMenu("Flight track Colorramp", menIdFSColormap); //12
+ glutAddSubMenu("Flight track Mode", menIdFSMode); //13
+
+ if (conf.CURTAIN.get()) {
+ glutAddMenuEntry("Curtain off", 21); //14
+ } else {
+ glutAddMenuEntry("Curtain on", 21);
+ }
+
+
+ //---------
+ glutAddMenuEntry(" ", 0); //15
+
+ if (conf.MARKER.get()) {
+ glutAddMenuEntry("Marker off", 31); //16
+ } else {
+ glutAddMenuEntry("Marker on", 31);
+ }
+
+ if (conf.INFO.get()) {
+ glutAddMenuEntry("Info off", 32); //17
+ } else {
+ glutAddMenuEntry("Info on", 32);
+ }
+
+ if (conf.FOLLOW.get()) {
+ glutAddMenuEntry("Follow off", 33); //18
+ } else {
+ glutAddMenuEntry("Follow on", 33);
+ }
+
+ if (conf.MARKER_RANGE.get()) {
+ glutAddMenuEntry("Range off", 34); //19
+ } else {
+ glutAddMenuEntry("Range on", 34);
+ }
+
+ if (conf.FLYING.get()) {
+ glutAddMenuEntry("Movie off", 35); //20
+ } else {
+ glutAddMenuEntry("Movie on", 35);
+ }
+
+ if (conf.JOYSTICK.get()) {
+ glutAddMenuEntry("Joystick off",36); //21
+ } else {
+ glutAddMenuEntry("Joystick on",36);
+ }
+
+ //-------
+
+ glutAddMenuEntry(" ", 0); //22
+
+ if (conf.ORTHOVIEW.get()) {
+ glutAddMenuEntry("3D perspectivic view", 41); //23
+ } else {
+ glutAddMenuEntry("2D orthographic view", 41);
+ }
+
+ glutAddSubMenu("Stereo Modes", menIdStereo); //24
+
+ glutAddMenuEntry(" ", 0); //25
+
+ glutAddMenuEntry("Help", 97); //26
+ glutAddMenuEntry("About OGIE",98); //27
+ glutAddMenuEntry("Quit", 99); //28
+ glutAttachMenu(GLUT_RIGHT_BUTTON);
+}
+
+
+void menuStatus(int val, int x, int y)
+{
+ MENUPOPPED = true;
+
+ if (conf.DEBUG.get())
+ cout << "menuStatus called: ";
+
+ if (val == GLUT_MENU_IN_USE) {
+ MENUSTATE = true;
+ if (conf.DEBUG.get())
+ cout << "ON" << endl;
+
+ }
+
+ if (val == GLUT_MENU_NOT_IN_USE) {
+ MENUSTATE = false;
+ MENUPOPPED = false;
+ if (conf.DEBUG.get())
+ cout << "OFF" << endl;
+ if (MENUCHANGED)
+ menuRecreate();
+ }
+}
+
+// all the menu stuff #ifndef ONLY_OSMESA
+#endif
+
+
+//this function sets up the flight-display list
+void GenFlightList(void)
+{
+ if (conf.DEBUG.get()) {
+ cout << "GenFlightList START: " << flush;
+ #ifndef ONLY_OSMESA
+ glutReportErrors();
+ #endif
+ cout << endl << flush;
+ }
+
+ glDeleteLists(flightdata_displ_list, 1); //delete list to free memory
+ flightdata_displ_list = glGenLists(1); //create new List
+ glNewList(flightdata_displ_list, GL_COMPILE);
+
+ /*
+ if (conf.DEBUG.get()) {
+ cout << "GenFlightList 1: " << flush;
+ glutReportErrors();
+ cout << endl << flush;
+ }
+ */
+
+ // draw flight linestrip
+ if (!conf.LANDSCAPE.get() && !conf.MAP.get()) {
+ fd.draw_linestrip(conf.offset.get(), conf.STEREO_RB.get()
+ || conf.STEREO_RG.get()
+ || conf.BW.get(), 0.8, 0.1, 0.1,
+ 1.0, 1.0, 1.0);
+ } else {
+ fd.draw_linestrip(conf.offset.get(), conf.STEREO_RB.get()
+ || conf.STEREO_RG.get()
+ || conf.BW.get(), conf.flightstrip_col_rup.get(), conf.flightstrip_col_gup.get(), conf.flightstrip_col_bup.get(),
+ conf.flightstrip_col_rdown.get(), conf.flightstrip_col_gdown.get(), conf.flightstrip_col_bdown.get());
+ }
+
+ /*
+ if (conf.DEBUG.get()) {
+ cout << "GenFlightList 2: " << flush;
+ glutReportErrors();
+ cout << endl << flush;
+ }
+ */
+
+ // The "Shadow" for "Flat-Landscape"
+ if (conf.FLIGHT.get()) {
+ if (!conf.LANDSCAPE.get()) {
+ fd.draw_shadow(conf.offset.get(),
+ conf.STEREO_RB.get()
+ || conf.STEREO_RG.get()
+ || conf.BW.get(), 2.0, 0.0, 0.0,
+ 0.0);
+ } else {
+ fd.draw_shadow_terrain(conf.STEREO_RB.get()
+ || conf.STEREO_RG.get()
+ || conf.BW.get(), 1.0, 0.0,
+ 0.0, 0.3);
+ }
+ }
+ // we need to render transparent stuff at the end (thus put it at the end of the flight_list)
+
+ /*
+ if (conf.DEBUG.get()) {
+ cout << "GenFlightList 3: " << flush;
+ glutReportErrors();
+ cout << endl << flush;
+ }
+ */
+
+ // Curtain
+ if (conf.CURTAIN.get()) {
+ fd.draw_curtain(conf.offset.get(), conf.STEREO_RB.get()
+ || conf.STEREO_RG.get()
+ || conf.BW.get(), 0.0, 0.0, 0.4, 0.4);
+ }
+ glEndList();
+ // this used to be an experiment to smooth the linestrip:
+ // fd.setglEvaluator();
+ if (conf.DEBUG.get()) {
+ cout << "GenFlightList END: " << flush;
+ #ifndef ONLY_OSMESA
+ glutReportErrors();
+ #endif
+ cout << endl << flush;
+ }
+}
+
+void GenAirspaceList()
+{
+
+ if (conf.DEBUG.get()) {
+ cout << "GenAirList START: " << flush;
+ #ifndef ONLY_OSMESA
+ glutReportErrors();
+ #endif
+ cout << endl << flush;
+ }
+
+ glDeleteLists(airspace_displ_list, 1); // delete list to free memory
+ airspace_displ_list = glGenLists(1); // create new List
+ glNewList(airspace_displ_list, GL_COMPILE);
+
+ //Airspace
+ if (conf.AIRSPACE.get()) {
+ air.drawAirspace(conf.STEREO_RB.get()
+ || conf.STEREO_RG.get() || conf.BW.get());
+ }
+ glEndList();
+
+ if (conf.DEBUG.get()) {
+ cout << "GenAirList END: " << flush;
+ #ifndef ONLY_OSMESA
+ glutReportErrors();
+ #endif
+ cout << endl << flush;
+ }
+}
+
+/*
+void GenPointsList()
+{
+ if (conf.DEBUG.get()) {
+ cout << "GenPointsList START: " << flush;
+ #ifndef ONLY_OSMESA
+ glutReportErrors();
+ #endif
+ cout << endl << flush;
+ }
+
+ // lifts. more sections are needed for WPs etc
+ glDeleteLists(lifts_displ_list,1);
+ lifts_displ_list = glGenLists(1);
+ glNewList(lifts_displ_list, GL_COMPILE);
+
+ if (conf.LIFTS.get()) {
+ lifts.drawLifts(conf.STEREO_RB.get()
+ || conf.STEREO_RG.get() || conf.BW.get());
+ }
+
+ glEndList();
+
+ if (conf.DEBUG.get()) {
+ cout << "GenPointsList END: " << flush;
+ #ifndef ONLY_OSMESA
+ glutReportErrors();
+ #endif
+ cout << endl << flush;
+ }
+
+}
+*/
+
+// generate the terrain display list
+void GenLandscapeList()
+{
+
+ landscape_jump:
+
+ if (conf.DEBUG.get()) {
+ cout << "GenLandList START: " << flush;
+ #ifndef ONLY_OSMESA
+ glutReportErrors();
+ #endif
+ cout << endl << flush;
+ }
+
+
+ // loading message
+ #ifndef ONLY_OSMESA
+ if (!( conf.OSMESA.get() || conf.OFFSCREEN.get()))
+ glutSwapBuffers(); //nobody knows whats in the back buffer,
+ // but there is a good changce that after swapping there is the previous displayed image
+
+ // make shure that the text appears right and left in hw-stereo-mode
+ // doesnt make sense in offscreen mode... and GL_BACK would segfault!
+ if (! ( conf.OSMESA.get() || conf.OFFSCREEN.get() )) {
+ if (conf.STEREO_HW.get()) {
+ glDrawBuffer(GL_BACK);
+ }
+
+ //vector <string> message;
+ //message.push_back("loading...");
+
+
+ int font_height = conf.getheight() / 5;
+ glLineWidth(5.0);
+ gltext(conf.getwidth() / 4, (conf.getheight() / 2),
+ font_height, "loading...", conf.getwidth(),
+ conf.getheight());
+ glutSwapBuffers();
+ glLineWidth(1.0);
+ }
+ #endif
+
+
+
+ glDeleteLists(landscape_displ_list, 1); //free memory
+ landscape_displ_list = glGenLists(1); //create new List
+ glNewList(landscape_displ_list, GL_COMPILE);
+
+
+
+
+
+ //the huge green rectangle (flat-landscape)
+ if (!conf.LANDSCAPE.get() && !conf.MAP.get()) {
+ //glPushAttrib(GL_ENABLE_BIT);
+ //glPushAttrib(GL_POLYGON_BIT);
+
+ //glPolygonMode(GL_FRONT, GL_FILL); //should already be set (default)
+ glDisable(GL_LIGHTING);
+
+ glBegin(GL_POLYGON);
+
+ float _col[3] = { 0.0, 0.3, 0.0 };
+
+ if (conf.BW.get() || conf.STEREO_RB.get()
+ || conf.STEREO_RG.get()) {
+ glColor3fv(graycolor(_col));
+ } else {
+ glColor3fv(_col);
+ }
+
+ // if we have texture maps the green floor should be deeper to avoid strange effects...
+ // can be deeper in any case (why not?) fd.getzmin - 0.1 km (=-100m)
+ GLfloat greenheight =
+ fd.getzmin() + ((float) conf.offset.get() / 1000.0) -
+ 0.1;
+
+
+ glVertex3f((GLfloat) fd.getxmax() + conf.getborder(),
+ (GLfloat) fd.getymin() - conf.getborder(),
+ greenheight);
+ glVertex3f((GLfloat) fd.getxmax() + conf.getborder(),
+ (GLfloat) fd.getymax() + conf.getborder(),
+ greenheight);
+ glVertex3f((GLfloat) fd.getxmin() - conf.getborder(),
+ (GLfloat) fd.getymax() + conf.getborder(),
+ greenheight);
+ glVertex3f((GLfloat) fd.getxmin() - conf.getborder(),
+ (GLfloat) fd.getymin() - conf.getborder(),
+ greenheight);
+ glEnd();
+
+ //glPopAttrib();
+ glEnable (GL_LIGHTING); // reset our default
+ }
+
+
+ // TESTING
+/* float _x,_y;
+ proj.get_xy(47.0,11.0,_x,_y);
+ glRasterPos3f(_x,_y,3.5);
+ glColor3f(0,0,0);
+ glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'X');
+*/
+
+ // textured maps... on flat ground
+ if (conf.MAP.get() && !conf.LANDSCAPE.get()) {
+
+ for (int r = conf.getMapIndexLow();
+ r < conf.getMapIndexHigh(); r++) {
+
+ Map map;
+ map.set_proj_pointer(&proj);
+ map.set_conf_pointer(&conf);
+
+ if (conf.getMapFilename(r)[ conf.getMapFilename(r).size() - 3] == 'j'
+ || conf.getMapFilename(r)[ conf.getMapFilename(r).size() - 3] == 'J') {
+
+ map.readMap_jpeg(conf.getMapFilename(r),
+ conf.getmap_width(r),
+ conf.getmap_height(r));
+ } else {
+
+ map.readMap(conf.getMapFilename(r),
+ conf.getmap_width(r),
+ conf.getmap_height(r));
+ }
+
+ map.setcenter_lat(fd.getcenter_lat());
+ map.setcenter_lon(fd.getcenter_lon());
+
+ map.settop(conf.getmap_top(r));
+ map.setbottom(conf.getmap_bottom(r));
+ map.setright(conf.getmap_right(r));
+ map.setleft(conf.getmap_left(r));
+
+ map.setglmap(fd.getzmin() +
+ ((float) conf.offset.get() / 1000.0) -
+ 0.01, conf.COMPRESSION.get(), true,
+ conf.STEREO_RB.get()
+ || conf.STEREO_RG.get()
+ || conf.BW.get());
+ }
+ }
+
+
+
+
+ //Terrain with textured map
+ if (conf.LANDSCAPE.get() && conf.MAP.get()) {
+
+ short int _max_h_bkp;
+ short int _min_h_bkp;
+
+ if (conf.MODULATE.get()) {
+
+ short int _max_h = -8888;
+ short int _min_h = -8888;
+
+ _max_h_bkp = conf.getmax_h();
+ _min_h_bkp = conf.getmin_h();
+
+ // get min and max_h with dummy readDEM_fast
+ // vielleicht kriegt man das noch mal schneller hin?
+
+ //cout << conf.getmax_h() << " max -- min: " << conf.getmin_h() << endl;
+
+ if (conf.getmax_h() == -9999
+ || conf.getmin_h() == -9999) {
+
+ for (int r = conf.getMapIndexLow();
+ r < conf.getMapIndexHigh(); r++) {
+
+ Landscape land;
+ land.set_conf_pointer(&conf);
+
+ land.set_sealevel((double) conf.
+ get_sealevel());
+ land.set_sealevel2((double) conf.
+ get_sealevel2
+ ());
+ land.set_sealevel3((double) conf.
+ get_sealevel3());
+
+ land.set_proj_pointer(&proj);
+ land.setdownscalefactor(conf.
+ getdownscalefactor
+ ());
+ land.setcenter_lat(fd.
+ getcenter_lat
+ ());
+ land.setcenter_lon(fd.
+ getcenter_lon
+ ());
+ land.setmax_lat(conf.
+ getmap_top(r));
+ land.setmin_lat(conf.
+ getmap_bottom(r));
+ land.setmax_lon(conf.
+ getmap_right(r));
+ land.setmin_lon(conf.
+ getmap_left(r));
+ land.setgrid_lat(conf.
+ getdem_grid_lat
+ ());
+ land.setgrid_lon(conf.
+ getdem_grid_lon
+ ());
+
+ int ret = land.readDEM(conf.
+ getDemFileName(),
+ conf.
+ getdem_rows(),
+ conf.
+ getdem_columns(),
+ conf.
+ getdem_lat_min(),
+ conf.
+ getdem_lat_max(),
+ conf.
+ getdem_lon_min(),
+ conf.
+ getdem_lon_max
+ (), true);
+
+ if (ret == 99) {
+ if (conf.DEBUG.get())
+ cout << "readDEM returned 99 " << endl << flush;
+ glEndList();
+ goto landscape_jump;
+ }
+
+
+ if (_min_h == -8888)
+ _min_h = land.getmin_h();
+ if (_max_h == -8888)
+ _max_h = land.getmax_h();
+
+ if (land.getmin_h() < _min_h)
+ _min_h = land.getmin_h();
+ if (land.getmax_h() > _max_h)
+ _max_h = land.getmax_h();
+ }
+
+ if (conf.getmax_h() == -9999)
+ conf.setmax_h(_max_h);
+ if (conf.getmin_h() == -9999)
+ conf.setmin_h(_min_h);
+ }
+ if (conf.VERBOSE.get()) {
+ cout <<
+ "Max and Min Alt used for modulated colors: (min, max): "
+ << conf.getmin_h() << ", " << conf.
+ getmax_h() << endl;
+ }
+ }
+
+
+
+
+ //cout << "entering Terrain AND Map mode..." << endl;
+ for (int r = conf.getMapIndexLow();
+ r < conf.getMapIndexHigh(); r++) {
+
+ Map map;
+ map.set_proj_pointer(&proj);
+ map.set_conf_pointer(&conf);
+ Landscape land;
+ land.set_conf_pointer(&conf);
+
+ land.set_sealevel((double) conf.get_sealevel());
+ land.set_sealevel2((double) conf.get_sealevel2());
+ land.set_sealevel3((double) conf.get_sealevel3());
+
+
+ land.set_proj_pointer(&proj);
+
+ land.setdownscalefactor(conf.getdownscalefactor());
+
+ if (conf.getMapFilename(r)[conf.getMapFilename(r).size() - 3] == 'j') {
+
+ map.readMap_jpeg(conf.getMapFilename(r),
+ conf.getmap_width(r),
+ conf.getmap_height(r));
+
+ } else {
+
+ map.readMap(conf.getMapFilename(r),
+ conf.getmap_width(r),
+ conf.getmap_height(r));
+ }
+
+ land.setcenter_lat(fd.getcenter_lat());
+ land.setcenter_lon(fd.getcenter_lon());
+ map.setcenter_lat(fd.getcenter_lat());
+ map.setcenter_lon(fd.getcenter_lon());
+
+ land.setmax_lat(conf.getmap_top(r));
+ land.setmin_lat(conf.getmap_bottom(r));
+ land.setmax_lon(conf.getmap_right(r));
+ land.setmin_lon(conf.getmap_left(r));
+
+ land.setgrid_lat(conf.getdem_grid_lat());
+ land.setgrid_lon(conf.getdem_grid_lon());
+
+ int ret = land.readDEM(conf.getDemFileName(),
+ conf.getdem_rows(),
+ conf.getdem_columns(),
+ conf.getdem_lat_min(),
+ conf.getdem_lat_max(),
+ conf.getdem_lon_min(),
+ conf.getdem_lon_max());
+
+ if (ret == 99) {
+ if (conf.DEBUG.get())
+ cout << "readDEM returned 99 " << endl << flush;
+ glEndList();
+ goto landscape_jump;
+ }
+
+ // load map, but do not set texture coordinates
+ // that will be done via land.setgltrainglestrip_tex
+ map.setglmap(fd.getzmin() +
+ ((float) conf.offset.get() / 1000.0) -
+ 0.01, conf.COMPRESSION.get(),
+ conf.MAPS_UNLIGHTED.get(),
+ conf.STEREO_RB.get()
+ || conf.STEREO_RG.get()
+ || conf.BW.get(), false);
+
+ if (conf.getmax_h() != -9999) {
+ land.setmax_h(conf.getmax_h());
+ //cout << "max = "<< conf.getmax_h() << endl;
+ }
+
+ if (conf.getmin_h() != -9999) {
+ land.setmin_h(conf.getmin_h());
+ //cout << "min = "<<conf.getmin_h() << endl;
+ }
+
+ land.setgltrianglestrip_tex(conf.colmapnumber.
+ get(),
+ conf.colmap2number.
+ get(),
+ (conf.STEREO_RB.get()
+ || conf.STEREO_RG.
+ get()
+ || conf.BW.get()));
+
+ }
+
+ // restore values
+ if (conf.MODULATE.get()) {
+ conf.setmax_h(_max_h_bkp);
+ conf.setmin_h(_min_h_bkp);
+ }
+ }
+ // Terrain, only
+ if (conf.LANDSCAPE.get() && !conf.MAP.get()) {
+
+ Landscape land;
+ land.set_conf_pointer(&conf);
+
+ land.set_sealevel((double) conf.get_sealevel());
+ land.set_sealevel2((double) conf.get_sealevel2());
+ land.set_sealevel3((double) conf.get_sealevel3());
+
+
+ land.set_proj_pointer(&proj);
+
+ land.setdownscalefactor(conf.getdownscalefactor());
+
+ land.setcenter_lat(fd.getcenter_lat());
+ land.setcenter_lon(fd.getcenter_lon());
+ //adding a border in km (border_land)
+ float border_deg_lat = conf.getborder_land_lat() / DEGDIST;
+ float border_deg_lon =
+ (conf.getborder_land_lon() / DEGDIST) /
+ cos(fd.getcenter_lat() * PI_180);
+ land.setmin_lat(fd.getlatmin() - border_deg_lat);
+ land.setmin_lon(fd.getlonmin() - border_deg_lon);
+ land.setmax_lat(fd.getlatmax() + border_deg_lat);
+ land.setmax_lon(fd.getlonmax() + border_deg_lon);
+
+ if (conf.VERBOSE.get()) {
+ cout << "Terrain boundaries: " << land.getmax_lat() << " " << land.getmin_lat() <<
+ " " << land.getmin_lon() << " " << land.getmax_lon() << endl;
+ }
+
+ land.setgrid_lat(conf.getdem_grid_lat());
+ land.setgrid_lon(conf.getdem_grid_lon());
+
+ int ret = land.readDEM(conf.getDemFileName(), conf.getdem_rows(),
+ conf.getdem_columns(), conf.getdem_lat_min(),
+ conf.getdem_lat_max(), conf.getdem_lon_min(),
+ conf.getdem_lon_max());
+
+
+ if (ret == 99) {
+ if (conf.DEBUG.get())
+ cout << "readDEM returned 99 " << endl << flush;
+ glEndList();
+ goto landscape_jump;
+ }
+
+ if (conf.getmax_h() != -9999) {
+ land.setmax_h(conf.getmax_h());
+ //cout << "max = "<< conf.getmax_h() << endl;
+ }
+
+ if (conf.getmin_h() != -9999) {
+ land.setmin_h(conf.getmin_h());
+ //cout << "min = "<<conf.getmin_h() << endl;
+ }
+
+ if (conf.VERBOSE.get()) {
+ cout <<
+ "Max and Min Alt used for colors: (min, max): "
+ << land.getmin_h() << ", " << land.
+ getmax_h() << endl;
+
+
+/*
+ // these are derived from landscape.cpp
+ int latsteps = (int) (((float)
+ (land.getsteps_lat() -
+ 3 *
+ conf.
+ getdownscalefactor()) /
+ (float) conf.
+ getdownscalefactor()) +
+ 0.5);
+ int lonsteps = (int) (((float)
+ (land.getsteps_lon() -
+ 2 *
+ conf.getdownscalefactor() -
+ 1) /
+ (float) conf.
+ getdownscalefactor()) +
+ 0.5);
+
+ cout << "The Surface is build with " <<
+ latsteps * lonsteps * 2
+ << " Triangles." << endl;
+*/
+
+ cout << "DEM data is read in byte order: ";
+ if (conf.BIGENDIAN.get()) {
+ cout << "big endian" << endl;
+ } else {
+ cout << "little endian" << endl;
+ }
+
+ if (conf.input_dem_factor.get() != 1.0)
+ cout << "DEM input scaling factor: " << conf.input_dem_factor.get() << endl;
+
+
+ }
+
+ land.setgltrianglestrip(conf.WIRE.get(),
+ conf.colmapnumber.get(),
+ conf.colmap2number.get(),
+ (conf.STEREO_RB.get()
+ || conf.STEREO_RG.get()
+ || conf.BW.get()), false);
+
+
+ }
+ glEndList(); //end of the list
+
+ if (conf.DEBUG.get()) {
+ cout << "GenLandList END: " << flush;
+ #ifndef ONLY_OSMESA
+ glutReportErrors();
+ #endif
+ cout << endl << flush;
+ }
+
+}
+
+// mouse callback-function (when any button is clicked)
+#ifndef ONLY_OSMESA
+void mouseClickMove(int xmouse, int ymouse)
+{
+
+ if (HELP || INFO) {
+ return;
+ }
+
+ if (!conf.MOUSE.get()) {
+ if (MOUSEWARPED) {
+ lastmx = conf.getwidth() / 2;
+ lastmy = conf.getheight() / 2;
+ MOUSEWARPED = false;
+ return;
+ }
+ }
+
+
+ if (lastmx == 0) { //nothing to do in first call
+ lastmx = xmouse; //but set the x and y in global lastmx
+ lastmy = ymouse; //and lastmy
+ return;
+ }
+
+
+
+
+ //double factor;
+ if (lastmx == 0) { //nothing to do in first call
+ lastmx = xmouse; //but set the x and y in global lastmx
+ lastmy = ymouse; //and lastmy
+ return;
+ }
+
+ double _dx = xmouse - lastmx; //put differentials into _dx and _dy
+ double _dy = ymouse - lastmy;
+ lastmx = xmouse; //save present position
+ lastmy = ymouse;
+
+ //cout << "dx dy " << _dx << " " << _dy << endl;
+ if (abs(_dx) > 20 || abs(_dy) > 20) {
+ // we don't want the view to skip, so ignore what is most likely the first call
+ return;
+ }
+
+
+ if (!conf.ORTHOVIEW.get()) { // Only if we are not in ORTHO view
+ float _mstep;
+
+
+ // left button: move towards point (center) and back
+
+ if (middlebuttonstate == GLUT_DOWN && leftbuttonstate != GLUT_DOWN) {
+ double factor;
+ if(_dy < 0){
+ factor = pow(0.99, abs((int)_dy));
+ } else {
+ factor = pow(1.01, abs((int)_dy));
+ }
+
+ if (!conf.MARKER.get()) {
+
+ // move to central point
+ ego.setx(ego.getx() * factor);
+ ego.sety(ego.gety() * factor);
+ ego.setz(ego.getz() * factor);
+
+ //if (conf.DEBUG.get())
+ // cout << "wo marker ego.x: " << ego.getx() << " ego.y: " << ego.gety() << " ego.z: " << ego.getz() << endl;
+
+ } else {
+ //move towards markerpos
+
+ // z-koordinates is fscked, even for !MARKER!!!
+ //cout << "egoz/3: " << ego.getz()/3<< " markerz: "<<fd.getmarkerz()<< " fac" << factor << endl;
+ //cout << (ego.getz()/3) - fd.getmarkerz() << "diff " << endl;
+ //if (conf.DEBUG.get())
+ // cout << "w marker ego.x: " << ego.getx() << " ego.y: " << ego.gety() << " ego.z: " << ego.getz() << endl;
+
+ ego.setx( - fd.getmarkerx() + ( ego.getx() + fd.getmarkerx()) * factor );
+ ego.sety( - fd.getmarkery() + ( ego.gety() + fd.getmarkery()) * factor );
+ ego.setz( ( fd.getmarkerz() + ( ego.getz()/conf.z_scale.get() - fd.getmarkerz()) * factor ) * conf.z_scale.get() );
+ }
+
+ // this is probably not needed...
+ //ego.movef(0.2 * _dy);
+
+ }
+
+ if (middlebuttonstate == GLUT_DOWN && leftbuttonstate == GLUT_DOWN) {
+ ego.moveu(0.2 * _dy);
+ ego.moves(0.2 * _dx);
+ } else if (leftbuttonstate == GLUT_DOWN && middlebuttonstate != GLUT_DOWN) { // left button is down
+ if (args_info.smooth_mouse_given) {
+ _mstep = 10;
+ } else {
+ _mstep = 3;
+ }
+ if (!conf.MARKER.get()) {
+ ego.spinmoveradial(_dx / _mstep); //spin the ego around the view centre while adjusting view angle
+ ego.spinmovevertical(_dy / _mstep); // grosser Teiler = sanfte Bewegung
+ } else {
+ ego.spinmoveradialpoint(_dx / _mstep, fd.getmarkerx(), fd.getmarkery()); //spin the ego around the view centre while adjusting view angle
+ ego.spinmoveverticalpoint(_dy / _mstep, fd.getmarkerx(), fd.getmarkery()); // grosser Teiler = sanfte Bewegung
+ }
+ }
+ }
+
+
+ if (conf.FOLLOW.get()) {
+ update_diff_pos();
+ }
+
+
+ if (!conf.MOUSE.get()) {
+ // warp pointer to center of window
+ glutWarpPointer(conf.getwidth() / 2, conf.getheight() / 2);
+ MOUSEWARPED = true;
+ }
+
+ glutPostRedisplay(); //update display
+}
+
+void mouseClickState(int button, int state, int xmouse, int ymouse)
+{
+ if (button == GLUT_RIGHT_BUTTON) {
+ rightbuttonstate = state;
+ }
+ if (button == GLUT_MIDDLE_BUTTON) {
+ middlebuttonstate = state;
+ }
+
+ if (button == GLUT_LEFT_BUTTON) {
+ leftbuttonstate = state;
+ }
+
+}
+
+// mouse callback-function
+void mouseMove(int xmouse, int ymouse)
+{
+
+ if (HELP || INFO) {
+ return;
+ }
+
+
+
+ // return imediatley if any menu is in use
+ if (MENUSTATE) {
+ //cout << "menu acitve" << endl;
+ return;
+ }
+
+ // if menu was used right before avoid "jumping"
+ if (MENUPOPPED) {
+ //cout << "mouse move called after menu POPPPED" << endl;
+ lastmx = 0;
+ lastmy=0;
+ MENUPOPPED = false;
+
+ //glutWarpPointer(conf.getwidth() / 2, conf.getheight() / 2);
+ //MOUSEWARPED = true;
+ return;
+ }
+
+ //if pointer was warped before (callback is triggered by warping...)
+ //
+ if (MOUSEWARPED) {
+ lastmx = conf.getwidth() / 2;
+ lastmy = conf.getheight() / 2;
+ MOUSEWARPED = false;
+ return;
+ }
+
+ if (lastmx == 0) { //nothing to do in first call
+ lastmx = xmouse; //but set the x and y in global lastmx
+ lastmy = ymouse; //and lastmy
+ return;
+ }
+
+ double _dx = xmouse - lastmx; //put differences to _dx and _dy
+ double _dy = ymouse - lastmy;
+ lastmx = xmouse; //save actual position
+ lastmy = ymouse;
+
+ //cout << "dx dy " << _dx << " " << _dy << endl;
+
+
+ // this should prevent "jumps" if the curser enters the window again!
+ // seems to be effective
+ if (abs(_dx)+abs(_dy) > 100) {
+ return;
+ }
+
+ if (!conf.ORTHOVIEW.get()) {
+ float _mstep;
+ if (args_info.smooth_mouse_given) {
+ _mstep = 10;
+ } else {
+ _mstep = 3;
+ }
+ ego.spinz(_dx / _mstep); //spin the ego!
+ ego.spinx(-_dy / _mstep); // grosser Teiler = sanfte Bewegung
+ } else {
+ ego.shiftx(_dx * conf.getorthoshift());
+ ego.shifty(_dy * conf.getorthoshift());
+
+ if (conf.FOLLOW.get())
+ update_diff_pos(); // ????
+ InitGL(conf.getwidth(), conf.getheight());
+
+ }
+
+ // warp pointer to center of window
+ glutWarpPointer(conf.getwidth() / 2, conf.getheight() / 2);
+ MOUSEWARPED = true;
+
+
+ glutPostRedisplay(); //update display
+}
+#endif
+//mouse functions excluded for ONLY_OSMESA
+
+//Draw only.
+void Draw(void)
+{
+
+ //Timecheck drawtime("Draw", &conf);
+
+ //call the lists
+ glCallList(landscape_displ_list);
+
+
+ if (conf.FLIGHT.get()) {
+ if (conf.MARKER.get()) {
+ if (!conf.ORTHOVIEW.get()) {
+ fd.draw_marker(conf.offset.get(),
+ conf.z_scale.get(),
+ conf.STEREO_RB.get()
+ || conf.STEREO_RG.get()
+ || conf.BW.get());
+ } else {
+ fd.draw_marker_ortho();
+ }
+ }
+
+ }
+
+
+ if (conf.LIFTS.get()) {
+ lifts.drawLifts(conf.STEREO_RB.get()
+ || conf.STEREO_RG.get() || conf.BW.get());
+ lifts.drawLiftsTxt(conf.STEREO_RB.get()
+ || conf.STEREO_RG.get() || conf.BW.get(), &ego);
+ }
+
+ if (conf.WAYPOINTS.get()) {
+ waypoints.drawWaypoints(conf.STEREO_RB.get()
+ || conf.STEREO_RG.get() || conf.BW.get());
+ waypoints.drawWaypointsTxt(conf.STEREO_RB.get()
+ || conf.STEREO_RG.get() || conf.BW.get(), &ego);
+ }
+
+ //glCallList(lifts_displ_list);
+ glCallList(flightdata_displ_list);
+ glCallList(airspace_displ_list);
+
+ //lifts.drawLifts(1);
+
+ if (conf.INFO.get()) {
+ DrawInfo();
+ }
+
+ //drawtime.checknow("end of Draw");
+
+}
+
+
+// set the position and view-direction...
+void setpos(void)
+{
+
+ glLoadIdentity();
+ glRotatef(ego.getspinx(), 1.0, 0.0, 0.0); //do the viewpoint transformation
+ glRotatef(ego.getspiny(), 0.0, 1.0, 0.0);
+ glRotatef(ego.getspinz(), 0.0, 0.0, 1.0);
+
+ glTranslatef(ego.getx(), ego.gety(), -ego.getz());
+ glScalef(1.0, 1.0, conf.z_scale.get()); //do z-axis scaling
+
+
+}
+
+void DrawBackground(int bgType)
+{
+ // Use an orthographic view, and save all matrices
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(-1, 1, -1, 1, -1, 1);
+
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ // we also save the enables, as we plan to enable/disable a lot of things
+ glPushAttrib(GL_ENABLE_BIT);
+
+ // disable the expensive tests
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_BLEND);
+ glDisable(GL_LIGHTING);
+
+ // vertical gradient
+ //int bgType = 2;
+
+ switch (bgType) {
+
+ case 1:
+ // solid background // like the old one
+
+ glDisable(GL_TEXTURE_2D);
+ glColor3f(conf.background_color_1r.get(), conf.background_color_1g.get(), conf.background_color_1b.get());
+ glBegin(GL_QUADS);
+ glVertex2i( 1, -1);
+ glVertex2i( 1, 1);
+ glVertex2i(-1, 1);
+ glVertex2i(-1, -1);
+ glEnd();
+ break;
+
+ case 2:
+ // vertical gradient
+ glDisable(GL_TEXTURE_2D);
+ glBegin(GL_QUADS);
+ glColor3f(conf.background_color_1r.get(), conf.background_color_1g.get(), conf.background_color_1b.get()); // lighter!
+ glVertex2i(-1, 1);
+ glVertex2i( 1, 1);
+
+ glColor3f(conf.background_color_2r.get(), conf.background_color_2g.get(), conf.background_color_2b.get());
+ glVertex2i( 1, -1);
+ glVertex2i(-1, -1);
+ glEnd();
+ break;
+
+ case 3:
+ // horizontal gradient
+ glDisable(GL_TEXTURE_2D);
+ glBegin(GL_QUADS);
+ glColor3f(conf.background_color_1r.get(), conf.background_color_1g.get(), conf.background_color_1b.get());
+ glVertex2i(-1, 1);
+ glVertex2i(-1, -1);
+
+ glColor3f(conf.background_color_2r.get(), conf.background_color_2g.get(), conf.background_color_2b.get());
+ glVertex2i( 1, -1);
+ glVertex2i( 1, 1);
+ glEnd();
+ break;
+
+ }
+
+ //
+ // restore our states
+ // this is done so as to leave the modelview matrix as the last active
+ // matrix
+ //
+ glPopAttrib();
+
+ glMatrixMode (GL_PROJECTION);
+ glPopMatrix();
+
+ glMatrixMode (GL_MODELVIEW);
+ glPopMatrix();
+
+}
+
+// rendering routine
+void DrawGLScene(void)
+{
+ // temporary
+/* if (conf.DEBUG.get()) {
+ cout << "entered DRAWGLSCENE" << endl;
+ }
+*/
+ //Timecheck drawgl("DrawGLScene", &conf);
+ if (HELP) {
+ HelpScreen();
+ return;
+ }
+
+ if (INFO) {
+ InfoScreen();
+ return;
+ }
+
+ if (conf.ORTHOVIEW.get())
+ InitGL(conf.getwidth(), conf.getheight());
+
+ if (conf.STEREO_RB.get() || conf.STEREO_RG.get() || conf.BW.get()) {
+ glClearColor(0.144f, 0.144f, 0.144f, 0.0f); //Background is set to nice blue sky (grayscaled :)
+ } else {
+
+ glClearColor(0.1f, 0.1f, 0.5f, 0.0f); //Background is set to nice blue sky
+ }
+
+
+ if (!conf.OFFSCREEN.get() && !conf.OSMESA.get()) {
+
+ glDrawBuffer(GL_BACK);
+
+ } else {
+ glDrawBuffer(GL_FRONT);
+ }
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear screen and depth buffer
+
+ glLoadIdentity(); //load identity matrix
+
+ if(! (conf.BW.get() || conf.FOG.get() || conf.STEREO_RB.get() || conf.STEREO_RG.get())) {
+ DrawBackground(conf.background.get());
+ }
+
+ if (!conf.ORTHOVIEW.get()) {
+ setpos();
+ }
+
+
+ // light position was here.... maybe here again for dynamic light-pos moving?
+ GLfloat light_position[4] = { 5.0, 5.0, 1.0, 0.0 }; //set the light position
+ glLightfv(GL_LIGHT0, GL_POSITION, light_position);
+
+
+ // stereoscopic drawing with 2 images
+ if (conf.STEREO.get() && !conf.ORTHOVIEW.get()) {
+
+ float _ed = conf.eye_dist.get();
+ if (conf.SWAP_STEREO.get())
+ _ed *= -1.0;
+
+
+ // render left image!
+ glViewport(0, 0, conf.getwidth() / 2, conf.getheight());
+ ego.moves(-_ed / 2);
+ setpos();
+ Draw();
+ ego.moves(_ed / 2);
+
+ //render right image!
+ glViewport(conf.getwidth() / 2, 0, conf.getwidth() / 2,
+ conf.getheight());
+ ego.moves(_ed / 2);
+ setpos();
+ Draw();
+ ego.moves(-_ed / 2);
+
+ glViewport(0, 0, conf.getwidth(), conf.getheight());
+
+
+ }
+ // stereoscopic drawing with hardware
+ #ifndef ONLY_OSMESA
+ if (conf.STEREO_HW.get() && !conf.ORTHOVIEW.get()) {
+
+ float _ed = conf.eye_dist.get();
+ if (conf.SWAP_STEREO.get())
+ _ed *= -1.0;
+
+
+ // render left image!
+ glDrawBuffer(GL_BACK_LEFT);
+ ego.moves(_ed / 2);
+ setpos();
+ Draw();
+ ego.moves(-_ed / 2);
+
+ glClear(GL_DEPTH_BUFFER_BIT);
+
+ //render right image!
+ glDrawBuffer(GL_BACK_RIGHT);
+ ego.moves(-_ed / 2);
+ setpos();
+ Draw();
+ ego.moves(_ed / 2);
+
+
+
+
+ }
+ #endif
+
+ // stereoscopic red/green or red/blue
+ if ((conf.STEREO_RB.get() || conf.STEREO_RG.get())
+ && !conf.ORTHOVIEW.get()) {
+
+ float _ed = conf.eye_dist.get();
+ if (conf.SWAP_STEREO.get())
+ _ed *= -1.0;
+
+
+ //render red image
+ ego.moves(-_ed / 2);
+ setpos();
+ glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE);
+
+
+ Draw();
+ ego.moves(_ed / 2);
+
+ glClear(GL_DEPTH_BUFFER_BIT);
+
+ //render green or blue image
+ ego.moves(_ed / 2);
+ setpos();
+
+ if (conf.STEREO_RB.get()) {
+ glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE);
+ }
+
+ if (conf.STEREO_RG.get()) {
+ glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE);
+ }
+
+ Draw();
+ ego.moves(-_ed / 2);
+
+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+ }
+
+ // normal rendering , if no stereo or ortho-mode
+ if ((!conf.STEREO.get() && !conf.STEREO_RB.get()
+ && !conf.STEREO_RG.get() && !conf.STEREO_HW.get())
+ || conf.ORTHOVIEW.get()) {
+ Draw();
+ //cout << "normal" << endl;
+ }
+
+
+
+
+
+ if (!conf.OFFSCREEN.get() && !conf.OSMESA.get()) {
+ #ifndef ONLY_OSMESA
+ glutSwapBuffers();
+ #endif
+ } //and swap the buffers
+
+
+ // every frame will be written as jpeg
+ if (conf.MOVIE.get()) {
+ screenshot();
+ }
+
+ //drawgl.checknow("end");
+
+}
+
+#ifndef ONLY_OSMESA
+void ReSizeGLScene(int nwidth, int nheight)
+{
+ if (nheight == 0) // this shouldnt happen
+ nheight = 1;
+
+ conf.setwidth(nwidth);
+ conf.setheight(nheight);
+
+ //glViewport(0, 0, conf.getwidth(), conf.getheight()); // Reset The Current Viewport
+
+ InitGL(conf.getwidth(), conf.getheight());
+ glutPostRedisplay();
+}
+#endif
+
+
+// initialize openGL
+void InitGL(int Width, int Height) //set GL-Window size
+{
+
+ if (conf.DEBUG.get()) {
+ cout << "entered void InitGL(WxH)" << Width << "x" << Height << endl << flush;
+ //cout << "going to call glPixelstorei(GL_PACK_ALIGNEMENT, 1) ..." << flush;
+ }
+
+//#ifndef __OSX__
+ glPixelStorei(GL_PACK_ALIGNMENT, 1); //Prevents some strange crashes in the glReadPixels in the screenshot-function
+//#else
+// if (conf.DEBUG.get()) {
+// cout << "... (SKIPPED __OSX__) ..." << flush;
+// }
+//#endif
+
+ /*if (conf.DEBUG.get()) {
+ cout << "... returned from glPixelstorei(GL...)" << endl << flush;
+ }*/
+
+ glDepthFunc(GL_LESS); // The Type Of Depth Test To Do
+ glEnable(GL_DEPTH_TEST); // Enables Depth Testing
+ glEnable(GL_NORMALIZE); // Enables normalizing of normal vectors
+
+ glEnable(GL_CULL_FACE);
+ glPolygonMode(GL_FRONT, GL_FILL);
+ glDisable(GL_COLOR_MATERIAL);
+ glLineWidth(1.0);
+
+ if (conf.SHADE.get()) {
+ glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading
+ } else {
+ glShadeModel(GL_FLAT);
+ }
+
+ if (conf.FOG.get()) {
+ glEnable(GL_FOG);
+ glFogi(GL_FOG_MODE, GL_EXP2);
+ glFogf(GL_FOG_DENSITY, conf.fogdensity.get());
+ GLfloat fogcolor[4] = { 0.1, 0.1, 0.5, 1.0 };
+
+ if (!(conf.BW.get() || conf.STEREO_RG.get()
+ || conf.STEREO_RB.get())) {
+ glFogfv(GL_FOG_COLOR, fogcolor);
+ } else {
+ glFogfv(GL_FOG_COLOR, graycolor(fogcolor));
+ }
+
+
+ } else {
+ glDisable(GL_FOG);
+ }
+
+
+
+ GLfloat light_ambient[4] = { 0.5, 0.5, 0.5, 1.0 };
+ GLfloat light_color[4] = { 0.8, 0.8, 0.8, 1.0 };
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, light_color);
+ glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+ //light-position is set in DrawGLScene, after setpos
+
+
+ //set viewport and projection
+ glViewport(0, 0, Width, Height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity(); // Reset the projection Matrix
+
+ if (!conf.ORTHOVIEW.get()) {
+
+ int _q=0;
+ double _far;
+ glGetIntegerv(GL_DEPTH_BITS, (GLint*) &_q);
+
+ float screenfactor;
+
+ float _near;
+
+ //maybe this can be exactly calculated!
+ if (_q < 24) {
+ _near = 1.0;
+ } else {
+ _near = 0.2;
+ }
+
+ if (_q < 24) {
+ _far = 300.0;
+ } else {
+ //_far = 500.0;
+ _far = 600.0;
+ // cout << "FAR: 600 " <<_q << endl;
+ }
+ if (_q > 24) {
+ _far = 2000.0;
+// cout << "FAR: 2000 " << _q <<endl;
+ }
+
+ if (args_info.clipping_far_given) {
+ _far = args_info.clipping_far_arg;
+ }
+
+ if (args_info.clipping_near_given) {
+ _near = args_info.clipping_near_arg;
+ }
+
+ if (conf.DEBUG.get()){
+ cout << "Depth buffer: " << _q << " bit." <<endl
+ << "Clipping near: " << _near << endl << "Clipping far: "<< _far <<endl;
+
+ double _s = pow(2.0, _q);
+ cout << "depth values: " << _s << endl;;
+ double zf = _far * _near / ((1/(double)_s)*(_far-_near) -_far);
+ double zb = _far * _near / ((((double)_s-1)/_s) * (_far-_near) -_far);
+ cout << "next near: " << zf <<endl<<"next far: "<< zb<<endl;
+
+
+ }
+
+ float _front_clip_width =
+ 2.0 * _near * tan(((float) conf.aov.get() / 2.0) *
+ (M_PI / 180.0));
+
+
+ if (conf.STEREO.get()) {
+ screenfactor =
+ ((_front_clip_width) *
+ ((float) conf.getheight() /
+ ((float) conf.getwidth() / 2.0))) / 2.0;
+ } else {
+ screenfactor =
+ ((_front_clip_width) *
+ ((float) conf.getheight() /
+ (float) conf.getwidth())) / 2.0;
+ }
+
+ glFrustum(-_front_clip_width / 2.0,
+ _front_clip_width / 2.0, -screenfactor,
+ screenfactor, _near,
+ _far * conf.getdownscalefactor());
+ } else {
+ //experimental for now
+
+ float xclip = (conf.orthoclipping.get() / 2.0); //*(conf.getwidth() / conf.getheight()) ;
+ float yclip =
+ (conf.orthoclipping.get() / 2.0) *
+ ((float) conf.getheight() / (float) conf.getwidth());
+
+ glOrtho(ego.getOx() - xclip, ego.getOx() + xclip,
+ ego.getOy() - yclip, ego.getOy() + yclip, -20.0,
+ 20.0);
+
+ }
+
+ //reset MatrixModel to our default state policy
+ glMatrixMode(GL_MODELVIEW);
+}
+
+void screenshot() {
+
+ Timecheck sshottime("Screenshot",&conf);
+ if ( (strcasecmp(conf.get_image_format().c_str(), "jpg") == 0)
+ || (strcasecmp(conf.get_image_format().c_str(), "jpeg") == 0) )
+ screenshot_jpeg();
+
+ if ( strcasecmp(conf.get_image_format().c_str(),"rgb") == 0)
+ screenshot_rgb();
+
+ sshottime.checknow("");
+
+
+}
+
+
+// ersetzt von screenshot_jpeg
+//framebuffer schreibt den framebuffer in ein *.rgb file
+void screenshot_rgb() {
+
+ short int* rgbmap = new short int[conf.getwidth()*conf.getheight()*3];
+
+
+ glReadPixels(0,0,conf.getwidth(),conf.getheight(),GL_RGB,GL_UNSIGNED_SHORT,rgbmap);
+
+
+ char name[1024];
+ //char _buff[2];
+
+ cout << "writing a rgb " << conf.getwidth() << "x" << conf.getheight() << " picture with 6 Byte per Pixel" << endl;
+
+ std::string basename = conf.get_basename();
+ std::string path = conf.get_save_path();
+ if (args_info.basename_given) { basename = args_info.basename_arg; }
+ if (args_info.save_path_given) { path = args_info.save_path_arg + SEPERATOR; }
+
+
+ if (args_info.os_outfile_given) {
+ sprintf(name, "%s", args_info.os_outfile_arg);
+ } else {
+
+ ifstream testfile;
+
+ while (1) {
+ sprintf(name, "%s%s%d.rgb", path.c_str(), basename.c_str(), conf.getnextframewriternumber());
+ //cout << name << " geht nixht" << endl;
+ testfile.open(name, ios::binary);
+ if (!testfile) {break;}
+ testfile.close();
+ //cout << name << " NEIN gibt schon" << endl;
+ }
+ //cout << name << " geht!!!!" << endl;
+ }
+
+ ofstream framefile;
+ framefile.open(name, ios::binary);
+
+// for (int _z=0 ;_z < (width*height*3); _z++){
+// framefile.write((char*)&rgbmap[_z],2);
+// }
+
+ for (int _z=(conf.getwidth()*(conf.getheight()-1)*3); _z>=0; _z=_z-conf.getwidth()*3) {
+ for (int _s=0; _s<conf.getwidth()*3; _s++) {
+ framefile.write((char*)&rgbmap[_z+_s],2);
+ }
+ }
+
+
+ cout << name << " written." << endl <<flush;
+ //cout << sizeof (GLushort) << endl;
+ delete [] rgbmap;
+
+}
+
+
+
+void screenshot_jpeg()
+{
+
+ // rendering in the GL_BACK buffer and reading from it will only work on
+ // software GL. If GL_BACK is a hardware buffer it wont work
+ // maybe they dont render overlayed regions of the buffer.
+ // we will read from (GL_FRONT)
+
+ glFinish();
+
+ unsigned char *tmpArray, *jpegArray;
+ int quality = conf.jpeg_quality.get();
+ char name[1024];
+ int index = 0;
+
+ tmpArray =
+ new unsigned char[conf.getwidth() * conf.getheight() * 3];
+ jpegArray =
+ new unsigned char[conf.getwidth() * conf.getheight() * 3];
+
+ if (conf.OSMESA.get())
+ glReadBuffer(GL_FRONT);
+
+ if (conf.OFFSCREEN.get())
+ glReadBuffer(GL_FRONT);
+
+ glFinish();
+
+
+
+ glReadPixels(0, 0, conf.getwidth(), conf.getheight(), GL_RGB,
+ GL_UNSIGNED_BYTE, tmpArray);
+
+
+
+ index = 0;
+ for (int _z = (conf.getwidth() * (conf.getheight() - 1) * 3);
+ _z >= 0; _z = _z - conf.getwidth() * 3) {
+ for (int _s = 0; _s < conf.getwidth() * 3; _s++) {
+ jpegArray[index] = tmpArray[_z + _s];
+ index++;
+ }
+ }
+
+
+ if (conf.VERBOSE.get()) {
+ cout << "writing a " << conf.getwidth() << "x" << conf.
+ getheight() << " jpg image" << endl;
+ cout << "jpeg quality: " << conf.jpeg_quality.get() << endl;
+ }
+
+ std::string basename = conf.get_basename();
+ std::string path = conf.get_save_path();
+ if (args_info.basename_given) { basename = args_info.basename_arg; }
+ if (args_info.save_path_given) { path = args_info.save_path_arg + SEPERATOR; }
+
+ if (args_info.os_outfile_given) {
+ sprintf(name, "%s", args_info.os_outfile_arg);
+ } else {
+ ifstream testfile;
+ while (1) {
+ sprintf(name, "%s%s%d.jpg", path.c_str(), basename.c_str(), conf.getnextframewriternumber());
+ //cout << name << " geht nixht" << endl;
+ testfile.open(name, ios::binary);
+ if (!testfile) {break;}
+ testfile.close();
+ //cout << name << " NEIN gibt schon" << endl;
+ }
+ //cout << name << " geht!!!!" << endl;
+ }
+
+ //sprintf(name, "%s%s%d.jpg", path.c_str(), basename.c_str(), conf.getnextframewriternumber());
+
+ //sprintf(name, "frame%d.jpg", conf.getnextframewriternumber());
+
+ //if (args_info.os_outfile_given) {
+
+ // sprintf(name, "%s", args_info.os_outfile_arg);
+
+ //}
+
+ write_JPEG_file(conf.getwidth(), conf.getheight(), quality, name,
+ (JSAMPLE *) jpegArray);
+
+ if (conf.VERBOSE.get())
+ cout << "jpeg: " << name << " written ! " << endl <<
+ flush;
+
+ delete tmpArray;
+ delete jpegArray;
+
+}
+
+
+#ifndef ONLY_OSMESA
+void IdleFunc(void)
+{
+
+ //needed in movie mode, to decide whether to repeat frame, or to move marker forward
+ bool FORWARD=false;
+ bool REPEAT=false;
+
+ if (conf.JOYSTICK.get() && !conf.ORTHOVIEW.get()) {
+ glutForceJoystickFunc();
+ }
+
+ // determine framerate;
+
+ timeval now;
+ timeval last;
+ //timezone zone;
+
+ //zone.tz_minuteswest = 0;
+ //zone.tz_dsttime = DST_NONE;
+
+ gettimeofday(&now, NULL);
+
+ last = conf.get_time_mem();
+ conf.set_time_mem(now);
+
+ //cout << "last : " << last.tv_sec << " " << last.tv_usec << endl;
+ //cout << "now : " << now.tv_sec << " " << now.tv_usec << endl;
+
+ float rate =
+ 1.0 / (((float) now.tv_sec - (float) last.tv_sec)
+ +
+ (((float) now.tv_usec -
+ (float) last.tv_usec) / 1000000.0));
+
+ //cout << "rate: " << rate << endl;
+ conf.set_framerate(rate);
+ conf.set_fps(rate);
+
+
+
+ // conf.movi_msec is millisecs usleep is in microseconds!
+ if (conf.FLYING.get() && !conf.GPSD.get() ) {
+ usleep((unsigned long int) conf.movie_msecs.get() * 1000);
+
+ if (conf.FLYING_REPEAT.get())
+ REPEAT=true;
+ if (conf.FLYING_AUTO_REPEAT.get()) {
+ if (conf.get_fps() > conf.idle_auto_repeat_limit.get()) {
+ //cout << "fps exceeeds limit" << endl;
+ REPEAT=true;
+ }
+ }
+
+ if (REPEAT) {
+ movie_repeat_counter++;
+ //cout << "repeater : "<< movie_repeat_counter << endl;
+ if (movie_repeat_counter >= conf.movie_repeat_factor.get()) {
+ movie_repeat_counter=0;
+ FORWARD=true;
+ }
+ } else {
+ FORWARD=true;
+ }
+ }
+ /*
+ // update date in GPSD mode
+ if (conf.GPSD.get())
+ fd.querygps();
+
+ // FLYING with GPSD: marker is kept at recent position!
+ if (conf.FLYING.get() && conf.GPSD.get() ) {
+ fd.marker_head();
+ }
+ */
+ if (conf.SPINNING.get() != 0) {
+ ego.spinmoveradialpoint(conf.SPINNING.get(), fd.getmarkerx(), fd.getmarkery() ); //spin the ego around the marker
+ if (conf.FOLLOW.get())
+ update_diff_pos();
+ }
+
+
+ if (conf.GPSD.get()) {
+ if (fd.querygps() == 0) { // new data;
+ if (conf.FLYING.get())
+ fd.marker_head();
+ GenFlightList();
+
+ // leaving area!
+
+ //cout << fd.getlat() << " " << fd.getlon() << endl;
+ //cout <<"lim: "<< fd.getcenter_lat()+(conf.getborder_land_lat()/DEGDIST) <<
+ //" " << fd.getcenter_lat()-(conf.getborder_land_lat()/DEGDIST) << endl;
+ //cout << "lim2: " << fd.getcenter_lon()+(conf.getborder_land_lon()/DEGDIST)
+ //<< " " << fd.getcenter_lon()-(conf.getborder_land_lon()/DEGDIST) << endl;
+
+ if (conf.LANDSCAPE.get() && !conf.MAP.get()) {
+ // hier noch die limits checken
+ // in lat gehts manchmal ueber die kante..? ZZZZZ
+ // immer noch? sieht ganz gut aus soweit
+ if (fd.getlat() > fd.getcenter_lat()-conf.getdem_grid_lat()*conf.getdownscalefactor()+((conf.getborder_land_lat()-0.0)/DEGDIST)
+ || fd.getlat() < fd.getcenter_lat()+conf.getdem_grid_lat()*conf.getdownscalefactor()-((conf.getborder_land_lat()-0.0)/DEGDIST)
+ || fd.getlon() > fd.getcenter_lon()-conf.getdem_grid_lon()*conf.getdownscalefactor()+(((conf.getborder_land_lon()-0.0)/DEGDIST)/
+ cos(fd.getcenter_lat() * PI_180))
+ || fd.getlon() < fd.getcenter_lon()+conf.getdem_grid_lon()*conf.getdownscalefactor()-(((conf.getborder_land_lon()-0.0)/DEGDIST)/
+ cos(fd.getcenter_lat() * PI_180))
+ ) {
+
+ //cout << "REBUILDING LANDSCAPE" << endl;
+ fd.setcenter_lat(fd.getlat());
+ fd.setcenter_lon(fd.getlon());
+ fd.setlatmin(fd.getlat());
+ fd.setlatmax(fd.getlat());
+ fd.setlonmax(fd.getlon());
+ fd.setlonmin(fd.getlon());
+ GenLandscapeList();
+
+ }
+ }
+
+ }
+ }
+
+
+ // forward exits only in flying mode without gpsd
+ if (FORWARD && conf.FLIGHT.get()) {
+ fd.forward_marker();
+
+ if (fd.getcycles() == 0)
+ Ende(0);
+
+ // wenn marker bewegt neue flightlist machen
+ if (conf.MARKER_RANGE.get()) {
+ GenFlightList();
+ }
+
+#ifndef __WIN32__
+ update_shmem();
+#endif
+ }
+
+ if (conf.FOLLOW.get())
+ update_locked_pos();
+
+
+ glutPostRedisplay();
+}
+#endif
+
+
+#ifndef ONLY_OSMESA
+//joystick function
+void joystick(unsigned int buttonMask, int x, int y, int z)
+{
+ if (conf.DEBUG.get())
+ cout << "Joystick: ButtonMask: " << buttonMask << " X=" << x
+ << " Y=" << y << " Z=" << z << " " << '\r' << flush;
+
+ ego.movef(0.2 * conf.joyfac_y.get() * (float) y * conf.getdownscalefactor());
+ ego.moves(-0.2 * conf.joyfac_x.get() * (float) x * conf.getdownscalefactor());
+ ego.movez(-0.05 * conf.joyfac_z.get() * (float) z * conf.getdownscalefactor());
+
+ // here is something wrong...
+ // "flying-mode, follow-mode... ?!
+ // update the diff-pos, only if we really have moved!
+ if (conf.FOLLOW.get() && (x != 0 || y!=0 || z!=0))
+ update_diff_pos();
+
+}
+#endif
+
+
+#ifndef ONLY_OSMESA
+// Keyboard callback
+void keyPressed(unsigned char key, int x, int y)
+{
+
+ //not too fast
+ usleep(100);
+
+ /*if (conf.DEBUG.get())
+ cout << "Key: \"" << key << "\" pressed." << endl << flush;*/
+
+ if (HELP || INFO) {
+ HELP = false;
+ INFO = false;
+ glutPostRedisplay();
+ return;
+ }
+
+ // escape?
+ if (key == ESCAPE || key == 'q') {
+ Ende(0);
+ }
+
+
+
+
+ // MOVING
+ // some things do not make sense in ORTHO-MODE
+ if (!conf.ORTHOVIEW.get()) {
+ if (key == 't') {
+ ego.movez(0.05 * conf.getdownscalefactor());
+ if (conf.FOLLOW.get()) {
+ update_diff_pos();
+ }
+ }
+ if (key == 'z') {
+ ego.movez(-0.05 * conf.getdownscalefactor());
+ if (conf.FOLLOW.get()) {
+ update_diff_pos();
+ }
+ }
+ if (key == 'd') {
+ ego.moves(0.2 * conf.getdownscalefactor());
+ if (conf.FOLLOW.get()) {
+ update_diff_pos();
+ }
+ }
+ if (key == 'f') {
+ ego.moves(-0.2 * conf.getdownscalefactor());
+ if (conf.FOLLOW.get()) {
+ update_diff_pos();
+ }
+ }
+ }
+
+ if (key == 'g') {
+ if (!conf.ORTHOVIEW.get()) {
+ ego.movef(-0.2 * conf.getdownscalefactor());
+ if (conf.FOLLOW.get()) {
+ update_diff_pos();
+ }
+ } else {
+
+ float zoomfac = 1;
+
+ if (conf.orthoclipping.get() < 5) {
+ zoomfac = conf.orthoclipping.get()/50.0;
+ }
+
+ conf.orthoclipping.dec(2.0 *
+ conf.getdownscalefactor()
+ * zoomfac
+ );
+ //InitGL(conf.getwidth(), conf.getheight());
+ }
+
+ }
+
+
+ if (key == 's') {
+ if (!conf.ORTHOVIEW.get()) {
+ ego.movef(0.2 * conf.getdownscalefactor());
+ if (conf.FOLLOW.get()) {
+ update_diff_pos();
+ }
+ } else {
+
+ float zoomfac = 1;
+
+ if (conf.orthoclipping.get() < 5) {
+ zoomfac = conf.orthoclipping.get()/50.0;
+ }
+
+ conf.orthoclipping.inc(2.0 *
+ conf.getdownscalefactor()
+ * zoomfac
+ );
+ //InitGL(conf.getwidth(), conf.getheight());
+ }
+ }
+
+ if (key == ' ') {
+ if (!conf.ORTHOVIEW.get()) {
+ ego.movef(-1.0 * conf.getdownscalefactor());
+ if (conf.FOLLOW.get()) {
+ update_diff_pos();
+ }
+ } else {
+ conf.orthoclipping.dec(10.0 *
+ conf.getdownscalefactor());
+ //InitGL(conf.getwidth(), conf.getheight());
+ }
+ }
+
+ if (key == 'a') {
+ if (!conf.ORTHOVIEW.get()) {
+ ego.movef(1.0 * conf.getdownscalefactor());
+ if (conf.FOLLOW.get()) {
+ update_diff_pos();
+ }
+ } else {
+ conf.orthoclipping.inc(10.0 *
+ conf.getdownscalefactor());
+ //InitGL(conf.getwidth(), conf.getheight());
+ }
+ }
+
+
+ if (!conf.ORTHOVIEW.get()) {
+
+ if (key == '+')
+ conf.z_scale.inc(0.1);
+// GenPointsList();
+ if (key == '-')
+ conf.z_scale.dec(0.1);
+// GenPointsList();
+ }
+// You cant get lower than fd.getzmin()+0.02
+ if (ego.getz() <
+ (fd.getzmin() + ((float) conf.offset.get() / 1000.0) +
+ 0.05) * conf.z_scale.get()) {
+ ego.setz((fd.getzmin() +
+ ((float) conf.offset.get() / 1000.0) +
+ 0.05) * conf.z_scale.get());
+ }
+
+
+ if (key == 'P')
+ conf.MOVIE.toggle();
+
+ //Curtain
+ if (key == 'h') {
+ menuMain(21);
+ }
+
+ if (key == 'p') {
+ screenshot();
+ }
+
+ if (key == 'm') {
+ conf.MOUSE.toggle();
+
+ if (conf.MOUSE.get()) {
+ glutPassiveMotionFunc(NULL);
+ //glutMotionFunc(&mouseClickMove);
+ glutSetCursor(GLUT_CURSOR_INHERIT);
+ } else {
+ //lastmx =0; lastmy =0;
+ glutWarpPointer(conf.getwidth() / 2,
+ conf.getheight() / 2);
+ MOUSEWARPED = true;
+ glutPassiveMotionFunc(&mouseMove);
+ //glutMotionFunc(NULL);
+ glutSetCursor(GLUT_CURSOR_NONE);
+ }
+ }
+ //adjusting offset
+ if (key == 'u') {
+ conf.offset.inc(1);
+ GenFlightList();
+ }
+
+ if (key == 'i') {
+ conf.offset.dec(1);
+ GenFlightList();
+ }
+
+
+ if (key == 'w') {
+ if (conf.FULLSCREEN.get()) {
+ glutReshapeWindow(conf.getinitwidth(),
+ conf.getinitheight());
+ conf.setwidth(conf.getinitwidth());
+ conf.setheight(conf.getinitheight());
+ conf.FULLSCREEN.toggle();
+ } else {
+ glutFullScreen();
+ //glutEnterGameMode();
+ conf.FULLSCREEN.toggle();
+ }
+ }
+
+ //switch on/off textured maps
+ if (key == 'b') {
+ menuMain(1);
+ }
+
+ if (key == 'j') {
+ menuMain(12);
+ }
+
+ if (key == '9') {
+ conf.fogdensity.dec(0.001);
+ InitGL(conf.getwidth(), conf.getheight());
+ //cout << conf.fogdensity.get() << endl;
+ }
+
+ if (key == '0') {
+ conf.fogdensity.inc(0.001);
+ InitGL(conf.getwidth(), conf.getheight());
+ //cout << conf.fogdensity.get() << endl;
+ }
+
+
+ if (key == '7') {
+ conf.aov.inc(1);
+ //cout << conf.getFrust()<< endl;
+ InitGL(conf.getwidth(), conf.getheight());
+ }
+
+ if (key == '8') {
+ conf.aov.dec(1);
+ //cout << conf.getFrust()<< endl;
+ InitGL(conf.getwidth(), conf.getheight());
+ }
+
+ if (key == 'l') {
+ menuMain(11);
+ }
+
+ if (key == 'L') {
+ conf.WIRE.toggle();
+
+ if ((!conf.MAP.get() || conf.LANDSCAPE.get())
+ && !(conf.MAP.get() && conf.LANDSCAPE.get())) {
+ GenFlightList();
+ GenLandscapeList();
+ }
+ }
+
+ if (key == 'o') {
+ menuMain(41);
+ }
+
+ if (key == 'O') {
+ conf.SHADE.toggle();
+ InitGL(conf.getwidth(), conf.getheight());
+ }
+
+ if (key == '1' && conf.colmapnumber.get() != 1) {
+ menuColormap(1);
+ }
+
+ if (key == '2' && conf.colmapnumber.get() != 2) {
+ menuColormap(2);
+ }
+
+ if (key == '3' && conf.colmapnumber.get() != 3) {
+ menuColormap(3);
+ }
+
+ if (key == '4' && conf.colmapnumber.get() != 4) {
+ menuColormap(4);
+ }
+
+ if (key == '5' && conf.colmapnumber.get() != 5) {
+ menuColormap(5);
+ }
+
+ if (key == '6' && conf.colmapnumber.get() != 6) {
+ menuColormap(6);
+ }
+
+
+ if (key == 'x') {
+ int tmp = conf.ActiveMapSet.get();
+ conf.ActiveMapSet.dec(1);
+ if ((tmp != conf.ActiveMapSet.get()) && conf.MAP.get()) {
+ GenLandscapeList();
+ }
+ }
+
+ if (key == 'X') {
+ conf.NOLIGHTING.toggle();
+ GenLandscapeList();
+
+ }
+
+ if (key == 'c') {
+ int tmp = conf.ActiveMapSet.get();
+ conf.ActiveMapSet.inc(1);
+ if ((tmp != conf.ActiveMapSet.get()) && conf.MAP.get()) {
+ GenLandscapeList();
+ }
+ }
+
+ if (key == 'y') {
+ conf.COMPRESSION.toggle();
+ if (conf.MAP.get()) {
+ GenLandscapeList();
+ }
+ }
+
+ if (key == 'A') {
+ conf.SWAP_STEREO.toggle();
+ }
+
+ if (key == 'S') {
+ if (conf.STEREO.get()) {
+ menuStereo(1);
+ } else {
+ menuStereo(2);
+ }
+ }
+ // Black and white
+ if (key == 'B') {
+ conf.BW.toggle();
+
+ if (!(conf.STEREO_RG.get() || conf.STEREO_RB.get())) {
+ GenLandscapeList();
+ GenFlightList();
+ GenAirspaceList();
+ InitGL(conf.getwidth(), conf.getheight());
+ }
+ }
+
+ if (key == 'D') {
+ if (conf.STEREO_RG.get()) {
+ menuStereo(1);
+ } else {
+ menuStereo(3);
+ }
+ }
+
+ if (key == 'F') {
+ if (conf.STEREO_RB.get()) {
+ menuStereo(1);
+ } else {
+ menuStereo(4);
+ }
+ }
+
+ if (key == 'Q') {
+ conf.eye_dist.dec(0.05);
+ }
+
+ if (key == 'W') {
+ conf.eye_dist.inc(0.05);
+ }
+ //cout << int(key) << " key" << endl;
+
+ if (key == 'U') {
+ menuMain(34);
+ }
+
+ if (key == 'M') {
+ menuMain(33);
+ }
+
+ if (key == 'I') {
+ menuMain(35);
+ }
+
+ if (key == 'J')
+ menuMain(36);
+
+
+ glutPostRedisplay();
+}
+#endif
+
+
+
+
+
+
+#ifndef ONLY_OSMESA
+void SpecialKeyPressed(int key, int x, int y)
+{
+
+ if (HELP || INFO) {
+ HELP = false;
+ INFO = false;
+ glutPostRedisplay();
+ return;
+ }
+ // no modifiers!
+ if (glutGetModifiers() != GLUT_ACTIVE_SHIFT &&
+ glutGetModifiers() != GLUT_ACTIVE_CTRL &&
+ glutGetModifiers() != GLUT_ACTIVE_ALT) {
+
+
+
+ if (key == GLUT_KEY_F1) {
+ fd.fbackward_marker();
+ if (conf.FOLLOW.get()) {
+ update_locked_pos();
+ }
+ if (conf.MARKER_RANGE.get()) {
+ GenFlightList();
+ }
+ //cout << fd.getmarker() << endl;
+#ifndef __WIN32__
+ update_shmem();
+#endif
+ }
+
+ if (key == GLUT_KEY_F2) {
+ fd.backward_marker();
+ if (conf.FOLLOW.get()) {
+ update_locked_pos();
+ }
+ if (conf.MARKER_RANGE.get()) {
+ GenFlightList();
+ }
+ //cout << fd.getmarker() << endl;
+#ifndef __WIN32__
+ update_shmem();
+#endif
+ }
+
+ if (key == GLUT_KEY_F3) {
+ fd.forward_marker();
+ if (conf.FOLLOW.get()) {
+ update_locked_pos();
+ }
+ if (conf.MARKER_RANGE.get()) {
+ GenFlightList();
+ }
+ //cout << fd.getmarker() << endl;
+#ifndef __WIN32__
+ update_shmem();
+#endif
+ }
+ if (key == GLUT_KEY_F4) {
+ fd.fforward_marker();
+ if (conf.FOLLOW.get()) {
+ update_locked_pos();
+ }
+ if (conf.MARKER_RANGE.get()) {
+ GenFlightList();
+ }
+ //cout << fd.getmarker() << endl;
+#ifndef __WIN32__
+ update_shmem();
+#endif
+ }
+
+ if (key == GLUT_KEY_F5) {
+ setinitpos();
+ }
+
+ if (key == GLUT_KEY_F6) {
+ menuMain(32);
+ }
+
+ if (key == GLUT_KEY_F7) {
+ menuMain(31);
+ //cout << "toggel marker" << endl;
+ }
+
+ if (key == GLUT_KEY_F8) {
+ menuMain(2);
+ }
+
+ if (key == GLUT_KEY_F9) {
+ menuMain(13);
+ }
+
+
+ if (key == GLUT_KEY_F10) {
+ if (conf.colmap2number.get() >=
+ conf.colmap2number.getmin() + 1) {
+ //conf.colmap2number.dec(1);
+ menuColormap_sea(conf.colmap2number.get() -
+ 1);
+ //GenLandscapeList();
+ }
+
+ }
+
+ if (key == GLUT_KEY_F11) {
+ if (conf.colmap2number.get() <=
+ conf.colmap2number.getmax() - 1) {
+ //conf.colmap2number.inc(1);
+ menuColormap_sea(conf.colmap2number.get() +
+ 1);
+ //GenLandscapeList();
+ }
+
+ }
+
+ if (key == GLUT_KEY_F12) {
+ conf.WAYPOINTS.toggle();
+ }
+
+
+ // Rotations around marker pos (by A. Somers)
+ // arrow-keys without mofifiers
+ if (key == GLUT_KEY_LEFT) {
+ ego.spinmoveradialpoint(1, fd.getmarkerx(), fd.getmarkery() ); //spin the ego around the marker
+ if (conf.FOLLOW.get())
+ update_diff_pos();
+ }
+
+ if (key == GLUT_KEY_UP) {
+
+ ego.spinmoveverticalpoint(1, fd.getmarkerx(), fd.getmarkery() ); //spin the ego around the marker
+ if (conf.FOLLOW.get())
+ update_diff_pos();
+ }
+
+ if (key == GLUT_KEY_RIGHT) {
+ ego.spinmoveradialpoint(-1, fd.getmarkerx(), fd.getmarkery() ); //spin the ego around the marker
+ if (conf.FOLLOW.get())
+ update_diff_pos();
+ }
+
+ if (key == GLUT_KEY_DOWN) {
+ ego.spinmoveverticalpoint(-1, fd.getmarkerx(), fd.getmarkery() ); //spin the ego around the marker
+ if (conf.FOLLOW.get())
+ update_diff_pos();
+ }
+
+
+
+
+ if (key == GLUT_KEY_PAGE_UP) {
+ conf.MARKER_SIZE.inc(0.02);
+ }
+
+ if (key == GLUT_KEY_PAGE_DOWN) {
+ conf.MARKER_SIZE.dec(0.02);
+ }
+
+
+ if (key == GLUT_KEY_HOME) {
+ conf.lifts_info_mode.inc(1);
+ }
+ if (key == GLUT_KEY_END) {
+ conf.lifts_info_mode.dec(1);
+ }
+ if (key == GLUT_KEY_INSERT) {
+ cout << "insert unused" << endl;
+ }
+ } // end no modifiers
+
+
+ //modifier shift
+ if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) {
+
+ if (key == GLUT_KEY_F1) {
+
+
+ conf.movie_repeat_factor.dec(2);
+
+ // warum dies?
+ //if (conf.FLYING.get()) {
+ // glutIdleFunc(&IdleFunc);
+ //}
+
+
+ }
+
+ if (key == GLUT_KEY_F2) {
+ conf.movie_repeat_factor.inc(2);
+
+ //if (conf.FLYING.get()) {
+ // glutIdleFunc(&IdleFunc);
+ //}
+
+ }
+
+
+
+ if (key == GLUT_KEY_F3) {
+ conf.flightstrip_width.dec(1.0);
+ GenFlightList();
+ }
+
+ if (key == GLUT_KEY_F4) {
+ conf.flightstrip_width.inc(1.0);
+ GenFlightList();
+
+ }
+
+
+ if (key == GLUT_KEY_F5) {
+ conf.flightstrip_mode.dec(1);
+ GenFlightList();
+ }
+
+ if (key == GLUT_KEY_F6) {
+ conf.flightstrip_mode.inc(1);
+ GenFlightList();
+
+ }
+
+ if (key == GLUT_KEY_F7) {
+ conf.flightstrip_colmap.dec(1);
+ GenFlightList();
+ }
+
+ if (key == GLUT_KEY_F8) {
+ conf.flightstrip_colmap.inc(1);
+ GenFlightList();
+
+ }
+
+
+
+ if (key == GLUT_KEY_F9) {
+ conf.AIRSPACE_WIRE.toggle();
+ GenAirspaceList();
+ }
+
+
+ if (key == GLUT_KEY_F10) {
+ cout << "shift-f10 unused" << endl;
+ }
+
+ if (key == GLUT_KEY_F11) {
+ cout << "shift-f11 unused" << endl;
+ }
+
+ if (key == GLUT_KEY_F12) {
+ cout << "Shift F12 glGetError" << endl;
+ cout << "glGetError: " << gluErrorString(glGetError()) << endl;
+ }
+
+
+ //rotations around the center of the scene
+ // with shift
+ if (key == GLUT_KEY_LEFT) {
+ ego.spinmoveradial(1); //spin the ego around the center
+ if (conf.FOLLOW.get())
+ update_diff_pos();
+
+ }
+ if (key == GLUT_KEY_UP) {
+ ego.spinmovevertical(1); //spin the ego around the center vertically
+ if (conf.FOLLOW.get())
+ update_diff_pos();
+ }
+ if (key == GLUT_KEY_RIGHT) {
+ ego.spinmoveradial(-1); //spin the ego around the center
+ if (conf.FOLLOW.get())
+ update_diff_pos();
+ }
+ if (key == GLUT_KEY_DOWN) {
+ ego.spinmovevertical(-1); //spin the ego around the center vertically
+ if (conf.FOLLOW.get())
+ update_diff_pos();
+ }
+
+
+
+ if (key == GLUT_KEY_PAGE_UP) {
+ conf.pTextSize.inc(0.0005);
+ }
+
+ if (key == GLUT_KEY_PAGE_DOWN) {
+ conf.pTextSize.dec(0.0005);
+ }
+
+ if (key == GLUT_KEY_HOME) {
+ conf.waypoints_info_mode.inc(1);
+ }
+ if (key == GLUT_KEY_END) {
+ conf.waypoints_info_mode.dec(1);
+ }
+ /*
+ if (key == GLUT_KEY_HOME) {
+ cout << "shift-home unused" << endl;
+ }
+ if (key == GLUT_KEY_END) {
+ cout << "shift-end unused" << endl;
+ }*/
+ if (key == GLUT_KEY_INSERT) {
+ cout << "shift-insert unused" << endl;
+ }
+
+
+ } // end shift modifier
+
+
+ glutPostRedisplay();
+
+}
+#endif
+
+
+#ifndef ONLY_OSMESA
+void update_diff_pos()
+{
+
+ if (!conf.FLIGHT.get())
+ return;
+
+
+ double _x = 0, _y = 0, _z = 0;
+
+ for (int _i = fd.getmarker() - 10; _i <= fd.getmarker() + 10; _i++) {
+ int _c;
+ _c = _i;
+ if (_i < 0) {
+ _c = 0;
+ }
+ if (_i >= fd.getn()) {
+ _c = fd.getn() - 1;
+ }
+ _x += -fd.getx(_c);
+ _y += -fd.gety(_c);
+ _z += fd.getz(_c) * conf.z_scale.get();
+ }
+
+ _x /= 21;
+ _y /= 21;
+ _z /= 21;
+
+ ego.setdx(ego.getx() - _x); //fd.getx(fd.getmarker()));
+ ego.setdy(ego.gety() - _y); //fd.gety(fd.getmarker()));
+ ego.setdz(ego.getz() - _z);
+ // (fd.getz(fd.getmarker()) * conf.z_scale.get()));
+
+ ego.setdox(ego.getOx() + _x);
+ ego.setdoy(ego.getOy() + _y);
+
+ //cout << "diff updated" << endl;
+
+}
+#endif
+
+#ifndef ONLY_OSMESA
+void update_locked_pos()
+{
+
+ if (!conf.FLIGHT.get())
+ return;
+
+ double _x = 0, _y = 0, _z = 0;
+
+ for (int _i = fd.getmarker() - 10; _i <= fd.getmarker() + 10; _i++) {
+ int _c;
+ _c = _i;
+ if (_i < 0) {
+ _c = 0;
+ }
+ if (_i >= fd.getn()) {
+ _c = fd.getn() - 1;
+ }
+ _x += -fd.getx(_c);
+ _y += -fd.gety(_c);
+ _z += fd.getz(_c) * conf.z_scale.get();
+ }
+
+ _x /= 21;
+ _y /= 21;
+ _z /= 21;
+
+
+
+ ego.setx(ego.getdx() + _x);
+ ego.sety(ego.getdy() + _y);
+ ego.setz(ego.getdz() + _z);
+
+ ego.setOx(ego.getdox() - _x);
+ ego.setOy(ego.getdoy() - _y);
+
+ if (conf.ORTHOVIEW.get())
+ InitGL(conf.getwidth(), conf.getheight());
+
+}
+#endif
+
+void DrawInfo(void)
+{
+
+//int font_height = int(glutGet(GLUT_WINDOW_HEIGHT) / 30);
+ int font_height = conf.getheight() / conf.info_fontsize.get();
+
+//cout << font_height << "fh" << endl;
+
+
+ vector < string > lines;
+ char buf[256];
+
+ if (args_info.text_given) {
+
+ //if (args_info.text_arg.length() < 256) {
+ //sprintf(buf, args_info.text_arg);
+ //lines.push_back(buf);
+ lines.push_back(args_info.text_arg);
+ //} else {lines.push_back("too long");}
+
+ }
+
+ if (!args_info.no_position_info_given) {
+ if (!conf.ORTHOVIEW.get()) {
+ sprintf(buf, "Heading: %.0f", ego.getspinz());
+ lines.push_back(buf);
+ sprintf(buf, "Dive angle: %.0f", 270 - ego.getspinx());
+ lines.push_back(buf);
+ int alt =
+ int ((ego.getz() * 1000 / conf.z_scale.get()) *
+ conf.getalt_unit_fac());
+ sprintf(buf, "Altitude: %d %s", alt,
+ conf.getalt_unit_name().c_str());
+ lines.push_back(buf);
+
+
+ float lat, lon;
+ proj.get_latlon(-ego.getx(), -ego.gety(), lat, lon);
+
+ sprintf(buf, "Lat: %.4f", lat);
+ lines.push_back(buf);
+ sprintf(buf, "Lon: %.4f", lon);
+ lines.push_back(buf);
+
+
+ sprintf(buf, "Angle of view %d", conf.aov.get());
+ lines.push_back(buf);
+
+ if (conf.JOYSTICK.get()) {
+ sprintf(buf, "Joystick mode on");
+ lines.push_back(buf);
+ }
+
+ if (conf.STEREO_HW.get () || conf.STEREO.get () || conf.STEREO_RG.get () || conf.STEREO_RB.get ()) {
+
+ sprintf(buf, "Eye distance: %.2f",conf.eye_dist.get());
+ lines.push_back(buf);
+
+
+ }
+
+
+ } else {
+
+
+ float lat, lon;
+ proj.get_latlon(ego.getOx(), ego.getOy(), lat, lon);
+
+ sprintf(buf, "Lat: %.4f", lat);
+ lines.push_back(buf);
+ sprintf(buf, "Lon: %.4f", lon);
+ lines.push_back(buf);
+ }
+ }
+
+ if (!args_info.no_marker_pos_info_given) {
+ if (conf.MARKER.get()) {
+
+ if (!args_info.no_position_info_given) {
+ lines.push_back("----------"); }
+
+ if (conf.GPSD.get() ) {
+ lines.push_back(fd.serverstring.c_str());
+ }
+
+ if (conf.GPSD.get() && conf.FLYING.get() ) {
+ sprintf(buf, "GPS live mode / Position:");
+ lines.push_back(buf);
+
+
+ }
+
+ if (conf.GPSD.get() && !conf.FLYING.get() ) {
+ sprintf(buf, "GPS live mode / Marker:");
+ lines.push_back(buf);
+ }
+
+ sprintf(buf, "Lat: %.4f", fd.getlat());
+ lines.push_back(buf);
+ sprintf(buf, "Lon: %.4f", fd.getlon());
+ lines.push_back(buf);
+
+ float offsetgps, offsetbaro;
+
+ if (conf.GPSALT.get()) {
+ offsetgps = conf.offset.get();
+ offsetbaro = 0;
+ } else {
+ offsetgps = 0;
+ offsetbaro = conf.offset.get();
+ }
+
+
+ if (!conf.GPSALT.get()) {
+ sprintf(buf, "Alt (baro, MSL): %.0f %s",
+ (fd.getalt() +
+ offsetbaro) * conf.getalt_unit_fac(),
+ conf.getalt_unit_name().c_str());
+ lines.push_back(buf);
+
+ sprintf(buf, "Alt (baro, GND): %.0f %s",
+ ((fd.getalt() + offsetbaro) -
+ fd.getgndelevation()) *
+ conf.getalt_unit_fac(),
+ conf.getalt_unit_name().c_str());
+ lines.push_back(buf);
+ } else {
+
+ sprintf(buf, "Alt (GPS, MSL): %.0f %s",
+ (fd.getgpsalt() +
+ offsetgps) * conf.getalt_unit_fac(),
+ conf.getalt_unit_name().c_str());
+ lines.push_back(buf);
+
+ sprintf(buf, "Alt (GPS, GND): %.0f %s",
+ ((fd.getgpsalt() + offsetgps) -
+ fd.getgndelevation()) *
+ conf.getalt_unit_fac(),
+ conf.getalt_unit_name().c_str());
+ lines.push_back(buf);
+ }
+
+ if (conf.offset.get() != 0) {
+ sprintf(buf, "Calibration offset: %d m",
+ conf.offset.get());
+ lines.push_back(buf);
+ }
+
+ sprintf(buf, "Surface elevation (MSL): %.0f %s",
+ fd.getgndelevation() * conf.getalt_unit_fac(),
+ conf.getalt_unit_name().c_str());
+ lines.push_back(buf);
+
+ if (conf.GPSD.get()) {
+ sprintf(buf, "Sat_vis/Sat_used/Mode: %.0f/%.0f/%.0fD",
+ fd.getsatvis(), fd.getsatused(), fd.getgpsmode());
+ lines.push_back(buf);
+
+ sprintf(buf, "eph/epv: %.0f/%.0f m",
+ fd.geteph(), fd.getepv());
+ lines.push_back(buf);
+
+
+ /* // rubbish?
+ sprintf(buf, "eps/epc: %.2fkm/h / %.2fm/s",
+ fd.geteps(), fd.getepc());
+ lines.push_back(buf);
+ */
+
+ sprintf(buf,"GPS interruptions: %d",fd.getgpsinterruptions());
+ lines.push_back(buf);
+ }
+
+ sprintf(buf, "Markerpos: %d",
+ fd.getmarker());
+ lines.push_back(buf);
+
+ sprintf(buf, "Time (%s): %s", conf.getTimeZoneName().c_str(), fd.gettime().c_str());
+ lines.push_back(buf);
+
+ double drawvario, drawintvario;
+ string gpsadd = "(baro)";
+
+ if (conf.GPSALT.get()) {
+ drawvario = fd.getgpsvario();
+ drawintvario = fd.getgpsintvario(10);
+ gpsadd = "(gps)";
+ } else {
+ drawvario = fd.getvario();
+ drawintvario = fd.getintvario(10);
+ }
+
+
+
+ sprintf(buf, "Vario %s: %.2f %s", gpsadd.c_str(),
+ drawvario * conf.getvspeed_unit_fac(),
+ conf.getvspeed_unit_name().c_str());
+ lines.push_back(buf);
+ sprintf(buf, "Int.Vario %s: %.2f %s", gpsadd.c_str(),
+ drawintvario * conf.getvspeed_unit_fac(),
+ conf.getvspeed_unit_name().c_str());
+ lines.push_back(buf);
+ sprintf(buf, "Groundspeed: %.0f %s",
+ fd.getspeed() * conf.getspeed_unit_fac(),
+ conf.getspeed_unit_name().c_str());
+ lines.push_back(buf);
+
+ }
+ }
+
+ if (conf.FLYING.get() || conf.JOYSTICK.get() || conf.GPSD.get()) {
+
+
+ if (conf.VERBOSE.get()) {
+ sprintf(buf, "FPS: %.1f", conf.get_fps());
+ lines.push_back(buf);
+ }
+
+ if (conf.FLYING.get() && conf.VERBOSE.get() && !conf.GPSD.get()) {
+ sprintf(buf, "Framerepeat: %dx", conf.movie_repeat_factor.get());
+ lines.push_back(buf);
+ }
+ }
+
+ if (conf.GPSD.get()) {
+ if (fd.getvalidfix() == 0) {
+ sprintf(buf,"NO GPS SIGNAL!");
+ lines.push_back(buf);
+ }
+ }
+
+
+ //glLineWidth(2.0);
+ glLineWidth(conf.info_fontwidth.get());
+
+
+ if (conf.style.get() == 1) {
+ gltextvect(5, conf.getheight(),
+ font_height, lines, conf.getwidth(),
+ conf.getheight(),conf.ORTHOVIEW.get());
+ }
+ if (conf.style.get() == 2) {
+ for (int z=0; z<=(int(lines.size()-1)); z++) {
+ gltext(5, conf.getheight()-(font_height*(z+1)),
+ font_height, lines[z].c_str(), conf.getwidth(),
+ conf.getheight());
+
+ }
+ }
+
+ glLineWidth(1.0);
+}
+
+
+
+
+// this function sets the initial position! (at start and at F5-key)
+void setinitpos(void)
+{
+
+ if (conf.DEBUG.get()) {
+ cout << "setinitpos() called..." << endl;
+ }
+
+ ego.setspinx(270); //initial dive angle = 0 ( 270-spinx)
+
+ // initial ortho-position is in center
+ ego.setOx(0);
+ ego.setOy(0);
+
+ // these are the dimnsions in lon and lat direction. In openGL-coordinates (x,y)
+ float _lon_dist, _lat_dist;
+
+ // these are used since we need to respect the projection
+ // calculate borders in lat/lon
+ float _latmax, _lonmax, _latmin, _lonmin;
+
+
+
+ //-------------------------------------------------------------------------------- !!!!
+ // hier gehts weiter
+
+
+ if (!conf.FLIGHT.get()) {
+ _latmax =
+ fd.getcenter_lat() +
+ (conf.getborder_land_lat() / DEGDIST);
+ _latmin =
+ fd.getcenter_lat() -
+ (conf.getborder_land_lat() / DEGDIST);
+
+ _lonmax = fd.getcenter_lon()
+ + (conf.getborder_land_lon() /
+ (DEGDIST *
+ cos(fd.getcenter_lat() * (M_PI / 180.0))));
+
+
+ _lonmin =
+ fd.getcenter_lon() -
+ (conf.getborder_land_lon() /
+ (DEGDIST * cos(fd.getcenter_lat() * (M_PI / 180.0))));
+
+ } else {
+
+ proj.get_latlon(fd.getxmax(), fd.getymax(), _latmax,
+ _lonmax);
+ proj.get_latlon(fd.getxmin(), fd.getymin(), _latmin,
+ _lonmin);
+
+ _latmax += (conf.getborder_land_lat() / DEGDIST);
+ _latmin -= (conf.getborder_land_lat() / DEGDIST);
+ _lonmax +=
+ conf.getborder_land_lon() / (DEGDIST *
+ cos(fd.getcenter_lat() *
+ (M_PI / 180.0)));
+ _lonmin -=
+ conf.getborder_land_lon() / (DEGDIST *
+ cos(fd.getcenter_lat() *
+ (M_PI / 180.0)));
+
+
+ }
+
+ if (_latmax > 90) {
+ _latmax = 90;
+ }
+ if (_latmin < -90) {
+ _latmin = -90;
+ }
+
+ if (proj.get_projection() == PROJ_CYL_MERCATOR) {
+
+ if (_latmax > MERCATOR_MAX_LAT) {
+ _latmax = MERCATOR_MAX_LAT;
+ }
+ if (_latmin < -MERCATOR_MAX_LAT) {
+ _latmin = -MERCATOR_MAX_LAT;
+ }
+
+ }
+
+ float _screenratio =
+ (float) conf.getwidth() / (float) conf.getheight();
+
+ float _xmax, _xmin, _ymax, _ymin;
+ proj.get_xy(_latmax, _lonmax, _xmax, _ymax);
+ proj.get_xy(_latmin, _lonmin, _xmin, _ymin);
+
+ _lon_dist = -(_xmax - _xmin);
+ _lat_dist = -(_ymax - _ymin);
+
+ //cout << _lat_dist << " latdist londist->" << _lon_dist << endl;
+
+ float _landratio = _lon_dist / _lat_dist;
+
+ if (_screenratio < _landratio) {
+ conf.orthoclipping.set(_lon_dist);
+
+ //cout << "wide" << endl;
+ } else {
+
+ conf.orthoclipping.set(_lat_dist * _screenratio);
+ //cout << "hi " << _lat_dist * _screenratio << endl;
+ //cout << "screenra " << _screenratio << endl;
+ }
+
+ //cout << "otrhocliiping: " << conf.getorthoclipping() << endl;
+ // set orthoclipping END
+
+
+ // set position for 3D mode
+ // this is aequivalent to "S", default
+ if (conf.FLIGHT.get()) {
+ ego.setz(fd.getzmin() + 10 * conf.z_scale.get()); //set position 10km above minimum
+ ego.setx(0);
+ ego.sety(_ymin); //over south border
+
+ if (conf.DEBUG.get())
+ cout << "setinitpos: flight zmin: " << fd.getzmin() << endl;
+
+ }
+
+ if (!conf.FLIGHT.get()) {
+ ego.setz(10 * conf.z_scale.get()); // altitude is 10 km
+ ego.setx(0);
+ ego.sety(_ymin); // over south border
+
+ }
+ // check for user given position:
+
+ //position "north"
+ if (args_info.init_pos_N_given) {
+ if (conf.FLIGHT.get()) {
+ ego.setx(0);
+ ego.sety(_ymax); //over north border
+ } else {
+ ego.setx(0);
+ ego.sety(_ymax); // over north border
+ }
+ }
+ //position "south"
+ if (args_info.init_pos_S_given) {
+ if (conf.FLIGHT.get()) {
+ ego.setx(0);
+ ego.sety(_ymin);
+ } else {
+ ego.setx(0);
+ ego.sety(_ymin);
+ }
+ }
+ //position "West"
+ if (args_info.init_pos_W_given) {
+ if (conf.FLIGHT.get()) {
+ ego.setx(_xmin);
+ ego.sety(0); //-(conf.getborder_land_lat()+fd.getymax ()) );
+ } else {
+ ego.setx(_xmin);
+ ego.sety(0); //-conf.getborder_land_lat());
+ }
+ }
+ //position "east"
+ if (args_info.init_pos_E_given) {
+ if (conf.FLIGHT.get()) {
+ ego.setx(_xmax);
+ ego.sety(0); //-(conf.getborder_land_lat()+fd.getymax ()) );
+ } else {
+ ego.setx(_xmax);
+ ego.sety(0); //-conf.getborder_land_lat());
+ }
+ }
+ //position "NW"
+ if (args_info.init_pos_NW_given) {
+ if (conf.FLIGHT.get()) {
+ ego.setx(_xmin);
+ ego.sety(_ymax);
+ } else {
+ ego.setx(_xmin);
+ ego.sety(_ymax);
+ }
+ }
+ //position "SW"
+ if (args_info.init_pos_SW_given) {
+ if (conf.FLIGHT.get()) {
+ ego.setx(_xmin);
+ ego.sety(_ymin);
+ } else {
+ ego.setx(_xmin);
+ ego.sety(_ymin);
+ }
+ }
+ //position "NE"
+ if (args_info.init_pos_NE_given) {
+ if (conf.FLIGHT.get()) {
+ ego.setx(_xmax);
+ ego.sety(_ymax);
+ } else {
+ ego.setx(_xmax);
+ ego.sety(_ymax);
+ }
+ }
+ //position "SE"
+ if (args_info.init_pos_SE_given) {
+ if (conf.FLIGHT.get()) {
+ ego.setx(_xmax);
+ ego.sety(_ymin);
+ } else {
+ ego.setx(_xmax);
+ ego.sety(_ymin);
+ }
+ }
+
+
+ if (args_info.init_lat_given && args_info.init_lon_given) {
+ float _x, _y;
+ proj.get_xy(args_info.init_lat_arg, args_info.init_lon_arg,
+ _x, _y);
+
+ ego.sety(_y);
+ ego.setx(_x);
+ }
+
+ if (args_info.init_ortho_lat_given
+ && args_info.init_ortho_lon_given) {
+ float _x2, _y2;
+ proj.get_xy(args_info.init_ortho_lat_arg,
+ args_info.init_ortho_lon_arg, _x2, _y2);
+
+ ego.setOy(-_y2);
+ ego.setOx(-_x2);
+ }
+
+ if (args_info.init_ortho_width_given)
+ conf.orthoclipping.set(args_info.init_ortho_width_arg);
+
+ if (args_info.init_alt_given)
+ ego.setz(((double) args_info.init_alt_arg / 1000.0) *
+ conf.z_scale.get());
+
+
+ //calculate dive
+ float _dist =
+ sqrt(ego.getx() * ego.getx() + ego.gety() * ego.gety());
+ float _alt;
+ if (conf.FLIGHT.get()) {
+ _alt = ego.getz() - (fd.getzmin() * conf.z_scale.get());
+ } else {
+ _alt = ego.getz() - (0.5 * conf.z_scale.get());
+ }
+ float _atanarg = _alt / _dist;
+
+ ego.setspinx((int) (270.0 + (atan(_atanarg)) / PI_180));
+
+ //calculate heading
+ // SW quadrant
+ if (ego.getx() >= 0 && ego.gety() >= 0) {
+ //cout << "SW Quadrant" << endl;
+ if (ego.gety() != 0) {
+ //cout << "y != 0" << endl;
+ ego.setspinz((int)
+ (atan(ego.getx() / ego.gety())
+ / PI_180)
+ );
+ } else {
+ ego.setspinz(90);
+ }
+ }
+ // NW quadrant
+ if (ego.getx() >= 0 && ego.gety() < 0) {
+ //cout << "NW Quadrant" << endl;
+ if (ego.getx() != 0) {
+ //cout << "x != 0" << endl;
+ ego.setspinz((int)
+ (90.0 - (atan(ego.gety() / ego.getx())
+ / PI_180)
+ )
+ );
+ } else {
+ //cout << "else?" << endl;
+ ego.setspinz(180);
+ }
+ }
+ // NE quadrant
+ if (ego.getx() < 0 && ego.gety() <= 0) {
+ //cout << "NE Quadrant" << endl;
+ if (ego.gety() != 0) {
+ //cout << "y != 0" << endl;
+ ego.setspinz((int)
+ (180.0 +
+ (atan(ego.getx() / ego.gety())
+ / PI_180)
+ )
+ );
+ } else {
+ //cout << "else?" << endl;
+ ego.setspinz(270);
+ }
+ }
+ // SE quadrant
+ if (ego.getx() < 0 && ego.gety() > 0) {
+ //cout << "SE Quadrant" << endl;
+ if (ego.gety() != 0) {
+ //cout << "y != 0" << endl;
+ ego.setspinz((int)
+ (360.0 +
+ (atan(ego.getx() / ego.gety())
+ / PI_180)
+ )
+ );
+ } else {
+ //cout << "else?" << endl;
+ ego.setspinz(270);
+ }
+ }
+
+
+ if (args_info.init_pos_center_given) {
+ ego.setx(0);
+ ego.sety(0);
+ ego.setspinz(0);
+ ego.setspinx(360);
+
+ }
+
+ if (args_info.init_heading_given) {
+ ego.setspinz((double) args_info.init_heading_arg);
+ ego.spinz(0.1);
+ ego.spinz(-0.1);
+ }
+
+ if (args_info.init_dive_given) {
+ ego.setspinx((double) 270 - args_info.init_dive_arg);
+ ego.spinx(0.1);
+ ego.spinx(-0.1);
+ }
+
+
+
+ if (conf.FOLLOW.get() && conf.FLIGHT.get()) {
+ #ifndef ONLY_OSMESA
+ update_diff_pos();
+ #endif
+ }
+
+
+ // this caused crashes on Mac OS X
+ // setinitpos is called before glutcreatewindow, therefore initGL
+ // causes gl... calls before the context is established!
+ // but this call is not necessary...
+
+// InitGL(conf.getwidth(), conf.getheight());
+}
+
+void mesaonly_info (void) {
+ #ifdef ONLY_OSMESA
+ cout << endl << " This version of openGLIGCexplorer (ogie) can be used" << endl
+ << " for offscreen-rendering with osmesa only!" << endl
+ << " No interactive controlling, no output to the display!" << endl << endl;
+ #endif
+}
+
+
+//main startup!
+//----------------------------------------------------------------------------------------------------
+
+int main(int argc, char *argv[])
+{
+
+
+// if no argument is given, print help and exit
+ if (argc == 1) {
+ cmdline_parser_print_help();
+
+ #ifdef ONLY_OSMESA
+ mesaonly_info();
+ #endif
+
+ Ende(0);
+ //exit(0);
+ }
+
+
+/* let's call our cmdline parser */
+ if (cmdline_parser(argc, argv, &args_info) != 0) {
+ Ende(1);
+ }
+
+// check option (for GPLIGC)
+ if (args_info.check_given) {
+ Ende(0);
+ }
+
+// build info...
+ if (args_info.compiler_given) {
+
+ char compiler[80] = "unkown";
+ char system[80] = "unknown";
+ char build[80] = "unknown";
+
+
+#ifdef __GNUC__
+
+#ifndef __GNUC_MINOR__
+#define __GNUC_MINOR__ 0
+#endif
+
+#ifndef __GNUC_PATCHLEVEL__
+#define __GNUC_PATCHLEVEL__ 0
+#endif
+
+#ifndef __VERSION__
+#define __VERSION__ 0
+#endif
+
+ sprintf(compiler, "gcc %d.%d.%d (%s)", __GNUC__,
+ __GNUC_MINOR__, __GNUC_PATCHLEVEL__, __VERSION__);
+#endif
+
+ sprintf(build, "%s %s", __DATE__, __TIME__);
+
+#ifdef __WIN32__
+ sprintf(system, "Windows (__WIN32__) is set");
+#endif
+
+#ifdef __linux__
+ sprintf(system, "Linux (__linux__) is set");
+#endif
+
+#ifdef __MACOSX__
+ sprintf(system, "Mac OS X (__MAC_OS_X__) is set");
+#endif
+
+ std::cout << "Compiler: " << compiler << std::endl;
+#ifdef __CYGWIN__
+ std::cout << "Cygwin (__CYGWIN__) is set" << std::endl;
+#endif
+
+ std::cout << "Build: " << build << std::endl;
+ std::cout << "Platform: " << system << std::endl;
+
+#ifdef __unix__
+ std::cout << "Unix (__unix__) is set" << std::endl;
+#endif
+
+// std::cout << "System: " << SYSINFO << endl;
+
+ Ende(0);
+}
+
+
+//-------------- THIS WILL FAIL without X!
+// however, for osmesa offscreen, freeglut will fail without glutInit
+// first call glutStrokeCharacter will stop the runtime
+// no real offscreen without Xserver for now!
+// see freeglut bug #204
+// --no-info hilft!
+#ifndef ONLY_OSMESA
+ glutInit(&argc, argv);
+#endif
+
+#ifndef __WIN32__
+#ifndef ONLY_OSMESA
+// register function for SIGUSR1
+ signal(SIGUSR1, SIGUSR1Handler);
+#endif
+#endif
+
+
+ // if verbose given turn it on...
+ // in reading configfile we will know, that --verbose was given,
+ // because otherwise the default verbose=off would be active...
+ if (args_info.verbose_given)
+ conf.VERBOSE.on();
+
+ // to be evaluated while reading configfile
+ // quiet should override --verbose !!!
+ if (args_info.quiet_given) {
+ conf.QUIET.on();
+ conf.VERBOSE.off();
+ }
+
+ // check for debugging option
+ // later if debug is given, but after reading configfile
+ // debug should override --quiet and activates VERBOSE
+ if (args_info.debug_given) {
+ conf.DEBUG.on();
+ conf.VERBOSE.on();
+ conf.QUIET.off();
+ cout << "Debugging output enabled..." << endl;
+ }
+
+ #ifdef ONLY_OSMESA
+ if (!conf.QUIET.get()){
+ mesaonly_info();
+ }
+ #endif
+
+
+
+
+//openGL query
+#ifndef ONLY_OSMESA
+ if (args_info.query_gl_given) {
+
+
+ // this needs to be created, to get the information
+ window = glutCreateWindow("");
+
+ cout << "Information on the openGL implementation:" <<
+ endl;
+
+ int _q;
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint*)&_q);
+ cout << "GL_MAX_TEXTURE_SIZE: " << _q << endl;
+
+ glGetIntegerv(GL_MAX_EVAL_ORDER, (GLint*)&_q);
+ cout << "GL_MAX_EVAL_ORDER: " << _q << endl;
+
+ glGetIntegerv(GL_MAX_LIGHTS, (GLint*)&_q);
+ cout << "GL_MAX_LIGHTS: " << _q << endl;
+
+ glGetIntegerv(GL_RED_BITS, (GLint*)&_q);
+ cout << "GL_RED_BITS: " << _q << endl;
+
+ glGetIntegerv(GL_GREEN_BITS, (GLint*)&_q);
+ cout << "GL_GREEN_BITS: " << _q << endl;
+
+ glGetIntegerv(GL_BLUE_BITS, (GLint*)&_q);
+ cout << "GL_BLUE_BITS: " << _q << endl;
+
+ glGetIntegerv(GL_ALPHA_BITS, (GLint*)&_q);
+ cout << "GL_ALPHA_BITS: " << _q << endl;
+
+ glGetIntegerv(GL_DEPTH_BITS, (GLint*)&_q);
+ cout << "GL_DEPTH_BITS: " << _q << endl;
+
+ glGetIntegerv(GL_MAX_VIEWPORT_DIMS, (GLint*)&_q);
+ cout << "GL_MAX_VIEWPORT_DIMS: " << _q << endl;
+
+ glGetIntegerv(GL_AUX_BUFFERS, (GLint*)&_q);
+ cout << "GL_AUX_BUFFERS: " << _q << endl;
+
+
+ const GLubyte *_string;
+ _string = glGetString(GL_VENDOR);
+ cout << "GL_VENDOR: " << _string << endl;
+ _string = glGetString(GL_RENDERER);
+ cout << "GL_RENDERER: " << _string << endl;
+ _string = glGetString(GL_VERSION);
+ cout << "GL_VERSION: " << _string << endl;
+ _string = glGetString(GL_EXTENSIONS);
+ cout << "GL_EXTENSIONS: " << _string << endl;
+
+
+#ifndef NOGLX
+ cout << endl << "Information on the GLX library" << endl;
+ //Xlib Diplay
+ Display *dpy;
+ //Get the Diplay...
+ dpy = XOpenDisplay(NULL); //will use env DIPLAY on posix .. man XOpenDisplay
+ int major, minor;
+
+ glXQueryVersion(dpy, &major, &minor);
+ cout << "glXQueryVersion: " << major << "." << minor <<
+ endl;
+
+ cout << "glXGetClientString(GLX_VENDOR): " <<
+ glXGetClientString(dpy, GLX_VENDOR) << endl;
+ cout << "glXGetClientString(GLX_VERSION): " <<
+ glXGetClientString(dpy, GLX_VERSION) << endl;
+ cout << "glXGetClientString(GLX_EXTENSIONS): " <<
+ glXGetClientString(dpy, GLX_EXTENSIONS) << endl;
+
+ // int screen ?
+ cout << "glXQueryExtensionsString(screen 0): " <<
+ glXQueryExtensionsString(dpy, 0) << endl;
+ //cout << "glXQueryExtensionsString(): " << glXQueryExtensionsString(dpy,1) << endl;
+
+
+ cout << "glXQueryServerString(screen 0, GLX_VENDOR): " <<
+ glXQueryServerString(dpy, 0, GLX_VENDOR) << endl;
+ cout << "glXQueryServerString(screen 0, GLX_VERSION): " <<
+ glXQueryServerString(dpy, 0, GLX_VERSION) << endl;
+ cout << "glXQueryServerString(screen 0, GLX_EXTENSIONS): "
+ << glXQueryServerString(dpy, 0,
+ GLX_EXTENSIONS) << endl;
+#endif
+
+ // and here some information from GLUT header files
+ // can be 1-5 (5 is glut.h in mesa 5.0.2 for example)
+// cout << endl << "Information about GLUT (compiled in from glut.h)" << endl;
+// cout << "GLUT_API_VERSION: " << GLUT_API_VERSION << endl;
+// #ifdef FREEGLUT
+// cout << "FREEGLUT: " << FREEGLUT << endl;
+// #endif
+// #ifdef FREEGLUT_VERSION_2_0
+// cout << "FREEGLUT_VERSION_2_0: " << FREEGLUT_VERSION_2_0 << endl;
+// #endif
+
+ // some information from GLUT at runtime....
+ cout << endl << "Some runtime GLUT information:" << endl;
+
+ // IN FREEGLUT 2.2.0 (GLUT_VERSION=20200) these are only lies (for X11) (see freeglut_state.c)
+ //cout << "glutDeviceGet(GLUT_HAS_MOUSE): " << glutDeviceGet(GLUT_HAS_MOUSE) << endl;
+ //cout << "glutDeviceGet(GLUT_HAS_JOYSTICK): " << glutDeviceGet(GLUT_HAS_JOYSTICK) << endl;
+ //cout << "glutDeviceGet(GLUT_OWNS_JOYSTICK): " << glutDeviceGet(GLUT_OWNS_JOYSTICK) << endl;
+ //cout << "glutDeviceGet(GLUT_JOYSTICK_BUTTONS): " << glutDeviceGet(GLUT_JOYSTICK_BUTTONS) << endl;
+ //cout << "glutDeviceGet(GLUT_JOYSTICK_AXES): " << glutDeviceGet(GLUT_JOYSTICK_AXES) << endl;
+ //cout << "glutDeviceGet(GLUT_JOYSTICK_POLL_RATE): " << glutDeviceGet(GLUT_JOYSTICK_POLL_RATE) << endl;
+
+
+ // will cause a warning on old-glut (because GLUT_VERSION isnt known to old-glut)
+ cout << "glutGet(GLUT_VERSION): " << glutGet(GLUT_VERSION) << endl;
+#ifdef HAVE_LIBGPS
+ cout << endl << "GPSD supported"<< endl << "gpsd header version:" << endl;
+ cout << "GPSD_API_MAJOR_VERSION: " << GPSD_API_MAJOR_VERSION << endl;
+ cout << "GPSD_API_MINOR_VERSION: " << GPSD_API_MINOR_VERSION << endl;
+#else
+ cout << endl << "GPSD _NOT_ supported"<< endl;
+#endif
+
+#ifdef HAVE_LIBOSMESA
+ cout << endl << "OSMesa supported" << endl;
+#else
+ cout << endl << "OSMesa _NOT_ supported" << endl;
+#endif
+
+ Ende(0);
+ }
+#endif
+
+
+// ----------------- READ CONFIGFILE ---- override compiled in defaults
+// some things (projection for example) need to be known before loading any igc files
+
+// check for config file first
+ if (args_info.config_file_given) {
+ //cout << "Configfile !!! :: " << conf.getConfigFileName() << endl;
+ conf.setConfigFileName(args_info.config_file_arg);
+ }
+// read the configuration file first, then evaluate the cmdline
+// cmdl can override configuration-file!
+
+ conf.readConfigFile();
+
+//------------------------------------------------------------------------
+
+ if (args_info.get_elevation_given) {
+ if (args_info.lat_given && args_info.lon_given) {
+
+ vector<int>_alt;
+ vector<float>_lat;
+ vector<float>_lon;
+
+ // WARN on should be used for srtm-3 from seamless server
+ // off for SRTM30
+ // see get_gnd_elevation
+ conf.GETELEV_WARN.on();
+// conf.GETELEV_WARN.off();
+ conf.GETELEV_ERROR.on();
+
+ _lat.push_back(args_info.lat_arg);
+ _lon.push_back(args_info.lon_arg);
+ _alt.push_back(0);
+
+ get_gnd_elevations(&_alt,&_lat,&_lon,&conf);
+
+ // smaller 0 is invalid
+ if (_alt[0] > 0) {
+ cout << _alt[0] << endl;
+
+ if (conf.GETELEV_ERROR.get())
+ cout << _alt[1] << endl;
+ } else {
+
+ if (conf.GETELEV_WARN.get()) {
+ cout << _alt[1] << endl;
+ cout << "INVALID" << (-1*_alt[0]) <<endl;
+ } else {
+ cout << _alt[0] << endl;
+ if (conf.GETELEV_ERROR.get())
+ cout << _alt[1] << endl;
+ }
+ }
+
+
+
+ exit (0);
+
+
+
+ } else {
+ cerr << "--get-elevation without --lat and --lon!" << endl ;
+
+ }
+ }
+
+//air class knows the configuration...
+ air.setConfig(&conf);
+ fd.set_proj_pointer(&proj);
+ fd.set_conf_pointer(&conf);
+ lifts.set_proj_pointer(&proj);
+ lifts.set_conf_pointer(&conf);
+ waypoints.set_proj_pointer(&proj);
+ waypoints.set_conf_pointer(&conf);
+
+
+ if (args_info.cycles_given)
+ fd.setcycles(args_info.cycles_arg);
+
+//-----cmd line options to be read before igc file is loaded-------
+
+ proj.set_projection(conf.get_projection());
+
+ if (args_info.projection_cyl_platt_given)
+ proj.set_projection(PROJ_CYL_PLATT);
+
+ if (args_info.projection_cyl_mercator_given)
+ proj.set_projection(PROJ_CYL_MERCATOR);
+
+ if (args_info.projection_cyl_no1_given)
+ proj.set_projection(PROJ_CYL_NO1);
+
+ if (args_info.projection_pseudo_cyl_no1_given)
+ proj.set_projection(PROJ_PSEUDO_CYL_NO1);
+
+
+ // handled at the beginning of main, and config-reading now...
+ //if (args_info.verbose_given)
+ // conf.VERBOSE.on();
+
+ //if (args_info.quiet_given)
+ // conf.VERBOSE.off();
+
+
+//------------------------------------------------------------------------
+
+
+// if only one argument is given, assume that it is an igc-file
+ if (argc == 2 && !args_info.gpsd_given && !args_info.gpsd_port_given && !args_info.gpsd_server_given) {
+ //cout << "nur 1 arg ? : " << argc << endl;
+ fd.readIGCFile(argv[1], args_info.use_all_fixes_given);
+
+ // no valid fixes? try invalid ones
+ if (fd.getn() == 0) {
+ cerr <<
+ "No valid position fixes found... looking for invalid ones"
+ << endl;
+ fd.readIGCFile(argv[1], true);
+ }
+ //if no position fixes recognized....
+ if (fd.getn() == 0) {
+ cerr << "This seems not to be an igc-file!" <<
+ endl;
+ Ende(1);
+ }
+
+ conf.setIGCFileName(argv[1]);
+ }
+
+ if ( ! (argc==2 || args_info.igc_file_given || (args_info.lat_given && args_info.lon_given))
+ && (! args_info.gpsd_given && !args_info.gpsd_port_given && !args_info.gpsd_server_given)
+ ) {
+ cerr << "Not enough! Give -i igcfile or --lat and --lon" << endl;
+ Ende(1);
+ }
+
+ if (args_info.gpsd_given || args_info.gpsd_port_given || args_info.gpsd_server_given) {
+
+#ifdef HAVE_LIBGPS
+#if GPSD_API_MAJOR_VERSION != 5
+ cerr << "We need libgps with GPSD_API_MAJOR_VERSION == 5 !!!" << endl
+ << "Version " << GPSD_API_MAJOR_VERSION << " was found ;-(" << endl;
+ Ende(1);
+#endif
+#endif
+
+
+ conf.GPSD.on();
+ conf.MARKER.on();
+ conf.FOLLOW.on();
+ conf.FLYING.on();
+
+ stringstream _sp;
+
+ if (args_info.gpsd_port_given) {
+ _sp << args_info.gpsd_port_arg;
+ }
+
+ if (args_info.gpsd_server_given && !args_info.gpsd_port_given) {
+ fd.initgps(args_info.gpsd_server_arg);
+ }
+ if (args_info.gpsd_server_given && args_info.gpsd_port_given) {
+ fd.initgps(args_info.gpsd_server_arg, _sp.str().c_str());
+ }
+ if (!args_info.gpsd_server_given && args_info.gpsd_port_given) {
+ fd.initgps("localhost", _sp.str().c_str());
+ }
+ if (!args_info.gpsd_server_given && !args_info.gpsd_port_given) {
+ fd.initgps();
+ }
+
+ }
+
+
+
+ // check for igc-file (-i option)
+ if (args_info.igc_file_given) {
+ fd.readIGCFile(args_info.igc_file_arg,
+ args_info.use_all_fixes_given);
+
+ // no valid fixes? try invalid ones
+ if (fd.getn() == 0) {
+ cerr <<
+ "No valid position fixes found... looking for invalid ones"
+ << endl;
+ fd.readIGCFile(args_info.igc_file_arg, true);
+ }
+ //if no position fixes recognized....
+ if (fd.getn() == 0) {
+ cerr << "This seems not to be an igc-file!" <<
+ endl;
+ Ende(1);
+ }
+
+ conf.setIGCFileName(args_info.igc_file_arg);
+ }
+// ------------------- READ CMDLINE ----- override CONFIGFILE options...
+
+
+
+ if (args_info.airspace_file_given)
+ conf.setAirspaceFileName(args_info.airspace_file_arg);
+
+ if (args_info.lifts_given) {
+ conf.LIFTS.on();
+ conf.setLiftsFileName(args_info.lifts_arg);
+ if (conf.VERBOSE.get()) {
+ cout << "Lifts: " << conf.getLiftsFileName() << endl;
+ }
+ }
+
+ if (args_info.waypoints_file_given) {
+ conf.WAYPOINTS.on();
+ conf.setWaypointsFileName(args_info.waypoints_file_arg);
+ if (conf.VERBOSE.get()) {
+ cout << "Waypoints: " << conf.getWaypointsFileName() << endl;
+ }
+ }
+
+ if (args_info.waypoints_given) { conf.WAYPOINTS.on();}
+ if (args_info.no_waypoints_given) { conf.WAYPOINTS.off();}
+
+ if (args_info.waypoints_offset_given) { conf.waypoints_offset.set(args_info.waypoints_offset_arg);}
+
+ if (args_info.waypoints_offset_spheres_given) { conf.waypoints_offset.set(args_info.waypoints_offset_spheres_arg);
+ conf.WAYPOINTS_OFFSET_TEXT_ONLY.off();
+ }
+
+ if (args_info.map_set_name_given) {
+ if (conf.set_ActiveMapSet(args_info.map_set_name_arg) != 0) {
+ cout << args_info.
+ map_set_name_arg << " not found ...." << endl;
+ }
+ }
+// some output (if VERBOSE)
+ if (conf.VERBOSE.get()) {
+ cout << "Configfile: " << conf.
+ getConfigFileName() << endl;
+ cout << "OpenAir: " << conf.getAirspaceFileName() << endl;
+ cout << "DEM-File: " << conf.getDemFileName() << endl;
+
+ if (conf.getNumberOfMaps() != 0) {
+ cout << conf.getNumberOfMaps() << " Digital maps found, " << conf.getNumberOfMapSets() << " Map-Sets"
+ << endl;
+ }
+ }
+// landscape or flat?
+ if (args_info.landscape_given)
+ conf.LANDSCAPE.on();
+
+ if (args_info.flat_given) {
+ conf.LANDSCAPE.off();
+ //conf.toggleLANDSCAPE();
+ }
+
+ if (args_info.flat_given && args_info.landscape_given) {
+ cerr << "specify \"--flat\" _or_ \"--landscape\"" <<
+ endl;
+ Ende(1);
+ }
+// ALTITUDE DATA used !
+ if (args_info.gpsalt_given)
+ conf.GPSALT.on();
+ if (args_info.baroalt_given)
+ conf.GPSALT.off();
+
+ if (args_info.ignore_elev_min_given && args_info.ignore_elev_max_given) {
+ conf.IGNORE_ELEV_RANGE.on();
+ conf.ignore_elev_max.set(args_info.ignore_elev_max_arg);
+ conf.ignore_elev_min.set(args_info.ignore_elev_min_arg);
+ }
+
+
+// modulate or not?
+ if (args_info.modulate_given)
+ conf.MODULATE.on();
+
+ if (args_info.no_modulate_given)
+ conf.MODULATE.off();
+
+// lighting of unmodulated maps
+ if (args_info.maps_unlighted_given)
+ conf.MAPS_UNLIGHTED.on();
+
+ if (args_info.maps_lighted_given)
+ conf.MAPS_UNLIGHTED.off();
+
+
+// Airspace or not?
+ if (args_info.airspace_given)
+ conf.AIRSPACE.on();
+
+ if (args_info.no_airspace_given)
+ conf.AIRSPACE.off();
+
+ if (args_info.airspace_wire_given)
+ conf.AIRSPACE_WIRE.on();
+
+ if (args_info.airspace_transparent_given)
+ conf.AIRSPACE_WIRE.off();
+
+ if (args_info.airspace_limit_given)
+ conf.AirspaceLimit.set(args_info.airspace_limit_arg);
+
+
+// dont start in this condition....
+ if (conf.AIRSPACE.get()
+ && (conf.getAirspaceFileName() == "not available")) {
+ cerr << "No Airspace available..." << endl;
+ Ende(1);
+ }
+// MAP
+ if (args_info.map_given) {
+ //conf.setLANDSCAPE();
+ //conf.toggleLANDSCAPE();
+ conf.MAP.on();
+ }
+
+ if (args_info.no_map_given) {
+ conf.MAP.off();
+ }
+// Wireframe or filled polygons
+ if (args_info.wire_given)
+ conf.WIRE.on();
+ if (args_info.filled_given)
+ conf.WIRE.off();
+
+// sealevel stuff
+ if (args_info.sealevel_given)
+ conf.set_sealevel(args_info.sealevel_arg);
+ if (args_info.sealevel2_given)
+ conf.set_sealevel2(args_info.sealevel2_arg);
+ if (args_info.sealevel3_given)
+ conf.set_sealevel3(args_info.sealevel3_arg);
+
+
+
+// no --marker-pos without igc-file
+ if (args_info.marker_pos_given
+ && !(args_info.igc_file_given || argc == 2)) {
+ cerr << "Can't use --marker-pos without flightdata" <<
+ endl;
+ Ende(1);
+ }
+// no --marker without igc-file
+// marker will be turned off later, if no flightdata is available... (see below)
+/*
+if (args_info.marker_given && !(args_info.igc_file_given || argc == 2) ) {
+ cerr << "Can't use --marker without flightdata" << endl;
+ Ende (1);
+ }
+*/
+
+
+// Marker on or off?
+ if (args_info.marker_given)
+ conf.MARKER.on();
+ if (args_info.no_marker_given)
+ conf.MARKER.off();
+
+
+ if (args_info.marker_size_given)
+ conf.MARKER_SIZE.set(args_info.marker_size_arg);
+
+ if (args_info.text_width_given)
+ conf.text_width.set(args_info.text_width_arg);
+
+ if (args_info.lifts_info_mode_given)
+ conf.lifts_info_mode.set(args_info.lifts_info_mode_arg);
+
+ if (args_info.waypoints_info_mode_given)
+ conf.waypoints_info_mode.set(args_info.waypoints_info_mode_arg);
+
+ if (args_info.text_size_given)
+ conf.pTextSize.set(args_info.text_size_arg);
+
+//spinning for movie
+ if (args_info.spinning_given) {
+ conf.SPINNING.set(args_info.spinning_arg);
+ }
+
+// Info Diplay on or off?
+ if (args_info.info_given)
+ conf.INFO.on();
+ if (args_info.no_info_given)
+ conf.INFO.off();
+
+
+// avoid --lat --lon with igc-file
+ if ((args_info.lat_given && args_info.lon_given)
+ && (args_info.igc_file_given || argc == 2)) {
+ cerr << "Can't use --lat, --lon and flightdata" << endl;
+ Ende(1);
+ }
+// set marker position
+ if (args_info.marker_pos_given)
+ fd.setmarkerpos(args_info.marker_pos_arg);
+ if (args_info.marker_time_given)
+ fd.setmarkertime(args_info.marker_time_arg);
+
+// fullscreen
+ if (args_info.fullscreen_given)
+ conf.FULLSCREEN.on();
+ if (args_info.window_given)
+ conf.FULLSCREEN.off();
+
+
+// window geometry
+ if (args_info.width_given) {
+ conf.setwidth(args_info.width_arg);
+ conf.setinitwidth(args_info.width_arg);
+ }
+ if (args_info.height_given) {
+ conf.setheight(args_info.height_arg);
+ conf.setinitheight(args_info.height_arg);
+ }
+// 3D or 2D
+ if (args_info.ortho_given)
+ conf.ORTHOVIEW.on();
+ if (args_info.perspective_given)
+ conf.ORTHOVIEW.off();
+
+
+//grayscale
+ if (args_info.grayscale_given)
+ conf.BW.on();
+ if (args_info.color_given)
+ conf.BW.off();
+
+//stereoscopic
+ if (args_info.stereo_given)
+ conf.STEREO.on();
+ if (args_info.no_stereo_given)
+ conf.STEREO.off();
+
+//stereo rg
+ if (args_info.stereo_rg_given)
+ conf.STEREO_RG.on();
+ if (args_info.no_stereo_rg_given)
+ conf.STEREO_RG.off();
+
+//stereo rb
+ if (args_info.stereo_rb_given)
+ conf.STEREO_RB.on();
+ if (args_info.no_stereo_rb_given)
+ conf.STEREO_RB.off();
+
+//stereo hardware
+ if (args_info.stereo_hw_given)
+ conf.STEREO_HW.on();
+ if (args_info.no_stereo_hw_given)
+ conf.STEREO_HW.off();
+
+// nur 1 von 4 ... STEREO modes...
+// ??
+
+ int _nr = 0;
+ _nr +=
+ (int) conf.STEREO_RB.get() + (int) conf.STEREO_RG.get() +
+ (int) conf.STEREO.get() + (int) conf.STEREO_HW.get();
+
+ if (_nr >= 2) {
+ cerr << "Only one stereo-option can be used!" << endl;
+ Ende(1);
+ }
+// image swapping! left <-> right
+ if (args_info.inverse_stereo_given)
+ conf.SWAP_STEREO.on();
+ if (args_info.no_inverse_stereo_given)
+ conf.SWAP_STEREO.off();
+
+
+// eye-distance
+ if (args_info.eye_dist_given) {
+ if (args_info.eye_dist_arg > 0)
+ conf.eye_dist.set(args_info.eye_dist_arg);
+ }
+// Offscreen rendering
+ if (args_info.offscreen_given)
+ conf.OFFSCREEN.on();
+
+// Offscreen with mesa
+ if (args_info.osmesa_given)
+ conf.OSMESA.on();
+
+ if (conf.OSMESA.get() && conf.OFFSCREEN.get()) {
+ cerr << "only one offscreen rendering mode possible!" <<
+ endl;
+ Ende(1);
+ }
+
+ if (conf.STEREO_HW.get()
+ && (conf.OSMESA.get() || conf.OFFSCREEN.get())) {
+ cerr <<
+ "Hardware stereo isn't possible in offscreen rendering mode"
+ << endl;
+ Ende(1);
+ }
+
+// jpeg quality for screenshots
+ if (args_info.jpeg_quality_given) {
+ if ( (args_info.jpeg_quality_arg >= 0) && (args_info.jpeg_quality_arg <= 100))
+ conf.jpeg_quality.set(args_info.jpeg_quality_arg);
+ }
+
+// image format for output
+ if (args_info.image_format_given)
+ conf.set_image_format(args_info.image_format_arg);
+
+// offset
+ if (args_info.offset_given)
+ conf.offset.set(args_info.offset_arg);
+
+// airfield elevation
+ if (args_info.airfield_elevation_given) {
+ conf.setairfield_elevation(args_info.
+ airfield_elevation_arg);
+ }
+// avoid --airfield-elevation and --offset
+ if (args_info.airfield_elevation_given && args_info.offset_given) {
+ cerr <<
+ "specify \"--offset\" _or_ \"--airfield-elevation\"" <<
+ endl;
+ Ende(1);
+ }
+ // gpsalt?
+ if (conf.GPSALT.get()) {
+
+ if (conf.VERBOSE.get())
+ cout << "gps-altitude is used." << endl;
+
+ fd.usegps();
+
+ }
+// if we have an elevation and an igc-file. Calculate offset!
+ if (args_info.airfield_elevation_given
+ && (args_info.igc_file_given || argc == 2)) {
+ conf.offset.set(-1 *
+ (fd.getstartelevation(conf.GPSALT.get()) -
+ args_info.airfield_elevation_arg));
+ if (conf.VERBOSE.get())
+ cout << "offset = " << (-1 *
+ (fd.
+ getstartelevation(conf.
+ GPSALT.
+ get()) -
+ args_info.
+ airfield_elevation_arg))
+ << endl;
+ //cout << "offset = " << conf.getoffset() << endl;
+ }
+// Z-Axis scaling!
+ if (args_info.scalez_given)
+ conf.z_scale.set(args_info.scalez_arg);
+
+// Downscaling
+ if (args_info.downscaling_given)
+ conf.setdownscalefactor(args_info.downscaling_arg);
+ if (args_info.upscaling_given)
+ conf.setupscalefactor(args_info.upscaling_arg);
+
+// don't allow Landscape, Map and downscaling!
+// but it is possible to switch in this state later... (not very beautiful, but works)
+/* if (conf.LANDSCAPE.get() && conf.MAP.get()
+ && conf.getdownscalefactor() != 1) {
+ cerr << "Can't use textured maps, DEM and downscaling!" <<
+ endl;
+ Ende(1);
+ }
+*/
+
+// texture map compression!
+ if (args_info.compression_given) {
+ conf.COMPRESSION.on();
+ }
+ if (args_info.no_compression_given) {
+ conf.COMPRESSION.off();
+ //conf.toggleCOMPRESSION();
+ }
+
+ if (args_info.airspace_wire_col_r_given) {
+ conf.airspace_wire_color_r.set(args_info.airspace_wire_col_r_arg);
+ }
+ if (args_info.airspace_wire_col_g_given) {
+ conf.airspace_wire_color_g.set(args_info.airspace_wire_col_g_arg);
+ }
+ if (args_info.airspace_wire_col_b_given) {
+ conf.airspace_wire_color_b.set(args_info.airspace_wire_col_b_arg);
+ }
+ if (args_info.airspace_wire_width_given) {
+ conf.airspace_wire_width.set(args_info.airspace_wire_width_arg);
+ }
+
+// set colormap
+ if (args_info.colormap_given) {
+ if (args_info.colormap_arg >= 1
+ && args_info.colormap_arg <= 8) {
+ conf.colmapnumber.set(args_info.colormap_arg);
+ } else {
+ cerr << "Colormap " << args_info.
+ colormap_arg << " doesnt exist. using default."
+ << endl;
+ }
+ }
+
+// set colormap
+ if (args_info.colormap_sea_given) {
+ if (args_info.colormap_sea_arg >= 1
+ && args_info.colormap_sea_arg <= 8) {
+ conf.colmap2number.set(args_info.colormap_sea_arg);
+ } else {
+ cerr << "Colormap " << args_info.
+ colormap_sea_arg <<
+ " doesnt exist. using default." << endl;
+ }
+ }
+
+// Set border .....
+ if (args_info.border_given) {
+ conf.setborder_land_lat(args_info.border_arg);
+ conf.setborder_land_lon(args_info.border_arg);
+ }
+
+ if (args_info.border_lat_given)
+ conf.setborder_land_lat(args_info.border_lat_arg);
+ if (args_info.border_lon_given)
+ conf.setborder_land_lon(args_info.border_lon_arg);
+
+
+// flat or gouraud-shading !
+ if (args_info.flat_shading_given) {
+ conf.SHADE.off();
+ }
+ if (args_info.gouraud_shading_given) {
+ conf.SHADE.on();
+ }
+
+// lighting workaround for upscaling
+ if (args_info.no_lighting_given) {
+ conf.NOLIGHTING.on();
+ }
+ if (args_info.terrain_shading_given) {
+ conf.TERRAINSHADING.on();
+ conf.NOLIGHTING.on();
+ }
+ if (args_info.light_direction_given) {
+ conf.shadedirection.set(args_info.light_direction_arg);
+ }
+ if (args_info.shading_scale_given) {
+ conf.setshadescale(args_info.shading_scale_arg);
+ }
+
+//quads
+ if (args_info.quads_given) {
+ conf.QUADS.on();
+ }
+
+// Fog related stuff
+ if (args_info.haze_given)
+ conf.FOG.on();
+ if (args_info.no_haze_given)
+ conf.FOG.off();
+ if (args_info.haze_density_given) {
+ conf.fogdensity.set(args_info.haze_density_arg);
+ }
+//curtain
+ if (args_info.curtain_given)
+ conf.CURTAIN.on();
+ if (args_info.no_curtain_given)
+ conf.CURTAIN.off();
+
+
+
+// Angle of View
+ if (args_info.aov_given) {
+
+ if (args_info.aov_arg >= 1 && args_info.aov_arg <= 179) {
+
+
+ conf.aov.set(args_info.aov_arg);
+
+
+ } else {
+
+ cerr <<
+ "Angle of view is out of Range. Using default."
+ << endl;
+
+ }
+ }
+// no flightdata, but lat lon! (dummy fd needed!)
+
+// avoid lat or lon!
+ if (args_info.lon_given && !args_info.lat_given) {
+ cerr << "specify --lon and --lat !" << endl;
+ Ende(1);
+ }
+
+ if (args_info.lat_given) {
+ if (!args_info.lon_given) {
+ cerr << "specify --lat and --lon !" << endl;
+ Ende(1);
+ }
+ conf.FLIGHT.off();
+
+ // maybe someone want to start without terrain (make sense since airspace and maps))
+ //conf.LANDSCAPE.on();
+
+ conf.setlat(args_info.lat_arg);
+ conf.setlon(args_info.lon_arg);
+
+ ///set dummy values in fd!
+ proj.set_center_lat(conf.getlat()); // set center for projections....
+ proj.set_center_lon(conf.getlon());
+ fd.setcenter_lat(conf.getlat());
+ fd.setcenter_lon(conf.getlon());
+ fd.setxcenter(0);
+ fd.setycenter(0);
+ fd.setzcenter(0);
+ fd.setlatmin(conf.getlat());
+ fd.setlonmin(conf.getlon());
+ fd.setlatmax(conf.getlat());
+ fd.setlonmax(conf.getlon());
+ fd.setmarkerpos(0);
+
+ }
+// if we have flightdata and DEM-data, we can calculate the ground-altitude!
+ if (conf.FLIGHT.get()) {
+ if (conf.DEM.get())
+ fd.readGNDElevation(&conf);
+ }
+
+// initialize airspace class
+ if (conf.getAirspaceFileName() != "not available") {
+
+ float border_deg_lat = conf.getborder_land_lat() / DEGDIST;
+ float border_deg_lon =
+ (conf.getborder_land_lon() / DEGDIST) /
+ cos(fd.getcenter_lat() * PI_180);
+ float _latmin = (fd.getlatmin() - border_deg_lat);
+ float _lonmin = (fd.getlonmin() - border_deg_lon);
+ float _latmax = (fd.getlatmax() + border_deg_lat);
+ float _lonmax = (fd.getlonmax() + border_deg_lon);
+
+ air.initAirspace(fd.getcenter_lat(), fd.getcenter_lon(),
+ _latmax, _latmin, _lonmax, _lonmin);
+ air.set_proj_pointer(&proj);
+ air.readOpenAirFile(conf.getAirspaceFileName());
+ }
+// some Verbosity!
+ if (conf.VERBOSE.get()) {
+ cout << fd.getn() << " = Number of position fixes" << endl;
+
+ /*cout << "some info from igc-file:" << endl << "center x; y; z " << fd.getxcenter () << " " << fd.
+ getycenter () << " " << fd.getzcenter () << endl << "xmin xmax ymin ymax zmin zmax " << fd.
+ getxmin () << " " << fd.getxmax () << " " << fd.getymin () << " " << fd.getymax () << " " << fd.
+ getzmin () << " " << fd.getzmax () << endl; */
+ }
+// if no DEM-data available, turn off LANDSCAPE
+ if (!conf.DEM.get()) {
+ //no DEM File
+ cerr << "No Digital Elevation Model (DEM-File)" << endl
+ << "Read documention how to set up the config file" <<
+ endl << "starting without Terrain" << endl;
+ conf.LANDSCAPE.off();
+ //conf.toggleLANDSCAPE();
+ }
+// impossibel condition ?!
+ if (!conf.FLIGHT.get() && conf.MARKER.get()) {
+ cerr <<
+ "Can't use \"Marker\" with no flightdata. \"Marker\" turned off."
+ << endl;
+ conf.MARKER.off();
+ }
+// set colormap limits !
+ if (args_info.colormap_max_given) {
+ conf.setmax_h(args_info.colormap_max_arg);
+ //cout << "colormap max" << endl;
+ }
+ if (args_info.colormap_min_given) {
+ conf.setmin_h(args_info.colormap_min_arg);
+ //cout << "colormap min" << endl;
+ }
+// set marker-range and follow
+ if (args_info.follow_given)
+ conf.FOLLOW.on();
+ if (args_info.no_follow_given)
+ conf.FOLLOW.off();
+ if (args_info.marker_range_given)
+ conf.MARKER_RANGE.on();
+ if (args_info.no_marker_range_given)
+ conf.MARKER_RANGE.off();
+ if (args_info.marker_ahead_given)
+ conf.set_marker_ahead(args_info.marker_ahead_arg);
+ if (args_info.marker_back_given)
+ conf.set_marker_back(args_info.marker_back_arg);
+
+ if (args_info.flighttrack_mode_given) {
+ if (args_info.flighttrack_mode_arg >= 0
+ && args_info.flighttrack_mode_arg <= 3) {
+ conf.flightstrip_mode.set(args_info.flighttrack_mode_arg);
+ } else {
+ cerr << "Flighttrack mode " << args_info.
+ flighttrack_mode_arg << " doesnt exist. (0=classic 2 color,1=alt,2=speed,3=vario). using default now."
+ << endl;
+ }
+ }
+
+//flightstrip_linewidth
+ if (args_info.flighttrack_linewidth_given) {
+ conf.flightstrip_width.set(args_info.flighttrack_linewidth_arg);
+ }
+
+ if (args_info.flighttrack_colormap_given) {
+ conf.flightstrip_colmap.set(args_info.flighttrack_colormap_arg);
+ }
+//set initial position...
+
+ if (conf.DEBUG.get()) {
+ cout << "end of preliminary work... calling setinitpos" << endl << flush;
+ }
+
+ setinitpos();
+
+ if (conf.DEBUG.get()) {
+ cout << "returned from setinipos()" << endl << flush;
+ }
+
+ if (conf.LIFTS.get()) {
+ lifts.readLiftsFile(conf.getLiftsFileName());
+ float border_deg_lat = conf.getborder_land_lat() / DEGDIST;
+ float border_deg_lon =
+ (conf.getborder_land_lon() / DEGDIST) /
+ cos(fd.getcenter_lat() * PI_180);
+ float _latmin = (fd.getlatmin() - border_deg_lat);
+ float _lonmin = (fd.getlonmin() - border_deg_lon);
+ float _latmax = (fd.getlatmax() + border_deg_lat);
+ float _lonmax = (fd.getlonmax() + border_deg_lon);
+ lifts.setDegRanges(_latmax,_latmin,_lonmax,_lonmin);
+ }
+
+ if (conf.getWaypointsFileName() != "not available") {
+ waypoints.readWaypointsFile(conf.getWaypointsFileName());
+ float border_deg_lat = conf.getborder_land_lat() / DEGDIST;
+ float border_deg_lon =
+ (conf.getborder_land_lon() / DEGDIST) /
+ cos(fd.getcenter_lat() * PI_180);
+ float _latmin = (fd.getlatmin() - border_deg_lat);
+ float _lonmin = (fd.getlonmin() - border_deg_lon);
+ float _latmax = (fd.getlatmax() + border_deg_lat);
+ float _lonmax = (fd.getlonmax() + border_deg_lon);
+ waypoints.setDegRanges(_latmax,_latmin,_lonmax,_lonmin);
+ }
+
+// ------------------ END of setting options etc -------------------------------------------------------
+// ------------------ rendering ---------------------------------------------------------------------------
+
+
+#ifdef NOGLX
+// if someone tries to offscreen via GLX on non-GLX platform...
+ if (conf.OFFSCREEN.get()) {
+ cerr << "GLX offscreen rendering is not available!" << endl;
+ Ende(1);
+ }
+#endif
+
+
+
+#ifndef NOGLX
+#ifndef ONLY_OSMESA
+ // OFFRSCEEN Rendering (with GLX)
+ if (conf.OFFSCREEN.get()) {
+
+ // measuring time
+ //timeval start;
+ //timeval stop;
+ //gettimeofday(&start, NULL);
+ Timecheck offscreentime("offscreen_rendering", &conf);
+
+ //create GLX offscreen rendering context....
+ //Xlib Diplay
+ Display *dpy;
+
+ //Get the Diplay...
+ dpy = XOpenDisplay(NULL); //will use env DIPLAY on posix .. man XOpenDisplay
+
+ if (dpy == NULL) {
+ cerr << "Cannot open Display!" << endl;
+ Ende(1);
+ }
+ // check for GLX extensions
+ if (!glXQueryExtension(dpy, NULL, NULL)) {
+ cerr <<
+ "X-Server doesn't have an OpenGL GLX extension"
+ << endl;
+ Ende(1);
+ }
+ // Check GLX Version (we need >=1.3)
+ int major, minor;
+ glXQueryVersion(dpy, &major, &minor);
+
+ if (conf.VERBOSE.get())
+ cout << "GLX Version " << major << " . " << minor
+ << endl;
+
+
+ if ((major == 1 && minor < 3) || major < 1) {
+ cerr <<
+ "at least GLX 1.3 is needed for offscreen rendering using glx-pbuffers!"
+ << endl;
+ cerr << "your version is: " << major << "." <<
+ minor << endl;
+ Ende(1);
+ }
+ // these are the attributes the GLXFBConfig should have
+ int attrib_list[] = {
+ GLX_MAX_PBUFFER_PIXELS,
+ conf.getheight() * conf.getwidth(),
+ GLX_DOUBLEBUFFER, GL_FALSE,
+ //GLX_RGBA, GL_TRUE,
+ GLX_RENDER_TYPE, GLX_RGBA_BIT,
+ GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
+
+ //GLX_DEPTH_SIZE, 8,
+ //GLX_X_RENDERABLE, GL_TRUE,
+ //GLX_X_VISUAL_TYPE, GLX_X_VISUAL_TYPE,
+
+ GLX_RED_SIZE, 8,
+ GLX_BLUE_SIZE, 8,
+ GLX_GREEN_SIZE, 8,
+ GLX_DEPTH_SIZE, 16,
+ None
+ };
+
+
+ // these are the attributes the pbuffer should have
+ int pbuffattrib_list[] = {
+ GLX_PBUFFER_HEIGHT, conf.getheight(),
+ GLX_PBUFFER_WIDTH, conf.getwidth(),
+ GLX_PRESERVED_CONTENTS, GL_TRUE,
+ GLX_LARGEST_PBUFFER, GL_FALSE,
+ None
+ };
+
+ // number of GLXFBConfigs returned by glXChooseFBConfig
+ int elements;
+ GLXFBConfig *configs;
+
+
+ configs =
+ glXChooseFBConfig(dpy, 0, attrib_list, &elements);
+
+
+ if (elements < 1) {
+ cerr << "No GLXFBConfigs returned ... (" << elements << ")" << endl;
+ Ende(1);
+ }
+ // Pbuffer and GLXContext
+ GLXPbuffer pbuff;
+ GLXContext ctx;
+
+ // Create Pbuffer
+ pbuff =
+ glXCreatePbuffer(dpy, configs[0], pbuffattrib_list);
+
+ // this seems not to work? what will be returned if glXCreatePbuffer fails?
+ /*
+ if (pbuff == NULL) {
+ cerr << "Can't create pbuffer" << endl;
+ Ende(1);
+ }
+ */
+
+ // Create Context ( NULL -> no share list, GL_TRUE -> try to get an direct rendering context
+
+ ctx =
+ glXCreateNewContext(dpy, configs[0], GLX_RGBA_TYPE,
+ NULL, GL_FALSE);
+
+ if (ctx == NULL) {
+ cerr << "context not created" << endl;
+ Ende(1);
+ }
+ //make the context current
+ //glXMakeContextCurrent(dpy, pbuff, pbuff, ctx);
+ // hier gibts nen badAlloc wenn man auf der console ist :(
+ glXMakeCurrent(dpy, pbuff, ctx);
+
+
+ //now we are ready to openGL!
+
+ InitGL(conf.getwidth(), conf.getheight());
+
+ if (conf.FLIGHT.get())
+ GenFlightList(); //call the list-creator // with igc filename
+
+ GenLandscapeList();
+ GenAirspaceList();
+// GenPointsList();
+
+ DrawGLScene();
+
+ screenshot();
+
+ /*gettimeofday(&stop, NULL);
+
+ float _time = (((float) stop.tv_sec - (float) start.tv_sec)
+ +
+ (((float) stop.tv_usec -
+ (float) start.tv_usec) / 1000000.0));
+
+ if (conf.VERBOSE.get())
+ cout << "Rendering time: " << _time << " secs" <<
+ endl;*/
+ offscreentime.checknow("rendering finished");
+
+ Ende(0);
+
+ }
+#endif
+#endif
+
+
+#ifdef HAVE_LIBOSMESA
+ // OFFRSCEEN Rendering with mesa (osmesa)
+ // MESAMESAMESAMESAMESAMESAMESAMESAMESAMESAMESAMESAMESAMESAMESA ###############################
+ if (conf.OSMESA.get()) {
+ Timecheck osmesatime("osmesa_offscreen_redering", &conf);
+
+ //create mesa offscreen rendering context....
+ OSMesaContext ctx;
+ void *buffer;
+
+ if (conf.VERBOSE.get())
+ cout << "Rendering offscreen using OSMesa." << endl;
+
+ // 32 depth buffer bits
+ ctx = OSMesaCreateContextExt(OSMESA_RGBA, 32,0,0,NULL);
+ if (!ctx) {
+ cerr << "creating osmesa context failed!" << endl;
+ Ende(1);
+ }
+
+ // check max viewport dimensions
+ int _osmaxh, _osmaxw;//, _maj, _min, _pat;
+ OSMesaGetIntegerv(OSMESA_MAX_HEIGHT, &_osmaxh);
+ OSMesaGetIntegerv(OSMESA_MAX_WIDTH, &_osmaxw);
+ //OSMesaGetIntegerv(OSMESA_MAJOR_VERSION, &_maj);
+ //OSMesaGetIntegerv(OSMESA_MINOR_VERSION, &_min);
+ //OSMesaGetIntegerv(OSMESA_PATCH_VERSION, &_pat);
+
+ if (conf.VERBOSE.get()){
+ //cout << "Mesa, Version " << _maj <<"."<<_min<<"."<<_pat<<endl;
+ cout << "OSMESA_MAX_HEIGHT: " << _osmaxh << endl;
+ cout << "OSMESA_MAX_WIDTH: " << _osmaxw << endl;
+
+ }
+
+ if (conf.getwidth() <= _osmaxw && conf.getheight() <= _osmaxh) {
+
+ buffer =
+ malloc(conf.getwidth() * conf.getheight() * 4 *
+ sizeof(GLubyte));
+ if (!buffer) {
+ cerr <<
+ "allocating buffer for osmesa failed!"
+ << endl;
+ Ende(1);
+ } else {
+ if (conf.VERBOSE.get())
+ cout << "buffer created " << conf.
+ getwidth() * conf.getheight() *
+ 4 * sizeof(GLubyte) << endl;
+
+ }
+
+
+ } else {
+
+ cerr <<
+ "width and/or height too big for osmesa (max "<< _osmaxw << "x" <<_osmaxh<<")" << endl;
+ Ende(1);
+
+ }
+
+ if (!OSMesaMakeCurrent
+ (ctx, buffer, GL_UNSIGNED_BYTE, conf.getwidth(),
+ conf.getheight())) {
+ cerr << "Make context current failed!" << endl;
+ Ende(1);
+ }
+
+
+ //now we are ready to openGL!
+
+ InitGL(conf.getwidth(), conf.getheight());
+
+
+
+
+ if (conf.VERBOSE.get()){
+ int _dpw, _dph, _dpbpp;
+ void *bp;
+ OSMesaGetDepthBuffer( ctx, &_dpw, &_dph, &_dpbpp, &bp );//, void **buffer );
+ cout << "Depth buffer: "<< _dpw << " " << _dph << " " << _dpbpp << endl;
+
+ int _q;
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &_q);
+ cout << "GL_MAX_TEXTURE_SIZE: " << _q << endl;
+
+ //glGetIntegerv(GL_MAX_EVAL_ORDER, &_q);
+ //cout << "GL_MAX_EVAL_ORDER: " << _q << endl;
+
+ //glGetIntegerv(GL_MAX_LIGHTS, &_q);
+ //cout << "GL_MAX_LIGHTS: " << _q << endl;
+
+ glGetIntegerv(GL_RED_BITS, &_q);
+ cout << "GL_RED_BITS: " << _q << endl;
+
+ glGetIntegerv(GL_GREEN_BITS, &_q);
+ cout << "GL_GREEN_BITS: " << _q << endl;
+
+ glGetIntegerv(GL_BLUE_BITS, &_q);
+ cout << "GL_BLUE_BITS: " << _q << endl;
+
+ glGetIntegerv(GL_ALPHA_BITS, &_q);
+ cout << "GL_ALPHA_BITS: " << _q << endl;
+
+ glGetIntegerv(GL_DEPTH_BITS, &_q);
+ cout << "GL_DEPTH_BITS: " << _q << endl;
+
+ glGetIntegerv(GL_MAX_VIEWPORT_DIMS, &_q);
+ cout << "GL_MAX_VIEWPORT_DIMS: " << _q << endl;
+
+ glGetIntegerv(GL_AUX_BUFFERS, &_q);
+ cout << "GL_AUX_BUFFERS: " << _q << endl;
+
+
+ const GLubyte *_string;
+ _string = glGetString(GL_VENDOR);
+ cout << "GL_VENDOR: " << _string << endl;
+ _string = glGetString(GL_RENDERER);
+ cout << "GL_RENDERER: " << _string << endl;
+ _string = glGetString(GL_VERSION);
+ cout << "GL_VERSION: " << _string << endl;
+ //_string = glGetString(GL_EXTENSIONS);
+ //cout << "GL_EXTENSIONS: " << _string << endl;
+ }
+
+ if (conf.FLIGHT.get())
+ GenFlightList(); //call the list-creator // with igc filename
+
+ GenLandscapeList();
+ GenAirspaceList();
+ //GenPointsList();
+ DrawGLScene();
+ screenshot();
+
+ /* free the image buffer */
+ free(buffer);
+
+ /* destroy the context */
+ OSMesaDestroyContext(ctx);
+
+ osmesatime.checknow("rendering finished");
+ Ende(0);
+ }
+#endif
+
+#ifndef HAVE_LIBOSMESA
+ // OFFRSCEEN Rendering with mesa (osmesa)
+ if (conf.OSMESA.get()) {
+ cerr << "Osmesa support is not compiled into this binary..." << endl;
+ Ende(1);
+ }
+#endif
+
+
+
+#ifndef ONLY_OSMESA
+ //entering interactive mode....
+
+ if (conf.DEBUG.get()) {
+ cout << "entering interactive mode (no offscreen rendering)" << endl << flush;
+ }
+
+ if (args_info.movie_given ) {
+ conf.FLYING.on();
+ }
+
+
+ // do this check only if DEBUG or FGLUT_CHECK is given...
+// if (conf.DEBUG.get() || conf.FGLUT_CHECK.get()) {
+ // check GLUT_VERSION... (maybe this should be tested earlier?!
+ // but checking needs glutInit called before...
+ int _glut_version = glutGet(GLUT_VERSION);
+
+ if (_glut_version > 10000 && _glut_version < 20801) {
+ cout <<" ****************************************************** " <<endl<<
+ " ** You are using an ancient version of Freeglut. ** " <<endl<<
+ " ** Most likely you'll encounter problems with **" <<endl<<
+ " ** the menus or worse. Consider updating **" <<endl<<
+ " ** Freeglut to at least 2.8.1 **" <<endl<<
+ " ******************************************************" << endl;
+
+ }
+
+ if (conf.DEBUG.get()) {
+ cout << "glutGet(GLUT_VERSION) called:" << _glut_version << endl << flush;
+ }
+
+ // in freeglut freeglut_state.c
+
+ // this is the case, when old-glut is used (+warning... because GLUT_VERSION not known)
+ if (_glut_version == -1) {
+ cout << "above warning is harmless... I just tried to glutGet(GLUT_VERSION), which is available"
+ << " in freeglut only..." << endl;
+ } else {
+ // OK we got an GLUT_VERSION number, but is it sure that its freeglut then?
+ // maybe some strange gluts around, which have glutGet(GLUT_VERSION) ???
+ conf.FGLUT.on();
+ conf.fglut_version.set(_glut_version);
+ }
+// } else {
+// if (conf.VERBOSE.get())
+// cout << "FGLUT_CHECK skipped. Neither --debug nor FGLUT_CHECK given. Assume old glut." << endl;
+// }
+
+
+ if ( conf.DEBUG.get() || conf.VERBOSE.get() ){
+ cout << "glutGet(GLUT_VERSION): " << conf.fglut_version.get() << endl;
+ cout << "conf.FGLUT.get(): " << conf.FGLUT.get() << endl;
+ }
+
+
+ // try GLUT_STEREO if requestet by user
+ if (conf.DEBUG.get()) {
+ cout << "calling glutInitDisplayMode..." << endl << flush;
+ }
+
+ if (!conf.STEREO_HW.get()) {
+ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
+ } else {
+ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH |
+ GLUT_STEREO);
+ }
+ if (conf.DEBUG.get()) {
+ cout << "glutInitDisplayMode called..." << endl << flush;
+ }
+
+ // now with depth buffer !
+
+ if (conf.DEBUG.get()) {
+ cout << "calling glutInitWindowSize and InitWindowPosition" << endl << flush;
+ }
+ glutInitWindowSize(conf.getwidth(), conf.getheight());
+
+ // initial window position
+ glutInitWindowPosition(0, 0);
+
+ if (conf.DEBUG.get()) {
+ cout << "initwindowsize and initwindowposition finished" << endl << flush;
+ }
+
+ // open the GLUT window
+ char namestring[80];
+ sprintf(namestring, "%s %s%s %s by %s", OGIE_PACKAGE.c_str(), OGIE_VERSION.c_str(),
+ DEVELOPEMENT.c_str(), COPYRIGHT.c_str(), AUTHOR.c_str());
+
+ if (conf.DEBUG.get()) {
+ cout << "calling glutCreateWindow! :" << namestring << endl << flush;
+ }
+
+ window = glutCreateWindow(namestring);
+
+ if (conf.DEBUG.get()) {
+ cout << "glutCreateWindow called:" << window << endl << flush;
+ }
+
+ if (conf.DEBUG.get()) {
+ const GLubyte *_string;
+ _string = glGetString(GL_VENDOR);
+ cout << "GL_VENDOR: " << _string;
+ _string = glGetString(GL_RENDERER);
+ cout << " GL_RENDERER: " << _string;
+ _string = glGetString(GL_VERSION);
+ cout << " GL_VERSION: " << _string << endl;
+ }
+
+
+ if (conf.FULLSCREEN.get())
+ glutFullScreen();
+
+ // register the rendering routine
+ glutDisplayFunc(&DrawGLScene);
+
+ glutReshapeFunc(&ReSizeGLScene);
+
+ if (conf.GPSD.get() || conf.FLYING.get()) {
+ glutIdleFunc(&IdleFunc);
+ }
+
+ // Initialize the window.
+ InitGL(conf.getwidth(), conf.getheight());
+
+ // openGL commandos erst nach erzeugung des openGL contextes (hier Glutfenster)
+ if (conf.FLIGHT.get())
+ GenFlightList(); //call the list-creator // with igc filename
+
+ GenLandscapeList();
+ GenAirspaceList();
+ //GenPointsList();
+
+ DrawGLScene();
+
+ //create menus
+ glutMenuStatusFunc(&menuStatus);
+ GenMenu();
+
+
+
+ //mouse and keyboard callback registration
+
+ if (!conf.MOUSE.get()) {
+ glutPassiveMotionFunc(&mouseMove);
+ //glutMotionFunc(NULL);
+ glutSetCursor(GLUT_CURSOR_NONE);
+ }
+
+ glutMotionFunc(&mouseClickMove);
+
+ glutMouseFunc(&mouseClickState);
+
+
+
+ glutKeyboardFunc(&keyPressed);
+ glutSpecialFunc(&SpecialKeyPressed);
+
+
+ // start main loop
+ glutMainLoop();
+
+#endif
+
+ return 1;
+
+}
+
+
+void Ende(int e)
+{
+
+#ifndef ONLY_OSMESA
+ if (window != -3992) {
+ glutDestroyWindow(window);
+ }
+#endif
+
+#ifndef __WIN32__
+ // this tells GPLIGC that OGIE exits
+ if (args_info.parent_pid_given) {
+ kill(args_info.parent_pid_arg, SIGUSR1);
+ }
+#endif
+
+ exit(e);
+}
diff --git a/src/GLexplorer.h b/src/GLexplorer.h
new file mode 100644
index 0000000..fb9fcd1
--- /dev/null
+++ b/src/GLexplorer.h
@@ -0,0 +1,75 @@
+/*
+ * (c) 2002-2016 Hannes Krueger
+ * This file is part of the GPLIGC/ogie package
+ */
+
+#ifndef GLEXPLORER_H
+#define GLEXPLORER_H 1
+
+#include <stdio.h>
+#include <jpeglib.h>
+#include "cmdline.h"
+#include "../config.h"
+
+
+// CMDLINE_PARSER_PACKAGE is set to OGIE in gengetopts cmdline.h (via cmdline.ggo)
+// uswed because PACKAGE from autotools is gpligc
+#ifdef CMDLINE_PARSER_PACKAGE
+const std::string OGIE_PACKAGE = CMDLINE_PARSER_PACKAGE ;
+#else
+const std::string OGIE_PACKAGE = "OGIE" ;
+#endif
+
+// this comes from ..config.h (autoconf)
+// the package version
+#ifdef VERSION
+const std::string OGIE_VERSION = VERSION ;
+#endif
+
+// DEVELOPEMENT and WEB2 can be erased, once all occurances checked and removed
+const std::string DEVELOPEMENT = "";
+const std::string COPYRIGHT = "(c) 2002-2016";
+const std::string AUTHOR = "Hannes Krueger";
+const std::string MAIL = "<Hannes.Krueger@gmail.com>";
+const std::string WEB2 = ""; //"http://freshmeat.net/projects/gpligc";
+const std::string WEB ="http://gpligc.sf.net";
+
+const int ESCAPE = 27; //ASCII ESCAPE
+const double PI_180 = 0.017453292; //Pi divided by 180
+const double DEGDIST = 111.1949266; //1 in km on surface of the earth
+
+
+extern "C" {
+void write_JPEG_file (int image_width, int image_height, int quality,
+ char *jpegFileName, JSAMPLE *image_buffer);
+unsigned char* read_jpg(int* width, int* height, char *filename); //, unsigned char *map);
+void copy_resample_image_buffer (unsigned char* destination, unsigned char* source,
+ int destination_x, int destination_y, int source_x, int source_y,
+ int destination_width, int destination_height, int source_width, int source_height,
+ int source_dimw, int destination_dimw);
+}
+
+void setinitpos(void);
+void DrawInfo(void);
+
+void screenshot();
+void screenshot_rgb();
+void screenshot_jpeg(); //Max's cool jpeg screenshot function
+void InitGL (int , int) ;
+
+void IdleFunc(void);
+void joystick(unsigned int, int, int, int);
+
+
+void update_locked_pos(void);
+void update_diff_pos(void);
+
+void GenFlightList(void);
+void GenLandscapeList(void);
+void GenAirspaceList(void);
+void GenPointsList(void);
+
+void Ende(int);
+
+
+#endif
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..e9581a7
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,27 @@
+# src/Makefile.am for the gpligc/ogie project
+
+bin_PROGRAMS = ogie merger optimizer etopo1merger etopo2merger createworld
+ogie_SOURCES = GLexplorer.cpp GLexplorer.h airspc.cpp airspc.h cmdline.c cmdline.h \
+ oconfig.cpp oconfig.h ego.cpp ego.h flightdata.cpp flightdata.h \
+ landscape.cpp landscape.h map.cpp map.h oglexfunc.cpp oglexfunc.h \
+ points.cpp points.h projection.cpp projection.h value.h write_jpeg.c
+ogie_LDFLAGS = -Wl,--as-needed
+
+merger_SOURCES = merger.cpp
+merger_LDFLAGS = -Wl,--as-needed
+
+optimizer_SOURCES = optimizer.cpp oglexfunc.cpp
+optimizer_CXXFLAGS = -DOPTIMIZER
+optimizer_LDFLAGS = -Wl,--as-needed
+
+etopo1merger_SOURCES = etopo1merger.cpp
+etopo1merger_LDFLAGS = -Wl,--as-needed
+
+etopo2merger_SOURCES = etopo2merger.cpp
+etopo2merger_LDFLAGS = -Wl,--as-needed
+
+createworld_SOURCES = createworlddem.cpp
+createworld_LDFLAGS = -Wl,--as-needed
+
+sharedir = $(datadir)/gpligc
+dist_share_DATA = .ogierc
diff --git a/src/Makefile.in b/src/Makefile.in
new file mode 100644
index 0000000..3cbb389
--- /dev/null
+++ b/src/Makefile.in
@@ -0,0 +1,780 @@
+# Makefile.in generated by automake 1.15 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# src/Makefile.am for the gpligc/ogie project
+
+
+VPATH = @srcdir@
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = ogie$(EXEEXT) merger$(EXEEXT) optimizer$(EXEEXT) \
+ etopo1merger$(EXEEXT) etopo2merger$(EXEEXT) \
+ createworld$(EXEEXT)
+subdir = src
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(dist_share_DATA) \
+ $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sharedir)"
+PROGRAMS = $(bin_PROGRAMS)
+am_createworld_OBJECTS = createworlddem.$(OBJEXT)
+createworld_OBJECTS = $(am_createworld_OBJECTS)
+createworld_LDADD = $(LDADD)
+createworld_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
+ $(createworld_LDFLAGS) $(LDFLAGS) -o $@
+am_etopo1merger_OBJECTS = etopo1merger.$(OBJEXT)
+etopo1merger_OBJECTS = $(am_etopo1merger_OBJECTS)
+etopo1merger_LDADD = $(LDADD)
+etopo1merger_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
+ $(etopo1merger_LDFLAGS) $(LDFLAGS) -o $@
+am_etopo2merger_OBJECTS = etopo2merger.$(OBJEXT)
+etopo2merger_OBJECTS = $(am_etopo2merger_OBJECTS)
+etopo2merger_LDADD = $(LDADD)
+etopo2merger_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
+ $(etopo2merger_LDFLAGS) $(LDFLAGS) -o $@
+am_merger_OBJECTS = merger.$(OBJEXT)
+merger_OBJECTS = $(am_merger_OBJECTS)
+merger_LDADD = $(LDADD)
+merger_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(merger_LDFLAGS) \
+ $(LDFLAGS) -o $@
+am_ogie_OBJECTS = GLexplorer.$(OBJEXT) airspc.$(OBJEXT) \
+ cmdline.$(OBJEXT) oconfig.$(OBJEXT) ego.$(OBJEXT) \
+ flightdata.$(OBJEXT) landscape.$(OBJEXT) map.$(OBJEXT) \
+ oglexfunc.$(OBJEXT) points.$(OBJEXT) projection.$(OBJEXT) \
+ write_jpeg.$(OBJEXT)
+ogie_OBJECTS = $(am_ogie_OBJECTS)
+ogie_LDADD = $(LDADD)
+ogie_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(ogie_LDFLAGS) \
+ $(LDFLAGS) -o $@
+am_optimizer_OBJECTS = optimizer-optimizer.$(OBJEXT) \
+ optimizer-oglexfunc.$(OBJEXT)
+optimizer_OBJECTS = $(am_optimizer_OBJECTS)
+optimizer_LDADD = $(LDADD)
+optimizer_LINK = $(CXXLD) $(optimizer_CXXFLAGS) $(CXXFLAGS) \
+ $(optimizer_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 =
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_@AM_V@)
+am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
+am__v_CXX_0 = @echo " CXX " $@;
+am__v_CXX_1 =
+CXXLD = $(CXX)
+CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
+ -o $@
+AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
+am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
+am__v_CXXLD_0 = @echo " CXXLD " $@;
+am__v_CXXLD_1 =
+SOURCES = $(createworld_SOURCES) $(etopo1merger_SOURCES) \
+ $(etopo2merger_SOURCES) $(merger_SOURCES) $(ogie_SOURCES) \
+ $(optimizer_SOURCES)
+DIST_SOURCES = $(createworld_SOURCES) $(etopo1merger_SOURCES) \
+ $(etopo2merger_SOURCES) $(merger_SOURCES) $(ogie_SOURCES) \
+ $(optimizer_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+DATA = $(dist_share_DATA)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+POW_LIB = @POW_LIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+ogie_SOURCES = GLexplorer.cpp GLexplorer.h airspc.cpp airspc.h cmdline.c cmdline.h \
+ oconfig.cpp oconfig.h ego.cpp ego.h flightdata.cpp flightdata.h \
+ landscape.cpp landscape.h map.cpp map.h oglexfunc.cpp oglexfunc.h \
+ points.cpp points.h projection.cpp projection.h value.h write_jpeg.c
+
+ogie_LDFLAGS = -Wl,--as-needed
+merger_SOURCES = merger.cpp
+merger_LDFLAGS = -Wl,--as-needed
+optimizer_SOURCES = optimizer.cpp oglexfunc.cpp
+optimizer_CXXFLAGS = -DOPTIMIZER
+optimizer_LDFLAGS = -Wl,--as-needed
+etopo1merger_SOURCES = etopo1merger.cpp
+etopo1merger_LDFLAGS = -Wl,--as-needed
+etopo2merger_SOURCES = etopo2merger.cpp
+etopo2merger_LDFLAGS = -Wl,--as-needed
+createworld_SOURCES = createworlddem.cpp
+createworld_LDFLAGS = -Wl,--as-needed
+sharedir = $(datadir)/gpligc
+dist_share_DATA = .ogierc
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .cpp .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
+ fi; \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed 's/$(EXEEXT)$$//' | \
+ while read p p1; do if test -f $$p \
+ ; then echo "$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n;h' \
+ -e 's|.*|.|' \
+ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+ sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) files[d] = files[d] " " $$1; \
+ else { print "f", $$3 "/" $$4, $$1; } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+ -e 's/$$/$(EXEEXT)/' \
+ `; \
+ test -n "$$list" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+ -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+
+createworld$(EXEEXT): $(createworld_OBJECTS) $(createworld_DEPENDENCIES) $(EXTRA_createworld_DEPENDENCIES)
+ @rm -f createworld$(EXEEXT)
+ $(AM_V_CXXLD)$(createworld_LINK) $(createworld_OBJECTS) $(createworld_LDADD) $(LIBS)
+
+etopo1merger$(EXEEXT): $(etopo1merger_OBJECTS) $(etopo1merger_DEPENDENCIES) $(EXTRA_etopo1merger_DEPENDENCIES)
+ @rm -f etopo1merger$(EXEEXT)
+ $(AM_V_CXXLD)$(etopo1merger_LINK) $(etopo1merger_OBJECTS) $(etopo1merger_LDADD) $(LIBS)
+
+etopo2merger$(EXEEXT): $(etopo2merger_OBJECTS) $(etopo2merger_DEPENDENCIES) $(EXTRA_etopo2merger_DEPENDENCIES)
+ @rm -f etopo2merger$(EXEEXT)
+ $(AM_V_CXXLD)$(etopo2merger_LINK) $(etopo2merger_OBJECTS) $(etopo2merger_LDADD) $(LIBS)
+
+merger$(EXEEXT): $(merger_OBJECTS) $(merger_DEPENDENCIES) $(EXTRA_merger_DEPENDENCIES)
+ @rm -f merger$(EXEEXT)
+ $(AM_V_CXXLD)$(merger_LINK) $(merger_OBJECTS) $(merger_LDADD) $(LIBS)
+
+ogie$(EXEEXT): $(ogie_OBJECTS) $(ogie_DEPENDENCIES) $(EXTRA_ogie_DEPENDENCIES)
+ @rm -f ogie$(EXEEXT)
+ $(AM_V_CXXLD)$(ogie_LINK) $(ogie_OBJECTS) $(ogie_LDADD) $(LIBS)
+
+optimizer$(EXEEXT): $(optimizer_OBJECTS) $(optimizer_DEPENDENCIES) $(EXTRA_optimizer_DEPENDENCIES)
+ @rm -f optimizer$(EXEEXT)
+ $(AM_V_CXXLD)$(optimizer_LINK) $(optimizer_OBJECTS) $(optimizer_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GLexplorer.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/airspc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmdline.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/createworlddem.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ego.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/etopo1merger.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/etopo2merger.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flightdata.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/landscape.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/map.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/merger.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oconfig.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oglexfunc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/optimizer-oglexfunc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/optimizer-optimizer.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/points.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/projection.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/write_jpeg.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+optimizer-optimizer.o: optimizer.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(optimizer_CXXFLAGS) $(CXXFLAGS) -MT optimizer-optimizer.o -MD -MP -MF $(DEPDIR)/optimizer-optimizer.Tpo -c -o optimizer-optimizer.o `test -f 'optimizer.cpp' || echo '$(srcdir)/'`optimizer.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/optimizer-optimizer.Tpo $(DEPDIR)/optimizer-optimizer.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='optimizer.cpp' object='optimizer-optimizer.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(optimizer_CXXFLAGS) $(CXXFLAGS) -c -o optimizer-optimizer.o `test -f 'optimizer.cpp' || echo '$(srcdir)/'`optimizer.cpp
+
+optimizer-optimizer.obj: optimizer.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(optimizer_CXXFLAGS) $(CXXFLAGS) -MT optimizer-optimizer.obj -MD -MP -MF $(DEPDIR)/optimizer-optimizer.Tpo -c -o optimizer-optimizer.obj `if test -f 'optimizer.cpp'; then $(CYGPATH_W) 'optimizer.cpp'; else $(CYGPATH_W) '$(srcdir)/optimizer.cpp'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/optimizer-optimizer.Tpo $(DEPDIR)/optimizer-optimizer.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='optimizer.cpp' object='optimizer-optimizer.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(optimizer_CXXFLAGS) $(CXXFLAGS) -c -o optimizer-optimizer.obj `if test -f 'optimizer.cpp'; then $(CYGPATH_W) 'optimizer.cpp'; else $(CYGPATH_W) '$(srcdir)/optimizer.cpp'; fi`
+
+optimizer-oglexfunc.o: oglexfunc.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(optimizer_CXXFLAGS) $(CXXFLAGS) -MT optimizer-oglexfunc.o -MD -MP -MF $(DEPDIR)/optimizer-oglexfunc.Tpo -c -o optimizer-oglexfunc.o `test -f 'oglexfunc.cpp' || echo '$(srcdir)/'`oglexfunc.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/optimizer-oglexfunc.Tpo $(DEPDIR)/optimizer-oglexfunc.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='oglexfunc.cpp' object='optimizer-oglexfunc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(optimizer_CXXFLAGS) $(CXXFLAGS) -c -o optimizer-oglexfunc.o `test -f 'oglexfunc.cpp' || echo '$(srcdir)/'`oglexfunc.cpp
+
+optimizer-oglexfunc.obj: oglexfunc.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(optimizer_CXXFLAGS) $(CXXFLAGS) -MT optimizer-oglexfunc.obj -MD -MP -MF $(DEPDIR)/optimizer-oglexfunc.Tpo -c -o optimizer-oglexfunc.obj `if test -f 'oglexfunc.cpp'; then $(CYGPATH_W) 'oglexfunc.cpp'; else $(CYGPATH_W) '$(srcdir)/oglexfunc.cpp'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/optimizer-oglexfunc.Tpo $(DEPDIR)/optimizer-oglexfunc.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='oglexfunc.cpp' object='optimizer-oglexfunc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(optimizer_CXXFLAGS) $(CXXFLAGS) -c -o optimizer-oglexfunc.obj `if test -f 'oglexfunc.cpp'; then $(CYGPATH_W) 'oglexfunc.cpp'; else $(CYGPATH_W) '$(srcdir)/oglexfunc.cpp'; fi`
+install-dist_shareDATA: $(dist_share_DATA)
+ @$(NORMAL_INSTALL)
+ @list='$(dist_share_DATA)'; test -n "$(sharedir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(sharedir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(sharedir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(sharedir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(sharedir)" || exit $$?; \
+ done
+
+uninstall-dist_shareDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(dist_share_DATA)'; test -n "$(sharedir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(sharedir)'; $(am__uninstall_files_from_dir)
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS) $(DATA)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sharedir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-dist_shareDATA
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-dist_shareDATA
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
+ clean-binPROGRAMS clean-generic cscopelist-am ctags ctags-am \
+ distclean distclean-compile distclean-generic distclean-tags \
+ distdir dvi dvi-am html html-am info info-am install \
+ install-am install-binPROGRAMS install-data install-data-am \
+ install-dist_shareDATA install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
+ uninstall-am uninstall-binPROGRAMS uninstall-dist_shareDATA
+
+.PRECIOUS: Makefile
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/airspc.cpp b/src/airspc.cpp
new file mode 100644
index 0000000..52b5e7b
--- /dev/null
+++ b/src/airspc.cpp
@@ -0,0 +1,1490 @@
+/*
+ * (c) 2002-2016 Hannes Krueger
+ * This file is part of the GPLIGC/ogie package
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "airspc.h"
+
+#include<fstream>
+#include<cmath>
+#include<cstring>
+
+#ifndef __OSX__
+#include <GL/gl.h>
+#include <GL/glu.h>
+#else
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
+#endif
+
+#include "oglexfunc.h"
+
+
+const double RADSTEP = 0.06; // step in rad for drawing arcs
+
+//const std::string rcsid_airspc_cpp =
+// "$Id: airspc.cpp 3 2014-07-31 09:59:20Z kruegerh $";
+//const std::string rcsid_airspc_h = AIRSPC_H;
+
+
+//Callback function for the gluTesselation
+void errorCallback(GLenum errorCode)
+{
+ const GLubyte *estring;
+ estring = gluErrorString(errorCode);
+ cerr <<
+ "Tessellation Error (plotting tops and bottoms of airspaces) :"
+ << estring << endl;
+ //exit(0);
+}
+
+
+Airspace::Airspace()
+{
+}
+
+Airspace::Airspace(float _center_lat, float _center_lon, float _latmax,
+ float _latmin, float _lonmax, float _lonmin)
+{
+ initAirspace(_center_lat, _center_lon, _latmax, _latmin, _lonmax,
+ _lonmin);
+}
+
+
+void Airspace::initAirspace(float _center_lat, float _center_lon,
+ float _latmax, float _latmin, float _lonmax,
+ float _lonmin)
+{
+ center_lat = _center_lat;
+ center_lon = _center_lon;
+
+ latmax = _latmax;
+ lonmax = _lonmax;
+ latmin = _latmin;
+ lonmin = _lonmin;
+}
+
+
+
+void Airspace::readOpenAirFile(string filename)
+{
+
+ ifstream airfile(filename.c_str());
+
+ if (!airfile) {
+ cerr << "Can not open OpenAirspace File: " << filename <<
+ endl;
+ exit(1);
+ }
+
+ if (conf->DEBUG.get())
+ cout << "start reading:" << filename << endl;
+
+ int badcounter=0;
+
+//char zeile[80];
+ string zeile;
+
+// Flag, set to true, while scanning first airspace
+ bool FIRST = true;
+
+ bool AIRDEBUG = false;
+
+// temporary scanning variables (-9999, - = not yet read)
+ int scantmp_ah = -9999;
+ string scantmp_ah_unit = "-";
+ int scantmp_al = -9999;
+ string scantmp_al_unit = "-";
+ string scantmp_an = "-";
+ string scantmp_ac = "-";
+ vector < float >scantmp_xcoor;
+ vector < float >scantmp_ycoor;
+ vector < float >scantmp_lat;
+ vector < float >scantmp_lon;
+
+
+// Direction (clockwise +, or counterclockwise -) for arcs
+ int D = +1;
+
+// center point coordinates for arcs
+ float X_lat = 0;
+ float X_lon = 0;
+
+
+
+ while (airfile) {
+ getline(airfile, zeile);
+
+ //skip lines starting # , empty lines...
+ if (zeile[0] == '#')
+ continue;
+ if (zeile[0] == '*')
+ continue;
+ if (zeile[0] == 0)
+ continue;
+ if (zeile[0] == 13)
+ continue;
+ if (zeile.size() == 0)
+ continue;
+
+ //cout << zeile << " " <<zeile.size() << endl;
+
+ char arg1[80], arg2[80], arg3[80], arg4[80];
+
+
+ //scan 2 arguments to check kind of entry
+ sscanf(zeile.c_str(), "%s %s", arg1, arg2);
+
+ //Airspace Type (Airspace Class)
+ // Here starts a new Airspace description!
+ // the last scanned from tmp has to be saved!
+ if (strcmp(arg1, "AC") == 0) {
+ if (!FIRST) { // means, that we scanned at least one airspace already
+
+ // save last scanned airspace
+ lower.push_back(scantmp_al);
+ lower_unit.push_back(scantmp_al_unit);
+ upper.push_back(scantmp_ah);
+ upper_unit.push_back(scantmp_ah_unit);
+ type.push_back(scantmp_ac);
+ name.push_back(scantmp_an);
+ xcoor.push_back(scantmp_xcoor);
+
+
+
+ ycoor.push_back(scantmp_ycoor);
+ lat.push_back(scantmp_lat);
+ lon.push_back(scantmp_lon);
+
+ // clear scantmp_ ...
+ scantmp_ah = -9999;
+ scantmp_ah_unit = "-";
+ scantmp_al = -9999;
+ scantmp_al_unit = "-";
+ scantmp_an = "-";
+ scantmp_ac = "-";
+ scantmp_xcoor.clear();
+ scantmp_ycoor.clear();
+ scantmp_lat.clear();
+ scantmp_lon.clear();
+
+ //reset direction
+ D = +1;
+
+
+ } else {
+ FIRST = false;
+ }
+
+ //Airspace Type
+ scantmp_ac = arg2;
+
+ }
+
+
+ // Airspace Name
+ if (strcmp(arg1, "AN") == 0) {
+ int pos = zeile.find("AN");
+ scantmp_an = zeile.substr(pos + 3);
+ }
+
+ //Polygon Point DP
+ if (strcmp(arg1, "DP") == 0) {
+ char lat[15], NS[5], lon[15], EW[5];
+ string zeile_tmp =
+ zeile.substr(zeile.find("DP") + 2);
+ //cout << "____>" << zeile_tmp << endl;
+ if (sscanf
+ (zeile_tmp.c_str(), "%s %1s %s %1s", lat, NS,
+ lon, EW) != 4) {
+ cerr <<
+ "Error parsing DP line (airspace-file)"
+ << endl;
+ exit(1);
+ }
+ float _tmplat = coor2dec(lat, NS);
+ float _tmplon = coor2dec(lon, EW);
+
+ if (_tmplat == -9999 || _tmplon == -9999) {
+ cerr <<
+ "Error parsing coordinates from DP line"
+ << endl;
+ exit(1);
+ }
+ //save coordinates
+ scantmp_lat.push_back(_tmplat);
+ scantmp_lon.push_back(_tmplon);
+
+ // convert coordinates to our x,y [km] system
+ /*float _lat_ddist = center_lat - _tmplat;
+ float _lon_ddist = center_lon - _tmplon;
+ float _xkmdist = - _lon_ddist * DEGDIST * cos (PI_180 * _tmplat);
+ float _ykmdist = - _lat_ddist * DEGDIST; */
+ float _xkmdist, _ykmdist;
+ proj->get_xy(_tmplat, _tmplon, _xkmdist,
+ _ykmdist);
+
+ //and save to tmp-variables
+ scantmp_xcoor.push_back(-_xkmdist);
+ scantmp_ycoor.push_back(-_ykmdist);
+
+ }
+
+ // Variable definition
+ if (strcmp(arg1, "V") == 0) {
+
+ //cout << zeile << "-------" << arg2 << endl;
+
+ if (strcmp(arg2, "D=+") == 0) {
+ D = +1;
+ //cout << " D + FOUND --------" << endl;
+ }
+ if (strcmp(arg2, "D=-") == 0) {
+ D = -1;
+ //cout << "D - FOUND -------" << endl;
+ }
+
+ string arg2_temp = arg2;
+
+ if (arg2_temp.substr(0, 1) == "X") {
+ char lat[15], NS[5], lon[15], EW[5];
+ string zeile_tmp =
+ zeile.substr(zeile.find("X=") + 2);
+ //cout << "____>" << zeile_tmp << endl;
+ if (sscanf
+ (zeile_tmp.c_str(), "%s %1s %s %1s",
+ lat, NS, lon, EW) != 4) {
+ cerr <<
+ "Error parsing V X= line (airspace-file)"
+ << endl;
+ exit(1);
+ }
+ X_lat = coor2dec(lat, NS);
+ X_lon = coor2dec(lon, EW);
+
+ //cout << "to parse " << lat << " " << NS << " " << lon << " " << EW << endl;
+ //cout << "parsed X= coordinates: " << X_y << " " << X_x << endl;
+
+ if (X_lat == -9999 || X_lon == -9999) {
+ cerr <<
+ "error parsing coordinates in V X=... line"
+ << endl;
+ exit(1);
+ }
+ //save coordinates // why ?? this is a center-point ?! dont need to be saved?
+ //scantmp_lat.push_back(X_y);
+ //scantmp_lon.push_back(X_x);
+
+ // X_x X_y should be X_lon, X_lat...
+ /*
+ float _lat_ddist = center_lat - X_y;
+ float _lon_ddist = center_lon - X_x;
+ X_x = - _lon_ddist * DEGDIST * cos (PI_180 * X_y);
+ X_y= - _lat_ddist * DEGDIST;
+ */
+ }
+
+ }
+
+ //Arc, 3 parameters DA
+ // this one isnt really tested yet
+ if (strcmp(arg1, "DA") == 0) {
+ float alpha;
+ float bravo;
+ float radius;
+ if (sscanf
+ (zeile.c_str(), "%s %f %f %f", arg1, &radius,
+ &alpha, &bravo) == 4) {
+
+
+ alpha *= (M_PI / 180.0);
+ bravo *= (M_PI / 180.0);
+ radius *= 1.852;
+
+
+ //draw the arcs
+ float _lat, _lon, _x, _y;
+ //counterclockwise
+ if (D == 1) {
+
+ if (alpha < bravo) {
+ for (float winkel = alpha;
+ winkel <= bravo;
+ winkel =
+ winkel + RADSTEP) {
+ go(X_lat, X_lon,
+ (winkel /
+ (M_PI /
+ 180.0)),
+ radius, _lat,
+ _lon);
+ proj->
+ get_xy(_lat,
+ _lon,
+ _x, _y);
+ scantmp_xcoor.
+ push_back(-_x);
+ scantmp_ycoor.
+ push_back(-_y);
+ //scantmp_xcoor.push_back(X_x +( radius * cos (winkel)) );
+ //scantmp_ycoor.push_back(X_y +( radius * sin (winkel)) );
+ }
+ } else { // alpha > bravo
+
+ for (float winkel = alpha;
+ winkel <= 2 * M_PI;
+ winkel =
+ winkel + RADSTEP) {
+ go(X_lat, X_lon,
+ (winkel /
+ (M_PI /
+ 180.0)),
+ radius, _lat,
+ _lon);
+ proj->
+ get_xy(_lat,
+ _lon,
+ _x, _y);
+ scantmp_xcoor.
+ push_back(-_x);
+ scantmp_ycoor.
+ push_back(-_y);
+ //scantmp_xcoor.push_back(X_x +( radius * cos (winkel)) );
+ //scantmp_ycoor.push_back(X_y +( radius * sin (winkel)) );
+ }
+ for (float winkel = 0;
+ winkel <= bravo;
+ winkel =
+ winkel + RADSTEP) {
+ go(X_lat, X_lon,
+ (winkel /
+ (M_PI /
+ 180.0)),
+ radius, _lat,
+ _lon);
+ proj->
+ get_xy(_lat,
+ _lon,
+ _x, _y);
+ scantmp_xcoor.
+ push_back(-_x);
+ scantmp_ycoor.
+ push_back(-_y);
+ //scantmp_xcoor.push_back(X_x +( radius * cos (winkel)) );
+ //scantmp_ycoor.push_back(X_y +( radius * sin (winkel)) );
+ }
+
+
+ }
+ }
+ // clockwise
+ if (D == +1) {
+ //cout << "CLOCKWISE" << endl;
+ if (alpha > bravo) {
+
+ for (float winkel = alpha;
+ winkel >= bravo;
+ winkel =
+ winkel - RADSTEP) {
+ go(X_lat, X_lon,
+ (winkel /
+ (M_PI /
+ 180.0)),
+ radius, _lat,
+ _lon);
+ proj->
+ get_xy(_lat,
+ _lon,
+ _x, _y);
+ scantmp_xcoor.
+ push_back(-_x);
+ scantmp_ycoor.
+ push_back(-_y);
+ //scantmp_xcoor.push_back(X_x +( radius * cos (winkel)) );
+ //scantmp_ycoor.push_back(X_y +( radius * sin (winkel)) );
+ }
+
+ } else {
+
+ for (float winkel = alpha;
+ winkel >= 0;
+ winkel =
+ winkel - RADSTEP) {
+ go(X_lat, X_lon,
+ (winkel /
+ (M_PI /
+ 180.0)),
+ radius, _lat,
+ _lon);
+ proj->
+ get_xy(_lat,
+ _lon,
+ _x, _y);
+ scantmp_xcoor.
+ push_back(-_x);
+ scantmp_ycoor.
+ push_back(-_y);
+ //scantmp_xcoor.push_back(X_x +( radius * cos (winkel)) );
+ //scantmp_ycoor.push_back(X_y +( radius * sin (winkel)) );
+ }
+ for (float winkel =
+ 2 * M_PI;
+ winkel >= bravo;
+ winkel =
+ winkel - RADSTEP) {
+ go(X_lat, X_lon,
+ (winkel /
+ (M_PI /
+ 180.0)),
+ radius, _lat,
+ _lon);
+ proj->
+ get_xy(_lat,
+ _lon,
+ _x, _y);
+ scantmp_xcoor.
+ push_back(-_x);
+ scantmp_ycoor.
+ push_back(-_y);
+ //scantmp_xcoor.push_back(X_x +( radius * cos (winkel)) );
+ //scantmp_ycoor.push_back(X_y +( radius * sin (winkel)) );
+ }
+
+
+ }
+ }
+
+
+ } else {
+
+ cerr <<
+ "Error reading DA-line from OpenAir file.. "
+ << zeile << endl;
+ exit(1);
+ }
+
+ }
+
+ // DB
+ //Arc, 2 parameters // this is the more important...
+ if (strcmp(arg1, "DB") == 0) {
+ char lat1[15], NS1[5], lon1[15], EW1[5];
+ char lat2[15], NS2[5], lon2[15], EW2[5];
+ string zeile_tmp =
+ zeile.substr(zeile.find("DB") + 2);
+ //cout << "____>" << zeile_tmp << endl;
+ if (sscanf
+ (zeile_tmp.c_str(),
+ "%s %1s %s %1s , %s %1s %s %1s", lat1, NS1,
+ lon1, EW1, lat2, NS2, lon2, EW2) != 8) {
+ cerr <<
+ "Error parsing DB line (airspace-file) "
+ << zeile << endl << scantmp_an << endl;
+ exit(1);
+ }
+ // store coord in A_ B_
+ float A_lat = coor2dec(lat1, NS1);
+ float A_lon = coor2dec(lon1, EW1);
+ float B_lat = coor2dec(lat2, NS2);
+ float B_lon = coor2dec(lon2, EW2);
+
+ if (A_lat == -9999 || A_lon == -9999
+ || B_lat == -9999 || B_lon == -9999) {
+ cerr <<
+ "error parsing coordinates in DB line"
+ << endl;
+ exit(1);
+ }
+ // why ??????????
+ /*
+ //save coordinates
+ scantmp_lat.push_back(A_y);
+ scantmp_lon.push_back(A_x);
+ //save coordinates
+ scantmp_lat.push_back(B_y);
+ scantmp_lon.push_back(B_x);
+ */
+
+
+ // dont convert to
+ /*
+ float _lat_ddist = center_lat - A_y;
+ float _lon_ddist = center_lon - A_x;
+ A_x = - _lon_ddist * DEGDIST * cos (PI_180 * A_y);
+ A_y = - _lat_ddist * DEGDIST;
+
+ _lat_ddist = center_lat - B_y;
+ _lon_ddist = center_lon - B_x;
+ B_x = - _lon_ddist * DEGDIST * cos (PI_180 * B_y);
+ B_y = - _lat_ddist * DEGDIST;
+ */
+
+ //calclulate radius (twice and check)
+ //float r1 = sqrt ( pow((A_x - X_x),2) + pow((A_y - X_y),2) );
+ //float r2 = sqrt ( pow((B_x - X_x),2) + pow((B_y - X_y),2) );
+ float r1 =
+ great_circle_dist(A_lat, A_lon, X_lat, X_lon);
+ float r2 =
+ great_circle_dist(B_lat, B_lon, X_lat, X_lon);
+
+
+ //cout << "diff : " << abs(r1-r2) << " " << r1 << endl;
+
+ /*if (abs(r1 - r2) > 100) {
+ cerr << "something is seriously wrong!" << endl;
+ exit (1);
+ }
+ */
+
+ //cout << "diff : " << r1-r2 << endl;
+
+ float R_ = (r1 + r2) / 2.0;
+
+ // dont needed anymore
+ //float _dlat = A_lat - X_lat;
+ //float _dlon = A_lon - X_lon;
+
+ /*float _asinarg = (X_lat - A_lat) / R_;
+ if (_asinarg > 1) {_asinarg =1; //cerr << "correction 1 alpha" << endl;
+ }
+ if (_asinarg < -1) {_asinarg = -1; //cerr << "correction -1 alpha" << endl;
+ }
+
+ float alpha = asin (_asinarg);
+
+ if (_dx > 0 && _dy > 0) { alpha = abs(alpha);}
+ if (_dx < 0 && _dy > 0) { alpha = M_PI - abs(alpha);}
+ if (_dx < 0 && _dy < 0) { alpha = M_PI + abs(alpha);}
+ if (_dx > 0 && _dy < 0) { alpha = 2 * M_PI - abs(alpha);}
+ */
+
+ float alpha = heading(X_lat, X_lon, A_lat,
+ A_lon) * (M_PI / 180.0);
+ //cout << "alpha " << alpha << endl;
+
+ //if (alpha < 0) alpha += 2 * M_PI;
+
+ //cout << R_ << " " << X_y - B_y << endl;
+ //cout << (X_y - B_y) / R_ << endl;
+
+ /*_asinarg = (X_y - B_y) / R_;
+ if (_asinarg > 1) {
+ _asinarg = 1;
+ //cerr << "argument of asin corrected to 1. bravo " << endl;
+ }
+
+ if (_asinarg < -1) { _asinarg = -1; //cerr << "correction bravo -1" << endl;
+ }
+
+
+
+
+ float bravo = asin (_asinarg);
+
+ //if (scantmp_an == "DDS: 128.95 MHz\n") {
+ //cout << "DEBUG: " << alpha << "<-alpha bravo->" << bravo << endl;
+
+ //}
+
+
+ _dx = B_x - X_x;
+ _dy = B_y - X_y;
+ if (_dx > 0 && _dy >0) { bravo = abs(bravo);}
+ if (_dx < 0 && _dy > 0) { bravo = M_PI - abs(bravo);}
+ if (_dx < 0 && _dy < 0) { bravo = M_PI + abs(bravo);}
+ if (_dx > 0 && _dy < 0) { bravo = 2 * M_PI - abs(bravo);}
+ */
+ float bravo = heading(X_lat, X_lon, B_lat,
+ B_lon) * (M_PI / 180.0);
+ //cout << "bravo " << bravo << endl;
+
+
+ //set point A
+ float _x, _y;
+ proj->get_xy(A_lat, A_lon, _x, _y);
+ scantmp_xcoor.push_back(-_x);
+ scantmp_ycoor.push_back(-_y);
+
+
+
+ //if (bravo < 0) bravo += 2 * M_PI;
+
+ //float winkeldelta = (M_PI / 50);
+
+ //draw the arcs
+ float _lat, _lon;
+
+ //counterclockwise
+ if (D == 1) {
+
+ if (alpha < bravo) {
+ for (float winkel =
+ alpha + RADSTEP;
+ winkel <= bravo - RADSTEP;
+ winkel = winkel + RADSTEP) {
+ go(X_lat, X_lon,
+ (winkel /
+ (M_PI / 180.0)), R_,
+ _lat, _lon);
+ proj->get_xy(_lat,
+ _lon,
+ _x,
+ _y);
+ scantmp_xcoor.
+ push_back(-_x);
+ scantmp_ycoor.
+ push_back(-_y);
+ }
+ } else { // alpha > bravo
+
+ for (float winkel =
+ alpha + RADSTEP;
+ winkel <= 2 * M_PI;
+ winkel = winkel + RADSTEP) {
+ //scantmp_xcoor.push_back(X_x +( R_ * cos (winkel)) );
+ //scantmp_ycoor.push_back(X_y +( R_ * sin (winkel)) );
+ go(X_lat, X_lon,
+ (winkel /
+ (M_PI / 180.0)), R_,
+ _lat, _lon);
+ proj->get_xy(_lat,
+ _lon,
+ _x,
+ _y);
+ scantmp_xcoor.
+ push_back(-_x);
+ scantmp_ycoor.
+ push_back(-_y);
+ }
+ for (float winkel = 0;
+ winkel <= bravo - RADSTEP;
+ winkel = winkel + RADSTEP) {
+ //scantmp_xcoor.push_back(X_x +( R_ * cos (winkel)) );
+ //scantmp_ycoor.push_back(X_y +( R_ * sin (winkel)) );
+ go(X_lat, X_lon,
+ (winkel /
+ (M_PI / 180.0)), R_,
+ _lat, _lon);
+ proj->get_xy(_lat,
+ _lon,
+ _x,
+ _y);
+ scantmp_xcoor.
+ push_back(-_x);
+ scantmp_ycoor.
+ push_back(-_y);
+ }
+
+
+ }
+ }
+ // clockwise
+ if (D == -1) {
+ //cout << "CLOCKWISE" << endl;
+ if (alpha > bravo) {
+
+ for (float winkel =
+ alpha - RADSTEP;
+ winkel >= bravo + RADSTEP;
+ winkel = winkel - RADSTEP) {
+ //scantmp_xcoor.push_back(X_x +( R_ * cos (winkel)) );
+ //scantmp_ycoor.push_back(X_y +( R_ * sin (winkel)) );
+ go(X_lat, X_lon,
+ (winkel /
+ (M_PI / 180.0)), R_,
+ _lat, _lon);
+ proj->get_xy(_lat,
+ _lon,
+ _x,
+ _y);
+ scantmp_xcoor.
+ push_back(-_x);
+ scantmp_ycoor.
+ push_back(-_y);
+ }
+
+ } else {
+
+ for (float winkel =
+ alpha - RADSTEP; winkel >= 0;
+ winkel = winkel - RADSTEP) {
+ //scantmp_xcoor.push_back(X_x +( R_ * cos (winkel)) );
+ //scantmp_ycoor.push_back(X_y +( R_ * sin (winkel)) );
+ go(X_lat, X_lon,
+ (winkel /
+ (M_PI / 180.0)), R_,
+ _lat, _lon);
+ proj->get_xy(_lat,
+ _lon,
+ _x,
+ _y);
+ scantmp_xcoor.
+ push_back(-_x);
+ scantmp_ycoor.
+ push_back(-_y);
+ }
+ for (float winkel = 2 * M_PI;
+ winkel >= bravo + RADSTEP;
+ winkel = winkel - RADSTEP) {
+ //scantmp_xcoor.push_back(X_x +( R_ * cos (winkel)) );
+ //scantmp_ycoor.push_back(X_y +( R_ * sin (winkel)) );
+ go(X_lat, X_lon,
+ (winkel /
+ (M_PI / 180.0)), R_,
+ _lat, _lon);
+ proj->get_xy(_lat,
+ _lon,
+ _x,
+ _y);
+ scantmp_xcoor.
+ push_back(-_x);
+ scantmp_ycoor.
+ push_back(-_y);
+ }
+
+
+ }
+ }
+ //set point B
+ //float _x, _y;
+ proj->get_xy(B_lat, B_lon, _x, _y);
+ scantmp_xcoor.push_back(-_x);
+ scantmp_ycoor.push_back(-_y);
+
+ }
+
+ // DC
+ //Circle
+ if (strcmp(arg1, "DC") == 0) {
+
+ float _radius; //radius of airspace
+ if (sscanf(zeile.c_str(), "%s %f", arg1, &_radius)
+ == 2) {
+ _radius *= 1.852; //convert to km.
+
+ //if (conf->DEBUG.get())
+ // cout << "Radius of circle: " << _radius << endl;
+
+
+ float _lat, _lon, _x, _y;
+ //float winkeldelta = M_PI / 50 ;
+ int _dbg = 0;
+ for (float winkel = 0; winkel < 2 * M_PI;
+ winkel = winkel + RADSTEP) {
+ go(X_lat, X_lon,
+ (winkel / (M_PI / 180.0)),
+ _radius, _lat, _lon);
+ proj->get_xy(_lat, _lon,
+ _x, _y);
+ scantmp_xcoor.push_back(-_x);
+ scantmp_ycoor.push_back(-_y);
+ _dbg++;
+ //scantmp_xcoor.push_back(X_x +( _radius * cos (winkel)) );
+ //scantmp_ycoor.push_back(X_y +( _radius * sin (winkel)) );
+ }
+ //cout << "number of circle: "<<_dbg<< endl;
+ //cout << "....: " << scantmp_xcoor.size() << endl;
+
+
+ } else {
+ cerr <<
+ "Error reading DC-Line (OpenAir file): "
+ << zeile << endl;
+ exit(0);
+ }
+
+ }
+
+ // Ceiling altitude and Floor altitude
+
+ if (strcmp(arg1, "AH") == 0 || strcmp(arg1, "AL") == 0) {
+
+ string _top_or_bottom = arg1;
+
+ int _alt = -9999;
+ string _unit = "no";
+
+
+ // four args: AH 50 00 MSL (strange syntax)
+ if ( (sscanf(zeile.c_str(), "%s %d %s %s", arg1, &_alt,
+ arg3, arg4) == 4)
+ && (strcmp(arg3, "00") == 0) ) {
+ _alt = _alt * 100;
+ _unit = arg4;
+
+ if (AIRDEBUG)
+ cout << "4 args read (strange syntax) >>"<< zeile.c_str()
+ << "<<==>>" << _alt << "<==>" << _unit << endl;
+
+ goto end;
+ }
+
+ // four args: AH 5000 ft STD or AH 5000 ft MSL
+ if (sscanf
+ (zeile.c_str(), "%s %d %s %s", arg1, &_alt,
+ arg2, arg3) == 4) {
+
+ _unit = arg3;
+
+ if (AIRDEBUG)
+ cout << "4 args read >>"<< zeile.c_str() << "<<==>>" <<
+ _alt << "<==>" << arg2 << "<==>" << arg3 << endl;
+
+ if (strcasecmp(arg2, "ft") != 0) {
+ cout << "UNRECOGNIZED string in Airspace >>" << arg2 << "<<" << endl;
+ badcounter++;
+ }
+
+ goto end;
+
+ }
+ // AH 5000 ft, AH 5000 MSL, AH 5000 GND ...
+ if (sscanf
+ (zeile.c_str(), "%s %d %s", arg1, &_alt,
+ arg2) == 3) {
+
+ if (AIRDEBUG)
+ cout << "3 args read >>" << zeile.c_str() << "<<==>>" <<
+ _alt << "<==>" << arg2 << "<=="<< endl;
+
+
+ _unit = arg2;
+ goto end;
+ }
+ // AH FL100
+ if (sscanf
+ (zeile.c_str(), "%s %2s %d", arg1, arg2,
+ &_alt) == 3) {
+
+ if (AIRDEBUG)
+ cout << "Flightlevel read >>" << zeile.c_str() << "<<==>>"
+ << arg2 << "<==>" << _alt << endl;
+
+ _unit = arg2;
+ goto end;
+ }
+ // AH 5000 -> probably 0
+ if (sscanf(zeile.c_str(), "%s %d", arg1, &_alt) ==
+ 2) {
+ _unit = "no";
+
+
+ goto end;
+ }
+ // AL GND, AL SFC, AH UNLIM, etc
+ if (sscanf(zeile.c_str(), "%s %s", arg1, arg2) ==
+ 2) {
+ _unit = arg2;
+ _alt = -9998;
+ goto end;
+
+ }
+
+ cout << "FAILURE!!!!!!! UNRECOGNIZED ALTITUDE IN AIRSPACE" << endl;
+ badcounter++;
+
+ end:
+
+
+ if (_alt != -9999) {
+
+ // Altitude QNH
+ if (_unit == "AMSL" || _unit == "ft"
+ || _unit == "FT" || _unit == "ALT"
+ || _unit == "alt" || _unit == "MSL") {
+ _alt =
+ int ((float (_alt) /
+ 3.28) +0.5);
+ _unit = "MSL";
+ //cout << "QNH -------" << endl;
+ } else
+ // Altitude GND ? Was machen wir denn mal damit
+ // Landscape.getSURFACE_elevation(?)
+ // siehe auch in der drawAirspace routine
+ if (_unit == "AGL" || _unit == "agl"
+ || _unit == "Agl" || (_unit == "GND"
+ && _alt !=
+ -9998)) {
+ _alt =
+ int ((float (_alt) /
+ 3.28) +0.5);
+ _unit = "GND";
+ //cout << "GND ---------" << endl;
+ } else
+
+ if (_unit == "SFC" || _unit == "sfc"
+ || _alt == 0 || (_unit == "GND"
+ && _alt == -9998)) {
+ _alt = -200; // plot down to -200...
+ _unit = "MSL";
+ //cout << "SURFACE ----------" << endl;
+ } else
+
+ if (_unit == "STD" || _unit == "std") {
+ _alt =
+ int ((float (_alt) /
+ 3.28) +0.5);
+ _unit = "STD";
+
+ } else
+ // Flightlevels ; FL = altitude / 100 [ft above STD]
+ if (_unit == "fl" || _unit == "FL") {
+ _alt =
+ int ((float (_alt * 100) /
+ 3.28) +0.5);
+ _unit = "STD";
+ //cout << "FLIGHTLEVEL ------------" << endl;
+
+ } else
+
+ if (_unit == "UNLIM" || _unit == "UNLTD"
+ || _unit == "UNLIMITED" || _unit == "UNL") {
+ _alt = 30000; //should be enough...
+ _unit = "MSL";
+ //cout << "UNLIMITED -----------" << endl;
+
+ } else {
+
+ if (conf->VERBOSE.get()) {
+ cerr << "Elevation unit unknown!!! >>" << _unit <<
+ "<< ==> in line: " << zeile << endl;
+ }
+ badcounter++;
+
+ }
+
+
+ } else {
+ cerr << "AL or AH Line not parsed :-( " <<
+ " Line ->" << zeile << "<-" <<
+ endl;
+
+ // << "Please send this output to: " << MAIL << endl;
+
+ //exit(1);
+ }
+
+
+ if (_top_or_bottom == "AH") {
+ scantmp_ah = _alt;
+ scantmp_ah_unit = _unit;
+ }
+
+ if (_top_or_bottom == "AL") {
+ scantmp_al = _alt;
+ scantmp_al_unit = _unit;
+ }
+
+
+ }
+
+
+
+ }
+
+ if (conf->VERBOSE.get()) {
+ cout << "Errors reading Airspacefile: " << badcounter <<endl;
+ }
+}
+
+float Airspace::coor2dec(char *coorstring, char *NESWstring)
+{
+
+ float dec_coor = -9999;
+
+ int degres = 0;
+ int minutes = 0;
+ int seconds = 0;
+ float decminutes = 0;
+
+ if (sscanf(coorstring, "%d:%d:%d", &degres, &minutes, &seconds) ==
+ 3) {
+ dec_coor =
+ (float) degres + ((float) minutes / 60.0) +
+ ((float) seconds / 3600.0);
+ if (strcmp(NESWstring, "S") == 0
+ || strcmp(NESWstring, "W") == 0)
+ dec_coor *= -1;
+ return dec_coor;
+ }
+
+ if (sscanf(coorstring, "%d:%f", &degres, &decminutes) == 2) {
+ dec_coor = (float) degres + (decminutes / 60.0);
+ if (strcmp(NESWstring, "S") == 0
+ || strcmp(NESWstring, "W") == 0)
+ dec_coor *= -1;
+ return dec_coor;
+
+
+ }
+
+ return dec_coor;
+
+}
+
+
+void Airspace::drawAirspace(bool BW)
+{
+
+
+ // use blending
+ glEnable(GL_BLEND);
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ glEnable(GL_COLOR_MATERIAL);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_LIGHTING);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+
+ //depth buffer read-only (for transparent objects with blending)
+ glDepthMask(GL_FALSE);
+
+
+
+ // _n is the number of Airspaces read from Airspace file
+ int _n = (int) type.size();
+
+ // _m will be the number of polygon_points in one Airspace
+ int _m;
+
+ //loop over all airspaces
+ for (int _z = 0; _z < _n; _z++) {
+
+
+
+ _m = (int) xcoor[_z].size();
+ //if (_m == 2) continue;
+
+ bool DRAW = false;
+
+ //default color for non classified airspaces
+ // red almost opaque
+ float col[4] = {1.0, 0.0, 0.0, 0.7};
+
+
+ if (lower[_z] > ( ((float)conf->AirspaceLimit.get()*100.0)/3.28) ) {
+ continue;
+ }
+
+
+ //set color for type of airspace R restricted, P prohibited, Q danger
+ // and check if we should draw this type of airspace
+ // we need to continue before anything is drawn!
+ if (type[_z] == "R") {
+
+ if (!conf->AIRSPACE_R.get()) {continue;}
+ col[0] = 0.0;
+ col[1] = 0.0;
+ col[2] = 1.0;
+ col[3] = 0.2;
+ }
+
+ if (type[_z] == "Q") {
+
+ if (!conf->AIRSPACE_Q.get()) {continue;}
+ col[0] = 0.0;
+ col[1] = 0.0;
+ col[2] = 1.0;
+ col[3] = 0.2;
+ }
+
+ if (type[_z] == "P") {
+
+ if (!conf->AIRSPACE_P.get()) {continue;}
+ col[0] = 0.0;
+ col[1] = 0.0;
+ col[2] = 1.0;
+ col[3] = 0.2;
+ }
+
+
+
+ if (type[_z] == "CTR") {
+ if (!conf->AIRSPACE_CTR.get()) {continue;}
+ col[0] = 0.7;
+ col[1] = 0.0;
+ col[2] = 0.6;
+ col[3] = 0.2;
+ }
+
+ if (type[_z] == "C") {
+ if (!conf->AIRSPACE_C.get()) {continue;}
+ col[0] = 0.0;
+ col[1] = 0.7;
+ col[2] = 0.0;
+ col[3] = 0.2;
+ }
+
+ // D is same as ctr
+ if (type[_z] == "D") {
+ if (!conf->AIRSPACE_D.get()) {continue;}
+ col[0] = 0.7;
+ col[1] = 0.0;
+ col[2] = 0.6;
+ col[3] = 0.2;
+ }
+
+
+
+ // loop over all polygon-points of airspce _z
+ //to check, if we need to draw it
+ for (int _p = 0; _p < _m; _p++) {
+
+ // if one single point is in limits, set DRAW to true
+
+ //float _lat_ddist = center_lat - latmax;
+ //float _lon_ddist = center_lon - lonmax;
+ float xkmmax; // = - _lon_ddist * DEGDIST * cos (PI_180 * latmax);
+ float ykmmax; // = - _lat_ddist * DEGDIST;
+
+ proj->get_xy(latmax, lonmax, xkmmax,
+ ykmmax);
+
+ xkmmax *= -1.0;
+ ykmmax *= -1.0;
+
+ float xkmmin = xkmmax * -1.0;
+ float ykmmin = ykmmax * -1.0;
+
+ if (ycoor[_z][_p] < ykmmax
+ && ycoor[_z][_p] > ykmmin
+ && xcoor[_z][_p] < xkmmax
+ && xcoor[_z][_p] > xkmmin)
+ DRAW = true;
+ }
+
+
+
+ if (DRAW) {
+
+
+
+ float buttom = lower[_z] / 1000.0;
+ float top = upper[_z] / 1000.0;
+
+ if (conf->DEBUG.get()) {
+ cout << "-----------------------------" << endl;
+ cout << "Airspace no. " << _z << ", Type: " << type[_z] << " --> " << name[_z] << endl;
+ cout << buttom << " <-> "<< top << endl;
+
+ if (buttom < -0.2001)
+ cout << "EEEERRRRROOOORRRR!!!!!! No altitude for airspace lower limit!" << endl;
+ if (top < -0.2001)
+ cout << "EEEERRRRROOOORRRR!!!!!! No altitude for airspace upper limit!" << endl;
+
+
+ }
+
+ if (conf->DEBUG.get()) {
+ cout << "Numbers of points defining the airspace (lat/lon): " << lat[_z].size() << endl;
+ cout << "Numbers of points defining the airspace (x/y): " << xcoor[_z].size() << endl;
+ }
+
+ // if Altitude is above ground...
+ if (upper_unit[_z] == "GND") {
+
+ if (conf->DEBUG.get())
+ cout << "GND... detected altering altitude (upper)" << endl;
+
+ //create vec
+ vector < int >alt_tmp;
+
+
+
+ // check if we have lat/lon of airspace points
+ // in case of a circle-only (cylindric) airspace, we have the generated x/y only!
+ if ((int) lat[_z].size() > 0) {
+ alt_tmp.resize(lat[_z].size());
+
+ // braucht coordinaten....
+ get_gnd_elevations(&alt_tmp, &lat[_z],&lon[_z], conf);
+
+ } else { // airspaces with only V X= and DC (no lat/lon DP)
+ alt_tmp.resize(xcoor[_z].size());
+
+ vector<float> tmp_lat;
+ vector<float> tmp_lon;
+ tmp_lat.resize(xcoor[_z].size());
+ tmp_lon.resize(xcoor[_z].size());
+
+ if (conf->DEBUG.get())
+ cout << "Airspace "<<name[_z]<<" is circle only..." << endl;
+
+ for (int tmp=0; tmp < (int) xcoor[_z].size(); tmp++) {
+ proj->get_latlon(xcoor[_z][tmp], ycoor[_z][tmp], tmp_lat[tmp], tmp_lon[tmp]);
+ //cout << tmp_lat[tmp] << " " << tmp_lon[tmp] << endl;
+ }
+
+ get_gnd_elevations(&alt_tmp, &tmp_lat,&tmp_lon, conf);
+ }
+
+
+
+ float _gnd_alt_tmp = 0;
+ for (unsigned int _q = 0;
+ _q < alt_tmp.size(); _q++) {
+
+ if (alt_tmp[_q] > -16384 && alt_tmp[_q] != -9999) {
+ _gnd_alt_tmp += alt_tmp[_q];
+ }
+
+ if (conf->DEBUG.get())
+ cout << alt_tmp[_q] << " " << endl;
+ }
+ _gnd_alt_tmp /= alt_tmp.size();
+
+ if (conf->DEBUG.get())
+ cout << "Orignal (GND) altitude: " << top ;
+
+ top += (_gnd_alt_tmp / 1000.0);
+
+ if (conf->DEBUG.get())
+ cout << " altered to MSL: " << top << endl <<
+ " Sum of groundpoints is:" << _gnd_alt_tmp << " no points: " << alt_tmp.size() << " added: " << (_gnd_alt_tmp / 1000.0) << endl;
+ }
+ // if Altitude is above ground...
+ if (lower_unit[_z] == "GND") {
+
+ if (conf->DEBUG.get())
+ cout << "GND... detected altering altitude (lower)" << endl;
+ //create vec
+
+ vector < int >alt_tmp;
+
+
+ //cylindric airspace
+ if ((int)lat[_z].size() > 0) {
+ alt_tmp.resize(lat[_z].size());
+
+ // braucht coordinaten....
+ get_gnd_elevations(&alt_tmp, &lat[_z],&lon[_z], conf);
+
+ } else { // airspaces with only V X= and DC (no lat/lon DP)
+ alt_tmp.resize(xcoor[_z].size());
+
+ vector<float> tmp_lat;
+ vector<float> tmp_lon;
+ tmp_lat.resize(xcoor[_z].size());
+ tmp_lon.resize(xcoor[_z].size());
+
+ if (conf->DEBUG.get())
+ cout << "Airspace "<<name[_z]<<" is circle only..." << endl;
+
+ for (int tmp=0; tmp < (int) xcoor[_z].size(); tmp++) {
+ proj->get_latlon(xcoor[_z][tmp], ycoor[_z][tmp], tmp_lat[tmp], tmp_lon[tmp]);
+ }
+
+ get_gnd_elevations(&alt_tmp, &tmp_lat,&tmp_lon, conf);
+ }
+
+
+ float _gnd_alt_tmp = 0;
+ for (unsigned int _q = 0;
+ _q < alt_tmp.size(); _q++) {
+ _gnd_alt_tmp += alt_tmp[_q];
+
+ if (conf->DEBUG.get())
+ cout << alt_tmp[_q] << " " << endl;
+ }
+ _gnd_alt_tmp /= alt_tmp.size();
+
+ if (conf->DEBUG.get())
+ cout << "Orignal (GND) altitude: " << buttom ;
+
+ buttom += (_gnd_alt_tmp / 1000.0);
+
+ if (conf->DEBUG.get())
+ cout << "altered to MSL: " << buttom << endl;
+ }
+
+
+
+ // at first we plot black wireframes (but only vertical boundaries (outlines)
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+
+ glColor3f(conf->airspace_wire_color_r.get(), conf->airspace_wire_color_g.get(), conf->airspace_wire_color_b.get());
+ glLineWidth(conf->airspace_wire_width.get());
+// glColor3fv(conf->)
+ glBegin(GL_QUAD_STRIP);
+ //cout << "---------------" << endl;
+ for (int _p = 0; _p < _m; _p++) {
+
+
+ //cout << xcoor[_z][_p] << " " << ycoor[_z][_p] << endl;
+
+ glVertex3f(xcoor[_z][_p], ycoor[_z][_p],
+ buttom);
+ glVertex3f(xcoor[_z][_p], ycoor[_z][_p],
+ top);
+
+ }
+
+ // first point .... to close
+
+ glVertex3f(xcoor[_z][0], ycoor[_z][0], buttom);
+ glVertex3f(xcoor[_z][0], ycoor[_z][0], top);
+
+ glEnd();
+ // END of black wireframes;
+
+ //switch back to filled polygons
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+
+ if (!conf->AIRSPACE_WIRE.get()) {
+
+ if (!BW) {
+ glColor4fv(col);
+ } else {
+ glColor4fv(graycolor(col));
+ }
+
+
+ // draw outlines (this time coloured and transparent)
+ glBegin(GL_QUAD_STRIP);
+ for (int _p = 0; _p < _m; _p++) {
+
+
+
+ glVertex3f(xcoor[_z][_p], ycoor[_z][_p],
+ buttom);
+ glVertex3f(xcoor[_z][_p], ycoor[_z][_p],
+ top);
+
+ }
+
+ // first point .... to close
+
+
+ glVertex3f(xcoor[_z][0], ycoor[_z][0], buttom);
+ glVertex3f(xcoor[_z][0], ycoor[_z][0], top);
+
+ glEnd();
+
+
+
+ // draw ceiling
+
+ //this is needed, because the GLU_TESS_VERTEX callback will return pointers to this
+ // no airspace will have more than thousand polygon-points. (I hope)
+ GLdouble coor[1000][3];
+
+ GLUtesselator *tess;
+ tess = gluNewTess();
+
+
+ // the (void(*)()) typecasts are needed, because of differences between c and c++ !!!
+ // windows needs (void(__stdcall *)())
+
+// why ifndes ONLY_OSMESA?!
+//#define CALLBACK
+//#ifndef ONLY_OSMESA
+//#ifdef __WIN32__
+//#define CALLBACK __stdcall
+//#endif
+//#endif
+
+#ifdef __WIN32__
+#define CALLBACK __stdcall
+#else
+#define CALLBACK
+#endif
+
+// on matthews ppc mac this seems to be needed (its a 10.4.11?)
+
+#ifdef __tripledotfix__
+#define MACTRICK ...
+#else
+#define MACTRICK
+#endif
+ gluTessCallback(tess, GLU_TESS_VERTEX,
+ (void (CALLBACK *)(MACTRICK)) glVertex3dv);
+ gluTessCallback(tess, GLU_TESS_BEGIN,
+ (void (CALLBACK *) (MACTRICK)) glBegin);
+ gluTessCallback(tess, GLU_TESS_END,
+ (void (CALLBACK *)(MACTRICK)) glEnd);
+ gluTessCallback(tess, GLU_TESS_ERROR,
+ (void (CALLBACK *) (MACTRICK)) errorCallback);
+
+ gluTessBeginPolygon(tess, NULL);
+ gluTessBeginContour(tess);
+
+ for (int _p = 0; _p < _m; _p++) {
+
+ coor[_p][0] = xcoor[_z][_p]; //_xkmdist;
+ coor[_p][1] = ycoor[_z][_p]; //_ykmdist;
+ coor[_p][2] = top;
+
+ gluTessVertex(tess, coor[_p], coor[_p]);
+
+ //cout << "tess" << ": " << coor[_p][0] << " " << coor[_p][1] << " " << coor[_p][2] << endl;
+
+ }
+
+ //cout << "TESS" << endl;
+ gluTessEndContour(tess);
+ gluTessEndPolygon(tess);
+ // we will delete this later (after we plotted to bottom)
+ //gluDeleteTess(tess);
+
+
+
+ //draw floor if alt != 0
+ if (lower[_z] != 0) {
+ gluTessBeginPolygon(tess, NULL);
+ gluTessBeginContour(tess);
+
+ for (int _p = 0; _p < _m; _p++) {
+
+
+ coor[_p][0] = xcoor[_z][_p]; //_xkmdist;
+ coor[_p][1] = ycoor[_z][_p]; //_ykmdist;
+ coor[_p][2] = buttom;
+
+ gluTessVertex(tess, coor[_p],
+ coor[_p]);
+
+ //cout << "tess" << endl;
+ //cout << "tess button" << ": " << coor[_p][0] << " " << coor[_p][1] << " " << coor[_p][2] << endl;
+
+ }
+
+ //cout << "TESS" << endl;
+ gluTessEndContour(tess);
+ gluTessEndPolygon(tess);
+ }
+ gluDeleteTess(tess);
+
+ }
+
+ }
+
+ }
+
+
+ //glPopAttrib();
+ glDepthMask(GL_TRUE);
+ glDisable(GL_BLEND);
+ //glBlendFunc(GL_ONE, GL_ZERO);
+
+ glDisable(GL_COLOR_MATERIAL);
+ glLineWidth(1.0);
+ glEnable(GL_CULL_FACE);
+ glEnable(GL_LIGHTING);
+ glPolygonMode(GL_FRONT, GL_FILL);
+
+}
diff --git a/src/airspc.h b/src/airspc.h
new file mode 100644
index 0000000..7b62d1a
--- /dev/null
+++ b/src/airspc.h
@@ -0,0 +1,64 @@
+/*
+ * (c) 2002-2016 Hannes Krueger
+ * This file is part of the GPLIGC/ogie package
+ */
+
+#ifndef AIRSPC_H
+#define AIRSPC_H 1
+
+#include<vector>
+#include<string>
+
+#include "oconfig.h"
+#include "projection.h"
+
+
+class Airspace {
+ public:
+
+ Airspace(float _center_lat, float _center_lon, float _latmax, float _latmin, float _lonmax, float _lonmin);
+ Airspace() ;
+
+ void initAirspace(float _center_lat, float _center_lon, float _latmax, float _latmin, float _lonmax, float _lonmin);
+
+ void drawAirspace(bool BW);
+
+ void readOpenAirFile(string);
+
+ void setConfig(Config* _c) {conf= _c;};
+ void set_proj_pointer(Projection *p) { proj = p;}
+
+ protected:
+
+ Config *conf;
+ Projection *proj; //the projection-class pointer
+
+ float center_lat;
+ float center_lon;
+
+ float latmax;
+ float lonmax;
+ float latmin;
+ float lonmin;
+
+ float coor2dec(char*, char*);
+
+ vector<int> lower; // altitudes in m
+ vector<string>lower_unit; // can be MSL, GND or STD
+ vector<int> upper;
+ vector<string>upper_unit;
+ //int n;
+ vector<vector<float> >xcoor;
+ vector<vector<float> >ycoor;
+ vector<vector<float> >lat;
+ vector<vector<float> >lon;
+ vector<string> type;
+ vector<string> name;
+ vector<string> direction; // only for testing
+};
+
+#endif
+
+
+
+
diff --git a/src/cmdline.c b/src/cmdline.c
new file mode 100644
index 0000000..7be21e6
--- /dev/null
+++ b/src/cmdline.c
@@ -0,0 +1,4232 @@
+/*
+ File autogenerated by gengetopt version 2.22.6
+ generated with the following command:
+ gengetopt -G
+
+ The developers of gengetopt consider the fixed text that goes in all
+ gengetopt output files to be in the public domain:
+ we make no copyright claims on it.
+*/
+
+/* If we use autoconf. */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef FIX_UNUSED
+#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
+#endif
+
+
+#include "cmdline.h"
+
+const char *gengetopt_args_info_purpose = "OGIE (c) 2002-2016 by Hannes Krueger <Hannes.Krueger@gmail.com>\nWeb: http://gpligc.sf.net\n\nopenGL viewer for igc flight data files and/or digital elevation data\nfrom SRTM30, GTOPO30, GLOBE, etc. Digitised maps and airspace data\nfiles can be used.\n\nThis program comes with ABSOLUTELY NO WARRANTY.\nThis is free software, and you are welcome to redistribute it\nunder certain conditions.\n\nThe full GPLv3 license is included in the manual\n";
+
+const char *gengetopt_args_info_usage = "Usage: OGIE [OPTIONS]...";
+
+const char *gengetopt_args_info_versiontext = "";
+
+const char *gengetopt_args_info_description = "";
+
+const char *gengetopt_args_info_help[] = {
+ " -h, --help Print help and exit",
+ " -V, --version Print version and exit",
+ " -v, --verbose verbosity? (default=off)",
+ " --quiet Quiet (default=off)",
+ " -q, --query-gl Querying openGL implementation (default=off)",
+ " --check return exitcode 0 (default=off)",
+ " --compiler info about build (default=off)",
+ " --debug lots of output (default=off)",
+ " -i, --igc-file=STRING igc-file",
+ " --gpsd live gps via gpsd (default=off)",
+ " --gpsd-server=STRING address of gpsd server",
+ " --gpsd-port=INT port of gpsd server",
+ " -g, --gpsalt use gps altitude (default=off)",
+ " -b, --baroalt use barometric alt (default=off)",
+ " --use-all-fixes Use all position fixes (default=off)",
+ " --lat=FLOAT Latitude",
+ " --lon=FLOAT Longitude",
+ " --get-elevation Return elevation of lat/lon (default=off)",
+ " -c, --config-file=STRING config file",
+ " -o, --ortho 2D Orthographic View (default=off)",
+ " --perspective 3D View (default=off)",
+ " --aov=INT angle of view",
+ " -l, --landscape landscape from dem (default=off)",
+ " -f, --flat flat underground (default=off)",
+ " -m, --map display digitized maps (default=off)",
+ " --no-map dont use maps (default=off)",
+ " --map-set-name=STRING name of map set to use",
+ " --modulate dem color and maps (default=off)",
+ " --no-modulate no color modulation (default=off)",
+ " --maps-unlighted dont use lighting for unmodulated maps\n (default=off)",
+ " --maps-lighted use lighting for unmodulated maps\n (default=off)",
+ " --no-lighting Dont use lighting for terrain (default=off)",
+ " --terrain-shading Use terrain shading (implies no-lighting)\n (default=off)",
+ " --shading-scale=FLOAT shading-scale (1-10000)",
+ " --light-direction=INT direction for light (1-8)",
+ " -a, --airspace Airspace visualization (default=off)",
+ " --airspace-wire Airspace as wireframe (default=off)",
+ " --airspace-wire-col-r=FLOAT\n wire color red",
+ " --airspace-wire-col-g=FLOAT\n wire color green",
+ " --airspace-wire-col-b=FLOAT\n wire color blue",
+ " --airspace-wire-width=FLOAT\n linewidth wires",
+ " --airspace-transparent Airspace transparent (default=off)",
+ " --no-airspace no Airspaces (default=off)",
+ " --airspace-file=STRING use airspaces from file",
+ " --airspace-limit=INT limit (FL) for airspaces",
+ " -w, --wire wireframe landscape (default=off)",
+ " --filled filled polygons (default=off)",
+ " --grayscale grayscaled image (default=off)",
+ " --color color image (default=off)",
+ " --stereo stereoscopic (default=off)",
+ " --no-stereo no stereoscopic view (default=off)",
+ " --stereo-rg stereoscopic red/green (default=off)",
+ " --no-stereo-rg no stereoscopic red/green (default=off)",
+ " --stereo-rb stereoscopic red/blue (default=off)",
+ " --no-stereo-rb no stereoscopic red/blue (default=off)",
+ " --stereo-hw stereoscopic hardware (default=off)",
+ " --no-stereo-hw no stereoscopic hardware (default=off)",
+ " --inverse-stereo invert right/left image (default=off)",
+ " --no-inverse-stereo dont invert right/left (default=off)",
+ " --eye-dist=FLOAT eye distance for stereoscopic view (km)",
+ " --flat-shading no gouraud (default=off)",
+ " --gouraud-shading use gouraud-shading (default=off)",
+ " --quads use quadrilaterals (default=off)",
+ " --curtain draw curtain (default=off)",
+ " --no-curtain draw no curtain (default=off)",
+ " --haze draw haze (default=off)",
+ " --no-haze draw no haze (default=off)",
+ " --haze-density=FLOAT haze density (0-0.5)",
+ " --colormap=INT no. of colormap to use",
+ " --colormap-sea=INT colormap 2 (sea)",
+ " --colormap-min=INT mininum height",
+ " --colormap-max=INT maximum height",
+ " --sealevel=INT set sealevel",
+ " --sealevel2=INT set sealevel2",
+ " --sealevel3=INT set sealevel3",
+ " --ignore-elev-min=INT ignore range min",
+ " --ignore-elev-max=INT ignore range max",
+ " -s, --scalez=FLOAT z axis scaling",
+ " -d, --downscaling=INT dem raster downscaling",
+ " --upscaling=INT dem raster interpolation factor",
+ " --fullscreen Fullscreen (default=off)",
+ " --window start windowed (default=off)",
+ " --width=INT Window width",
+ " --height=INT Window height",
+ " --border=FLOAT Border Lat and Lon",
+ " --border-lat=FLOAT Border Lat",
+ " --border-lon=FLOAT Border Lon",
+ " --offset=INT height offset in m",
+ " -e, --airfield-elevation=INT Elevation of airfield (take-off) in m",
+ " --marker-pos=INT Position of marker",
+ " --marker-time=STRING Time of markerposition",
+ " --marker Marker (default=off)",
+ " --marker-size=FLOAT Size of the Marker",
+ " --no-marker no Marker (default=off)",
+ " --info Info text display (default=off)",
+ " --no-info no info text display (default=off)",
+ " --text=STRING Text string to display",
+ " --no-position-info Turn off viewpoint position info (default=off)",
+ " --no-marker-pos-info Turn off marker position info (default=off)",
+ " --text-size=FLOAT Size of text for points/lifts (0.001-1.0)",
+ " --text-width=FLOAT Width of text (1-20)",
+ " --lifts=STRING GPLIGC liftsfile",
+ " --lifts-info-mode=INT which info to display (1-7)",
+ " --waypoints-file=STRING waypointsfile",
+ " --waypoints show waypoints (default=off)",
+ " --no-waypoints dont show waypoints (default=off)",
+ " --waypoints-info-mode=INT which info to display (1-4)",
+ " --waypoints-offset=INT offset for displaying waypoint text in 3D",
+ " --waypoints-offset-spheres=INT\n offset for displaying waypoint spheres and text\n in 3D",
+ " --flighttrack-mode=INT sets the mode of track display",
+ " --flighttrack-colormap=INT\n sets the colourmap for flighttrack",
+ " --flighttrack-linewidth=FLOAT\n sets the linewidth of the flighttrack",
+ " --follow viewpoint follows marker (default=off)",
+ " --no-follow viewpoint doesnt follow marker (default=off)",
+ " --marker-range range around marker is plottet (default=off)",
+ " --no-marker-range full flight is displayed (default=off)",
+ " --marker-ahead=INT define marker range",
+ " --marker-back=INT define marker range",
+ " --movie start up in movie mode (default=off)",
+ " --cycles=INT cycles for movie mode",
+ " --spinning=FLOAT spinning for movie mode",
+ " --smooth-mouse smooth movement (default=off)",
+ " --parent-pid=INT PID of parent",
+ " --compression Use texture map compression (default=off)",
+ " --no-compression Dont use texture map compression (default=off)",
+ " --offscreen Offscreen with GLX (default=off)",
+ " --osmesa Offscreen with Mesa (default=off)",
+ " --os-outfile=STRING outfile for offscreen rendering",
+ " --jpeg-quality=INT Quality (0-100) of jpeg output",
+ " --image-format=STRING Image format for screenshots",
+ " --save-path=STRING Path to save screenshots",
+ " --basename=STRING Basename of screenshots",
+ " --clipping-far=FLOAT clipping far",
+ " --clipping-near=FLOAT clipping near",
+ " --init-lat=FLOAT set initial latitude",
+ " --init-lon=FLOAT set initial longitude",
+ " --init-alt=INT set initial altitude",
+ " --init-heading=INT set initial heading",
+ " --init-dive=INT set initial dive angle",
+ " --init-pos-N set position North (default=off)",
+ " --init-pos-E set position East (default=off)",
+ " --init-pos-S set position South (default=off)",
+ " --init-pos-W set position West (default=off)",
+ " --init-pos-NE set position NE (default=off)",
+ " --init-pos-SE set position SE (default=off)",
+ " --init-pos-SW set position SW (default=off)",
+ " --init-pos-NW set position NW (default=off)",
+ " --init-pos-center set position center (default=off)",
+ " --init-ortho-lat=FLOAT set initial latitude for ortho mode",
+ " --init-ortho-lon=FLOAT set initial longitude for ortho mode",
+ " --init-ortho-width=FLOAT set initial ortho-view width [km]",
+ " --projection-cyl-platt set platt projection (default=off)",
+ " --projection-cyl-no1 set cylindric projection 1 (default=off)",
+ " --projection-pseudo-cyl-no1\n set pseudocylindric projection 1 (default=off)",
+ " --projection-cyl-mercator set mercator projection (default=off)",
+ 0
+};
+
+typedef enum {ARG_NO
+ , ARG_FLAG
+ , ARG_STRING
+ , ARG_INT
+ , ARG_FLOAT
+} cmdline_parser_arg_type;
+
+static
+void clear_given (struct gengetopt_args_info *args_info);
+static
+void clear_args (struct gengetopt_args_info *args_info);
+
+static int
+cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
+ struct cmdline_parser_params *params, const char *additional_error);
+
+
+static char *
+gengetopt_strdup (const char *s);
+
+static
+void clear_given (struct gengetopt_args_info *args_info)
+{
+ args_info->help_given = 0 ;
+ args_info->version_given = 0 ;
+ args_info->verbose_given = 0 ;
+ args_info->quiet_given = 0 ;
+ args_info->query_gl_given = 0 ;
+ args_info->check_given = 0 ;
+ args_info->compiler_given = 0 ;
+ args_info->debug_given = 0 ;
+ args_info->igc_file_given = 0 ;
+ args_info->gpsd_given = 0 ;
+ args_info->gpsd_server_given = 0 ;
+ args_info->gpsd_port_given = 0 ;
+ args_info->gpsalt_given = 0 ;
+ args_info->baroalt_given = 0 ;
+ args_info->use_all_fixes_given = 0 ;
+ args_info->lat_given = 0 ;
+ args_info->lon_given = 0 ;
+ args_info->get_elevation_given = 0 ;
+ args_info->config_file_given = 0 ;
+ args_info->ortho_given = 0 ;
+ args_info->perspective_given = 0 ;
+ args_info->aov_given = 0 ;
+ args_info->landscape_given = 0 ;
+ args_info->flat_given = 0 ;
+ args_info->map_given = 0 ;
+ args_info->no_map_given = 0 ;
+ args_info->map_set_name_given = 0 ;
+ args_info->modulate_given = 0 ;
+ args_info->no_modulate_given = 0 ;
+ args_info->maps_unlighted_given = 0 ;
+ args_info->maps_lighted_given = 0 ;
+ args_info->no_lighting_given = 0 ;
+ args_info->terrain_shading_given = 0 ;
+ args_info->shading_scale_given = 0 ;
+ args_info->light_direction_given = 0 ;
+ args_info->airspace_given = 0 ;
+ args_info->airspace_wire_given = 0 ;
+ args_info->airspace_wire_col_r_given = 0 ;
+ args_info->airspace_wire_col_g_given = 0 ;
+ args_info->airspace_wire_col_b_given = 0 ;
+ args_info->airspace_wire_width_given = 0 ;
+ args_info->airspace_transparent_given = 0 ;
+ args_info->no_airspace_given = 0 ;
+ args_info->airspace_file_given = 0 ;
+ args_info->airspace_limit_given = 0 ;
+ args_info->wire_given = 0 ;
+ args_info->filled_given = 0 ;
+ args_info->grayscale_given = 0 ;
+ args_info->color_given = 0 ;
+ args_info->stereo_given = 0 ;
+ args_info->no_stereo_given = 0 ;
+ args_info->stereo_rg_given = 0 ;
+ args_info->no_stereo_rg_given = 0 ;
+ args_info->stereo_rb_given = 0 ;
+ args_info->no_stereo_rb_given = 0 ;
+ args_info->stereo_hw_given = 0 ;
+ args_info->no_stereo_hw_given = 0 ;
+ args_info->inverse_stereo_given = 0 ;
+ args_info->no_inverse_stereo_given = 0 ;
+ args_info->eye_dist_given = 0 ;
+ args_info->flat_shading_given = 0 ;
+ args_info->gouraud_shading_given = 0 ;
+ args_info->quads_given = 0 ;
+ args_info->curtain_given = 0 ;
+ args_info->no_curtain_given = 0 ;
+ args_info->haze_given = 0 ;
+ args_info->no_haze_given = 0 ;
+ args_info->haze_density_given = 0 ;
+ args_info->colormap_given = 0 ;
+ args_info->colormap_sea_given = 0 ;
+ args_info->colormap_min_given = 0 ;
+ args_info->colormap_max_given = 0 ;
+ args_info->sealevel_given = 0 ;
+ args_info->sealevel2_given = 0 ;
+ args_info->sealevel3_given = 0 ;
+ args_info->ignore_elev_min_given = 0 ;
+ args_info->ignore_elev_max_given = 0 ;
+ args_info->scalez_given = 0 ;
+ args_info->downscaling_given = 0 ;
+ args_info->upscaling_given = 0 ;
+ args_info->fullscreen_given = 0 ;
+ args_info->window_given = 0 ;
+ args_info->width_given = 0 ;
+ args_info->height_given = 0 ;
+ args_info->border_given = 0 ;
+ args_info->border_lat_given = 0 ;
+ args_info->border_lon_given = 0 ;
+ args_info->offset_given = 0 ;
+ args_info->airfield_elevation_given = 0 ;
+ args_info->marker_pos_given = 0 ;
+ args_info->marker_time_given = 0 ;
+ args_info->marker_given = 0 ;
+ args_info->marker_size_given = 0 ;
+ args_info->no_marker_given = 0 ;
+ args_info->info_given = 0 ;
+ args_info->no_info_given = 0 ;
+ args_info->text_given = 0 ;
+ args_info->no_position_info_given = 0 ;
+ args_info->no_marker_pos_info_given = 0 ;
+ args_info->text_size_given = 0 ;
+ args_info->text_width_given = 0 ;
+ args_info->lifts_given = 0 ;
+ args_info->lifts_info_mode_given = 0 ;
+ args_info->waypoints_file_given = 0 ;
+ args_info->waypoints_given = 0 ;
+ args_info->no_waypoints_given = 0 ;
+ args_info->waypoints_info_mode_given = 0 ;
+ args_info->waypoints_offset_given = 0 ;
+ args_info->waypoints_offset_spheres_given = 0 ;
+ args_info->flighttrack_mode_given = 0 ;
+ args_info->flighttrack_colormap_given = 0 ;
+ args_info->flighttrack_linewidth_given = 0 ;
+ args_info->follow_given = 0 ;
+ args_info->no_follow_given = 0 ;
+ args_info->marker_range_given = 0 ;
+ args_info->no_marker_range_given = 0 ;
+ args_info->marker_ahead_given = 0 ;
+ args_info->marker_back_given = 0 ;
+ args_info->movie_given = 0 ;
+ args_info->cycles_given = 0 ;
+ args_info->spinning_given = 0 ;
+ args_info->smooth_mouse_given = 0 ;
+ args_info->parent_pid_given = 0 ;
+ args_info->compression_given = 0 ;
+ args_info->no_compression_given = 0 ;
+ args_info->offscreen_given = 0 ;
+ args_info->osmesa_given = 0 ;
+ args_info->os_outfile_given = 0 ;
+ args_info->jpeg_quality_given = 0 ;
+ args_info->image_format_given = 0 ;
+ args_info->save_path_given = 0 ;
+ args_info->basename_given = 0 ;
+ args_info->clipping_far_given = 0 ;
+ args_info->clipping_near_given = 0 ;
+ args_info->init_lat_given = 0 ;
+ args_info->init_lon_given = 0 ;
+ args_info->init_alt_given = 0 ;
+ args_info->init_heading_given = 0 ;
+ args_info->init_dive_given = 0 ;
+ args_info->init_pos_N_given = 0 ;
+ args_info->init_pos_E_given = 0 ;
+ args_info->init_pos_S_given = 0 ;
+ args_info->init_pos_W_given = 0 ;
+ args_info->init_pos_NE_given = 0 ;
+ args_info->init_pos_SE_given = 0 ;
+ args_info->init_pos_SW_given = 0 ;
+ args_info->init_pos_NW_given = 0 ;
+ args_info->init_pos_center_given = 0 ;
+ args_info->init_ortho_lat_given = 0 ;
+ args_info->init_ortho_lon_given = 0 ;
+ args_info->init_ortho_width_given = 0 ;
+ args_info->projection_cyl_platt_given = 0 ;
+ args_info->projection_cyl_no1_given = 0 ;
+ args_info->projection_pseudo_cyl_no1_given = 0 ;
+ args_info->projection_cyl_mercator_given = 0 ;
+}
+
+static
+void clear_args (struct gengetopt_args_info *args_info)
+{
+ FIX_UNUSED (args_info);
+ args_info->verbose_flag = 0;
+ args_info->quiet_flag = 0;
+ args_info->query_gl_flag = 0;
+ args_info->check_flag = 0;
+ args_info->compiler_flag = 0;
+ args_info->debug_flag = 0;
+ args_info->igc_file_arg = NULL;
+ args_info->igc_file_orig = NULL;
+ args_info->gpsd_flag = 0;
+ args_info->gpsd_server_arg = NULL;
+ args_info->gpsd_server_orig = NULL;
+ args_info->gpsd_port_orig = NULL;
+ args_info->gpsalt_flag = 0;
+ args_info->baroalt_flag = 0;
+ args_info->use_all_fixes_flag = 0;
+ args_info->lat_orig = NULL;
+ args_info->lon_orig = NULL;
+ args_info->get_elevation_flag = 0;
+ args_info->config_file_arg = NULL;
+ args_info->config_file_orig = NULL;
+ args_info->ortho_flag = 0;
+ args_info->perspective_flag = 0;
+ args_info->aov_orig = NULL;
+ args_info->landscape_flag = 0;
+ args_info->flat_flag = 0;
+ args_info->map_flag = 0;
+ args_info->no_map_flag = 0;
+ args_info->map_set_name_arg = NULL;
+ args_info->map_set_name_orig = NULL;
+ args_info->modulate_flag = 0;
+ args_info->no_modulate_flag = 0;
+ args_info->maps_unlighted_flag = 0;
+ args_info->maps_lighted_flag = 0;
+ args_info->no_lighting_flag = 0;
+ args_info->terrain_shading_flag = 0;
+ args_info->shading_scale_orig = NULL;
+ args_info->light_direction_orig = NULL;
+ args_info->airspace_flag = 0;
+ args_info->airspace_wire_flag = 0;
+ args_info->airspace_wire_col_r_orig = NULL;
+ args_info->airspace_wire_col_g_orig = NULL;
+ args_info->airspace_wire_col_b_orig = NULL;
+ args_info->airspace_wire_width_orig = NULL;
+ args_info->airspace_transparent_flag = 0;
+ args_info->no_airspace_flag = 0;
+ args_info->airspace_file_arg = NULL;
+ args_info->airspace_file_orig = NULL;
+ args_info->airspace_limit_orig = NULL;
+ args_info->wire_flag = 0;
+ args_info->filled_flag = 0;
+ args_info->grayscale_flag = 0;
+ args_info->color_flag = 0;
+ args_info->stereo_flag = 0;
+ args_info->no_stereo_flag = 0;
+ args_info->stereo_rg_flag = 0;
+ args_info->no_stereo_rg_flag = 0;
+ args_info->stereo_rb_flag = 0;
+ args_info->no_stereo_rb_flag = 0;
+ args_info->stereo_hw_flag = 0;
+ args_info->no_stereo_hw_flag = 0;
+ args_info->inverse_stereo_flag = 0;
+ args_info->no_inverse_stereo_flag = 0;
+ args_info->eye_dist_orig = NULL;
+ args_info->flat_shading_flag = 0;
+ args_info->gouraud_shading_flag = 0;
+ args_info->quads_flag = 0;
+ args_info->curtain_flag = 0;
+ args_info->no_curtain_flag = 0;
+ args_info->haze_flag = 0;
+ args_info->no_haze_flag = 0;
+ args_info->haze_density_orig = NULL;
+ args_info->colormap_orig = NULL;
+ args_info->colormap_sea_orig = NULL;
+ args_info->colormap_min_orig = NULL;
+ args_info->colormap_max_orig = NULL;
+ args_info->sealevel_orig = NULL;
+ args_info->sealevel2_orig = NULL;
+ args_info->sealevel3_orig = NULL;
+ args_info->ignore_elev_min_orig = NULL;
+ args_info->ignore_elev_max_orig = NULL;
+ args_info->scalez_orig = NULL;
+ args_info->downscaling_orig = NULL;
+ args_info->upscaling_orig = NULL;
+ args_info->fullscreen_flag = 0;
+ args_info->window_flag = 0;
+ args_info->width_orig = NULL;
+ args_info->height_orig = NULL;
+ args_info->border_orig = NULL;
+ args_info->border_lat_orig = NULL;
+ args_info->border_lon_orig = NULL;
+ args_info->offset_orig = NULL;
+ args_info->airfield_elevation_orig = NULL;
+ args_info->marker_pos_orig = NULL;
+ args_info->marker_time_arg = NULL;
+ args_info->marker_time_orig = NULL;
+ args_info->marker_flag = 0;
+ args_info->marker_size_orig = NULL;
+ args_info->no_marker_flag = 0;
+ args_info->info_flag = 0;
+ args_info->no_info_flag = 0;
+ args_info->text_arg = NULL;
+ args_info->text_orig = NULL;
+ args_info->no_position_info_flag = 0;
+ args_info->no_marker_pos_info_flag = 0;
+ args_info->text_size_orig = NULL;
+ args_info->text_width_orig = NULL;
+ args_info->lifts_arg = NULL;
+ args_info->lifts_orig = NULL;
+ args_info->lifts_info_mode_orig = NULL;
+ args_info->waypoints_file_arg = NULL;
+ args_info->waypoints_file_orig = NULL;
+ args_info->waypoints_flag = 0;
+ args_info->no_waypoints_flag = 0;
+ args_info->waypoints_info_mode_orig = NULL;
+ args_info->waypoints_offset_orig = NULL;
+ args_info->waypoints_offset_spheres_orig = NULL;
+ args_info->flighttrack_mode_orig = NULL;
+ args_info->flighttrack_colormap_orig = NULL;
+ args_info->flighttrack_linewidth_orig = NULL;
+ args_info->follow_flag = 0;
+ args_info->no_follow_flag = 0;
+ args_info->marker_range_flag = 0;
+ args_info->no_marker_range_flag = 0;
+ args_info->marker_ahead_orig = NULL;
+ args_info->marker_back_orig = NULL;
+ args_info->movie_flag = 0;
+ args_info->cycles_orig = NULL;
+ args_info->spinning_orig = NULL;
+ args_info->smooth_mouse_flag = 0;
+ args_info->parent_pid_orig = NULL;
+ args_info->compression_flag = 0;
+ args_info->no_compression_flag = 0;
+ args_info->offscreen_flag = 0;
+ args_info->osmesa_flag = 0;
+ args_info->os_outfile_arg = NULL;
+ args_info->os_outfile_orig = NULL;
+ args_info->jpeg_quality_orig = NULL;
+ args_info->image_format_arg = NULL;
+ args_info->image_format_orig = NULL;
+ args_info->save_path_arg = NULL;
+ args_info->save_path_orig = NULL;
+ args_info->basename_arg = NULL;
+ args_info->basename_orig = NULL;
+ args_info->clipping_far_orig = NULL;
+ args_info->clipping_near_orig = NULL;
+ args_info->init_lat_orig = NULL;
+ args_info->init_lon_orig = NULL;
+ args_info->init_alt_orig = NULL;
+ args_info->init_heading_orig = NULL;
+ args_info->init_dive_orig = NULL;
+ args_info->init_pos_N_flag = 0;
+ args_info->init_pos_E_flag = 0;
+ args_info->init_pos_S_flag = 0;
+ args_info->init_pos_W_flag = 0;
+ args_info->init_pos_NE_flag = 0;
+ args_info->init_pos_SE_flag = 0;
+ args_info->init_pos_SW_flag = 0;
+ args_info->init_pos_NW_flag = 0;
+ args_info->init_pos_center_flag = 0;
+ args_info->init_ortho_lat_orig = NULL;
+ args_info->init_ortho_lon_orig = NULL;
+ args_info->init_ortho_width_orig = NULL;
+ args_info->projection_cyl_platt_flag = 0;
+ args_info->projection_cyl_no1_flag = 0;
+ args_info->projection_pseudo_cyl_no1_flag = 0;
+ args_info->projection_cyl_mercator_flag = 0;
+
+}
+
+static
+void init_args_info(struct gengetopt_args_info *args_info)
+{
+
+
+ args_info->help_help = gengetopt_args_info_help[0] ;
+ args_info->version_help = gengetopt_args_info_help[1] ;
+ args_info->verbose_help = gengetopt_args_info_help[2] ;
+ args_info->quiet_help = gengetopt_args_info_help[3] ;
+ args_info->query_gl_help = gengetopt_args_info_help[4] ;
+ args_info->check_help = gengetopt_args_info_help[5] ;
+ args_info->compiler_help = gengetopt_args_info_help[6] ;
+ args_info->debug_help = gengetopt_args_info_help[7] ;
+ args_info->igc_file_help = gengetopt_args_info_help[8] ;
+ args_info->gpsd_help = gengetopt_args_info_help[9] ;
+ args_info->gpsd_server_help = gengetopt_args_info_help[10] ;
+ args_info->gpsd_port_help = gengetopt_args_info_help[11] ;
+ args_info->gpsalt_help = gengetopt_args_info_help[12] ;
+ args_info->baroalt_help = gengetopt_args_info_help[13] ;
+ args_info->use_all_fixes_help = gengetopt_args_info_help[14] ;
+ args_info->lat_help = gengetopt_args_info_help[15] ;
+ args_info->lon_help = gengetopt_args_info_help[16] ;
+ args_info->get_elevation_help = gengetopt_args_info_help[17] ;
+ args_info->config_file_help = gengetopt_args_info_help[18] ;
+ args_info->ortho_help = gengetopt_args_info_help[19] ;
+ args_info->perspective_help = gengetopt_args_info_help[20] ;
+ args_info->aov_help = gengetopt_args_info_help[21] ;
+ args_info->landscape_help = gengetopt_args_info_help[22] ;
+ args_info->flat_help = gengetopt_args_info_help[23] ;
+ args_info->map_help = gengetopt_args_info_help[24] ;
+ args_info->no_map_help = gengetopt_args_info_help[25] ;
+ args_info->map_set_name_help = gengetopt_args_info_help[26] ;
+ args_info->modulate_help = gengetopt_args_info_help[27] ;
+ args_info->no_modulate_help = gengetopt_args_info_help[28] ;
+ args_info->maps_unlighted_help = gengetopt_args_info_help[29] ;
+ args_info->maps_lighted_help = gengetopt_args_info_help[30] ;
+ args_info->no_lighting_help = gengetopt_args_info_help[31] ;
+ args_info->terrain_shading_help = gengetopt_args_info_help[32] ;
+ args_info->shading_scale_help = gengetopt_args_info_help[33] ;
+ args_info->light_direction_help = gengetopt_args_info_help[34] ;
+ args_info->airspace_help = gengetopt_args_info_help[35] ;
+ args_info->airspace_wire_help = gengetopt_args_info_help[36] ;
+ args_info->airspace_wire_col_r_help = gengetopt_args_info_help[37] ;
+ args_info->airspace_wire_col_g_help = gengetopt_args_info_help[38] ;
+ args_info->airspace_wire_col_b_help = gengetopt_args_info_help[39] ;
+ args_info->airspace_wire_width_help = gengetopt_args_info_help[40] ;
+ args_info->airspace_transparent_help = gengetopt_args_info_help[41] ;
+ args_info->no_airspace_help = gengetopt_args_info_help[42] ;
+ args_info->airspace_file_help = gengetopt_args_info_help[43] ;
+ args_info->airspace_limit_help = gengetopt_args_info_help[44] ;
+ args_info->wire_help = gengetopt_args_info_help[45] ;
+ args_info->filled_help = gengetopt_args_info_help[46] ;
+ args_info->grayscale_help = gengetopt_args_info_help[47] ;
+ args_info->color_help = gengetopt_args_info_help[48] ;
+ args_info->stereo_help = gengetopt_args_info_help[49] ;
+ args_info->no_stereo_help = gengetopt_args_info_help[50] ;
+ args_info->stereo_rg_help = gengetopt_args_info_help[51] ;
+ args_info->no_stereo_rg_help = gengetopt_args_info_help[52] ;
+ args_info->stereo_rb_help = gengetopt_args_info_help[53] ;
+ args_info->no_stereo_rb_help = gengetopt_args_info_help[54] ;
+ args_info->stereo_hw_help = gengetopt_args_info_help[55] ;
+ args_info->no_stereo_hw_help = gengetopt_args_info_help[56] ;
+ args_info->inverse_stereo_help = gengetopt_args_info_help[57] ;
+ args_info->no_inverse_stereo_help = gengetopt_args_info_help[58] ;
+ args_info->eye_dist_help = gengetopt_args_info_help[59] ;
+ args_info->flat_shading_help = gengetopt_args_info_help[60] ;
+ args_info->gouraud_shading_help = gengetopt_args_info_help[61] ;
+ args_info->quads_help = gengetopt_args_info_help[62] ;
+ args_info->curtain_help = gengetopt_args_info_help[63] ;
+ args_info->no_curtain_help = gengetopt_args_info_help[64] ;
+ args_info->haze_help = gengetopt_args_info_help[65] ;
+ args_info->no_haze_help = gengetopt_args_info_help[66] ;
+ args_info->haze_density_help = gengetopt_args_info_help[67] ;
+ args_info->colormap_help = gengetopt_args_info_help[68] ;
+ args_info->colormap_sea_help = gengetopt_args_info_help[69] ;
+ args_info->colormap_min_help = gengetopt_args_info_help[70] ;
+ args_info->colormap_max_help = gengetopt_args_info_help[71] ;
+ args_info->sealevel_help = gengetopt_args_info_help[72] ;
+ args_info->sealevel2_help = gengetopt_args_info_help[73] ;
+ args_info->sealevel3_help = gengetopt_args_info_help[74] ;
+ args_info->ignore_elev_min_help = gengetopt_args_info_help[75] ;
+ args_info->ignore_elev_max_help = gengetopt_args_info_help[76] ;
+ args_info->scalez_help = gengetopt_args_info_help[77] ;
+ args_info->downscaling_help = gengetopt_args_info_help[78] ;
+ args_info->upscaling_help = gengetopt_args_info_help[79] ;
+ args_info->fullscreen_help = gengetopt_args_info_help[80] ;
+ args_info->window_help = gengetopt_args_info_help[81] ;
+ args_info->width_help = gengetopt_args_info_help[82] ;
+ args_info->height_help = gengetopt_args_info_help[83] ;
+ args_info->border_help = gengetopt_args_info_help[84] ;
+ args_info->border_lat_help = gengetopt_args_info_help[85] ;
+ args_info->border_lon_help = gengetopt_args_info_help[86] ;
+ args_info->offset_help = gengetopt_args_info_help[87] ;
+ args_info->airfield_elevation_help = gengetopt_args_info_help[88] ;
+ args_info->marker_pos_help = gengetopt_args_info_help[89] ;
+ args_info->marker_time_help = gengetopt_args_info_help[90] ;
+ args_info->marker_help = gengetopt_args_info_help[91] ;
+ args_info->marker_size_help = gengetopt_args_info_help[92] ;
+ args_info->no_marker_help = gengetopt_args_info_help[93] ;
+ args_info->info_help = gengetopt_args_info_help[94] ;
+ args_info->no_info_help = gengetopt_args_info_help[95] ;
+ args_info->text_help = gengetopt_args_info_help[96] ;
+ args_info->no_position_info_help = gengetopt_args_info_help[97] ;
+ args_info->no_marker_pos_info_help = gengetopt_args_info_help[98] ;
+ args_info->text_size_help = gengetopt_args_info_help[99] ;
+ args_info->text_width_help = gengetopt_args_info_help[100] ;
+ args_info->lifts_help = gengetopt_args_info_help[101] ;
+ args_info->lifts_info_mode_help = gengetopt_args_info_help[102] ;
+ args_info->waypoints_file_help = gengetopt_args_info_help[103] ;
+ args_info->waypoints_help = gengetopt_args_info_help[104] ;
+ args_info->no_waypoints_help = gengetopt_args_info_help[105] ;
+ args_info->waypoints_info_mode_help = gengetopt_args_info_help[106] ;
+ args_info->waypoints_offset_help = gengetopt_args_info_help[107] ;
+ args_info->waypoints_offset_spheres_help = gengetopt_args_info_help[108] ;
+ args_info->flighttrack_mode_help = gengetopt_args_info_help[109] ;
+ args_info->flighttrack_colormap_help = gengetopt_args_info_help[110] ;
+ args_info->flighttrack_linewidth_help = gengetopt_args_info_help[111] ;
+ args_info->follow_help = gengetopt_args_info_help[112] ;
+ args_info->no_follow_help = gengetopt_args_info_help[113] ;
+ args_info->marker_range_help = gengetopt_args_info_help[114] ;
+ args_info->no_marker_range_help = gengetopt_args_info_help[115] ;
+ args_info->marker_ahead_help = gengetopt_args_info_help[116] ;
+ args_info->marker_back_help = gengetopt_args_info_help[117] ;
+ args_info->movie_help = gengetopt_args_info_help[118] ;
+ args_info->cycles_help = gengetopt_args_info_help[119] ;
+ args_info->spinning_help = gengetopt_args_info_help[120] ;
+ args_info->smooth_mouse_help = gengetopt_args_info_help[121] ;
+ args_info->parent_pid_help = gengetopt_args_info_help[122] ;
+ args_info->compression_help = gengetopt_args_info_help[123] ;
+ args_info->no_compression_help = gengetopt_args_info_help[124] ;
+ args_info->offscreen_help = gengetopt_args_info_help[125] ;
+ args_info->osmesa_help = gengetopt_args_info_help[126] ;
+ args_info->os_outfile_help = gengetopt_args_info_help[127] ;
+ args_info->jpeg_quality_help = gengetopt_args_info_help[128] ;
+ args_info->image_format_help = gengetopt_args_info_help[129] ;
+ args_info->save_path_help = gengetopt_args_info_help[130] ;
+ args_info->basename_help = gengetopt_args_info_help[131] ;
+ args_info->clipping_far_help = gengetopt_args_info_help[132] ;
+ args_info->clipping_near_help = gengetopt_args_info_help[133] ;
+ args_info->init_lat_help = gengetopt_args_info_help[134] ;
+ args_info->init_lon_help = gengetopt_args_info_help[135] ;
+ args_info->init_alt_help = gengetopt_args_info_help[136] ;
+ args_info->init_heading_help = gengetopt_args_info_help[137] ;
+ args_info->init_dive_help = gengetopt_args_info_help[138] ;
+ args_info->init_pos_N_help = gengetopt_args_info_help[139] ;
+ args_info->init_pos_E_help = gengetopt_args_info_help[140] ;
+ args_info->init_pos_S_help = gengetopt_args_info_help[141] ;
+ args_info->init_pos_W_help = gengetopt_args_info_help[142] ;
+ args_info->init_pos_NE_help = gengetopt_args_info_help[143] ;
+ args_info->init_pos_SE_help = gengetopt_args_info_help[144] ;
+ args_info->init_pos_SW_help = gengetopt_args_info_help[145] ;
+ args_info->init_pos_NW_help = gengetopt_args_info_help[146] ;
+ args_info->init_pos_center_help = gengetopt_args_info_help[147] ;
+ args_info->init_ortho_lat_help = gengetopt_args_info_help[148] ;
+ args_info->init_ortho_lon_help = gengetopt_args_info_help[149] ;
+ args_info->init_ortho_width_help = gengetopt_args_info_help[150] ;
+ args_info->projection_cyl_platt_help = gengetopt_args_info_help[151] ;
+ args_info->projection_cyl_no1_help = gengetopt_args_info_help[152] ;
+ args_info->projection_pseudo_cyl_no1_help = gengetopt_args_info_help[153] ;
+ args_info->projection_cyl_mercator_help = gengetopt_args_info_help[154] ;
+
+}
+
+void
+cmdline_parser_print_version (void)
+{
+ printf ("%s %s\n",
+ (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
+ CMDLINE_PARSER_VERSION);
+
+ if (strlen(gengetopt_args_info_versiontext) > 0)
+ printf("\n%s\n", gengetopt_args_info_versiontext);
+}
+
+static void print_help_common(void) {
+ cmdline_parser_print_version ();
+
+ if (strlen(gengetopt_args_info_purpose) > 0)
+ printf("\n%s\n", gengetopt_args_info_purpose);
+
+ if (strlen(gengetopt_args_info_usage) > 0)
+ printf("\n%s\n", gengetopt_args_info_usage);
+
+ printf("\n");
+
+ if (strlen(gengetopt_args_info_description) > 0)
+ printf("%s\n\n", gengetopt_args_info_description);
+}
+
+void
+cmdline_parser_print_help (void)
+{
+ int i = 0;
+ print_help_common();
+ while (gengetopt_args_info_help[i])
+ printf("%s\n", gengetopt_args_info_help[i++]);
+}
+
+void
+cmdline_parser_init (struct gengetopt_args_info *args_info)
+{
+ clear_given (args_info);
+ clear_args (args_info);
+ init_args_info (args_info);
+}
+
+void
+cmdline_parser_params_init(struct cmdline_parser_params *params)
+{
+ if (params)
+ {
+ params->override = 0;
+ params->initialize = 1;
+ params->check_required = 1;
+ params->check_ambiguity = 0;
+ params->print_errors = 1;
+ }
+}
+
+struct cmdline_parser_params *
+cmdline_parser_params_create(void)
+{
+ struct cmdline_parser_params *params =
+ (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
+ cmdline_parser_params_init(params);
+ return params;
+}
+
+static void
+free_string_field (char **s)
+{
+ if (*s)
+ {
+ free (*s);
+ *s = 0;
+ }
+}
+
+
+static void
+cmdline_parser_release (struct gengetopt_args_info *args_info)
+{
+
+ free_string_field (&(args_info->igc_file_arg));
+ free_string_field (&(args_info->igc_file_orig));
+ free_string_field (&(args_info->gpsd_server_arg));
+ free_string_field (&(args_info->gpsd_server_orig));
+ free_string_field (&(args_info->gpsd_port_orig));
+ free_string_field (&(args_info->lat_orig));
+ free_string_field (&(args_info->lon_orig));
+ free_string_field (&(args_info->config_file_arg));
+ free_string_field (&(args_info->config_file_orig));
+ free_string_field (&(args_info->aov_orig));
+ free_string_field (&(args_info->map_set_name_arg));
+ free_string_field (&(args_info->map_set_name_orig));
+ free_string_field (&(args_info->shading_scale_orig));
+ free_string_field (&(args_info->light_direction_orig));
+ free_string_field (&(args_info->airspace_wire_col_r_orig));
+ free_string_field (&(args_info->airspace_wire_col_g_orig));
+ free_string_field (&(args_info->airspace_wire_col_b_orig));
+ free_string_field (&(args_info->airspace_wire_width_orig));
+ free_string_field (&(args_info->airspace_file_arg));
+ free_string_field (&(args_info->airspace_file_orig));
+ free_string_field (&(args_info->airspace_limit_orig));
+ free_string_field (&(args_info->eye_dist_orig));
+ free_string_field (&(args_info->haze_density_orig));
+ free_string_field (&(args_info->colormap_orig));
+ free_string_field (&(args_info->colormap_sea_orig));
+ free_string_field (&(args_info->colormap_min_orig));
+ free_string_field (&(args_info->colormap_max_orig));
+ free_string_field (&(args_info->sealevel_orig));
+ free_string_field (&(args_info->sealevel2_orig));
+ free_string_field (&(args_info->sealevel3_orig));
+ free_string_field (&(args_info->ignore_elev_min_orig));
+ free_string_field (&(args_info->ignore_elev_max_orig));
+ free_string_field (&(args_info->scalez_orig));
+ free_string_field (&(args_info->downscaling_orig));
+ free_string_field (&(args_info->upscaling_orig));
+ free_string_field (&(args_info->width_orig));
+ free_string_field (&(args_info->height_orig));
+ free_string_field (&(args_info->border_orig));
+ free_string_field (&(args_info->border_lat_orig));
+ free_string_field (&(args_info->border_lon_orig));
+ free_string_field (&(args_info->offset_orig));
+ free_string_field (&(args_info->airfield_elevation_orig));
+ free_string_field (&(args_info->marker_pos_orig));
+ free_string_field (&(args_info->marker_time_arg));
+ free_string_field (&(args_info->marker_time_orig));
+ free_string_field (&(args_info->marker_size_orig));
+ free_string_field (&(args_info->text_arg));
+ free_string_field (&(args_info->text_orig));
+ free_string_field (&(args_info->text_size_orig));
+ free_string_field (&(args_info->text_width_orig));
+ free_string_field (&(args_info->lifts_arg));
+ free_string_field (&(args_info->lifts_orig));
+ free_string_field (&(args_info->lifts_info_mode_orig));
+ free_string_field (&(args_info->waypoints_file_arg));
+ free_string_field (&(args_info->waypoints_file_orig));
+ free_string_field (&(args_info->waypoints_info_mode_orig));
+ free_string_field (&(args_info->waypoints_offset_orig));
+ free_string_field (&(args_info->waypoints_offset_spheres_orig));
+ free_string_field (&(args_info->flighttrack_mode_orig));
+ free_string_field (&(args_info->flighttrack_colormap_orig));
+ free_string_field (&(args_info->flighttrack_linewidth_orig));
+ free_string_field (&(args_info->marker_ahead_orig));
+ free_string_field (&(args_info->marker_back_orig));
+ free_string_field (&(args_info->cycles_orig));
+ free_string_field (&(args_info->spinning_orig));
+ free_string_field (&(args_info->parent_pid_orig));
+ free_string_field (&(args_info->os_outfile_arg));
+ free_string_field (&(args_info->os_outfile_orig));
+ free_string_field (&(args_info->jpeg_quality_orig));
+ free_string_field (&(args_info->image_format_arg));
+ free_string_field (&(args_info->image_format_orig));
+ free_string_field (&(args_info->save_path_arg));
+ free_string_field (&(args_info->save_path_orig));
+ free_string_field (&(args_info->basename_arg));
+ free_string_field (&(args_info->basename_orig));
+ free_string_field (&(args_info->clipping_far_orig));
+ free_string_field (&(args_info->clipping_near_orig));
+ free_string_field (&(args_info->init_lat_orig));
+ free_string_field (&(args_info->init_lon_orig));
+ free_string_field (&(args_info->init_alt_orig));
+ free_string_field (&(args_info->init_heading_orig));
+ free_string_field (&(args_info->init_dive_orig));
+ free_string_field (&(args_info->init_ortho_lat_orig));
+ free_string_field (&(args_info->init_ortho_lon_orig));
+ free_string_field (&(args_info->init_ortho_width_orig));
+
+
+
+ clear_given (args_info);
+}
+
+
+static void
+write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
+{
+ FIX_UNUSED (values);
+ if (arg) {
+ fprintf(outfile, "%s=\"%s\"\n", opt, arg);
+ } else {
+ fprintf(outfile, "%s\n", opt);
+ }
+}
+
+
+int
+cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
+{
+ int i = 0;
+
+ if (!outfile)
+ {
+ fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
+ return EXIT_FAILURE;
+ }
+
+ if (args_info->help_given)
+ write_into_file(outfile, "help", 0, 0 );
+ if (args_info->version_given)
+ write_into_file(outfile, "version", 0, 0 );
+ if (args_info->verbose_given)
+ write_into_file(outfile, "verbose", 0, 0 );
+ if (args_info->quiet_given)
+ write_into_file(outfile, "quiet", 0, 0 );
+ if (args_info->query_gl_given)
+ write_into_file(outfile, "query-gl", 0, 0 );
+ if (args_info->check_given)
+ write_into_file(outfile, "check", 0, 0 );
+ if (args_info->compiler_given)
+ write_into_file(outfile, "compiler", 0, 0 );
+ if (args_info->debug_given)
+ write_into_file(outfile, "debug", 0, 0 );
+ if (args_info->igc_file_given)
+ write_into_file(outfile, "igc-file", args_info->igc_file_orig, 0);
+ if (args_info->gpsd_given)
+ write_into_file(outfile, "gpsd", 0, 0 );
+ if (args_info->gpsd_server_given)
+ write_into_file(outfile, "gpsd-server", args_info->gpsd_server_orig, 0);
+ if (args_info->gpsd_port_given)
+ write_into_file(outfile, "gpsd-port", args_info->gpsd_port_orig, 0);
+ if (args_info->gpsalt_given)
+ write_into_file(outfile, "gpsalt", 0, 0 );
+ if (args_info->baroalt_given)
+ write_into_file(outfile, "baroalt", 0, 0 );
+ if (args_info->use_all_fixes_given)
+ write_into_file(outfile, "use-all-fixes", 0, 0 );
+ if (args_info->lat_given)
+ write_into_file(outfile, "lat", args_info->lat_orig, 0);
+ if (args_info->lon_given)
+ write_into_file(outfile, "lon", args_info->lon_orig, 0);
+ if (args_info->get_elevation_given)
+ write_into_file(outfile, "get-elevation", 0, 0 );
+ if (args_info->config_file_given)
+ write_into_file(outfile, "config-file", args_info->config_file_orig, 0);
+ if (args_info->ortho_given)
+ write_into_file(outfile, "ortho", 0, 0 );
+ if (args_info->perspective_given)
+ write_into_file(outfile, "perspective", 0, 0 );
+ if (args_info->aov_given)
+ write_into_file(outfile, "aov", args_info->aov_orig, 0);
+ if (args_info->landscape_given)
+ write_into_file(outfile, "landscape", 0, 0 );
+ if (args_info->flat_given)
+ write_into_file(outfile, "flat", 0, 0 );
+ if (args_info->map_given)
+ write_into_file(outfile, "map", 0, 0 );
+ if (args_info->no_map_given)
+ write_into_file(outfile, "no-map", 0, 0 );
+ if (args_info->map_set_name_given)
+ write_into_file(outfile, "map-set-name", args_info->map_set_name_orig, 0);
+ if (args_info->modulate_given)
+ write_into_file(outfile, "modulate", 0, 0 );
+ if (args_info->no_modulate_given)
+ write_into_file(outfile, "no-modulate", 0, 0 );
+ if (args_info->maps_unlighted_given)
+ write_into_file(outfile, "maps-unlighted", 0, 0 );
+ if (args_info->maps_lighted_given)
+ write_into_file(outfile, "maps-lighted", 0, 0 );
+ if (args_info->no_lighting_given)
+ write_into_file(outfile, "no-lighting", 0, 0 );
+ if (args_info->terrain_shading_given)
+ write_into_file(outfile, "terrain-shading", 0, 0 );
+ if (args_info->shading_scale_given)
+ write_into_file(outfile, "shading-scale", args_info->shading_scale_orig, 0);
+ if (args_info->light_direction_given)
+ write_into_file(outfile, "light-direction", args_info->light_direction_orig, 0);
+ if (args_info->airspace_given)
+ write_into_file(outfile, "airspace", 0, 0 );
+ if (args_info->airspace_wire_given)
+ write_into_file(outfile, "airspace-wire", 0, 0 );
+ if (args_info->airspace_wire_col_r_given)
+ write_into_file(outfile, "airspace-wire-col-r", args_info->airspace_wire_col_r_orig, 0);
+ if (args_info->airspace_wire_col_g_given)
+ write_into_file(outfile, "airspace-wire-col-g", args_info->airspace_wire_col_g_orig, 0);
+ if (args_info->airspace_wire_col_b_given)
+ write_into_file(outfile, "airspace-wire-col-b", args_info->airspace_wire_col_b_orig, 0);
+ if (args_info->airspace_wire_width_given)
+ write_into_file(outfile, "airspace-wire-width", args_info->airspace_wire_width_orig, 0);
+ if (args_info->airspace_transparent_given)
+ write_into_file(outfile, "airspace-transparent", 0, 0 );
+ if (args_info->no_airspace_given)
+ write_into_file(outfile, "no-airspace", 0, 0 );
+ if (args_info->airspace_file_given)
+ write_into_file(outfile, "airspace-file", args_info->airspace_file_orig, 0);
+ if (args_info->airspace_limit_given)
+ write_into_file(outfile, "airspace-limit", args_info->airspace_limit_orig, 0);
+ if (args_info->wire_given)
+ write_into_file(outfile, "wire", 0, 0 );
+ if (args_info->filled_given)
+ write_into_file(outfile, "filled", 0, 0 );
+ if (args_info->grayscale_given)
+ write_into_file(outfile, "grayscale", 0, 0 );
+ if (args_info->color_given)
+ write_into_file(outfile, "color", 0, 0 );
+ if (args_info->stereo_given)
+ write_into_file(outfile, "stereo", 0, 0 );
+ if (args_info->no_stereo_given)
+ write_into_file(outfile, "no-stereo", 0, 0 );
+ if (args_info->stereo_rg_given)
+ write_into_file(outfile, "stereo-rg", 0, 0 );
+ if (args_info->no_stereo_rg_given)
+ write_into_file(outfile, "no-stereo-rg", 0, 0 );
+ if (args_info->stereo_rb_given)
+ write_into_file(outfile, "stereo-rb", 0, 0 );
+ if (args_info->no_stereo_rb_given)
+ write_into_file(outfile, "no-stereo-rb", 0, 0 );
+ if (args_info->stereo_hw_given)
+ write_into_file(outfile, "stereo-hw", 0, 0 );
+ if (args_info->no_stereo_hw_given)
+ write_into_file(outfile, "no-stereo-hw", 0, 0 );
+ if (args_info->inverse_stereo_given)
+ write_into_file(outfile, "inverse-stereo", 0, 0 );
+ if (args_info->no_inverse_stereo_given)
+ write_into_file(outfile, "no-inverse-stereo", 0, 0 );
+ if (args_info->eye_dist_given)
+ write_into_file(outfile, "eye-dist", args_info->eye_dist_orig, 0);
+ if (args_info->flat_shading_given)
+ write_into_file(outfile, "flat-shading", 0, 0 );
+ if (args_info->gouraud_shading_given)
+ write_into_file(outfile, "gouraud-shading", 0, 0 );
+ if (args_info->quads_given)
+ write_into_file(outfile, "quads", 0, 0 );
+ if (args_info->curtain_given)
+ write_into_file(outfile, "curtain", 0, 0 );
+ if (args_info->no_curtain_given)
+ write_into_file(outfile, "no-curtain", 0, 0 );
+ if (args_info->haze_given)
+ write_into_file(outfile, "haze", 0, 0 );
+ if (args_info->no_haze_given)
+ write_into_file(outfile, "no-haze", 0, 0 );
+ if (args_info->haze_density_given)
+ write_into_file(outfile, "haze-density", args_info->haze_density_orig, 0);
+ if (args_info->colormap_given)
+ write_into_file(outfile, "colormap", args_info->colormap_orig, 0);
+ if (args_info->colormap_sea_given)
+ write_into_file(outfile, "colormap-sea", args_info->colormap_sea_orig, 0);
+ if (args_info->colormap_min_given)
+ write_into_file(outfile, "colormap-min", args_info->colormap_min_orig, 0);
+ if (args_info->colormap_max_given)
+ write_into_file(outfile, "colormap-max", args_info->colormap_max_orig, 0);
+ if (args_info->sealevel_given)
+ write_into_file(outfile, "sealevel", args_info->sealevel_orig, 0);
+ if (args_info->sealevel2_given)
+ write_into_file(outfile, "sealevel2", args_info->sealevel2_orig, 0);
+ if (args_info->sealevel3_given)
+ write_into_file(outfile, "sealevel3", args_info->sealevel3_orig, 0);
+ if (args_info->ignore_elev_min_given)
+ write_into_file(outfile, "ignore-elev-min", args_info->ignore_elev_min_orig, 0);
+ if (args_info->ignore_elev_max_given)
+ write_into_file(outfile, "ignore-elev-max", args_info->ignore_elev_max_orig, 0);
+ if (args_info->scalez_given)
+ write_into_file(outfile, "scalez", args_info->scalez_orig, 0);
+ if (args_info->downscaling_given)
+ write_into_file(outfile, "downscaling", args_info->downscaling_orig, 0);
+ if (args_info->upscaling_given)
+ write_into_file(outfile, "upscaling", args_info->upscaling_orig, 0);
+ if (args_info->fullscreen_given)
+ write_into_file(outfile, "fullscreen", 0, 0 );
+ if (args_info->window_given)
+ write_into_file(outfile, "window", 0, 0 );
+ if (args_info->width_given)
+ write_into_file(outfile, "width", args_info->width_orig, 0);
+ if (args_info->height_given)
+ write_into_file(outfile, "height", args_info->height_orig, 0);
+ if (args_info->border_given)
+ write_into_file(outfile, "border", args_info->border_orig, 0);
+ if (args_info->border_lat_given)
+ write_into_file(outfile, "border-lat", args_info->border_lat_orig, 0);
+ if (args_info->border_lon_given)
+ write_into_file(outfile, "border-lon", args_info->border_lon_orig, 0);
+ if (args_info->offset_given)
+ write_into_file(outfile, "offset", args_info->offset_orig, 0);
+ if (args_info->airfield_elevation_given)
+ write_into_file(outfile, "airfield-elevation", args_info->airfield_elevation_orig, 0);
+ if (args_info->marker_pos_given)
+ write_into_file(outfile, "marker-pos", args_info->marker_pos_orig, 0);
+ if (args_info->marker_time_given)
+ write_into_file(outfile, "marker-time", args_info->marker_time_orig, 0);
+ if (args_info->marker_given)
+ write_into_file(outfile, "marker", 0, 0 );
+ if (args_info->marker_size_given)
+ write_into_file(outfile, "marker-size", args_info->marker_size_orig, 0);
+ if (args_info->no_marker_given)
+ write_into_file(outfile, "no-marker", 0, 0 );
+ if (args_info->info_given)
+ write_into_file(outfile, "info", 0, 0 );
+ if (args_info->no_info_given)
+ write_into_file(outfile, "no-info", 0, 0 );
+ if (args_info->text_given)
+ write_into_file(outfile, "text", args_info->text_orig, 0);
+ if (args_info->no_position_info_given)
+ write_into_file(outfile, "no-position-info", 0, 0 );
+ if (args_info->no_marker_pos_info_given)
+ write_into_file(outfile, "no-marker-pos-info", 0, 0 );
+ if (args_info->text_size_given)
+ write_into_file(outfile, "text-size", args_info->text_size_orig, 0);
+ if (args_info->text_width_given)
+ write_into_file(outfile, "text-width", args_info->text_width_orig, 0);
+ if (args_info->lifts_given)
+ write_into_file(outfile, "lifts", args_info->lifts_orig, 0);
+ if (args_info->lifts_info_mode_given)
+ write_into_file(outfile, "lifts-info-mode", args_info->lifts_info_mode_orig, 0);
+ if (args_info->waypoints_file_given)
+ write_into_file(outfile, "waypoints-file", args_info->waypoints_file_orig, 0);
+ if (args_info->waypoints_given)
+ write_into_file(outfile, "waypoints", 0, 0 );
+ if (args_info->no_waypoints_given)
+ write_into_file(outfile, "no-waypoints", 0, 0 );
+ if (args_info->waypoints_info_mode_given)
+ write_into_file(outfile, "waypoints-info-mode", args_info->waypoints_info_mode_orig, 0);
+ if (args_info->waypoints_offset_given)
+ write_into_file(outfile, "waypoints-offset", args_info->waypoints_offset_orig, 0);
+ if (args_info->waypoints_offset_spheres_given)
+ write_into_file(outfile, "waypoints-offset-spheres", args_info->waypoints_offset_spheres_orig, 0);
+ if (args_info->flighttrack_mode_given)
+ write_into_file(outfile, "flighttrack-mode", args_info->flighttrack_mode_orig, 0);
+ if (args_info->flighttrack_colormap_given)
+ write_into_file(outfile, "flighttrack-colormap", args_info->flighttrack_colormap_orig, 0);
+ if (args_info->flighttrack_linewidth_given)
+ write_into_file(outfile, "flighttrack-linewidth", args_info->flighttrack_linewidth_orig, 0);
+ if (args_info->follow_given)
+ write_into_file(outfile, "follow", 0, 0 );
+ if (args_info->no_follow_given)
+ write_into_file(outfile, "no-follow", 0, 0 );
+ if (args_info->marker_range_given)
+ write_into_file(outfile, "marker-range", 0, 0 );
+ if (args_info->no_marker_range_given)
+ write_into_file(outfile, "no-marker-range", 0, 0 );
+ if (args_info->marker_ahead_given)
+ write_into_file(outfile, "marker-ahead", args_info->marker_ahead_orig, 0);
+ if (args_info->marker_back_given)
+ write_into_file(outfile, "marker-back", args_info->marker_back_orig, 0);
+ if (args_info->movie_given)
+ write_into_file(outfile, "movie", 0, 0 );
+ if (args_info->cycles_given)
+ write_into_file(outfile, "cycles", args_info->cycles_orig, 0);
+ if (args_info->spinning_given)
+ write_into_file(outfile, "spinning", args_info->spinning_orig, 0);
+ if (args_info->smooth_mouse_given)
+ write_into_file(outfile, "smooth-mouse", 0, 0 );
+ if (args_info->parent_pid_given)
+ write_into_file(outfile, "parent-pid", args_info->parent_pid_orig, 0);
+ if (args_info->compression_given)
+ write_into_file(outfile, "compression", 0, 0 );
+ if (args_info->no_compression_given)
+ write_into_file(outfile, "no-compression", 0, 0 );
+ if (args_info->offscreen_given)
+ write_into_file(outfile, "offscreen", 0, 0 );
+ if (args_info->osmesa_given)
+ write_into_file(outfile, "osmesa", 0, 0 );
+ if (args_info->os_outfile_given)
+ write_into_file(outfile, "os-outfile", args_info->os_outfile_orig, 0);
+ if (args_info->jpeg_quality_given)
+ write_into_file(outfile, "jpeg-quality", args_info->jpeg_quality_orig, 0);
+ if (args_info->image_format_given)
+ write_into_file(outfile, "image-format", args_info->image_format_orig, 0);
+ if (args_info->save_path_given)
+ write_into_file(outfile, "save-path", args_info->save_path_orig, 0);
+ if (args_info->basename_given)
+ write_into_file(outfile, "basename", args_info->basename_orig, 0);
+ if (args_info->clipping_far_given)
+ write_into_file(outfile, "clipping-far", args_info->clipping_far_orig, 0);
+ if (args_info->clipping_near_given)
+ write_into_file(outfile, "clipping-near", args_info->clipping_near_orig, 0);
+ if (args_info->init_lat_given)
+ write_into_file(outfile, "init-lat", args_info->init_lat_orig, 0);
+ if (args_info->init_lon_given)
+ write_into_file(outfile, "init-lon", args_info->init_lon_orig, 0);
+ if (args_info->init_alt_given)
+ write_into_file(outfile, "init-alt", args_info->init_alt_orig, 0);
+ if (args_info->init_heading_given)
+ write_into_file(outfile, "init-heading", args_info->init_heading_orig, 0);
+ if (args_info->init_dive_given)
+ write_into_file(outfile, "init-dive", args_info->init_dive_orig, 0);
+ if (args_info->init_pos_N_given)
+ write_into_file(outfile, "init-pos-N", 0, 0 );
+ if (args_info->init_pos_E_given)
+ write_into_file(outfile, "init-pos-E", 0, 0 );
+ if (args_info->init_pos_S_given)
+ write_into_file(outfile, "init-pos-S", 0, 0 );
+ if (args_info->init_pos_W_given)
+ write_into_file(outfile, "init-pos-W", 0, 0 );
+ if (args_info->init_pos_NE_given)
+ write_into_file(outfile, "init-pos-NE", 0, 0 );
+ if (args_info->init_pos_SE_given)
+ write_into_file(outfile, "init-pos-SE", 0, 0 );
+ if (args_info->init_pos_SW_given)
+ write_into_file(outfile, "init-pos-SW", 0, 0 );
+ if (args_info->init_pos_NW_given)
+ write_into_file(outfile, "init-pos-NW", 0, 0 );
+ if (args_info->init_pos_center_given)
+ write_into_file(outfile, "init-pos-center", 0, 0 );
+ if (args_info->init_ortho_lat_given)
+ write_into_file(outfile, "init-ortho-lat", args_info->init_ortho_lat_orig, 0);
+ if (args_info->init_ortho_lon_given)
+ write_into_file(outfile, "init-ortho-lon", args_info->init_ortho_lon_orig, 0);
+ if (args_info->init_ortho_width_given)
+ write_into_file(outfile, "init-ortho-width", args_info->init_ortho_width_orig, 0);
+ if (args_info->projection_cyl_platt_given)
+ write_into_file(outfile, "projection-cyl-platt", 0, 0 );
+ if (args_info->projection_cyl_no1_given)
+ write_into_file(outfile, "projection-cyl-no1", 0, 0 );
+ if (args_info->projection_pseudo_cyl_no1_given)
+ write_into_file(outfile, "projection-pseudo-cyl-no1", 0, 0 );
+ if (args_info->projection_cyl_mercator_given)
+ write_into_file(outfile, "projection-cyl-mercator", 0, 0 );
+
+
+ i = EXIT_SUCCESS;
+ return i;
+}
+
+int
+cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
+{
+ FILE *outfile;
+ int i = 0;
+
+ outfile = fopen(filename, "w");
+
+ if (!outfile)
+ {
+ fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
+ return EXIT_FAILURE;
+ }
+
+ i = cmdline_parser_dump(outfile, args_info);
+ fclose (outfile);
+
+ return i;
+}
+
+void
+cmdline_parser_free (struct gengetopt_args_info *args_info)
+{
+ cmdline_parser_release (args_info);
+}
+
+/** @brief replacement of strdup, which is not standard */
+char *
+gengetopt_strdup (const char *s)
+{
+ char *result = 0;
+ if (!s)
+ return result;
+
+ result = (char*)malloc(strlen(s) + 1);
+ if (result == (char*)0)
+ return (char*)0;
+ strcpy(result, s);
+ return result;
+}
+
+int
+cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
+{
+ return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
+}
+
+int
+cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
+ struct cmdline_parser_params *params)
+{
+ int result;
+ result = cmdline_parser_internal (argc, argv, args_info, params, 0);
+
+ if (result == EXIT_FAILURE)
+ {
+ cmdline_parser_free (args_info);
+ exit (EXIT_FAILURE);
+ }
+
+ return result;
+}
+
+int
+cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
+{
+ int result;
+ struct cmdline_parser_params params;
+
+ params.override = override;
+ params.initialize = initialize;
+ params.check_required = check_required;
+ params.check_ambiguity = 0;
+ params.print_errors = 1;
+
+ result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
+
+ if (result == EXIT_FAILURE)
+ {
+ cmdline_parser_free (args_info);
+ exit (EXIT_FAILURE);
+ }
+
+ return result;
+}
+
+int
+cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
+{
+ FIX_UNUSED (args_info);
+ FIX_UNUSED (prog_name);
+ return EXIT_SUCCESS;
+}
+
+/*
+ * Extracted from the glibc source tree, version 2.3.6
+ *
+ * Licensed under the GPL as per the whole glibc source tree.
+ *
+ * This file was modified so that getopt_long can be called
+ * many times without risking previous memory to be spoiled.
+ *
+ * Modified by Andre Noll and Lorenzo Bettini for use in
+ * GNU gengetopt generated files.
+ *
+ */
+
+/*
+ * we must include anything we need since this file is not thought to be
+ * inserted in a file already using getopt.h
+ *
+ * Lorenzo
+ */
+
+struct option
+{
+ const char *name;
+ /* has_arg can't be an enum because some compilers complain about
+ type mismatches in all the code that assumes it is an int. */
+ int has_arg;
+ int *flag;
+ int val;
+};
+
+/* This version of `getopt' appears to the caller like standard Unix `getopt'
+ but it behaves differently for the user, since it allows the user
+ to intersperse the options with the other arguments.
+
+ As `getopt' works, it permutes the elements of ARGV so that,
+ when it is done, all the options precede everything else. Thus
+ all application programs are extended to handle flexible argument order.
+*/
+/*
+ If the field `flag' is not NULL, it points to a variable that is set
+ to the value given in the field `val' when the option is found, but
+ left unchanged if the option is not found.
+
+ To have a long-named option do something other than set an `int' to
+ a compiled-in constant, such as set a value from `custom_optarg', set the
+ option's `flag' field to zero and its `val' field to a nonzero
+ value (the equivalent single-letter option character, if there is
+ one). For long options that have a zero `flag' field, `getopt'
+ returns the contents of the `val' field. */
+
+/* Names for the values of the `has_arg' field of `struct option'. */
+#ifndef no_argument
+#define no_argument 0
+#endif
+
+#ifndef required_argument
+#define required_argument 1
+#endif
+
+#ifndef optional_argument
+#define optional_argument 2
+#endif
+
+struct custom_getopt_data {
+ /*
+ * These have exactly the same meaning as the corresponding global variables,
+ * except that they are used for the reentrant versions of getopt.
+ */
+ int custom_optind;
+ int custom_opterr;
+ int custom_optopt;
+ char *custom_optarg;
+
+ /* True if the internal members have been initialized. */
+ int initialized;
+
+ /*
+ * The next char to be scanned in the option-element in which the last option
+ * character we returned was found. This allows us to pick up the scan where
+ * we left off. If this is zero, or a null string, it means resume the scan by
+ * advancing to the next ARGV-element.
+ */
+ char *nextchar;
+
+ /*
+ * Describe the part of ARGV that contains non-options that have been skipped.
+ * `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is
+ * the index after the last of them.
+ */
+ int first_nonopt;
+ int last_nonopt;
+};
+
+/*
+ * the variables optarg, optind, opterr and optopt are renamed with
+ * the custom_ prefix so that they don't interfere with getopt ones.
+ *
+ * Moreover they're static so they are visible only from within the
+ * file where this very file will be included.
+ */
+
+/*
+ * For communication from `custom_getopt' to the caller. When `custom_getopt' finds an
+ * option that takes an argument, the argument value is returned here.
+ */
+static char *custom_optarg;
+
+/*
+ * Index in ARGV of the next element to be scanned. This is used for
+ * communication to and from the caller and for communication between
+ * successive calls to `custom_getopt'.
+ *
+ * On entry to `custom_getopt', 1 means this is the first call; initialize.
+ *
+ * When `custom_getopt' returns -1, this is the index of the first of the non-option
+ * elements that the caller should itself scan.
+ *
+ * Otherwise, `custom_optind' communicates from one call to the next how much of ARGV
+ * has been scanned so far.
+ *
+ * 1003.2 says this must be 1 before any call.
+ */
+static int custom_optind = 1;
+
+/*
+ * Callers store zero here to inhibit the error message for unrecognized
+ * options.
+ */
+static int custom_opterr = 1;
+
+/*
+ * Set to an option character which was unrecognized. This must be initialized
+ * on some systems to avoid linking in the system's own getopt implementation.
+ */
+static int custom_optopt = '?';
+
+/*
+ * Exchange two adjacent subsequences of ARGV. One subsequence is elements
+ * [first_nonopt,last_nonopt) which contains all the non-options that have been
+ * skipped so far. The other is elements [last_nonopt,custom_optind), which contains
+ * all the options processed since those non-options were skipped.
+ * `first_nonopt' and `last_nonopt' are relocated so that they describe the new
+ * indices of the non-options in ARGV after they are moved.
+ */
+static void exchange(char **argv, struct custom_getopt_data *d)
+{
+ int bottom = d->first_nonopt;
+ int middle = d->last_nonopt;
+ int top = d->custom_optind;
+ char *tem;
+
+ /*
+ * Exchange the shorter segment with the far end of the longer segment.
+ * That puts the shorter segment into the right place. It leaves the
+ * longer segment in the right place overall, but it consists of two
+ * parts that need to be swapped next.
+ */
+ while (top > middle && middle > bottom) {
+ if (top - middle > middle - bottom) {
+ /* Bottom segment is the short one. */
+ int len = middle - bottom;
+ int i;
+
+ /* Swap it with the top part of the top segment. */
+ for (i = 0; i < len; i++) {
+ tem = argv[bottom + i];
+ argv[bottom + i] =
+ argv[top - (middle - bottom) + i];
+ argv[top - (middle - bottom) + i] = tem;
+ }
+ /* Exclude the moved bottom segment from further swapping. */
+ top -= len;
+ } else {
+ /* Top segment is the short one. */
+ int len = top - middle;
+ int i;
+
+ /* Swap it with the bottom part of the bottom segment. */
+ for (i = 0; i < len; i++) {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[middle + i];
+ argv[middle + i] = tem;
+ }
+ /* Exclude the moved top segment from further swapping. */
+ bottom += len;
+ }
+ }
+ /* Update records for the slots the non-options now occupy. */
+ d->first_nonopt += (d->custom_optind - d->last_nonopt);
+ d->last_nonopt = d->custom_optind;
+}
+
+/* Initialize the internal data when the first call is made. */
+static void custom_getopt_initialize(struct custom_getopt_data *d)
+{
+ /*
+ * Start processing options with ARGV-element 1 (since ARGV-element 0
+ * is the program name); the sequence of previously skipped non-option
+ * ARGV-elements is empty.
+ */
+ d->first_nonopt = d->last_nonopt = d->custom_optind;
+ d->nextchar = NULL;
+ d->initialized = 1;
+}
+
+#define NONOPTION_P (argv[d->custom_optind][0] != '-' || argv[d->custom_optind][1] == '\0')
+
+/* return: zero: continue, nonzero: return given value to user */
+static int shuffle_argv(int argc, char *const *argv,const struct option *longopts,
+ struct custom_getopt_data *d)
+{
+ /*
+ * Give FIRST_NONOPT & LAST_NONOPT rational values if CUSTOM_OPTIND has been
+ * moved back by the user (who may also have changed the arguments).
+ */
+ if (d->last_nonopt > d->custom_optind)
+ d->last_nonopt = d->custom_optind;
+ if (d->first_nonopt > d->custom_optind)
+ d->first_nonopt = d->custom_optind;
+ /*
+ * If we have just processed some options following some
+ * non-options, exchange them so that the options come first.
+ */
+ if (d->first_nonopt != d->last_nonopt &&
+ d->last_nonopt != d->custom_optind)
+ exchange((char **) argv, d);
+ else if (d->last_nonopt != d->custom_optind)
+ d->first_nonopt = d->custom_optind;
+ /*
+ * Skip any additional non-options and extend the range of
+ * non-options previously skipped.
+ */
+ while (d->custom_optind < argc && NONOPTION_P)
+ d->custom_optind++;
+ d->last_nonopt = d->custom_optind;
+ /*
+ * The special ARGV-element `--' means premature end of options. Skip
+ * it like a null option, then exchange with previous non-options as if
+ * it were an option, then skip everything else like a non-option.
+ */
+ if (d->custom_optind != argc && !strcmp(argv[d->custom_optind], "--")) {
+ d->custom_optind++;
+ if (d->first_nonopt != d->last_nonopt
+ && d->last_nonopt != d->custom_optind)
+ exchange((char **) argv, d);
+ else if (d->first_nonopt == d->last_nonopt)
+ d->first_nonopt = d->custom_optind;
+ d->last_nonopt = argc;
+ d->custom_optind = argc;
+ }
+ /*
+ * If we have done all the ARGV-elements, stop the scan and back over
+ * any non-options that we skipped and permuted.
+ */
+ if (d->custom_optind == argc) {
+ /*
+ * Set the next-arg-index to point at the non-options that we
+ * previously skipped, so the caller will digest them.
+ */
+ if (d->first_nonopt != d->last_nonopt)
+ d->custom_optind = d->first_nonopt;
+ return -1;
+ }
+ /*
+ * If we have come to a non-option and did not permute it, either stop
+ * the scan or describe it to the caller and pass it by.
+ */
+ if (NONOPTION_P) {
+ d->custom_optarg = argv[d->custom_optind++];
+ return 1;
+ }
+ /*
+ * We have found another option-ARGV-element. Skip the initial
+ * punctuation.
+ */
+ d->nextchar = (argv[d->custom_optind] + 1 + (longopts != NULL && argv[d->custom_optind][1] == '-'));
+ return 0;
+}
+
+/*
+ * Check whether the ARGV-element is a long option.
+ *
+ * If there's a long option "fubar" and the ARGV-element is "-fu", consider
+ * that an abbreviation of the long option, just like "--fu", and not "-f" with
+ * arg "u".
+ *
+ * This distinction seems to be the most useful approach.
+ *
+ */
+static int check_long_opt(int argc, char *const *argv, const char *optstring,
+ const struct option *longopts, int *longind,
+ int print_errors, struct custom_getopt_data *d)
+{
+ char *nameend;
+ const struct option *p;
+ const struct option *pfound = NULL;
+ int exact = 0;
+ int ambig = 0;
+ int indfound = -1;
+ int option_index;
+
+ for (nameend = d->nextchar; *nameend && *nameend != '='; nameend++)
+ /* Do nothing. */ ;
+
+ /* Test all long options for either exact match or abbreviated matches */
+ for (p = longopts, option_index = 0; p->name; p++, option_index++)
+ if (!strncmp(p->name, d->nextchar, nameend - d->nextchar)) {
+ if ((unsigned int) (nameend - d->nextchar)
+ == (unsigned int) strlen(p->name)) {
+ /* Exact match found. */
+ pfound = p;
+ indfound = option_index;
+ exact = 1;
+ break;
+ } else if (pfound == NULL) {
+ /* First nonexact match found. */
+ pfound = p;
+ indfound = option_index;
+ } else if (pfound->has_arg != p->has_arg
+ || pfound->flag != p->flag
+ || pfound->val != p->val)
+ /* Second or later nonexact match found. */
+ ambig = 1;
+ }
+ if (ambig && !exact) {
+ if (print_errors) {
+ fprintf(stderr,
+ "%s: option `%s' is ambiguous\n",
+ argv[0], argv[d->custom_optind]);
+ }
+ d->nextchar += strlen(d->nextchar);
+ d->custom_optind++;
+ d->custom_optopt = 0;
+ return '?';
+ }
+ if (pfound) {
+ option_index = indfound;
+ d->custom_optind++;
+ if (*nameend) {
+ if (pfound->has_arg != no_argument)
+ d->custom_optarg = nameend + 1;
+ else {
+ if (print_errors) {
+ if (argv[d->custom_optind - 1][1] == '-') {
+ /* --option */
+ fprintf(stderr, "%s: option `--%s' doesn't allow an argument\n",
+ argv[0], pfound->name);
+ } else {
+ /* +option or -option */
+ fprintf(stderr, "%s: option `%c%s' doesn't allow an argument\n",
+ argv[0], argv[d->custom_optind - 1][0], pfound->name);
+ }
+
+ }
+ d->nextchar += strlen(d->nextchar);
+ d->custom_optopt = pfound->val;
+ return '?';
+ }
+ } else if (pfound->has_arg == required_argument) {
+ if (d->custom_optind < argc)
+ d->custom_optarg = argv[d->custom_optind++];
+ else {
+ if (print_errors) {
+ fprintf(stderr,
+ "%s: option `%s' requires an argument\n",
+ argv[0],
+ argv[d->custom_optind - 1]);
+ }
+ d->nextchar += strlen(d->nextchar);
+ d->custom_optopt = pfound->val;
+ return optstring[0] == ':' ? ':' : '?';
+ }
+ }
+ d->nextchar += strlen(d->nextchar);
+ if (longind != NULL)
+ *longind = option_index;
+ if (pfound->flag) {
+ *(pfound->flag) = pfound->val;
+ return 0;
+ }
+ return pfound->val;
+ }
+ /*
+ * Can't find it as a long option. If this is not getopt_long_only, or
+ * the option starts with '--' or is not a valid short option, then
+ * it's an error. Otherwise interpret it as a short option.
+ */
+ if (print_errors) {
+ if (argv[d->custom_optind][1] == '-') {
+ /* --option */
+ fprintf(stderr,
+ "%s: unrecognized option `--%s'\n",
+ argv[0], d->nextchar);
+ } else {
+ /* +option or -option */
+ fprintf(stderr,
+ "%s: unrecognized option `%c%s'\n",
+ argv[0], argv[d->custom_optind][0],
+ d->nextchar);
+ }
+ }
+ d->nextchar = (char *) "";
+ d->custom_optind++;
+ d->custom_optopt = 0;
+ return '?';
+}
+
+static int check_short_opt(int argc, char *const *argv, const char *optstring,
+ int print_errors, struct custom_getopt_data *d)
+{
+ char c = *d->nextchar++;
+ const char *temp = strchr(optstring, c);
+
+ /* Increment `custom_optind' when we start to process its last character. */
+ if (*d->nextchar == '\0')
+ ++d->custom_optind;
+ if (!temp || c == ':') {
+ if (print_errors)
+ fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
+
+ d->custom_optopt = c;
+ return '?';
+ }
+ if (temp[1] == ':') {
+ if (temp[2] == ':') {
+ /* This is an option that accepts an argument optionally. */
+ if (*d->nextchar != '\0') {
+ d->custom_optarg = d->nextchar;
+ d->custom_optind++;
+ } else
+ d->custom_optarg = NULL;
+ d->nextchar = NULL;
+ } else {
+ /* This is an option that requires an argument. */
+ if (*d->nextchar != '\0') {
+ d->custom_optarg = d->nextchar;
+ /*
+ * If we end this ARGV-element by taking the
+ * rest as an arg, we must advance to the next
+ * element now.
+ */
+ d->custom_optind++;
+ } else if (d->custom_optind == argc) {
+ if (print_errors) {
+ fprintf(stderr,
+ "%s: option requires an argument -- %c\n",
+ argv[0], c);
+ }
+ d->custom_optopt = c;
+ if (optstring[0] == ':')
+ c = ':';
+ else
+ c = '?';
+ } else
+ /*
+ * We already incremented `custom_optind' once;
+ * increment it again when taking next ARGV-elt
+ * as argument.
+ */
+ d->custom_optarg = argv[d->custom_optind++];
+ d->nextchar = NULL;
+ }
+ }
+ return c;
+}
+
+/*
+ * Scan elements of ARGV for option characters given in OPTSTRING.
+ *
+ * If an element of ARGV starts with '-', and is not exactly "-" or "--",
+ * then it is an option element. The characters of this element
+ * (aside from the initial '-') are option characters. If `getopt'
+ * is called repeatedly, it returns successively each of the option characters
+ * from each of the option elements.
+ *
+ * If `getopt' finds another option character, it returns that character,
+ * updating `custom_optind' and `nextchar' so that the next call to `getopt' can
+ * resume the scan with the following option character or ARGV-element.
+ *
+ * If there are no more option characters, `getopt' returns -1.
+ * Then `custom_optind' is the index in ARGV of the first ARGV-element
+ * that is not an option. (The ARGV-elements have been permuted
+ * so that those that are not options now come last.)
+ *
+ * OPTSTRING is a string containing the legitimate option characters.
+ * If an option character is seen that is not listed in OPTSTRING,
+ * return '?' after printing an error message. If you set `custom_opterr' to
+ * zero, the error message is suppressed but we still return '?'.
+ *
+ * If a char in OPTSTRING is followed by a colon, that means it wants an arg,
+ * so the following text in the same ARGV-element, or the text of the following
+ * ARGV-element, is returned in `custom_optarg'. Two colons mean an option that
+ * wants an optional arg; if there is text in the current ARGV-element,
+ * it is returned in `custom_optarg', otherwise `custom_optarg' is set to zero.
+ *
+ * If OPTSTRING starts with `-' or `+', it requests different methods of
+ * handling the non-option ARGV-elements.
+ * See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
+ *
+ * Long-named options begin with `--' instead of `-'.
+ * Their names may be abbreviated as long as the abbreviation is unique
+ * or is an exact match for some defined option. If they have an
+ * argument, it follows the option name in the same ARGV-element, separated
+ * from the option name by a `=', or else the in next ARGV-element.
+ * When `getopt' finds a long-named option, it returns 0 if that option's
+ * `flag' field is nonzero, the value of the option's `val' field
+ * if the `flag' field is zero.
+ *
+ * The elements of ARGV aren't really const, because we permute them.
+ * But we pretend they're const in the prototype to be compatible
+ * with other systems.
+ *
+ * LONGOPTS is a vector of `struct option' terminated by an
+ * element containing a name which is zero.
+ *
+ * LONGIND returns the index in LONGOPT of the long-named option found.
+ * It is only valid when a long-named option has been found by the most
+ * recent call.
+ *
+ * Return the option character from OPTS just read. Return -1 when there are
+ * no more options. For unrecognized options, or options missing arguments,
+ * `custom_optopt' is set to the option letter, and '?' is returned.
+ *
+ * The OPTS string is a list of characters which are recognized option letters,
+ * optionally followed by colons, specifying that that letter takes an
+ * argument, to be placed in `custom_optarg'.
+ *
+ * If a letter in OPTS is followed by two colons, its argument is optional.
+ * This behavior is specific to the GNU `getopt'.
+ *
+ * The argument `--' causes premature termination of argument scanning,
+ * explicitly telling `getopt' that there are no more options. If OPTS begins
+ * with `--', then non-option arguments are treated as arguments to the option
+ * '\0'. This behavior is specific to the GNU `getopt'.
+ */
+
+static int getopt_internal_r(int argc, char *const *argv, const char *optstring,
+ const struct option *longopts, int *longind,
+ struct custom_getopt_data *d)
+{
+ int ret, print_errors = d->custom_opterr;
+
+ if (optstring[0] == ':')
+ print_errors = 0;
+ if (argc < 1)
+ return -1;
+ d->custom_optarg = NULL;
+
+ /*
+ * This is a big difference with GNU getopt, since optind == 0
+ * means initialization while here 1 means first call.
+ */
+ if (d->custom_optind == 0 || !d->initialized) {
+ if (d->custom_optind == 0)
+ d->custom_optind = 1; /* Don't scan ARGV[0], the program name. */
+ custom_getopt_initialize(d);
+ }
+ if (d->nextchar == NULL || *d->nextchar == '\0') {
+ ret = shuffle_argv(argc, argv, longopts, d);
+ if (ret)
+ return ret;
+ }
+ if (longopts && (argv[d->custom_optind][1] == '-' ))
+ return check_long_opt(argc, argv, optstring, longopts,
+ longind, print_errors, d);
+ return check_short_opt(argc, argv, optstring, print_errors, d);
+}
+
+static int custom_getopt_internal(int argc, char *const *argv, const char *optstring,
+ const struct option *longopts, int *longind)
+{
+ int result;
+ /* Keep a global copy of all internal members of d */
+ static struct custom_getopt_data d;
+
+ d.custom_optind = custom_optind;
+ d.custom_opterr = custom_opterr;
+ result = getopt_internal_r(argc, argv, optstring, longopts,
+ longind, &d);
+ custom_optind = d.custom_optind;
+ custom_optarg = d.custom_optarg;
+ custom_optopt = d.custom_optopt;
+ return result;
+}
+
+static int custom_getopt_long (int argc, char *const *argv, const char *options,
+ const struct option *long_options, int *opt_index)
+{
+ return custom_getopt_internal(argc, argv, options, long_options,
+ opt_index);
+}
+
+
+static char *package_name = 0;
+
+/**
+ * @brief updates an option
+ * @param field the generic pointer to the field to update
+ * @param orig_field the pointer to the orig field
+ * @param field_given the pointer to the number of occurrence of this option
+ * @param prev_given the pointer to the number of occurrence already seen
+ * @param value the argument for this option (if null no arg was specified)
+ * @param possible_values the possible values for this option (if specified)
+ * @param default_value the default value (in case the option only accepts fixed values)
+ * @param arg_type the type of this option
+ * @param check_ambiguity @see cmdline_parser_params.check_ambiguity
+ * @param override @see cmdline_parser_params.override
+ * @param no_free whether to free a possible previous value
+ * @param multiple_option whether this is a multiple option
+ * @param long_opt the corresponding long option
+ * @param short_opt the corresponding short option (or '-' if none)
+ * @param additional_error possible further error specification
+ */
+static
+int update_arg(void *field, char **orig_field,
+ unsigned int *field_given, unsigned int *prev_given,
+ char *value, const char *possible_values[],
+ const char *default_value,
+ cmdline_parser_arg_type arg_type,
+ int check_ambiguity, int override,
+ int no_free, int multiple_option,
+ const char *long_opt, char short_opt,
+ const char *additional_error)
+{
+ char *stop_char = 0;
+ const char *val = value;
+ int found;
+ char **string_field;
+ FIX_UNUSED (field);
+
+ stop_char = 0;
+ found = 0;
+
+ if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
+ {
+ if (short_opt != '-')
+ fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
+ package_name, long_opt, short_opt,
+ (additional_error ? additional_error : ""));
+ else
+ fprintf (stderr, "%s: `--%s' option given more than once%s\n",
+ package_name, long_opt,
+ (additional_error ? additional_error : ""));
+ return 1; /* failure */
+ }
+
+ FIX_UNUSED (default_value);
+
+ if (field_given && *field_given && ! override)
+ return 0;
+ if (prev_given)
+ (*prev_given)++;
+ if (field_given)
+ (*field_given)++;
+ if (possible_values)
+ val = possible_values[found];
+
+ switch(arg_type) {
+ case ARG_FLAG:
+ *((int *)field) = !*((int *)field);
+ break;
+ case ARG_INT:
+ if (val) *((int *)field) = strtol (val, &stop_char, 0);
+ break;
+ case ARG_FLOAT:
+ if (val) *((float *)field) = (float)strtod (val, &stop_char);
+ break;
+ case ARG_STRING:
+ if (val) {
+ string_field = (char **)field;
+ if (!no_free && *string_field)
+ free (*string_field); /* free previous string */
+ *string_field = gengetopt_strdup (val);
+ }
+ break;
+ default:
+ break;
+ };
+
+ /* check numeric conversion */
+ switch(arg_type) {
+ case ARG_INT:
+ case ARG_FLOAT:
+ if (val && !(stop_char && *stop_char == '\0')) {
+ fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
+ return 1; /* failure */
+ }
+ break;
+ default:
+ ;
+ };
+
+ /* store the original value */
+ switch(arg_type) {
+ case ARG_NO:
+ case ARG_FLAG:
+ break;
+ default:
+ if (value && orig_field) {
+ if (no_free) {
+ *orig_field = value;
+ } else {
+ if (*orig_field)
+ free (*orig_field); /* free previous string */
+ *orig_field = gengetopt_strdup (value);
+ }
+ }
+ };
+
+ return 0; /* OK */
+}
+
+
+int
+cmdline_parser_internal (
+ int argc, char **argv, struct gengetopt_args_info *args_info,
+ struct cmdline_parser_params *params, const char *additional_error)
+{
+ int c; /* Character of the parsed option. */
+
+ int error_occurred = 0;
+ struct gengetopt_args_info local_args_info;
+
+ int override;
+ int initialize;
+ int check_required;
+ int check_ambiguity;
+
+ char *optarg;
+ int optind;
+ int opterr;
+ int optopt;
+
+ package_name = argv[0];
+
+ override = params->override;
+ initialize = params->initialize;
+ check_required = params->check_required;
+ check_ambiguity = params->check_ambiguity;
+
+ if (initialize)
+ cmdline_parser_init (args_info);
+
+ cmdline_parser_init (&local_args_info);
+
+ optarg = 0;
+ optind = 0;
+ opterr = params->print_errors;
+ optopt = '?';
+
+ while (1)
+ {
+ int option_index = 0;
+
+ static struct option long_options[] = {
+ { "help", 0, NULL, 'h' },
+ { "version", 0, NULL, 'V' },
+ { "verbose", 0, NULL, 'v' },
+ { "quiet", 0, NULL, 0 },
+ { "query-gl", 0, NULL, 'q' },
+ { "check", 0, NULL, 0 },
+ { "compiler", 0, NULL, 0 },
+ { "debug", 0, NULL, 0 },
+ { "igc-file", 1, NULL, 'i' },
+ { "gpsd", 0, NULL, 0 },
+ { "gpsd-server", 1, NULL, 0 },
+ { "gpsd-port", 1, NULL, 0 },
+ { "gpsalt", 0, NULL, 'g' },
+ { "baroalt", 0, NULL, 'b' },
+ { "use-all-fixes", 0, NULL, 0 },
+ { "lat", 1, NULL, 0 },
+ { "lon", 1, NULL, 0 },
+ { "get-elevation", 0, NULL, 0 },
+ { "config-file", 1, NULL, 'c' },
+ { "ortho", 0, NULL, 'o' },
+ { "perspective", 0, NULL, 0 },
+ { "aov", 1, NULL, 0 },
+ { "landscape", 0, NULL, 'l' },
+ { "flat", 0, NULL, 'f' },
+ { "map", 0, NULL, 'm' },
+ { "no-map", 0, NULL, 0 },
+ { "map-set-name", 1, NULL, 0 },
+ { "modulate", 0, NULL, 0 },
+ { "no-modulate", 0, NULL, 0 },
+ { "maps-unlighted", 0, NULL, 0 },
+ { "maps-lighted", 0, NULL, 0 },
+ { "no-lighting", 0, NULL, 0 },
+ { "terrain-shading", 0, NULL, 0 },
+ { "shading-scale", 1, NULL, 0 },
+ { "light-direction", 1, NULL, 0 },
+ { "airspace", 0, NULL, 'a' },
+ { "airspace-wire", 0, NULL, 0 },
+ { "airspace-wire-col-r", 1, NULL, 0 },
+ { "airspace-wire-col-g", 1, NULL, 0 },
+ { "airspace-wire-col-b", 1, NULL, 0 },
+ { "airspace-wire-width", 1, NULL, 0 },
+ { "airspace-transparent", 0, NULL, 0 },
+ { "no-airspace", 0, NULL, 0 },
+ { "airspace-file", 1, NULL, 0 },
+ { "airspace-limit", 1, NULL, 0 },
+ { "wire", 0, NULL, 'w' },
+ { "filled", 0, NULL, 0 },
+ { "grayscale", 0, NULL, 0 },
+ { "color", 0, NULL, 0 },
+ { "stereo", 0, NULL, 0 },
+ { "no-stereo", 0, NULL, 0 },
+ { "stereo-rg", 0, NULL, 0 },
+ { "no-stereo-rg", 0, NULL, 0 },
+ { "stereo-rb", 0, NULL, 0 },
+ { "no-stereo-rb", 0, NULL, 0 },
+ { "stereo-hw", 0, NULL, 0 },
+ { "no-stereo-hw", 0, NULL, 0 },
+ { "inverse-stereo", 0, NULL, 0 },
+ { "no-inverse-stereo", 0, NULL, 0 },
+ { "eye-dist", 1, NULL, 0 },
+ { "flat-shading", 0, NULL, 0 },
+ { "gouraud-shading", 0, NULL, 0 },
+ { "quads", 0, NULL, 0 },
+ { "curtain", 0, NULL, 0 },
+ { "no-curtain", 0, NULL, 0 },
+ { "haze", 0, NULL, 0 },
+ { "no-haze", 0, NULL, 0 },
+ { "haze-density", 1, NULL, 0 },
+ { "colormap", 1, NULL, 0 },
+ { "colormap-sea", 1, NULL, 0 },
+ { "colormap-min", 1, NULL, 0 },
+ { "colormap-max", 1, NULL, 0 },
+ { "sealevel", 1, NULL, 0 },
+ { "sealevel2", 1, NULL, 0 },
+ { "sealevel3", 1, NULL, 0 },
+ { "ignore-elev-min", 1, NULL, 0 },
+ { "ignore-elev-max", 1, NULL, 0 },
+ { "scalez", 1, NULL, 's' },
+ { "downscaling", 1, NULL, 'd' },
+ { "upscaling", 1, NULL, 0 },
+ { "fullscreen", 0, NULL, 0 },
+ { "window", 0, NULL, 0 },
+ { "width", 1, NULL, 0 },
+ { "height", 1, NULL, 0 },
+ { "border", 1, NULL, 0 },
+ { "border-lat", 1, NULL, 0 },
+ { "border-lon", 1, NULL, 0 },
+ { "offset", 1, NULL, 0 },
+ { "airfield-elevation", 1, NULL, 'e' },
+ { "marker-pos", 1, NULL, 0 },
+ { "marker-time", 1, NULL, 0 },
+ { "marker", 0, NULL, 0 },
+ { "marker-size", 1, NULL, 0 },
+ { "no-marker", 0, NULL, 0 },
+ { "info", 0, NULL, 0 },
+ { "no-info", 0, NULL, 0 },
+ { "text", 1, NULL, 0 },
+ { "no-position-info", 0, NULL, 0 },
+ { "no-marker-pos-info", 0, NULL, 0 },
+ { "text-size", 1, NULL, 0 },
+ { "text-width", 1, NULL, 0 },
+ { "lifts", 1, NULL, 0 },
+ { "lifts-info-mode", 1, NULL, 0 },
+ { "waypoints-file", 1, NULL, 0 },
+ { "waypoints", 0, NULL, 0 },
+ { "no-waypoints", 0, NULL, 0 },
+ { "waypoints-info-mode", 1, NULL, 0 },
+ { "waypoints-offset", 1, NULL, 0 },
+ { "waypoints-offset-spheres", 1, NULL, 0 },
+ { "flighttrack-mode", 1, NULL, 0 },
+ { "flighttrack-colormap", 1, NULL, 0 },
+ { "flighttrack-linewidth", 1, NULL, 0 },
+ { "follow", 0, NULL, 0 },
+ { "no-follow", 0, NULL, 0 },
+ { "marker-range", 0, NULL, 0 },
+ { "no-marker-range", 0, NULL, 0 },
+ { "marker-ahead", 1, NULL, 0 },
+ { "marker-back", 1, NULL, 0 },
+ { "movie", 0, NULL, 0 },
+ { "cycles", 1, NULL, 0 },
+ { "spinning", 1, NULL, 0 },
+ { "smooth-mouse", 0, NULL, 0 },
+ { "parent-pid", 1, NULL, 0 },
+ { "compression", 0, NULL, 0 },
+ { "no-compression", 0, NULL, 0 },
+ { "offscreen", 0, NULL, 0 },
+ { "osmesa", 0, NULL, 0 },
+ { "os-outfile", 1, NULL, 0 },
+ { "jpeg-quality", 1, NULL, 0 },
+ { "image-format", 1, NULL, 0 },
+ { "save-path", 1, NULL, 0 },
+ { "basename", 1, NULL, 0 },
+ { "clipping-far", 1, NULL, 0 },
+ { "clipping-near", 1, NULL, 0 },
+ { "init-lat", 1, NULL, 0 },
+ { "init-lon", 1, NULL, 0 },
+ { "init-alt", 1, NULL, 0 },
+ { "init-heading", 1, NULL, 0 },
+ { "init-dive", 1, NULL, 0 },
+ { "init-pos-N", 0, NULL, 0 },
+ { "init-pos-E", 0, NULL, 0 },
+ { "init-pos-S", 0, NULL, 0 },
+ { "init-pos-W", 0, NULL, 0 },
+ { "init-pos-NE", 0, NULL, 0 },
+ { "init-pos-SE", 0, NULL, 0 },
+ { "init-pos-SW", 0, NULL, 0 },
+ { "init-pos-NW", 0, NULL, 0 },
+ { "init-pos-center", 0, NULL, 0 },
+ { "init-ortho-lat", 1, NULL, 0 },
+ { "init-ortho-lon", 1, NULL, 0 },
+ { "init-ortho-width", 1, NULL, 0 },
+ { "projection-cyl-platt", 0, NULL, 0 },
+ { "projection-cyl-no1", 0, NULL, 0 },
+ { "projection-pseudo-cyl-no1", 0, NULL, 0 },
+ { "projection-cyl-mercator", 0, NULL, 0 },
+ { 0, 0, 0, 0 }
+ };
+
+ custom_optarg = optarg;
+ custom_optind = optind;
+ custom_opterr = opterr;
+ custom_optopt = optopt;
+
+ c = custom_getopt_long (argc, argv, "hVvqi:gbc:olfmaws:d:e:", long_options, &option_index);
+
+ optarg = custom_optarg;
+ optind = custom_optind;
+ opterr = custom_opterr;
+ optopt = custom_optopt;
+
+ if (c == -1) break; /* Exit from `while (1)' loop. */
+
+ switch (c)
+ {
+ case 'h': /* Print help and exit. */
+ cmdline_parser_print_help ();
+ cmdline_parser_free (&local_args_info);
+ exit (EXIT_SUCCESS);
+
+ case 'V': /* Print version and exit. */
+ cmdline_parser_print_version ();
+ cmdline_parser_free (&local_args_info);
+ exit (EXIT_SUCCESS);
+
+ case 'v': /* verbosity?. */
+
+
+ if (update_arg((void *)&(args_info->verbose_flag), 0, &(args_info->verbose_given),
+ &(local_args_info.verbose_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "verbose", 'v',
+ additional_error))
+ goto failure;
+
+ break;
+ case 'q': /* Querying openGL implementation. */
+
+
+ if (update_arg((void *)&(args_info->query_gl_flag), 0, &(args_info->query_gl_given),
+ &(local_args_info.query_gl_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "query-gl", 'q',
+ additional_error))
+ goto failure;
+
+ break;
+ case 'i': /* igc-file. */
+
+
+ if (update_arg( (void *)&(args_info->igc_file_arg),
+ &(args_info->igc_file_orig), &(args_info->igc_file_given),
+ &(local_args_info.igc_file_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "igc-file", 'i',
+ additional_error))
+ goto failure;
+
+ break;
+ case 'g': /* use gps altitude. */
+
+
+ if (update_arg((void *)&(args_info->gpsalt_flag), 0, &(args_info->gpsalt_given),
+ &(local_args_info.gpsalt_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "gpsalt", 'g',
+ additional_error))
+ goto failure;
+
+ break;
+ case 'b': /* use barometric alt. */
+
+
+ if (update_arg((void *)&(args_info->baroalt_flag), 0, &(args_info->baroalt_given),
+ &(local_args_info.baroalt_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "baroalt", 'b',
+ additional_error))
+ goto failure;
+
+ break;
+ case 'c': /* config file. */
+
+
+ if (update_arg( (void *)&(args_info->config_file_arg),
+ &(args_info->config_file_orig), &(args_info->config_file_given),
+ &(local_args_info.config_file_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "config-file", 'c',
+ additional_error))
+ goto failure;
+
+ break;
+ case 'o': /* 2D Orthographic View. */
+
+
+ if (update_arg((void *)&(args_info->ortho_flag), 0, &(args_info->ortho_given),
+ &(local_args_info.ortho_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "ortho", 'o',
+ additional_error))
+ goto failure;
+
+ break;
+ case 'l': /* landscape from dem. */
+
+
+ if (update_arg((void *)&(args_info->landscape_flag), 0, &(args_info->landscape_given),
+ &(local_args_info.landscape_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "landscape", 'l',
+ additional_error))
+ goto failure;
+
+ break;
+ case 'f': /* flat underground. */
+
+
+ if (update_arg((void *)&(args_info->flat_flag), 0, &(args_info->flat_given),
+ &(local_args_info.flat_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "flat", 'f',
+ additional_error))
+ goto failure;
+
+ break;
+ case 'm': /* display digitized maps. */
+
+
+ if (update_arg((void *)&(args_info->map_flag), 0, &(args_info->map_given),
+ &(local_args_info.map_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "map", 'm',
+ additional_error))
+ goto failure;
+
+ break;
+ case 'a': /* Airspace visualization. */
+
+
+ if (update_arg((void *)&(args_info->airspace_flag), 0, &(args_info->airspace_given),
+ &(local_args_info.airspace_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "airspace", 'a',
+ additional_error))
+ goto failure;
+
+ break;
+ case 'w': /* wireframe landscape. */
+
+
+ if (update_arg((void *)&(args_info->wire_flag), 0, &(args_info->wire_given),
+ &(local_args_info.wire_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "wire", 'w',
+ additional_error))
+ goto failure;
+
+ break;
+ case 's': /* z axis scaling. */
+
+
+ if (update_arg( (void *)&(args_info->scalez_arg),
+ &(args_info->scalez_orig), &(args_info->scalez_given),
+ &(local_args_info.scalez_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "scalez", 's',
+ additional_error))
+ goto failure;
+
+ break;
+ case 'd': /* dem raster downscaling. */
+
+
+ if (update_arg( (void *)&(args_info->downscaling_arg),
+ &(args_info->downscaling_orig), &(args_info->downscaling_given),
+ &(local_args_info.downscaling_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "downscaling", 'd',
+ additional_error))
+ goto failure;
+
+ break;
+ case 'e': /* Elevation of airfield (take-off) in m. */
+
+
+ if (update_arg( (void *)&(args_info->airfield_elevation_arg),
+ &(args_info->airfield_elevation_orig), &(args_info->airfield_elevation_given),
+ &(local_args_info.airfield_elevation_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "airfield-elevation", 'e',
+ additional_error))
+ goto failure;
+
+ break;
+
+ case 0: /* Long option with no short option */
+ /* Quiet. */
+ if (strcmp (long_options[option_index].name, "quiet") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->quiet_flag), 0, &(args_info->quiet_given),
+ &(local_args_info.quiet_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "quiet", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* return exitcode 0. */
+ else if (strcmp (long_options[option_index].name, "check") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->check_flag), 0, &(args_info->check_given),
+ &(local_args_info.check_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "check", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* info about build. */
+ else if (strcmp (long_options[option_index].name, "compiler") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->compiler_flag), 0, &(args_info->compiler_given),
+ &(local_args_info.compiler_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "compiler", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* lots of output. */
+ else if (strcmp (long_options[option_index].name, "debug") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->debug_flag), 0, &(args_info->debug_given),
+ &(local_args_info.debug_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "debug", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* live gps via gpsd. */
+ else if (strcmp (long_options[option_index].name, "gpsd") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->gpsd_flag), 0, &(args_info->gpsd_given),
+ &(local_args_info.gpsd_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "gpsd", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* address of gpsd server. */
+ else if (strcmp (long_options[option_index].name, "gpsd-server") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->gpsd_server_arg),
+ &(args_info->gpsd_server_orig), &(args_info->gpsd_server_given),
+ &(local_args_info.gpsd_server_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "gpsd-server", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* port of gpsd server. */
+ else if (strcmp (long_options[option_index].name, "gpsd-port") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->gpsd_port_arg),
+ &(args_info->gpsd_port_orig), &(args_info->gpsd_port_given),
+ &(local_args_info.gpsd_port_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "gpsd-port", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Use all position fixes. */
+ else if (strcmp (long_options[option_index].name, "use-all-fixes") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->use_all_fixes_flag), 0, &(args_info->use_all_fixes_given),
+ &(local_args_info.use_all_fixes_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "use-all-fixes", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Latitude. */
+ else if (strcmp (long_options[option_index].name, "lat") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->lat_arg),
+ &(args_info->lat_orig), &(args_info->lat_given),
+ &(local_args_info.lat_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "lat", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Longitude. */
+ else if (strcmp (long_options[option_index].name, "lon") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->lon_arg),
+ &(args_info->lon_orig), &(args_info->lon_given),
+ &(local_args_info.lon_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "lon", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Return elevation of lat/lon. */
+ else if (strcmp (long_options[option_index].name, "get-elevation") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->get_elevation_flag), 0, &(args_info->get_elevation_given),
+ &(local_args_info.get_elevation_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "get-elevation", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* 3D View. */
+ else if (strcmp (long_options[option_index].name, "perspective") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->perspective_flag), 0, &(args_info->perspective_given),
+ &(local_args_info.perspective_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "perspective", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* angle of view. */
+ else if (strcmp (long_options[option_index].name, "aov") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->aov_arg),
+ &(args_info->aov_orig), &(args_info->aov_given),
+ &(local_args_info.aov_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "aov", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* dont use maps. */
+ else if (strcmp (long_options[option_index].name, "no-map") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->no_map_flag), 0, &(args_info->no_map_given),
+ &(local_args_info.no_map_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "no-map", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* name of map set to use. */
+ else if (strcmp (long_options[option_index].name, "map-set-name") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->map_set_name_arg),
+ &(args_info->map_set_name_orig), &(args_info->map_set_name_given),
+ &(local_args_info.map_set_name_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "map-set-name", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* dem color and maps. */
+ else if (strcmp (long_options[option_index].name, "modulate") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->modulate_flag), 0, &(args_info->modulate_given),
+ &(local_args_info.modulate_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "modulate", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* no color modulation. */
+ else if (strcmp (long_options[option_index].name, "no-modulate") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->no_modulate_flag), 0, &(args_info->no_modulate_given),
+ &(local_args_info.no_modulate_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "no-modulate", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* dont use lighting for unmodulated maps. */
+ else if (strcmp (long_options[option_index].name, "maps-unlighted") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->maps_unlighted_flag), 0, &(args_info->maps_unlighted_given),
+ &(local_args_info.maps_unlighted_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "maps-unlighted", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* use lighting for unmodulated maps. */
+ else if (strcmp (long_options[option_index].name, "maps-lighted") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->maps_lighted_flag), 0, &(args_info->maps_lighted_given),
+ &(local_args_info.maps_lighted_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "maps-lighted", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Dont use lighting for terrain. */
+ else if (strcmp (long_options[option_index].name, "no-lighting") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->no_lighting_flag), 0, &(args_info->no_lighting_given),
+ &(local_args_info.no_lighting_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "no-lighting", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Use terrain shading (implies no-lighting). */
+ else if (strcmp (long_options[option_index].name, "terrain-shading") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->terrain_shading_flag), 0, &(args_info->terrain_shading_given),
+ &(local_args_info.terrain_shading_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "terrain-shading", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* shading-scale (1-10000). */
+ else if (strcmp (long_options[option_index].name, "shading-scale") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->shading_scale_arg),
+ &(args_info->shading_scale_orig), &(args_info->shading_scale_given),
+ &(local_args_info.shading_scale_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "shading-scale", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* direction for light (1-8). */
+ else if (strcmp (long_options[option_index].name, "light-direction") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->light_direction_arg),
+ &(args_info->light_direction_orig), &(args_info->light_direction_given),
+ &(local_args_info.light_direction_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "light-direction", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Airspace as wireframe. */
+ else if (strcmp (long_options[option_index].name, "airspace-wire") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->airspace_wire_flag), 0, &(args_info->airspace_wire_given),
+ &(local_args_info.airspace_wire_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "airspace-wire", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* wire color red. */
+ else if (strcmp (long_options[option_index].name, "airspace-wire-col-r") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->airspace_wire_col_r_arg),
+ &(args_info->airspace_wire_col_r_orig), &(args_info->airspace_wire_col_r_given),
+ &(local_args_info.airspace_wire_col_r_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "airspace-wire-col-r", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* wire color green. */
+ else if (strcmp (long_options[option_index].name, "airspace-wire-col-g") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->airspace_wire_col_g_arg),
+ &(args_info->airspace_wire_col_g_orig), &(args_info->airspace_wire_col_g_given),
+ &(local_args_info.airspace_wire_col_g_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "airspace-wire-col-g", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* wire color blue. */
+ else if (strcmp (long_options[option_index].name, "airspace-wire-col-b") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->airspace_wire_col_b_arg),
+ &(args_info->airspace_wire_col_b_orig), &(args_info->airspace_wire_col_b_given),
+ &(local_args_info.airspace_wire_col_b_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "airspace-wire-col-b", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* linewidth wires. */
+ else if (strcmp (long_options[option_index].name, "airspace-wire-width") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->airspace_wire_width_arg),
+ &(args_info->airspace_wire_width_orig), &(args_info->airspace_wire_width_given),
+ &(local_args_info.airspace_wire_width_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "airspace-wire-width", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Airspace transparent. */
+ else if (strcmp (long_options[option_index].name, "airspace-transparent") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->airspace_transparent_flag), 0, &(args_info->airspace_transparent_given),
+ &(local_args_info.airspace_transparent_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "airspace-transparent", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* no Airspaces. */
+ else if (strcmp (long_options[option_index].name, "no-airspace") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->no_airspace_flag), 0, &(args_info->no_airspace_given),
+ &(local_args_info.no_airspace_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "no-airspace", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* use airspaces from file. */
+ else if (strcmp (long_options[option_index].name, "airspace-file") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->airspace_file_arg),
+ &(args_info->airspace_file_orig), &(args_info->airspace_file_given),
+ &(local_args_info.airspace_file_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "airspace-file", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* limit (FL) for airspaces. */
+ else if (strcmp (long_options[option_index].name, "airspace-limit") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->airspace_limit_arg),
+ &(args_info->airspace_limit_orig), &(args_info->airspace_limit_given),
+ &(local_args_info.airspace_limit_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "airspace-limit", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* filled polygons. */
+ else if (strcmp (long_options[option_index].name, "filled") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->filled_flag), 0, &(args_info->filled_given),
+ &(local_args_info.filled_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "filled", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* grayscaled image. */
+ else if (strcmp (long_options[option_index].name, "grayscale") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->grayscale_flag), 0, &(args_info->grayscale_given),
+ &(local_args_info.grayscale_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "grayscale", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* color image. */
+ else if (strcmp (long_options[option_index].name, "color") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->color_flag), 0, &(args_info->color_given),
+ &(local_args_info.color_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "color", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* stereoscopic. */
+ else if (strcmp (long_options[option_index].name, "stereo") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->stereo_flag), 0, &(args_info->stereo_given),
+ &(local_args_info.stereo_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "stereo", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* no stereoscopic view. */
+ else if (strcmp (long_options[option_index].name, "no-stereo") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->no_stereo_flag), 0, &(args_info->no_stereo_given),
+ &(local_args_info.no_stereo_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "no-stereo", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* stereoscopic red/green. */
+ else if (strcmp (long_options[option_index].name, "stereo-rg") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->stereo_rg_flag), 0, &(args_info->stereo_rg_given),
+ &(local_args_info.stereo_rg_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "stereo-rg", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* no stereoscopic red/green. */
+ else if (strcmp (long_options[option_index].name, "no-stereo-rg") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->no_stereo_rg_flag), 0, &(args_info->no_stereo_rg_given),
+ &(local_args_info.no_stereo_rg_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "no-stereo-rg", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* stereoscopic red/blue. */
+ else if (strcmp (long_options[option_index].name, "stereo-rb") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->stereo_rb_flag), 0, &(args_info->stereo_rb_given),
+ &(local_args_info.stereo_rb_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "stereo-rb", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* no stereoscopic red/blue. */
+ else if (strcmp (long_options[option_index].name, "no-stereo-rb") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->no_stereo_rb_flag), 0, &(args_info->no_stereo_rb_given),
+ &(local_args_info.no_stereo_rb_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "no-stereo-rb", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* stereoscopic hardware. */
+ else if (strcmp (long_options[option_index].name, "stereo-hw") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->stereo_hw_flag), 0, &(args_info->stereo_hw_given),
+ &(local_args_info.stereo_hw_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "stereo-hw", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* no stereoscopic hardware. */
+ else if (strcmp (long_options[option_index].name, "no-stereo-hw") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->no_stereo_hw_flag), 0, &(args_info->no_stereo_hw_given),
+ &(local_args_info.no_stereo_hw_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "no-stereo-hw", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* invert right/left image. */
+ else if (strcmp (long_options[option_index].name, "inverse-stereo") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->inverse_stereo_flag), 0, &(args_info->inverse_stereo_given),
+ &(local_args_info.inverse_stereo_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "inverse-stereo", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* dont invert right/left. */
+ else if (strcmp (long_options[option_index].name, "no-inverse-stereo") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->no_inverse_stereo_flag), 0, &(args_info->no_inverse_stereo_given),
+ &(local_args_info.no_inverse_stereo_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "no-inverse-stereo", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* eye distance for stereoscopic view (km). */
+ else if (strcmp (long_options[option_index].name, "eye-dist") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->eye_dist_arg),
+ &(args_info->eye_dist_orig), &(args_info->eye_dist_given),
+ &(local_args_info.eye_dist_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "eye-dist", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* no gouraud. */
+ else if (strcmp (long_options[option_index].name, "flat-shading") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->flat_shading_flag), 0, &(args_info->flat_shading_given),
+ &(local_args_info.flat_shading_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "flat-shading", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* use gouraud-shading. */
+ else if (strcmp (long_options[option_index].name, "gouraud-shading") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->gouraud_shading_flag), 0, &(args_info->gouraud_shading_given),
+ &(local_args_info.gouraud_shading_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "gouraud-shading", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* use quadrilaterals. */
+ else if (strcmp (long_options[option_index].name, "quads") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->quads_flag), 0, &(args_info->quads_given),
+ &(local_args_info.quads_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "quads", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* draw curtain. */
+ else if (strcmp (long_options[option_index].name, "curtain") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->curtain_flag), 0, &(args_info->curtain_given),
+ &(local_args_info.curtain_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "curtain", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* draw no curtain. */
+ else if (strcmp (long_options[option_index].name, "no-curtain") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->no_curtain_flag), 0, &(args_info->no_curtain_given),
+ &(local_args_info.no_curtain_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "no-curtain", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* draw haze. */
+ else if (strcmp (long_options[option_index].name, "haze") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->haze_flag), 0, &(args_info->haze_given),
+ &(local_args_info.haze_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "haze", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* draw no haze. */
+ else if (strcmp (long_options[option_index].name, "no-haze") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->no_haze_flag), 0, &(args_info->no_haze_given),
+ &(local_args_info.no_haze_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "no-haze", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* haze density (0-0.5). */
+ else if (strcmp (long_options[option_index].name, "haze-density") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->haze_density_arg),
+ &(args_info->haze_density_orig), &(args_info->haze_density_given),
+ &(local_args_info.haze_density_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "haze-density", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* no. of colormap to use. */
+ else if (strcmp (long_options[option_index].name, "colormap") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->colormap_arg),
+ &(args_info->colormap_orig), &(args_info->colormap_given),
+ &(local_args_info.colormap_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "colormap", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* colormap 2 (sea). */
+ else if (strcmp (long_options[option_index].name, "colormap-sea") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->colormap_sea_arg),
+ &(args_info->colormap_sea_orig), &(args_info->colormap_sea_given),
+ &(local_args_info.colormap_sea_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "colormap-sea", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* mininum height. */
+ else if (strcmp (long_options[option_index].name, "colormap-min") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->colormap_min_arg),
+ &(args_info->colormap_min_orig), &(args_info->colormap_min_given),
+ &(local_args_info.colormap_min_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "colormap-min", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* maximum height. */
+ else if (strcmp (long_options[option_index].name, "colormap-max") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->colormap_max_arg),
+ &(args_info->colormap_max_orig), &(args_info->colormap_max_given),
+ &(local_args_info.colormap_max_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "colormap-max", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set sealevel. */
+ else if (strcmp (long_options[option_index].name, "sealevel") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->sealevel_arg),
+ &(args_info->sealevel_orig), &(args_info->sealevel_given),
+ &(local_args_info.sealevel_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "sealevel", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set sealevel2. */
+ else if (strcmp (long_options[option_index].name, "sealevel2") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->sealevel2_arg),
+ &(args_info->sealevel2_orig), &(args_info->sealevel2_given),
+ &(local_args_info.sealevel2_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "sealevel2", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set sealevel3. */
+ else if (strcmp (long_options[option_index].name, "sealevel3") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->sealevel3_arg),
+ &(args_info->sealevel3_orig), &(args_info->sealevel3_given),
+ &(local_args_info.sealevel3_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "sealevel3", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* ignore range min. */
+ else if (strcmp (long_options[option_index].name, "ignore-elev-min") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->ignore_elev_min_arg),
+ &(args_info->ignore_elev_min_orig), &(args_info->ignore_elev_min_given),
+ &(local_args_info.ignore_elev_min_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "ignore-elev-min", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* ignore range max. */
+ else if (strcmp (long_options[option_index].name, "ignore-elev-max") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->ignore_elev_max_arg),
+ &(args_info->ignore_elev_max_orig), &(args_info->ignore_elev_max_given),
+ &(local_args_info.ignore_elev_max_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "ignore-elev-max", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* dem raster interpolation factor. */
+ else if (strcmp (long_options[option_index].name, "upscaling") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->upscaling_arg),
+ &(args_info->upscaling_orig), &(args_info->upscaling_given),
+ &(local_args_info.upscaling_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "upscaling", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Fullscreen. */
+ else if (strcmp (long_options[option_index].name, "fullscreen") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->fullscreen_flag), 0, &(args_info->fullscreen_given),
+ &(local_args_info.fullscreen_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "fullscreen", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* start windowed. */
+ else if (strcmp (long_options[option_index].name, "window") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->window_flag), 0, &(args_info->window_given),
+ &(local_args_info.window_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "window", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Window width. */
+ else if (strcmp (long_options[option_index].name, "width") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->width_arg),
+ &(args_info->width_orig), &(args_info->width_given),
+ &(local_args_info.width_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "width", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Window height. */
+ else if (strcmp (long_options[option_index].name, "height") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->height_arg),
+ &(args_info->height_orig), &(args_info->height_given),
+ &(local_args_info.height_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "height", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Border Lat and Lon. */
+ else if (strcmp (long_options[option_index].name, "border") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->border_arg),
+ &(args_info->border_orig), &(args_info->border_given),
+ &(local_args_info.border_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "border", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Border Lat. */
+ else if (strcmp (long_options[option_index].name, "border-lat") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->border_lat_arg),
+ &(args_info->border_lat_orig), &(args_info->border_lat_given),
+ &(local_args_info.border_lat_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "border-lat", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Border Lon. */
+ else if (strcmp (long_options[option_index].name, "border-lon") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->border_lon_arg),
+ &(args_info->border_lon_orig), &(args_info->border_lon_given),
+ &(local_args_info.border_lon_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "border-lon", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* height offset in m. */
+ else if (strcmp (long_options[option_index].name, "offset") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->offset_arg),
+ &(args_info->offset_orig), &(args_info->offset_given),
+ &(local_args_info.offset_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "offset", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Position of marker. */
+ else if (strcmp (long_options[option_index].name, "marker-pos") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->marker_pos_arg),
+ &(args_info->marker_pos_orig), &(args_info->marker_pos_given),
+ &(local_args_info.marker_pos_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "marker-pos", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Time of markerposition. */
+ else if (strcmp (long_options[option_index].name, "marker-time") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->marker_time_arg),
+ &(args_info->marker_time_orig), &(args_info->marker_time_given),
+ &(local_args_info.marker_time_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "marker-time", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Marker. */
+ else if (strcmp (long_options[option_index].name, "marker") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->marker_flag), 0, &(args_info->marker_given),
+ &(local_args_info.marker_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "marker", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Size of the Marker. */
+ else if (strcmp (long_options[option_index].name, "marker-size") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->marker_size_arg),
+ &(args_info->marker_size_orig), &(args_info->marker_size_given),
+ &(local_args_info.marker_size_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "marker-size", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* no Marker. */
+ else if (strcmp (long_options[option_index].name, "no-marker") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->no_marker_flag), 0, &(args_info->no_marker_given),
+ &(local_args_info.no_marker_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "no-marker", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Info text display. */
+ else if (strcmp (long_options[option_index].name, "info") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->info_flag), 0, &(args_info->info_given),
+ &(local_args_info.info_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "info", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* no info text display. */
+ else if (strcmp (long_options[option_index].name, "no-info") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->no_info_flag), 0, &(args_info->no_info_given),
+ &(local_args_info.no_info_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "no-info", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Text string to display. */
+ else if (strcmp (long_options[option_index].name, "text") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->text_arg),
+ &(args_info->text_orig), &(args_info->text_given),
+ &(local_args_info.text_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "text", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Turn off viewpoint position info. */
+ else if (strcmp (long_options[option_index].name, "no-position-info") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->no_position_info_flag), 0, &(args_info->no_position_info_given),
+ &(local_args_info.no_position_info_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "no-position-info", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Turn off marker position info. */
+ else if (strcmp (long_options[option_index].name, "no-marker-pos-info") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->no_marker_pos_info_flag), 0, &(args_info->no_marker_pos_info_given),
+ &(local_args_info.no_marker_pos_info_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "no-marker-pos-info", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Size of text for points/lifts (0.001-1.0). */
+ else if (strcmp (long_options[option_index].name, "text-size") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->text_size_arg),
+ &(args_info->text_size_orig), &(args_info->text_size_given),
+ &(local_args_info.text_size_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "text-size", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Width of text (1-20). */
+ else if (strcmp (long_options[option_index].name, "text-width") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->text_width_arg),
+ &(args_info->text_width_orig), &(args_info->text_width_given),
+ &(local_args_info.text_width_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "text-width", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* GPLIGC liftsfile. */
+ else if (strcmp (long_options[option_index].name, "lifts") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->lifts_arg),
+ &(args_info->lifts_orig), &(args_info->lifts_given),
+ &(local_args_info.lifts_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "lifts", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* which info to display (1-7). */
+ else if (strcmp (long_options[option_index].name, "lifts-info-mode") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->lifts_info_mode_arg),
+ &(args_info->lifts_info_mode_orig), &(args_info->lifts_info_mode_given),
+ &(local_args_info.lifts_info_mode_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "lifts-info-mode", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* waypointsfile. */
+ else if (strcmp (long_options[option_index].name, "waypoints-file") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->waypoints_file_arg),
+ &(args_info->waypoints_file_orig), &(args_info->waypoints_file_given),
+ &(local_args_info.waypoints_file_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "waypoints-file", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* show waypoints. */
+ else if (strcmp (long_options[option_index].name, "waypoints") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->waypoints_flag), 0, &(args_info->waypoints_given),
+ &(local_args_info.waypoints_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "waypoints", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* dont show waypoints. */
+ else if (strcmp (long_options[option_index].name, "no-waypoints") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->no_waypoints_flag), 0, &(args_info->no_waypoints_given),
+ &(local_args_info.no_waypoints_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "no-waypoints", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* which info to display (1-4). */
+ else if (strcmp (long_options[option_index].name, "waypoints-info-mode") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->waypoints_info_mode_arg),
+ &(args_info->waypoints_info_mode_orig), &(args_info->waypoints_info_mode_given),
+ &(local_args_info.waypoints_info_mode_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "waypoints-info-mode", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* offset for displaying waypoint text in 3D. */
+ else if (strcmp (long_options[option_index].name, "waypoints-offset") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->waypoints_offset_arg),
+ &(args_info->waypoints_offset_orig), &(args_info->waypoints_offset_given),
+ &(local_args_info.waypoints_offset_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "waypoints-offset", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* offset for displaying waypoint spheres and text in 3D. */
+ else if (strcmp (long_options[option_index].name, "waypoints-offset-spheres") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->waypoints_offset_spheres_arg),
+ &(args_info->waypoints_offset_spheres_orig), &(args_info->waypoints_offset_spheres_given),
+ &(local_args_info.waypoints_offset_spheres_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "waypoints-offset-spheres", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* sets the mode of track display. */
+ else if (strcmp (long_options[option_index].name, "flighttrack-mode") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->flighttrack_mode_arg),
+ &(args_info->flighttrack_mode_orig), &(args_info->flighttrack_mode_given),
+ &(local_args_info.flighttrack_mode_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "flighttrack-mode", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* sets the colourmap for flighttrack. */
+ else if (strcmp (long_options[option_index].name, "flighttrack-colormap") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->flighttrack_colormap_arg),
+ &(args_info->flighttrack_colormap_orig), &(args_info->flighttrack_colormap_given),
+ &(local_args_info.flighttrack_colormap_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "flighttrack-colormap", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* sets the linewidth of the flighttrack. */
+ else if (strcmp (long_options[option_index].name, "flighttrack-linewidth") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->flighttrack_linewidth_arg),
+ &(args_info->flighttrack_linewidth_orig), &(args_info->flighttrack_linewidth_given),
+ &(local_args_info.flighttrack_linewidth_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "flighttrack-linewidth", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* viewpoint follows marker. */
+ else if (strcmp (long_options[option_index].name, "follow") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->follow_flag), 0, &(args_info->follow_given),
+ &(local_args_info.follow_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "follow", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* viewpoint doesnt follow marker. */
+ else if (strcmp (long_options[option_index].name, "no-follow") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->no_follow_flag), 0, &(args_info->no_follow_given),
+ &(local_args_info.no_follow_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "no-follow", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* range around marker is plottet. */
+ else if (strcmp (long_options[option_index].name, "marker-range") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->marker_range_flag), 0, &(args_info->marker_range_given),
+ &(local_args_info.marker_range_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "marker-range", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* full flight is displayed. */
+ else if (strcmp (long_options[option_index].name, "no-marker-range") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->no_marker_range_flag), 0, &(args_info->no_marker_range_given),
+ &(local_args_info.no_marker_range_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "no-marker-range", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* define marker range. */
+ else if (strcmp (long_options[option_index].name, "marker-ahead") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->marker_ahead_arg),
+ &(args_info->marker_ahead_orig), &(args_info->marker_ahead_given),
+ &(local_args_info.marker_ahead_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "marker-ahead", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* define marker range. */
+ else if (strcmp (long_options[option_index].name, "marker-back") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->marker_back_arg),
+ &(args_info->marker_back_orig), &(args_info->marker_back_given),
+ &(local_args_info.marker_back_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "marker-back", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* start up in movie mode. */
+ else if (strcmp (long_options[option_index].name, "movie") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->movie_flag), 0, &(args_info->movie_given),
+ &(local_args_info.movie_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "movie", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* cycles for movie mode. */
+ else if (strcmp (long_options[option_index].name, "cycles") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->cycles_arg),
+ &(args_info->cycles_orig), &(args_info->cycles_given),
+ &(local_args_info.cycles_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "cycles", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* spinning for movie mode. */
+ else if (strcmp (long_options[option_index].name, "spinning") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->spinning_arg),
+ &(args_info->spinning_orig), &(args_info->spinning_given),
+ &(local_args_info.spinning_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "spinning", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* smooth movement. */
+ else if (strcmp (long_options[option_index].name, "smooth-mouse") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->smooth_mouse_flag), 0, &(args_info->smooth_mouse_given),
+ &(local_args_info.smooth_mouse_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "smooth-mouse", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* PID of parent. */
+ else if (strcmp (long_options[option_index].name, "parent-pid") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->parent_pid_arg),
+ &(args_info->parent_pid_orig), &(args_info->parent_pid_given),
+ &(local_args_info.parent_pid_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "parent-pid", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Use texture map compression. */
+ else if (strcmp (long_options[option_index].name, "compression") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->compression_flag), 0, &(args_info->compression_given),
+ &(local_args_info.compression_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "compression", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Dont use texture map compression. */
+ else if (strcmp (long_options[option_index].name, "no-compression") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->no_compression_flag), 0, &(args_info->no_compression_given),
+ &(local_args_info.no_compression_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "no-compression", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Offscreen with GLX. */
+ else if (strcmp (long_options[option_index].name, "offscreen") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->offscreen_flag), 0, &(args_info->offscreen_given),
+ &(local_args_info.offscreen_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "offscreen", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Offscreen with Mesa. */
+ else if (strcmp (long_options[option_index].name, "osmesa") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->osmesa_flag), 0, &(args_info->osmesa_given),
+ &(local_args_info.osmesa_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "osmesa", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* outfile for offscreen rendering. */
+ else if (strcmp (long_options[option_index].name, "os-outfile") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->os_outfile_arg),
+ &(args_info->os_outfile_orig), &(args_info->os_outfile_given),
+ &(local_args_info.os_outfile_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "os-outfile", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Quality (0-100) of jpeg output. */
+ else if (strcmp (long_options[option_index].name, "jpeg-quality") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->jpeg_quality_arg),
+ &(args_info->jpeg_quality_orig), &(args_info->jpeg_quality_given),
+ &(local_args_info.jpeg_quality_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "jpeg-quality", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Image format for screenshots. */
+ else if (strcmp (long_options[option_index].name, "image-format") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->image_format_arg),
+ &(args_info->image_format_orig), &(args_info->image_format_given),
+ &(local_args_info.image_format_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "image-format", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Path to save screenshots. */
+ else if (strcmp (long_options[option_index].name, "save-path") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->save_path_arg),
+ &(args_info->save_path_orig), &(args_info->save_path_given),
+ &(local_args_info.save_path_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "save-path", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* Basename of screenshots. */
+ else if (strcmp (long_options[option_index].name, "basename") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->basename_arg),
+ &(args_info->basename_orig), &(args_info->basename_given),
+ &(local_args_info.basename_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "basename", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* clipping far. */
+ else if (strcmp (long_options[option_index].name, "clipping-far") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->clipping_far_arg),
+ &(args_info->clipping_far_orig), &(args_info->clipping_far_given),
+ &(local_args_info.clipping_far_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "clipping-far", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* clipping near. */
+ else if (strcmp (long_options[option_index].name, "clipping-near") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->clipping_near_arg),
+ &(args_info->clipping_near_orig), &(args_info->clipping_near_given),
+ &(local_args_info.clipping_near_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "clipping-near", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set initial latitude. */
+ else if (strcmp (long_options[option_index].name, "init-lat") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->init_lat_arg),
+ &(args_info->init_lat_orig), &(args_info->init_lat_given),
+ &(local_args_info.init_lat_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "init-lat", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set initial longitude. */
+ else if (strcmp (long_options[option_index].name, "init-lon") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->init_lon_arg),
+ &(args_info->init_lon_orig), &(args_info->init_lon_given),
+ &(local_args_info.init_lon_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "init-lon", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set initial altitude. */
+ else if (strcmp (long_options[option_index].name, "init-alt") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->init_alt_arg),
+ &(args_info->init_alt_orig), &(args_info->init_alt_given),
+ &(local_args_info.init_alt_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "init-alt", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set initial heading. */
+ else if (strcmp (long_options[option_index].name, "init-heading") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->init_heading_arg),
+ &(args_info->init_heading_orig), &(args_info->init_heading_given),
+ &(local_args_info.init_heading_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "init-heading", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set initial dive angle. */
+ else if (strcmp (long_options[option_index].name, "init-dive") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->init_dive_arg),
+ &(args_info->init_dive_orig), &(args_info->init_dive_given),
+ &(local_args_info.init_dive_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "init-dive", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set position North. */
+ else if (strcmp (long_options[option_index].name, "init-pos-N") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->init_pos_N_flag), 0, &(args_info->init_pos_N_given),
+ &(local_args_info.init_pos_N_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "init-pos-N", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set position East. */
+ else if (strcmp (long_options[option_index].name, "init-pos-E") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->init_pos_E_flag), 0, &(args_info->init_pos_E_given),
+ &(local_args_info.init_pos_E_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "init-pos-E", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set position South. */
+ else if (strcmp (long_options[option_index].name, "init-pos-S") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->init_pos_S_flag), 0, &(args_info->init_pos_S_given),
+ &(local_args_info.init_pos_S_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "init-pos-S", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set position West. */
+ else if (strcmp (long_options[option_index].name, "init-pos-W") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->init_pos_W_flag), 0, &(args_info->init_pos_W_given),
+ &(local_args_info.init_pos_W_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "init-pos-W", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set position NE. */
+ else if (strcmp (long_options[option_index].name, "init-pos-NE") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->init_pos_NE_flag), 0, &(args_info->init_pos_NE_given),
+ &(local_args_info.init_pos_NE_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "init-pos-NE", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set position SE. */
+ else if (strcmp (long_options[option_index].name, "init-pos-SE") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->init_pos_SE_flag), 0, &(args_info->init_pos_SE_given),
+ &(local_args_info.init_pos_SE_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "init-pos-SE", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set position SW. */
+ else if (strcmp (long_options[option_index].name, "init-pos-SW") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->init_pos_SW_flag), 0, &(args_info->init_pos_SW_given),
+ &(local_args_info.init_pos_SW_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "init-pos-SW", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set position NW. */
+ else if (strcmp (long_options[option_index].name, "init-pos-NW") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->init_pos_NW_flag), 0, &(args_info->init_pos_NW_given),
+ &(local_args_info.init_pos_NW_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "init-pos-NW", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set position center. */
+ else if (strcmp (long_options[option_index].name, "init-pos-center") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->init_pos_center_flag), 0, &(args_info->init_pos_center_given),
+ &(local_args_info.init_pos_center_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "init-pos-center", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set initial latitude for ortho mode. */
+ else if (strcmp (long_options[option_index].name, "init-ortho-lat") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->init_ortho_lat_arg),
+ &(args_info->init_ortho_lat_orig), &(args_info->init_ortho_lat_given),
+ &(local_args_info.init_ortho_lat_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "init-ortho-lat", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set initial longitude for ortho mode. */
+ else if (strcmp (long_options[option_index].name, "init-ortho-lon") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->init_ortho_lon_arg),
+ &(args_info->init_ortho_lon_orig), &(args_info->init_ortho_lon_given),
+ &(local_args_info.init_ortho_lon_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "init-ortho-lon", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set initial ortho-view width [km]. */
+ else if (strcmp (long_options[option_index].name, "init-ortho-width") == 0)
+ {
+
+
+ if (update_arg( (void *)&(args_info->init_ortho_width_arg),
+ &(args_info->init_ortho_width_orig), &(args_info->init_ortho_width_given),
+ &(local_args_info.init_ortho_width_given), optarg, 0, 0, ARG_FLOAT,
+ check_ambiguity, override, 0, 0,
+ "init-ortho-width", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set platt projection. */
+ else if (strcmp (long_options[option_index].name, "projection-cyl-platt") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->projection_cyl_platt_flag), 0, &(args_info->projection_cyl_platt_given),
+ &(local_args_info.projection_cyl_platt_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "projection-cyl-platt", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set cylindric projection 1. */
+ else if (strcmp (long_options[option_index].name, "projection-cyl-no1") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->projection_cyl_no1_flag), 0, &(args_info->projection_cyl_no1_given),
+ &(local_args_info.projection_cyl_no1_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "projection-cyl-no1", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set pseudocylindric projection 1. */
+ else if (strcmp (long_options[option_index].name, "projection-pseudo-cyl-no1") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->projection_pseudo_cyl_no1_flag), 0, &(args_info->projection_pseudo_cyl_no1_given),
+ &(local_args_info.projection_pseudo_cyl_no1_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "projection-pseudo-cyl-no1", '-',
+ additional_error))
+ goto failure;
+
+ }
+ /* set mercator projection. */
+ else if (strcmp (long_options[option_index].name, "projection-cyl-mercator") == 0)
+ {
+
+
+ if (update_arg((void *)&(args_info->projection_cyl_mercator_flag), 0, &(args_info->projection_cyl_mercator_given),
+ &(local_args_info.projection_cyl_mercator_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "projection-cyl-mercator", '-',
+ additional_error))
+ goto failure;
+
+ }
+
+ break;
+ case '?': /* Invalid option. */
+ /* `getopt_long' already printed an error message. */
+ goto failure;
+
+ default: /* bug: option not considered. */
+ fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
+ abort ();
+ } /* switch */
+ } /* while */
+
+
+
+
+ cmdline_parser_release (&local_args_info);
+
+ if ( error_occurred )
+ return (EXIT_FAILURE);
+
+ return 0;
+
+failure:
+
+ cmdline_parser_release (&local_args_info);
+ return (EXIT_FAILURE);
+}
diff --git a/src/cmdline.h b/src/cmdline.h
new file mode 100644
index 0000000..1bec8e1
--- /dev/null
+++ b/src/cmdline.h
@@ -0,0 +1,704 @@
+/** @file cmdline.h
+ * @brief The header file for the command line option parser
+ * generated by GNU Gengetopt version 2.22.6
+ * http://www.gnu.org/software/gengetopt.
+ * DO NOT modify this file, since it can be overwritten
+ * @author GNU Gengetopt by Lorenzo Bettini */
+
+#ifndef CMDLINE_H
+#define CMDLINE_H
+
+/* If we use autoconf. */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h> /* for FILE */
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#ifndef CMDLINE_PARSER_PACKAGE
+/** @brief the program name (used for printing errors) */
+#define CMDLINE_PARSER_PACKAGE "OGIE"
+#endif
+
+#ifndef CMDLINE_PARSER_PACKAGE_NAME
+/** @brief the complete program name (used for help and version) */
+#define CMDLINE_PARSER_PACKAGE_NAME "OGIE"
+#endif
+
+#ifndef CMDLINE_PARSER_VERSION
+/** @brief the program version */
+#define CMDLINE_PARSER_VERSION VERSION
+#endif
+
+/** @brief Where the command line options are stored */
+struct gengetopt_args_info
+{
+ const char *help_help; /**< @brief Print help and exit help description. */
+ const char *version_help; /**< @brief Print version and exit help description. */
+ int verbose_flag; /**< @brief verbosity? (default=off). */
+ const char *verbose_help; /**< @brief verbosity? help description. */
+ int quiet_flag; /**< @brief Quiet (default=off). */
+ const char *quiet_help; /**< @brief Quiet help description. */
+ int query_gl_flag; /**< @brief Querying openGL implementation (default=off). */
+ const char *query_gl_help; /**< @brief Querying openGL implementation help description. */
+ int check_flag; /**< @brief return exitcode 0 (default=off). */
+ const char *check_help; /**< @brief return exitcode 0 help description. */
+ int compiler_flag; /**< @brief info about build (default=off). */
+ const char *compiler_help; /**< @brief info about build help description. */
+ int debug_flag; /**< @brief lots of output (default=off). */
+ const char *debug_help; /**< @brief lots of output help description. */
+ char * igc_file_arg; /**< @brief igc-file. */
+ char * igc_file_orig; /**< @brief igc-file original value given at command line. */
+ const char *igc_file_help; /**< @brief igc-file help description. */
+ int gpsd_flag; /**< @brief live gps via gpsd (default=off). */
+ const char *gpsd_help; /**< @brief live gps via gpsd help description. */
+ char * gpsd_server_arg; /**< @brief address of gpsd server. */
+ char * gpsd_server_orig; /**< @brief address of gpsd server original value given at command line. */
+ const char *gpsd_server_help; /**< @brief address of gpsd server help description. */
+ int gpsd_port_arg; /**< @brief port of gpsd server. */
+ char * gpsd_port_orig; /**< @brief port of gpsd server original value given at command line. */
+ const char *gpsd_port_help; /**< @brief port of gpsd server help description. */
+ int gpsalt_flag; /**< @brief use gps altitude (default=off). */
+ const char *gpsalt_help; /**< @brief use gps altitude help description. */
+ int baroalt_flag; /**< @brief use barometric alt (default=off). */
+ const char *baroalt_help; /**< @brief use barometric alt help description. */
+ int use_all_fixes_flag; /**< @brief Use all position fixes (default=off). */
+ const char *use_all_fixes_help; /**< @brief Use all position fixes help description. */
+ float lat_arg; /**< @brief Latitude. */
+ char * lat_orig; /**< @brief Latitude original value given at command line. */
+ const char *lat_help; /**< @brief Latitude help description. */
+ float lon_arg; /**< @brief Longitude. */
+ char * lon_orig; /**< @brief Longitude original value given at command line. */
+ const char *lon_help; /**< @brief Longitude help description. */
+ int get_elevation_flag; /**< @brief Return elevation of lat/lon (default=off). */
+ const char *get_elevation_help; /**< @brief Return elevation of lat/lon help description. */
+ char * config_file_arg; /**< @brief config file. */
+ char * config_file_orig; /**< @brief config file original value given at command line. */
+ const char *config_file_help; /**< @brief config file help description. */
+ int ortho_flag; /**< @brief 2D Orthographic View (default=off). */
+ const char *ortho_help; /**< @brief 2D Orthographic View help description. */
+ int perspective_flag; /**< @brief 3D View (default=off). */
+ const char *perspective_help; /**< @brief 3D View help description. */
+ int aov_arg; /**< @brief angle of view. */
+ char * aov_orig; /**< @brief angle of view original value given at command line. */
+ const char *aov_help; /**< @brief angle of view help description. */
+ int landscape_flag; /**< @brief landscape from dem (default=off). */
+ const char *landscape_help; /**< @brief landscape from dem help description. */
+ int flat_flag; /**< @brief flat underground (default=off). */
+ const char *flat_help; /**< @brief flat underground help description. */
+ int map_flag; /**< @brief display digitized maps (default=off). */
+ const char *map_help; /**< @brief display digitized maps help description. */
+ int no_map_flag; /**< @brief dont use maps (default=off). */
+ const char *no_map_help; /**< @brief dont use maps help description. */
+ char * map_set_name_arg; /**< @brief name of map set to use. */
+ char * map_set_name_orig; /**< @brief name of map set to use original value given at command line. */
+ const char *map_set_name_help; /**< @brief name of map set to use help description. */
+ int modulate_flag; /**< @brief dem color and maps (default=off). */
+ const char *modulate_help; /**< @brief dem color and maps help description. */
+ int no_modulate_flag; /**< @brief no color modulation (default=off). */
+ const char *no_modulate_help; /**< @brief no color modulation help description. */
+ int maps_unlighted_flag; /**< @brief dont use lighting for unmodulated maps (default=off). */
+ const char *maps_unlighted_help; /**< @brief dont use lighting for unmodulated maps help description. */
+ int maps_lighted_flag; /**< @brief use lighting for unmodulated maps (default=off). */
+ const char *maps_lighted_help; /**< @brief use lighting for unmodulated maps help description. */
+ int no_lighting_flag; /**< @brief Dont use lighting for terrain (default=off). */
+ const char *no_lighting_help; /**< @brief Dont use lighting for terrain help description. */
+ int terrain_shading_flag; /**< @brief Use terrain shading (implies no-lighting) (default=off). */
+ const char *terrain_shading_help; /**< @brief Use terrain shading (implies no-lighting) help description. */
+ float shading_scale_arg; /**< @brief shading-scale (1-10000). */
+ char * shading_scale_orig; /**< @brief shading-scale (1-10000) original value given at command line. */
+ const char *shading_scale_help; /**< @brief shading-scale (1-10000) help description. */
+ int light_direction_arg; /**< @brief direction for light (1-8). */
+ char * light_direction_orig; /**< @brief direction for light (1-8) original value given at command line. */
+ const char *light_direction_help; /**< @brief direction for light (1-8) help description. */
+ int airspace_flag; /**< @brief Airspace visualization (default=off). */
+ const char *airspace_help; /**< @brief Airspace visualization help description. */
+ int airspace_wire_flag; /**< @brief Airspace as wireframe (default=off). */
+ const char *airspace_wire_help; /**< @brief Airspace as wireframe help description. */
+ float airspace_wire_col_r_arg; /**< @brief wire color red. */
+ char * airspace_wire_col_r_orig; /**< @brief wire color red original value given at command line. */
+ const char *airspace_wire_col_r_help; /**< @brief wire color red help description. */
+ float airspace_wire_col_g_arg; /**< @brief wire color green. */
+ char * airspace_wire_col_g_orig; /**< @brief wire color green original value given at command line. */
+ const char *airspace_wire_col_g_help; /**< @brief wire color green help description. */
+ float airspace_wire_col_b_arg; /**< @brief wire color blue. */
+ char * airspace_wire_col_b_orig; /**< @brief wire color blue original value given at command line. */
+ const char *airspace_wire_col_b_help; /**< @brief wire color blue help description. */
+ float airspace_wire_width_arg; /**< @brief linewidth wires. */
+ char * airspace_wire_width_orig; /**< @brief linewidth wires original value given at command line. */
+ const char *airspace_wire_width_help; /**< @brief linewidth wires help description. */
+ int airspace_transparent_flag; /**< @brief Airspace transparent (default=off). */
+ const char *airspace_transparent_help; /**< @brief Airspace transparent help description. */
+ int no_airspace_flag; /**< @brief no Airspaces (default=off). */
+ const char *no_airspace_help; /**< @brief no Airspaces help description. */
+ char * airspace_file_arg; /**< @brief use airspaces from file. */
+ char * airspace_file_orig; /**< @brief use airspaces from file original value given at command line. */
+ const char *airspace_file_help; /**< @brief use airspaces from file help description. */
+ int airspace_limit_arg; /**< @brief limit (FL) for airspaces. */
+ char * airspace_limit_orig; /**< @brief limit (FL) for airspaces original value given at command line. */
+ const char *airspace_limit_help; /**< @brief limit (FL) for airspaces help description. */
+ int wire_flag; /**< @brief wireframe landscape (default=off). */
+ const char *wire_help; /**< @brief wireframe landscape help description. */
+ int filled_flag; /**< @brief filled polygons (default=off). */
+ const char *filled_help; /**< @brief filled polygons help description. */
+ int grayscale_flag; /**< @brief grayscaled image (default=off). */
+ const char *grayscale_help; /**< @brief grayscaled image help description. */
+ int color_flag; /**< @brief color image (default=off). */
+ const char *color_help; /**< @brief color image help description. */
+ int stereo_flag; /**< @brief stereoscopic (default=off). */
+ const char *stereo_help; /**< @brief stereoscopic help description. */
+ int no_stereo_flag; /**< @brief no stereoscopic view (default=off). */
+ const char *no_stereo_help; /**< @brief no stereoscopic view help description. */
+ int stereo_rg_flag; /**< @brief stereoscopic red/green (default=off). */
+ const char *stereo_rg_help; /**< @brief stereoscopic red/green help description. */
+ int no_stereo_rg_flag; /**< @brief no stereoscopic red/green (default=off). */
+ const char *no_stereo_rg_help; /**< @brief no stereoscopic red/green help description. */
+ int stereo_rb_flag; /**< @brief stereoscopic red/blue (default=off). */
+ const char *stereo_rb_help; /**< @brief stereoscopic red/blue help description. */
+ int no_stereo_rb_flag; /**< @brief no stereoscopic red/blue (default=off). */
+ const char *no_stereo_rb_help; /**< @brief no stereoscopic red/blue help description. */
+ int stereo_hw_flag; /**< @brief stereoscopic hardware (default=off). */
+ const char *stereo_hw_help; /**< @brief stereoscopic hardware help description. */
+ int no_stereo_hw_flag; /**< @brief no stereoscopic hardware (default=off). */
+ const char *no_stereo_hw_help; /**< @brief no stereoscopic hardware help description. */
+ int inverse_stereo_flag; /**< @brief invert right/left image (default=off). */
+ const char *inverse_stereo_help; /**< @brief invert right/left image help description. */
+ int no_inverse_stereo_flag; /**< @brief dont invert right/left (default=off). */
+ const char *no_inverse_stereo_help; /**< @brief dont invert right/left help description. */
+ float eye_dist_arg; /**< @brief eye distance for stereoscopic view (km). */
+ char * eye_dist_orig; /**< @brief eye distance for stereoscopic view (km) original value given at command line. */
+ const char *eye_dist_help; /**< @brief eye distance for stereoscopic view (km) help description. */
+ int flat_shading_flag; /**< @brief no gouraud (default=off). */
+ const char *flat_shading_help; /**< @brief no gouraud help description. */
+ int gouraud_shading_flag; /**< @brief use gouraud-shading (default=off). */
+ const char *gouraud_shading_help; /**< @brief use gouraud-shading help description. */
+ int quads_flag; /**< @brief use quadrilaterals (default=off). */
+ const char *quads_help; /**< @brief use quadrilaterals help description. */
+ int curtain_flag; /**< @brief draw curtain (default=off). */
+ const char *curtain_help; /**< @brief draw curtain help description. */
+ int no_curtain_flag; /**< @brief draw no curtain (default=off). */
+ const char *no_curtain_help; /**< @brief draw no curtain help description. */
+ int haze_flag; /**< @brief draw haze (default=off). */
+ const char *haze_help; /**< @brief draw haze help description. */
+ int no_haze_flag; /**< @brief draw no haze (default=off). */
+ const char *no_haze_help; /**< @brief draw no haze help description. */
+ float haze_density_arg; /**< @brief haze density (0-0.5). */
+ char * haze_density_orig; /**< @brief haze density (0-0.5) original value given at command line. */
+ const char *haze_density_help; /**< @brief haze density (0-0.5) help description. */
+ int colormap_arg; /**< @brief no. of colormap to use. */
+ char * colormap_orig; /**< @brief no. of colormap to use original value given at command line. */
+ const char *colormap_help; /**< @brief no. of colormap to use help description. */
+ int colormap_sea_arg; /**< @brief colormap 2 (sea). */
+ char * colormap_sea_orig; /**< @brief colormap 2 (sea) original value given at command line. */
+ const char *colormap_sea_help; /**< @brief colormap 2 (sea) help description. */
+ int colormap_min_arg; /**< @brief mininum height. */
+ char * colormap_min_orig; /**< @brief mininum height original value given at command line. */
+ const char *colormap_min_help; /**< @brief mininum height help description. */
+ int colormap_max_arg; /**< @brief maximum height. */
+ char * colormap_max_orig; /**< @brief maximum height original value given at command line. */
+ const char *colormap_max_help; /**< @brief maximum height help description. */
+ int sealevel_arg; /**< @brief set sealevel. */
+ char * sealevel_orig; /**< @brief set sealevel original value given at command line. */
+ const char *sealevel_help; /**< @brief set sealevel help description. */
+ int sealevel2_arg; /**< @brief set sealevel2. */
+ char * sealevel2_orig; /**< @brief set sealevel2 original value given at command line. */
+ const char *sealevel2_help; /**< @brief set sealevel2 help description. */
+ int sealevel3_arg; /**< @brief set sealevel3. */
+ char * sealevel3_orig; /**< @brief set sealevel3 original value given at command line. */
+ const char *sealevel3_help; /**< @brief set sealevel3 help description. */
+ int ignore_elev_min_arg; /**< @brief ignore range min. */
+ char * ignore_elev_min_orig; /**< @brief ignore range min original value given at command line. */
+ const char *ignore_elev_min_help; /**< @brief ignore range min help description. */
+ int ignore_elev_max_arg; /**< @brief ignore range max. */
+ char * ignore_elev_max_orig; /**< @brief ignore range max original value given at command line. */
+ const char *ignore_elev_max_help; /**< @brief ignore range max help description. */
+ float scalez_arg; /**< @brief z axis scaling. */
+ char * scalez_orig; /**< @brief z axis scaling original value given at command line. */
+ const char *scalez_help; /**< @brief z axis scaling help description. */
+ int downscaling_arg; /**< @brief dem raster downscaling. */
+ char * downscaling_orig; /**< @brief dem raster downscaling original value given at command line. */
+ const char *downscaling_help; /**< @brief dem raster downscaling help description. */
+ int upscaling_arg; /**< @brief dem raster interpolation factor. */
+ char * upscaling_orig; /**< @brief dem raster interpolation factor original value given at command line. */
+ const char *upscaling_help; /**< @brief dem raster interpolation factor help description. */
+ int fullscreen_flag; /**< @brief Fullscreen (default=off). */
+ const char *fullscreen_help; /**< @brief Fullscreen help description. */
+ int window_flag; /**< @brief start windowed (default=off). */
+ const char *window_help; /**< @brief start windowed help description. */
+ int width_arg; /**< @brief Window width. */
+ char * width_orig; /**< @brief Window width original value given at command line. */
+ const char *width_help; /**< @brief Window width help description. */
+ int height_arg; /**< @brief Window height. */
+ char * height_orig; /**< @brief Window height original value given at command line. */
+ const char *height_help; /**< @brief Window height help description. */
+ float border_arg; /**< @brief Border Lat and Lon. */
+ char * border_orig; /**< @brief Border Lat and Lon original value given at command line. */
+ const char *border_help; /**< @brief Border Lat and Lon help description. */
+ float border_lat_arg; /**< @brief Border Lat. */
+ char * border_lat_orig; /**< @brief Border Lat original value given at command line. */
+ const char *border_lat_help; /**< @brief Border Lat help description. */
+ float border_lon_arg; /**< @brief Border Lon. */
+ char * border_lon_orig; /**< @brief Border Lon original value given at command line. */
+ const char *border_lon_help; /**< @brief Border Lon help description. */
+ int offset_arg; /**< @brief height offset in m. */
+ char * offset_orig; /**< @brief height offset in m original value given at command line. */
+ const char *offset_help; /**< @brief height offset in m help description. */
+ int airfield_elevation_arg; /**< @brief Elevation of airfield (take-off) in m. */
+ char * airfield_elevation_orig; /**< @brief Elevation of airfield (take-off) in m original value given at command line. */
+ const char *airfield_elevation_help; /**< @brief Elevation of airfield (take-off) in m help description. */
+ int marker_pos_arg; /**< @brief Position of marker. */
+ char * marker_pos_orig; /**< @brief Position of marker original value given at command line. */
+ const char *marker_pos_help; /**< @brief Position of marker help description. */
+ char * marker_time_arg; /**< @brief Time of markerposition. */
+ char * marker_time_orig; /**< @brief Time of markerposition original value given at command line. */
+ const char *marker_time_help; /**< @brief Time of markerposition help description. */
+ int marker_flag; /**< @brief Marker (default=off). */
+ const char *marker_help; /**< @brief Marker help description. */
+ float marker_size_arg; /**< @brief Size of the Marker. */
+ char * marker_size_orig; /**< @brief Size of the Marker original value given at command line. */
+ const char *marker_size_help; /**< @brief Size of the Marker help description. */
+ int no_marker_flag; /**< @brief no Marker (default=off). */
+ const char *no_marker_help; /**< @brief no Marker help description. */
+ int info_flag; /**< @brief Info text display (default=off). */
+ const char *info_help; /**< @brief Info text display help description. */
+ int no_info_flag; /**< @brief no info text display (default=off). */
+ const char *no_info_help; /**< @brief no info text display help description. */
+ char * text_arg; /**< @brief Text string to display. */
+ char * text_orig; /**< @brief Text string to display original value given at command line. */
+ const char *text_help; /**< @brief Text string to display help description. */
+ int no_position_info_flag; /**< @brief Turn off viewpoint position info (default=off). */
+ const char *no_position_info_help; /**< @brief Turn off viewpoint position info help description. */
+ int no_marker_pos_info_flag; /**< @brief Turn off marker position info (default=off). */
+ const char *no_marker_pos_info_help; /**< @brief Turn off marker position info help description. */
+ float text_size_arg; /**< @brief Size of text for points/lifts (0.001-1.0). */
+ char * text_size_orig; /**< @brief Size of text for points/lifts (0.001-1.0) original value given at command line. */
+ const char *text_size_help; /**< @brief Size of text for points/lifts (0.001-1.0) help description. */
+ float text_width_arg; /**< @brief Width of text (1-20). */
+ char * text_width_orig; /**< @brief Width of text (1-20) original value given at command line. */
+ const char *text_width_help; /**< @brief Width of text (1-20) help description. */
+ char * lifts_arg; /**< @brief GPLIGC liftsfile. */
+ char * lifts_orig; /**< @brief GPLIGC liftsfile original value given at command line. */
+ const char *lifts_help; /**< @brief GPLIGC liftsfile help description. */
+ int lifts_info_mode_arg; /**< @brief which info to display (1-7). */
+ char * lifts_info_mode_orig; /**< @brief which info to display (1-7) original value given at command line. */
+ const char *lifts_info_mode_help; /**< @brief which info to display (1-7) help description. */
+ char * waypoints_file_arg; /**< @brief waypointsfile. */
+ char * waypoints_file_orig; /**< @brief waypointsfile original value given at command line. */
+ const char *waypoints_file_help; /**< @brief waypointsfile help description. */
+ int waypoints_flag; /**< @brief show waypoints (default=off). */
+ const char *waypoints_help; /**< @brief show waypoints help description. */
+ int no_waypoints_flag; /**< @brief dont show waypoints (default=off). */
+ const char *no_waypoints_help; /**< @brief dont show waypoints help description. */
+ int waypoints_info_mode_arg; /**< @brief which info to display (1-4). */
+ char * waypoints_info_mode_orig; /**< @brief which info to display (1-4) original value given at command line. */
+ const char *waypoints_info_mode_help; /**< @brief which info to display (1-4) help description. */
+ int waypoints_offset_arg; /**< @brief offset for displaying waypoint text in 3D. */
+ char * waypoints_offset_orig; /**< @brief offset for displaying waypoint text in 3D original value given at command line. */
+ const char *waypoints_offset_help; /**< @brief offset for displaying waypoint text in 3D help description. */
+ int waypoints_offset_spheres_arg; /**< @brief offset for displaying waypoint spheres and text in 3D. */
+ char * waypoints_offset_spheres_orig; /**< @brief offset for displaying waypoint spheres and text in 3D original value given at command line. */
+ const char *waypoints_offset_spheres_help; /**< @brief offset for displaying waypoint spheres and text in 3D help description. */
+ int flighttrack_mode_arg; /**< @brief sets the mode of track display. */
+ char * flighttrack_mode_orig; /**< @brief sets the mode of track display original value given at command line. */
+ const char *flighttrack_mode_help; /**< @brief sets the mode of track display help description. */
+ int flighttrack_colormap_arg; /**< @brief sets the colourmap for flighttrack. */
+ char * flighttrack_colormap_orig; /**< @brief sets the colourmap for flighttrack original value given at command line. */
+ const char *flighttrack_colormap_help; /**< @brief sets the colourmap for flighttrack help description. */
+ float flighttrack_linewidth_arg; /**< @brief sets the linewidth of the flighttrack. */
+ char * flighttrack_linewidth_orig; /**< @brief sets the linewidth of the flighttrack original value given at command line. */
+ const char *flighttrack_linewidth_help; /**< @brief sets the linewidth of the flighttrack help description. */
+ int follow_flag; /**< @brief viewpoint follows marker (default=off). */
+ const char *follow_help; /**< @brief viewpoint follows marker help description. */
+ int no_follow_flag; /**< @brief viewpoint doesnt follow marker (default=off). */
+ const char *no_follow_help; /**< @brief viewpoint doesnt follow marker help description. */
+ int marker_range_flag; /**< @brief range around marker is plottet (default=off). */
+ const char *marker_range_help; /**< @brief range around marker is plottet help description. */
+ int no_marker_range_flag; /**< @brief full flight is displayed (default=off). */
+ const char *no_marker_range_help; /**< @brief full flight is displayed help description. */
+ int marker_ahead_arg; /**< @brief define marker range. */
+ char * marker_ahead_orig; /**< @brief define marker range original value given at command line. */
+ const char *marker_ahead_help; /**< @brief define marker range help description. */
+ int marker_back_arg; /**< @brief define marker range. */
+ char * marker_back_orig; /**< @brief define marker range original value given at command line. */
+ const char *marker_back_help; /**< @brief define marker range help description. */
+ int movie_flag; /**< @brief start up in movie mode (default=off). */
+ const char *movie_help; /**< @brief start up in movie mode help description. */
+ int cycles_arg; /**< @brief cycles for movie mode. */
+ char * cycles_orig; /**< @brief cycles for movie mode original value given at command line. */
+ const char *cycles_help; /**< @brief cycles for movie mode help description. */
+ float spinning_arg; /**< @brief spinning for movie mode. */
+ char * spinning_orig; /**< @brief spinning for movie mode original value given at command line. */
+ const char *spinning_help; /**< @brief spinning for movie mode help description. */
+ int smooth_mouse_flag; /**< @brief smooth movement (default=off). */
+ const char *smooth_mouse_help; /**< @brief smooth movement help description. */
+ int parent_pid_arg; /**< @brief PID of parent. */
+ char * parent_pid_orig; /**< @brief PID of parent original value given at command line. */
+ const char *parent_pid_help; /**< @brief PID of parent help description. */
+ int compression_flag; /**< @brief Use texture map compression (default=off). */
+ const char *compression_help; /**< @brief Use texture map compression help description. */
+ int no_compression_flag; /**< @brief Dont use texture map compression (default=off). */
+ const char *no_compression_help; /**< @brief Dont use texture map compression help description. */
+ int offscreen_flag; /**< @brief Offscreen with GLX (default=off). */
+ const char *offscreen_help; /**< @brief Offscreen with GLX help description. */
+ int osmesa_flag; /**< @brief Offscreen with Mesa (default=off). */
+ const char *osmesa_help; /**< @brief Offscreen with Mesa help description. */
+ char * os_outfile_arg; /**< @brief outfile for offscreen rendering. */
+ char * os_outfile_orig; /**< @brief outfile for offscreen rendering original value given at command line. */
+ const char *os_outfile_help; /**< @brief outfile for offscreen rendering help description. */
+ int jpeg_quality_arg; /**< @brief Quality (0-100) of jpeg output. */
+ char * jpeg_quality_orig; /**< @brief Quality (0-100) of jpeg output original value given at command line. */
+ const char *jpeg_quality_help; /**< @brief Quality (0-100) of jpeg output help description. */
+ char * image_format_arg; /**< @brief Image format for screenshots. */
+ char * image_format_orig; /**< @brief Image format for screenshots original value given at command line. */
+ const char *image_format_help; /**< @brief Image format for screenshots help description. */
+ char * save_path_arg; /**< @brief Path to save screenshots. */
+ char * save_path_orig; /**< @brief Path to save screenshots original value given at command line. */
+ const char *save_path_help; /**< @brief Path to save screenshots help description. */
+ char * basename_arg; /**< @brief Basename of screenshots. */
+ char * basename_orig; /**< @brief Basename of screenshots original value given at command line. */
+ const char *basename_help; /**< @brief Basename of screenshots help description. */
+ float clipping_far_arg; /**< @brief clipping far. */
+ char * clipping_far_orig; /**< @brief clipping far original value given at command line. */
+ const char *clipping_far_help; /**< @brief clipping far help description. */
+ float clipping_near_arg; /**< @brief clipping near. */
+ char * clipping_near_orig; /**< @brief clipping near original value given at command line. */
+ const char *clipping_near_help; /**< @brief clipping near help description. */
+ float init_lat_arg; /**< @brief set initial latitude. */
+ char * init_lat_orig; /**< @brief set initial latitude original value given at command line. */
+ const char *init_lat_help; /**< @brief set initial latitude help description. */
+ float init_lon_arg; /**< @brief set initial longitude. */
+ char * init_lon_orig; /**< @brief set initial longitude original value given at command line. */
+ const char *init_lon_help; /**< @brief set initial longitude help description. */
+ int init_alt_arg; /**< @brief set initial altitude. */
+ char * init_alt_orig; /**< @brief set initial altitude original value given at command line. */
+ const char *init_alt_help; /**< @brief set initial altitude help description. */
+ int init_heading_arg; /**< @brief set initial heading. */
+ char * init_heading_orig; /**< @brief set initial heading original value given at command line. */
+ const char *init_heading_help; /**< @brief set initial heading help description. */
+ int init_dive_arg; /**< @brief set initial dive angle. */
+ char * init_dive_orig; /**< @brief set initial dive angle original value given at command line. */
+ const char *init_dive_help; /**< @brief set initial dive angle help description. */
+ int init_pos_N_flag; /**< @brief set position North (default=off). */
+ const char *init_pos_N_help; /**< @brief set position North help description. */
+ int init_pos_E_flag; /**< @brief set position East (default=off). */
+ const char *init_pos_E_help; /**< @brief set position East help description. */
+ int init_pos_S_flag; /**< @brief set position South (default=off). */
+ const char *init_pos_S_help; /**< @brief set position South help description. */
+ int init_pos_W_flag; /**< @brief set position West (default=off). */
+ const char *init_pos_W_help; /**< @brief set position West help description. */
+ int init_pos_NE_flag; /**< @brief set position NE (default=off). */
+ const char *init_pos_NE_help; /**< @brief set position NE help description. */
+ int init_pos_SE_flag; /**< @brief set position SE (default=off). */
+ const char *init_pos_SE_help; /**< @brief set position SE help description. */
+ int init_pos_SW_flag; /**< @brief set position SW (default=off). */
+ const char *init_pos_SW_help; /**< @brief set position SW help description. */
+ int init_pos_NW_flag; /**< @brief set position NW (default=off). */
+ const char *init_pos_NW_help; /**< @brief set position NW help description. */
+ int init_pos_center_flag; /**< @brief set position center (default=off). */
+ const char *init_pos_center_help; /**< @brief set position center help description. */
+ float init_ortho_lat_arg; /**< @brief set initial latitude for ortho mode. */
+ char * init_ortho_lat_orig; /**< @brief set initial latitude for ortho mode original value given at command line. */
+ const char *init_ortho_lat_help; /**< @brief set initial latitude for ortho mode help description. */
+ float init_ortho_lon_arg; /**< @brief set initial longitude for ortho mode. */
+ char * init_ortho_lon_orig; /**< @brief set initial longitude for ortho mode original value given at command line. */
+ const char *init_ortho_lon_help; /**< @brief set initial longitude for ortho mode help description. */
+ float init_ortho_width_arg; /**< @brief set initial ortho-view width [km]. */
+ char * init_ortho_width_orig; /**< @brief set initial ortho-view width [km] original value given at command line. */
+ const char *init_ortho_width_help; /**< @brief set initial ortho-view width [km] help description. */
+ int projection_cyl_platt_flag; /**< @brief set platt projection (default=off). */
+ const char *projection_cyl_platt_help; /**< @brief set platt projection help description. */
+ int projection_cyl_no1_flag; /**< @brief set cylindric projection 1 (default=off). */
+ const char *projection_cyl_no1_help; /**< @brief set cylindric projection 1 help description. */
+ int projection_pseudo_cyl_no1_flag; /**< @brief set pseudocylindric projection 1 (default=off). */
+ const char *projection_pseudo_cyl_no1_help; /**< @brief set pseudocylindric projection 1 help description. */
+ int projection_cyl_mercator_flag; /**< @brief set mercator projection (default=off). */
+ const char *projection_cyl_mercator_help; /**< @brief set mercator projection help description. */
+
+ unsigned int help_given ; /**< @brief Whether help was given. */
+ unsigned int version_given ; /**< @brief Whether version was given. */
+ unsigned int verbose_given ; /**< @brief Whether verbose was given. */
+ unsigned int quiet_given ; /**< @brief Whether quiet was given. */
+ unsigned int query_gl_given ; /**< @brief Whether query-gl was given. */
+ unsigned int check_given ; /**< @brief Whether check was given. */
+ unsigned int compiler_given ; /**< @brief Whether compiler was given. */
+ unsigned int debug_given ; /**< @brief Whether debug was given. */
+ unsigned int igc_file_given ; /**< @brief Whether igc-file was given. */
+ unsigned int gpsd_given ; /**< @brief Whether gpsd was given. */
+ unsigned int gpsd_server_given ; /**< @brief Whether gpsd-server was given. */
+ unsigned int gpsd_port_given ; /**< @brief Whether gpsd-port was given. */
+ unsigned int gpsalt_given ; /**< @brief Whether gpsalt was given. */
+ unsigned int baroalt_given ; /**< @brief Whether baroalt was given. */
+ unsigned int use_all_fixes_given ; /**< @brief Whether use-all-fixes was given. */
+ unsigned int lat_given ; /**< @brief Whether lat was given. */
+ unsigned int lon_given ; /**< @brief Whether lon was given. */
+ unsigned int get_elevation_given ; /**< @brief Whether get-elevation was given. */
+ unsigned int config_file_given ; /**< @brief Whether config-file was given. */
+ unsigned int ortho_given ; /**< @brief Whether ortho was given. */
+ unsigned int perspective_given ; /**< @brief Whether perspective was given. */
+ unsigned int aov_given ; /**< @brief Whether aov was given. */
+ unsigned int landscape_given ; /**< @brief Whether landscape was given. */
+ unsigned int flat_given ; /**< @brief Whether flat was given. */
+ unsigned int map_given ; /**< @brief Whether map was given. */
+ unsigned int no_map_given ; /**< @brief Whether no-map was given. */
+ unsigned int map_set_name_given ; /**< @brief Whether map-set-name was given. */
+ unsigned int modulate_given ; /**< @brief Whether modulate was given. */
+ unsigned int no_modulate_given ; /**< @brief Whether no-modulate was given. */
+ unsigned int maps_unlighted_given ; /**< @brief Whether maps-unlighted was given. */
+ unsigned int maps_lighted_given ; /**< @brief Whether maps-lighted was given. */
+ unsigned int no_lighting_given ; /**< @brief Whether no-lighting was given. */
+ unsigned int terrain_shading_given ; /**< @brief Whether terrain-shading was given. */
+ unsigned int shading_scale_given ; /**< @brief Whether shading-scale was given. */
+ unsigned int light_direction_given ; /**< @brief Whether light-direction was given. */
+ unsigned int airspace_given ; /**< @brief Whether airspace was given. */
+ unsigned int airspace_wire_given ; /**< @brief Whether airspace-wire was given. */
+ unsigned int airspace_wire_col_r_given ; /**< @brief Whether airspace-wire-col-r was given. */
+ unsigned int airspace_wire_col_g_given ; /**< @brief Whether airspace-wire-col-g was given. */
+ unsigned int airspace_wire_col_b_given ; /**< @brief Whether airspace-wire-col-b was given. */
+ unsigned int airspace_wire_width_given ; /**< @brief Whether airspace-wire-width was given. */
+ unsigned int airspace_transparent_given ; /**< @brief Whether airspace-transparent was given. */
+ unsigned int no_airspace_given ; /**< @brief Whether no-airspace was given. */
+ unsigned int airspace_file_given ; /**< @brief Whether airspace-file was given. */
+ unsigned int airspace_limit_given ; /**< @brief Whether airspace-limit was given. */
+ unsigned int wire_given ; /**< @brief Whether wire was given. */
+ unsigned int filled_given ; /**< @brief Whether filled was given. */
+ unsigned int grayscale_given ; /**< @brief Whether grayscale was given. */
+ unsigned int color_given ; /**< @brief Whether color was given. */
+ unsigned int stereo_given ; /**< @brief Whether stereo was given. */
+ unsigned int no_stereo_given ; /**< @brief Whether no-stereo was given. */
+ unsigned int stereo_rg_given ; /**< @brief Whether stereo-rg was given. */
+ unsigned int no_stereo_rg_given ; /**< @brief Whether no-stereo-rg was given. */
+ unsigned int stereo_rb_given ; /**< @brief Whether stereo-rb was given. */
+ unsigned int no_stereo_rb_given ; /**< @brief Whether no-stereo-rb was given. */
+ unsigned int stereo_hw_given ; /**< @brief Whether stereo-hw was given. */
+ unsigned int no_stereo_hw_given ; /**< @brief Whether no-stereo-hw was given. */
+ unsigned int inverse_stereo_given ; /**< @brief Whether inverse-stereo was given. */
+ unsigned int no_inverse_stereo_given ; /**< @brief Whether no-inverse-stereo was given. */
+ unsigned int eye_dist_given ; /**< @brief Whether eye-dist was given. */
+ unsigned int flat_shading_given ; /**< @brief Whether flat-shading was given. */
+ unsigned int gouraud_shading_given ; /**< @brief Whether gouraud-shading was given. */
+ unsigned int quads_given ; /**< @brief Whether quads was given. */
+ unsigned int curtain_given ; /**< @brief Whether curtain was given. */
+ unsigned int no_curtain_given ; /**< @brief Whether no-curtain was given. */
+ unsigned int haze_given ; /**< @brief Whether haze was given. */
+ unsigned int no_haze_given ; /**< @brief Whether no-haze was given. */
+ unsigned int haze_density_given ; /**< @brief Whether haze-density was given. */
+ unsigned int colormap_given ; /**< @brief Whether colormap was given. */
+ unsigned int colormap_sea_given ; /**< @brief Whether colormap-sea was given. */
+ unsigned int colormap_min_given ; /**< @brief Whether colormap-min was given. */
+ unsigned int colormap_max_given ; /**< @brief Whether colormap-max was given. */
+ unsigned int sealevel_given ; /**< @brief Whether sealevel was given. */
+ unsigned int sealevel2_given ; /**< @brief Whether sealevel2 was given. */
+ unsigned int sealevel3_given ; /**< @brief Whether sealevel3 was given. */
+ unsigned int ignore_elev_min_given ; /**< @brief Whether ignore-elev-min was given. */
+ unsigned int ignore_elev_max_given ; /**< @brief Whether ignore-elev-max was given. */
+ unsigned int scalez_given ; /**< @brief Whether scalez was given. */
+ unsigned int downscaling_given ; /**< @brief Whether downscaling was given. */
+ unsigned int upscaling_given ; /**< @brief Whether upscaling was given. */
+ unsigned int fullscreen_given ; /**< @brief Whether fullscreen was given. */
+ unsigned int window_given ; /**< @brief Whether window was given. */
+ unsigned int width_given ; /**< @brief Whether width was given. */
+ unsigned int height_given ; /**< @brief Whether height was given. */
+ unsigned int border_given ; /**< @brief Whether border was given. */
+ unsigned int border_lat_given ; /**< @brief Whether border-lat was given. */
+ unsigned int border_lon_given ; /**< @brief Whether border-lon was given. */
+ unsigned int offset_given ; /**< @brief Whether offset was given. */
+ unsigned int airfield_elevation_given ; /**< @brief Whether airfield-elevation was given. */
+ unsigned int marker_pos_given ; /**< @brief Whether marker-pos was given. */
+ unsigned int marker_time_given ; /**< @brief Whether marker-time was given. */
+ unsigned int marker_given ; /**< @brief Whether marker was given. */
+ unsigned int marker_size_given ; /**< @brief Whether marker-size was given. */
+ unsigned int no_marker_given ; /**< @brief Whether no-marker was given. */
+ unsigned int info_given ; /**< @brief Whether info was given. */
+ unsigned int no_info_given ; /**< @brief Whether no-info was given. */
+ unsigned int text_given ; /**< @brief Whether text was given. */
+ unsigned int no_position_info_given ; /**< @brief Whether no-position-info was given. */
+ unsigned int no_marker_pos_info_given ; /**< @brief Whether no-marker-pos-info was given. */
+ unsigned int text_size_given ; /**< @brief Whether text-size was given. */
+ unsigned int text_width_given ; /**< @brief Whether text-width was given. */
+ unsigned int lifts_given ; /**< @brief Whether lifts was given. */
+ unsigned int lifts_info_mode_given ; /**< @brief Whether lifts-info-mode was given. */
+ unsigned int waypoints_file_given ; /**< @brief Whether waypoints-file was given. */
+ unsigned int waypoints_given ; /**< @brief Whether waypoints was given. */
+ unsigned int no_waypoints_given ; /**< @brief Whether no-waypoints was given. */
+ unsigned int waypoints_info_mode_given ; /**< @brief Whether waypoints-info-mode was given. */
+ unsigned int waypoints_offset_given ; /**< @brief Whether waypoints-offset was given. */
+ unsigned int waypoints_offset_spheres_given ; /**< @brief Whether waypoints-offset-spheres was given. */
+ unsigned int flighttrack_mode_given ; /**< @brief Whether flighttrack-mode was given. */
+ unsigned int flighttrack_colormap_given ; /**< @brief Whether flighttrack-colormap was given. */
+ unsigned int flighttrack_linewidth_given ; /**< @brief Whether flighttrack-linewidth was given. */
+ unsigned int follow_given ; /**< @brief Whether follow was given. */
+ unsigned int no_follow_given ; /**< @brief Whether no-follow was given. */
+ unsigned int marker_range_given ; /**< @brief Whether marker-range was given. */
+ unsigned int no_marker_range_given ; /**< @brief Whether no-marker-range was given. */
+ unsigned int marker_ahead_given ; /**< @brief Whether marker-ahead was given. */
+ unsigned int marker_back_given ; /**< @brief Whether marker-back was given. */
+ unsigned int movie_given ; /**< @brief Whether movie was given. */
+ unsigned int cycles_given ; /**< @brief Whether cycles was given. */
+ unsigned int spinning_given ; /**< @brief Whether spinning was given. */
+ unsigned int smooth_mouse_given ; /**< @brief Whether smooth-mouse was given. */
+ unsigned int parent_pid_given ; /**< @brief Whether parent-pid was given. */
+ unsigned int compression_given ; /**< @brief Whether compression was given. */
+ unsigned int no_compression_given ; /**< @brief Whether no-compression was given. */
+ unsigned int offscreen_given ; /**< @brief Whether offscreen was given. */
+ unsigned int osmesa_given ; /**< @brief Whether osmesa was given. */
+ unsigned int os_outfile_given ; /**< @brief Whether os-outfile was given. */
+ unsigned int jpeg_quality_given ; /**< @brief Whether jpeg-quality was given. */
+ unsigned int image_format_given ; /**< @brief Whether image-format was given. */
+ unsigned int save_path_given ; /**< @brief Whether save-path was given. */
+ unsigned int basename_given ; /**< @brief Whether basename was given. */
+ unsigned int clipping_far_given ; /**< @brief Whether clipping-far was given. */
+ unsigned int clipping_near_given ; /**< @brief Whether clipping-near was given. */
+ unsigned int init_lat_given ; /**< @brief Whether init-lat was given. */
+ unsigned int init_lon_given ; /**< @brief Whether init-lon was given. */
+ unsigned int init_alt_given ; /**< @brief Whether init-alt was given. */
+ unsigned int init_heading_given ; /**< @brief Whether init-heading was given. */
+ unsigned int init_dive_given ; /**< @brief Whether init-dive was given. */
+ unsigned int init_pos_N_given ; /**< @brief Whether init-pos-N was given. */
+ unsigned int init_pos_E_given ; /**< @brief Whether init-pos-E was given. */
+ unsigned int init_pos_S_given ; /**< @brief Whether init-pos-S was given. */
+ unsigned int init_pos_W_given ; /**< @brief Whether init-pos-W was given. */
+ unsigned int init_pos_NE_given ; /**< @brief Whether init-pos-NE was given. */
+ unsigned int init_pos_SE_given ; /**< @brief Whether init-pos-SE was given. */
+ unsigned int init_pos_SW_given ; /**< @brief Whether init-pos-SW was given. */
+ unsigned int init_pos_NW_given ; /**< @brief Whether init-pos-NW was given. */
+ unsigned int init_pos_center_given ; /**< @brief Whether init-pos-center was given. */
+ unsigned int init_ortho_lat_given ; /**< @brief Whether init-ortho-lat was given. */
+ unsigned int init_ortho_lon_given ; /**< @brief Whether init-ortho-lon was given. */
+ unsigned int init_ortho_width_given ; /**< @brief Whether init-ortho-width was given. */
+ unsigned int projection_cyl_platt_given ; /**< @brief Whether projection-cyl-platt was given. */
+ unsigned int projection_cyl_no1_given ; /**< @brief Whether projection-cyl-no1 was given. */
+ unsigned int projection_pseudo_cyl_no1_given ; /**< @brief Whether projection-pseudo-cyl-no1 was given. */
+ unsigned int projection_cyl_mercator_given ; /**< @brief Whether projection-cyl-mercator was given. */
+
+} ;
+
+/** @brief The additional parameters to pass to parser functions */
+struct cmdline_parser_params
+{
+ int override; /**< @brief whether to override possibly already present options (default 0) */
+ int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */
+ int check_required; /**< @brief whether to check that all required options were provided (default 1) */
+ int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */
+ int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */
+} ;
+
+/** @brief the purpose string of the program */
+extern const char *gengetopt_args_info_purpose;
+/** @brief the usage string of the program */
+extern const char *gengetopt_args_info_usage;
+/** @brief the description string of the program */
+extern const char *gengetopt_args_info_description;
+/** @brief all the lines making the help output */
+extern const char *gengetopt_args_info_help[];
+
+/**
+ * The command line parser
+ * @param argc the number of command line options
+ * @param argv the command line options
+ * @param args_info the structure where option information will be stored
+ * @return 0 if everything went fine, NON 0 if an error took place
+ */
+int cmdline_parser (int argc, char **argv,
+ struct gengetopt_args_info *args_info);
+
+/**
+ * The command line parser (version with additional parameters - deprecated)
+ * @param argc the number of command line options
+ * @param argv the command line options
+ * @param args_info the structure where option information will be stored
+ * @param override whether to override possibly already present options
+ * @param initialize whether to initialize the option structure my_args_info
+ * @param check_required whether to check that all required options were provided
+ * @return 0 if everything went fine, NON 0 if an error took place
+ * @deprecated use cmdline_parser_ext() instead
+ */
+int cmdline_parser2 (int argc, char **argv,
+ struct gengetopt_args_info *args_info,
+ int override, int initialize, int check_required);
+
+/**
+ * The command line parser (version with additional parameters)
+ * @param argc the number of command line options
+ * @param argv the command line options
+ * @param args_info the structure where option information will be stored
+ * @param params additional parameters for the parser
+ * @return 0 if everything went fine, NON 0 if an error took place
+ */
+int cmdline_parser_ext (int argc, char **argv,
+ struct gengetopt_args_info *args_info,
+ struct cmdline_parser_params *params);
+
+/**
+ * Save the contents of the option struct into an already open FILE stream.
+ * @param outfile the stream where to dump options
+ * @param args_info the option struct to dump
+ * @return 0 if everything went fine, NON 0 if an error took place
+ */
+int cmdline_parser_dump(FILE *outfile,
+ struct gengetopt_args_info *args_info);
+
+/**
+ * Save the contents of the option struct into a (text) file.
+ * This file can be read by the config file parser (if generated by gengetopt)
+ * @param filename the file where to save
+ * @param args_info the option struct to save
+ * @return 0 if everything went fine, NON 0 if an error took place
+ */
+int cmdline_parser_file_save(const char *filename,
+ struct gengetopt_args_info *args_info);
+
+/**
+ * Print the help
+ */
+void cmdline_parser_print_help(void);
+/**
+ * Print the version
+ */
+void cmdline_parser_print_version(void);
+
+/**
+ * Initializes all the fields a cmdline_parser_params structure
+ * to their default values
+ * @param params the structure to initialize
+ */
+void cmdline_parser_params_init(struct cmdline_parser_params *params);
+
+/**
+ * Allocates dynamically a cmdline_parser_params structure and initializes
+ * all its fields to their default values
+ * @return the created and initialized cmdline_parser_params structure
+ */
+struct cmdline_parser_params *cmdline_parser_params_create(void);
+
+/**
+ * Initializes the passed gengetopt_args_info structure's fields
+ * (also set default values for options that have a default)
+ * @param args_info the structure to initialize
+ */
+void cmdline_parser_init (struct gengetopt_args_info *args_info);
+/**
+ * Deallocates the string fields of the gengetopt_args_info structure
+ * (but does not deallocate the structure itself)
+ * @param args_info the structure to deallocate
+ */
+void cmdline_parser_free (struct gengetopt_args_info *args_info);
+
+/**
+ * Checks that all the required options were specified
+ * @param args_info the structure to check
+ * @param prog_name the name of the program that will be used to print
+ * possible errors
+ * @return
+ */
+int cmdline_parser_required (struct gengetopt_args_info *args_info,
+ const char *prog_name);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* CMDLINE_H */
diff --git a/src/createworlddem.cpp b/src/createworlddem.cpp
new file mode 100644
index 0000000..b0c9e6d
--- /dev/null
+++ b/src/createworlddem.cpp
@@ -0,0 +1,466 @@
+/*
+ * (c) 2002-2016 Hannes Krueger
+ * This file is part of the GPLIGC/ogie package
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <cstdlib>
+
+
+//const std::string rcsid_createworld_cpp =
+// "$Id: createworlddem.cpp 3 2014-07-31 09:59:20Z kruegerh $";
+using namespace std;
+
+int main(void)
+{
+ int i, j;
+ char tmp;
+ bool FAILED = false;
+
+ // set 1
+ //6,000 rows and 4,800 columns
+ ifstream w180n90;
+ ifstream w140n90;
+ ifstream w100n90;
+ ifstream w060n90;
+ ifstream w020n90;
+ ifstream e020n90;
+ ifstream e060n90;
+ ifstream e100n90;
+ ifstream e140n90;
+
+ // set 2
+
+ ifstream w180n40;
+ ifstream w140n40;
+ ifstream w100n40;
+ ifstream w060n40;
+ ifstream w020n40;
+ ifstream e020n40;
+ ifstream e060n40;
+ ifstream e100n40;
+ ifstream e140n40;
+
+ // set 3
+
+ ifstream w180s10;
+ ifstream w140s10;
+ ifstream w100s10;
+ ifstream w060s10;
+ ifstream w020s10;
+ ifstream e020s10;
+ ifstream e060s10;
+ ifstream e100s10;
+ ifstream e140s10;
+
+ // set 4
+ //3,600 rows and 7,200 columns
+ ifstream w180s60;
+ ifstream w120s60;
+ ifstream w060s60;
+ ifstream w000s60;
+ ifstream e060s60;
+ ifstream e120s60;
+
+ // whole world compiled
+ // 21,600 rows and 43,200 columns
+ ofstream world;
+
+ cout << "trying to open all needed files... " << endl;
+
+ w180n90.open("W180N90.DEM", ios::binary);
+ w140n90.open("W140N90.DEM", ios::binary);
+ w100n90.open("W100N90.DEM", ios::binary);
+ w060n90.open("W060N90.DEM", ios::binary);
+ w020n90.open("W020N90.DEM", ios::binary);
+ e020n90.open("E020N90.DEM", ios::binary);
+ e060n90.open("E060N90.DEM", ios::binary);
+ e100n90.open("E100N90.DEM", ios::binary);
+ e140n90.open("E140N90.DEM", ios::binary);
+
+ w180n40.open("W180N40.DEM", ios::binary);
+ w140n40.open("W140N40.DEM", ios::binary);
+ w100n40.open("W100N40.DEM", ios::binary);
+ w060n40.open("W060N40.DEM", ios::binary);
+ w020n40.open("W020N40.DEM", ios::binary);
+ e020n40.open("E020N40.DEM", ios::binary);
+ e060n40.open("E060N40.DEM", ios::binary);
+ e100n40.open("E100N40.DEM", ios::binary);
+ e140n40.open("E140N40.DEM", ios::binary);
+
+ w180s10.open("W180S10.DEM", ios::binary);
+ w140s10.open("W140S10.DEM", ios::binary);
+ w100s10.open("W100S10.DEM", ios::binary);
+ w060s10.open("W060S10.DEM", ios::binary);
+ w020s10.open("W020S10.DEM", ios::binary);
+ e020s10.open("E020S10.DEM", ios::binary);
+ e060s10.open("E060S10.DEM", ios::binary);
+ e100s10.open("E100S10.DEM", ios::binary);
+ e140s10.open("E140S10.DEM", ios::binary);
+
+ w180s60.open("W180S60.DEM", ios::binary);
+ w120s60.open("W120S60.DEM", ios::binary);
+ w060s60.open("W060S60.DEM", ios::binary);
+ w000s60.open("W000S60.DEM", ios::binary);
+ e060s60.open("E060S60.DEM", ios::binary);
+ e120s60.open("E120S60.DEM", ios::binary);
+
+ world.open("WORLD.DEM", ios::binary);
+
+ if (!w180n90)
+ FAILED = true;
+ if (!w140n90)
+ FAILED = true;
+ if (!w100n90)
+ FAILED = true;
+ if (!w060n90)
+ FAILED = true;
+ if (!w020n90)
+ FAILED = true;
+ if (!e020n90)
+ FAILED = true;
+ if (!e060n90)
+ FAILED = true;
+ if (!e100n90)
+ FAILED = true;
+ if (!e140n90)
+ FAILED = true;
+
+ if (!w180n40)
+ FAILED = true;
+ if (!w140n40)
+ FAILED = true;
+ if (!w100n40)
+ FAILED = true;
+ if (!w060n40)
+ FAILED = true;
+ if (!w020n40)
+ FAILED = true;
+ if (!e020n40)
+ FAILED = true;
+ if (!e060n40)
+ FAILED = true;
+ if (!e100n40)
+ FAILED = true;
+ if (!e140n40)
+ FAILED = true;
+
+ if (!w180s10)
+ FAILED = true;
+ if (!w140s10)
+ FAILED = true;
+ if (!w100s10)
+ FAILED = true;
+ if (!w060s10)
+ FAILED = true;
+ if (!w020s10)
+ FAILED = true;
+ if (!e020s10)
+ FAILED = true;
+ if (!e060s10)
+ FAILED = true;
+ if (!e100s10)
+ FAILED = true;
+ if (!e140s10)
+ FAILED = true;
+
+ if (!w180s60)
+ FAILED = true;
+ if (!w120s60)
+ FAILED = true;
+ if (!w060s60)
+ FAILED = true;
+ if (!w000s60)
+ FAILED = true;
+ if (!e060s60)
+ FAILED = true;
+ if (!e120s60)
+ FAILED = true;
+
+ if (FAILED) {
+ cerr << endl <<
+ "At least one of the GTOPO30 tiles is missing... merging failed"
+ << endl;
+ exit(1);
+ }
+
+ if (!world) {
+ cerr << endl <<
+ "failed to open output file... merging failed" << endl;
+ exit(1);
+ }
+
+ cout << "OK" << endl;
+
+ for (i = 0; i < 6000; i++) { // all rows
+
+ cout << "Writing part 1 (of 4) " << 6000 -
+ i << " " << '\r' << flush;
+
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = w180n90.get();
+ world.put(tmp);
+ tmp = w180n90.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = w140n90.get();
+ world.put(tmp);
+ tmp = w140n90.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = w100n90.get();
+ world.put(tmp);
+ tmp = w100n90.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = w060n90.get();
+ world.put(tmp);
+ tmp = w060n90.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = w020n90.get();
+ world.put(tmp);
+ tmp = w020n90.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = e020n90.get();
+ world.put(tmp);
+ tmp = e020n90.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = e060n90.get();
+ world.put(tmp);
+ tmp = e060n90.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = e100n90.get();
+ world.put(tmp);
+ tmp = e100n90.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = e140n90.get();
+ world.put(tmp);
+ tmp = e140n90.get();
+ world.put(tmp);
+ }
+
+ if (!world) {
+ cerr << endl << "writing error occured!" << endl;
+ exit(1);
+ }
+ }
+
+ cout << endl;
+
+ for (i = 0; i < 6000; i++) { // all rows
+
+ cout << "Writing part 2 (of 4) " << 6000 -
+ i << " " << '\r' << flush;
+
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = w180n40.get();
+ world.put(tmp);
+ tmp = w180n40.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = w140n40.get();
+ world.put(tmp);
+ tmp = w140n40.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = w100n40.get();
+ world.put(tmp);
+ tmp = w100n40.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = w060n40.get();
+ world.put(tmp);
+ tmp = w060n40.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = w020n40.get();
+ world.put(tmp);
+ tmp = w020n40.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = e020n40.get();
+ world.put(tmp);
+ tmp = e020n40.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = e060n40.get();
+ world.put(tmp);
+ tmp = e060n40.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = e100n40.get();
+ world.put(tmp);
+ tmp = e100n40.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = e140n40.get();
+ world.put(tmp);
+ tmp = e140n40.get();
+ world.put(tmp);
+ }
+
+ if (!world) {
+ cerr << endl << "writing error occured!" << endl;
+ exit(1);
+ }
+ }
+
+ cout << endl;
+
+ for (i = 0; i < 6000; i++) { // all rows
+
+ cout << "Writing part 3 (of 4) " << 6000 -
+ i << " " << '\r' << flush;
+
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = w180s10.get();
+ world.put(tmp);
+ tmp = w180s10.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = w140s10.get();
+ world.put(tmp);
+ tmp = w140s10.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = w100s10.get();
+ world.put(tmp);
+ tmp = w100s10.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = w060s10.get();
+ world.put(tmp);
+ tmp = w060s10.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = w020s10.get();
+ world.put(tmp);
+ tmp = w020s10.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = e020s10.get();
+ world.put(tmp);
+ tmp = e020s10.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = e060s10.get();
+ world.put(tmp);
+ tmp = e060s10.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = e100s10.get();
+ world.put(tmp);
+ tmp = e100s10.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 4800; j++) { // all columns
+ tmp = e140s10.get();
+ world.put(tmp);
+ tmp = e140s10.get();
+ world.put(tmp);
+ }
+
+ if (!world) {
+ cerr << endl << "writing error occured!" << endl;
+ exit(1);
+ }
+
+ }
+
+ cout << endl;
+
+ for (i = 0; i < 3600; i++) { // all rows
+
+ cout << "Writing part 4 (of 4) " << 3600 -
+ i << " " << '\r' << flush;
+
+ for (j = 0; j < 7200; j++) { // all columns
+ tmp = w180s60.get();
+ world.put(tmp);
+ tmp = w180s60.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 7200; j++) { // all columns
+ tmp = w120s60.get();
+ world.put(tmp);
+ tmp = w120s60.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 7200; j++) { // all columns
+ tmp = w060s60.get();
+ world.put(tmp);
+ tmp = w060s60.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 7200; j++) { // all columns
+ tmp = w000s60.get();
+ world.put(tmp);
+ tmp = w000s60.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 7200; j++) { // all columns
+ tmp = e060s60.get();
+ world.put(tmp);
+ tmp = e060s60.get();
+ world.put(tmp);
+ }
+ for (j = 0; j < 7200; j++) { // all columns
+ tmp = e120s60.get();
+ world.put(tmp);
+ tmp = e120s60.get();
+ world.put(tmp);
+ }
+
+ if (!world) {
+ cerr << endl << "writing error occured!" << endl;
+ exit(1);
+ }
+ }
+
+ cout << endl << "finished." << endl;
+
+}
diff --git a/src/ego.cpp b/src/ego.cpp
new file mode 100644
index 0000000..d05d294
--- /dev/null
+++ b/src/ego.cpp
@@ -0,0 +1,256 @@
+/*
+ * (c) 2002-2016 Hannes Krueger
+ * This file is part of the GPLIGC/ogie package
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "ego.h"
+#include "GLexplorer.h"
+#include <cmath>
+#include <string>
+
+//const std::string rcsid_ego_cpp =
+// "$Id: ego.cpp 3 2014-07-31 09:59:20Z kruegerh $";
+//const std::string rcsid_ego_h = EGO_H;
+
+
+
+Ego::Ego(double _x, double _y, double _z, double _spinx, double _spiny,
+ double _spinz)
+{
+ pos[0] = _x;
+ pos[1] = _y;
+ pos[2] = _z;
+ spin[0] = _spinx;
+ spin[1] = _spiny;
+ spin[2] = _spinz;
+
+ dpos[0] = 0;
+ dpos[1] = 0;
+ dpos[2] = 0;
+
+ dorthopos[0]=0;
+ dorthopos[1]=0;
+ dorthopos[2]=0;
+
+ orthopos[0] = 0;
+ orthopos[1] = 0;
+ orthopos[2] = 100;
+
+}
+
+void
+ Ego::spinmoveradial(double _spinmoveradial)
+// This spins the ego around the centre of the view plane
+// while adjusting the view angle appropriately
+// Once this is working we can try spinning around the place we are looking at.
+{
+ double tmp;
+ tmp = pos[0];
+ pos[0] =
+ pos[0] * cos(_spinmoveradial * PI_180) +
+ pos[1] * sin(_spinmoveradial * PI_180);
+ pos[1] =
+ pos[1] * cos(_spinmoveradial * PI_180) -
+ tmp * sin(_spinmoveradial * PI_180);
+ spin[2] = spin[2] + _spinmoveradial;
+ if (spin[2] < 0.0)
+ spin[2] = spin[2] + 360.0;
+ if (spin[2] > 360.0)
+ spin[2] = spin[2] - 360.0;
+}
+
+void
+ Ego::spinmoveradialpoint(double _spinmoveradial, double x, double y)
+// This spins the ego around point (x,y)
+// while adjusting the view angle appropriately
+{
+ double tmp0, tmp1;
+ tmp0 = pos[0] + x;
+ tmp1 = pos[1] + y;
+ pos[0] =
+ tmp0 * cos(_spinmoveradial * PI_180) +
+ tmp1 * sin(_spinmoveradial * PI_180) -
+ x;
+ pos[1] =
+ tmp1 * cos(_spinmoveradial * PI_180) -
+ tmp0 * sin(_spinmoveradial * PI_180) -
+ y;
+
+
+ spin[2] = spin[2] + _spinmoveradial;
+ if (spin[2] < 0.0)
+ spin[2] = spin[2] + 360.0;
+ if (spin[2] > 360.0)
+ spin[2] = spin[2] - 360.0;
+}
+
+void Ego::spinmovevertical(double _spinmovevertical)
+// Spin the ego position up/down around centre of view plane
+{/*
+ double radial, radialnew, tmp;
+ tmp = pos[2];
+ radial = sqrt(pow(pos[0], 2) + pow(pos[1], 2));
+
+ // avoid weird robotic moronness ;-) Restrict to 80 deg azimuth
+ if ((_spinmovevertical > 0 && atan2(pos[2], radial) > 80 * PI_180)
+ || (_spinmovevertical < 0
+ && atan2(pos[2], radial) < 1 * PI_180)) {
+ return;
+ }
+
+ pos[2] =
+ pos[2] * cos(_spinmovevertical * PI_180) +
+ radial * sin(_spinmovevertical * PI_180);
+ radialnew =
+ radial * cos(_spinmovevertical * PI_180) -
+ tmp * sin(_spinmovevertical * PI_180);
+ pos[0] = pos[0] * radialnew / radial;
+ pos[1] = pos[1] * radialnew / radial;
+
+ tmp = spin[0];
+ spin[0] =
+ spin[0] +
+ _spinmovevertical *
+ cos(atan2(spin[1] * PI_180, spin[0] * PI_180));
+ if (spin[0] < 0.0)
+ spin[0] = spin[0] + 360.0;
+ if (spin[0] > 360.0)
+ spin[0] = spin[0] - 360.0;
+
+ spin[1] =
+ spin[1] +
+ _spinmovevertical * sin(atan2(spin[1] * PI_180, tmp * PI_180));
+ if (spin[1] < 0.0)
+ spin[1] = spin[1] + 360.0;
+ if (spin[1] > 360.0)
+ spin[1] = spin[1] - 360.0;
+*/
+ spinmoveverticalpoint(_spinmovevertical, 0, 0);
+}
+
+void Ego::spinmoveverticalpoint(double _spinmovevertical, double x, double y) //, double z)
+// Spin the ego position up/down around a point (x, y, z)
+{
+ double radial, radialnew, tmp2;
+ tmp2 = pos[2];
+ radial = sqrt(pow(pos[0] + x, 2) + pow(pos[1] + y, 2));
+
+ // avoid weird robotic moronness ;-) Restrict to 80 deg azimuth
+ if ((_spinmovevertical > 0 && atan2(pos[2], radial) > 80 * PI_180)
+ || (_spinmovevertical < 0
+ && atan2(pos[2], radial) < 1 * PI_180)) {
+ return;
+ }
+
+ pos[2] =
+ pos[2] * cos(_spinmovevertical * PI_180) +
+ radial * sin(_spinmovevertical * PI_180);
+ radialnew =
+ radial * cos(_spinmovevertical * PI_180) -
+ tmp2 * sin(_spinmovevertical * PI_180);
+ pos[0] = ( (pos[0] + x) * radialnew / radial ) - x;
+ pos[1] = ( (pos[1] + y) * radialnew / radial ) - y;
+
+ tmp2 = spin[0];
+ spin[0] =
+ spin[0] +
+ _spinmovevertical *
+ cos(atan2(spin[1] * PI_180, spin[0] * PI_180));
+ if (spin[0] < 0.0)
+ spin[0] = spin[0] + 360.0;
+ if (spin[0] > 360.0)
+ spin[0] = spin[0] - 360.0;
+
+ spin[1] =
+ spin[1] +
+ _spinmovevertical * sin(atan2(spin[1] * PI_180, tmp2 * PI_180));
+ if (spin[1] < 0.0)
+ spin[1] = spin[1] + 360.0;
+ if (spin[1] > 360.0)
+ spin[1] = spin[1] - 360.0;
+
+}
+
+void Ego::spinx(double _spinx)
+{
+ spin[0] = spin[0] + _spinx;
+ if (spin[0] < 0.0)
+ spin[0] = spin[0] + 360.0;
+ if (spin[0] > 360.0)
+ spin[0] = spin[0] - 360.0;
+}
+
+void Ego::spiny(double _spiny)
+{
+ spin[1] = spin[1] + _spiny;
+ if (spin[1] < 0.0)
+ spin[1] = spin[1] + 360.0;
+ if (spin[1] > 360.0)
+ spin[1] = spin[1] - 360.0;
+}
+
+void Ego::spinz(double _spinz)
+{
+ spin[2] = spin[2] + _spinz;
+ if (spin[2] < 0.0)
+ spin[2] = spin[2] + 360.0;
+ if (spin[2] > 360.0)
+ spin[2] = spin[2] - 360.0;
+}
+
+void Ego::movex(double _move)
+{
+ pos[0] = pos[0] + _move;
+}
+
+void Ego::movey(double _move)
+{
+ pos[1] = pos[1] + _move;
+}
+
+void Ego::movez(double _move)
+{
+ pos[2] = pos[2] + _move;
+}
+
+void Ego::movef(double _move)
+{
+ double _move_horizontal;
+ pos[2] = pos[2] - _move * sin((270.0 - spin[0]) * PI_180);
+ _move_horizontal = _move * cos((270.0 - spin[0]) * PI_180);
+
+ pos[0] = pos[0] + _move_horizontal * sin(PI_180 * spin[2]);
+ pos[1] = pos[1] + _move_horizontal * cos(PI_180 * spin[2]);
+}
+
+void Ego::moves(double _move)
+{
+ pos[0] = pos[0] + _move * sin(PI_180 * (spin[2] + 90.0));
+ pos[1] = pos[1] + _move * cos(PI_180 * (spin[2] + 90.0));
+}
+
+
+void Ego::moveu(double _move)
+{
+ double _move_horizontal;
+ pos[2] = pos[2] + _move * sin((spin[0] - 180.0) * PI_180);
+ _move_horizontal = _move * cos((spin[0] - 180.0) * PI_180);
+
+ pos[0] = pos[0] + _move_horizontal * sin(PI_180 * spin[2]);
+ pos[1] = pos[1] + _move_horizontal * cos(PI_180 * spin[2]);
+
+}
diff --git a/src/ego.h b/src/ego.h
new file mode 100644
index 0000000..7468d7b
--- /dev/null
+++ b/src/ego.h
@@ -0,0 +1,92 @@
+/*
+ * (c) 2002-2016 Hannes Krueger
+ * This file is part of the GPLIGC/ogie package
+ */
+
+/*
+DESCRIPTION:
+small class to track a position in cartesian coordinatesystem and to move/rotate
+*/
+
+#ifndef EGO_H
+#define EGO_H 1
+
+#include<string>
+
+class Ego {
+
+ public:
+ Ego (double _x, double _y, double _z, double _spinx, double _spiny, double _spinz);
+
+ double getx () const { return pos[0]; }
+ double gety () const {return pos[1]; }
+ double getz () const {return pos[2]; }
+ void setz (double _z) {pos[2] = _z;}
+ void setx (double _x) {pos[0] = _x;}
+ void sety (double _y) {pos[1] = _y;}
+
+ double getOx() const {return orthopos[0];}
+ double getOy() const {return orthopos[1];}
+ double getOz() const {return orthopos[2];}
+
+ void setOx(double _x) {orthopos[0]=_x;}
+ void setOy(double _y) {orthopos[1]=_y;}
+ void setOz(double _z) {orthopos[2]=_z;}
+
+ void shiftx(double x) {orthopos[0] += x;}
+ void shifty(double y) {orthopos[1] += y;}
+ void shiftz(double z) {orthopos[2] += z;}
+
+ //diffrerence vector position for marker_locked_pos
+ double getdx () const { return dpos[0]; }
+ double getdy () const {return dpos[1]; }
+ double getdz () const {return dpos[2]; }
+ void setdz (double _z) {dpos[2] = _z;}
+ void setdx (double _x) {dpos[0] = _x;}
+ void setdy (double _y) {dpos[1] = _y;}
+
+ double getdox () const { return dorthopos[0]; }
+ double getdoy () const {return dorthopos[1]; }
+ double getdoz () const {return dorthopos[2]; }
+ void setdoz (double _z) {dorthopos[2] = _z;}
+ void setdox (double _x) {dorthopos[0] = _x;}
+ void setdoy (double _y) {dorthopos[1] = _y;}
+
+ double getspinx () const { return spin[0];}
+ double getspiny () const {return spin[1];}
+ double getspinz () const {return spin[2];}
+ void setspinx (double _sx) {spin[0] = _sx;}
+ void setspiny (double _sy) {spin[1] = _sy;}
+ void setspinz (double _sz) {spin[2] = _sz;}
+
+ void spinmoveradial (double); // spin the ego around the viewing plane
+ void spinmovevertical (double);
+ void spinmoveradialpoint (double, double, double); // spin the ego around a point
+ void spinmoveverticalpoint (double, double, double);
+
+ void spinx (double); // Spin is the direction we are looking in
+ void spiny (double);
+ void spinz (double);
+
+ void movex (double);
+ void movey (double);
+ void movez (double);
+
+ void movef (double); //move forward
+ void moves (double); //move sidewards
+ void moveu (double); //move up
+
+ protected:
+ double pos[3];
+ double dpos[3];
+ double spin[3];
+
+ double orthopos[3];
+ double dorthopos[3];
+
+ private:
+ Ego ();
+
+};
+
+#endif
diff --git a/src/etopo1merger.cpp b/src/etopo1merger.cpp
new file mode 100644
index 0000000..8557913
--- /dev/null
+++ b/src/etopo1merger.cpp
@@ -0,0 +1,384 @@
+/*
+ * (c) 2002-2016 Hannes Krueger
+ * This file is part of the GPLIGC/ogie package
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+/*
+This program merges a WORLD.DEM (created with createworld from the GTOPO30-tiles)
+and an etopo1.i2 into a WORLD3.DEM. (world3 is the new version with water-flag!)
+(WORLD2 was without waterflag)
+All files have 2 byte integer-values in big-endian order.
+
+Another option is to prepare subsets of GTOPO30 WORLDx.DEM file
+--latmax --latmin --lonmax --lonmin --out file
+
+*/
+
+#include <fstream>
+#include <iostream>
+#include <cstring>
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
+
+//const double GTOPO30GRID = 0.00833333333333333;
+//const double ETOPO2GRID = 0.03333333333333333;
+const double GTOPO30GRID = 1.0/120.0;
+const double ETOPO1GRID = 1.0/60.0;
+
+using namespace std;
+//const string rcsid_etopo1merger_cpp =
+// "$Id: etopo1merger.cpp 3 2014-07-31 09:59:20Z kruegerh $";
+
+short int etopo_array[10801][21601];
+
+// This function uses bilinear interpolation to map values
+// from etopo1 to gtopo30
+short int getalt(double lat, double lon, int debug)
+{
+ int steps_lat, steps_lon;
+ short int alt, h1, h2, h3, h4, max, min;
+ double lat_frac, lon_frac, tmp;
+
+ double dem_lon_min = -180.0;
+ double dem_lat_max = 90.0;
+
+ // Layout:
+ // h3 h4
+ // h1 h2
+ // lat_frac is the remaining fraction on the side h1 towards h3
+ // lon_frac is the remaining fraction on the side h1 towards h2
+
+ steps_lat = (int) (1.0 + (dem_lat_max - lat) / ETOPO1GRID);
+ steps_lon = (int) ((lon - dem_lon_min) / ETOPO1GRID);
+
+ lat_frac = -1.0 * (-steps_lat * ETOPO1GRID + dem_lat_max - lat) / ETOPO1GRID;
+ lon_frac = (-steps_lon * ETOPO1GRID - dem_lon_min + lon) / ETOPO1GRID;
+ h1 = etopo_array[steps_lat][steps_lon];
+
+ if(lat_frac < 0 || lon_frac < 0 || debug) printf("latfrac = %f, lonfrac = %f\n", lat_frac, lon_frac);
+
+ steps_lat = (int) (1.0 + (dem_lat_max - lat) / ETOPO1GRID);
+ steps_lon = (int) (1.0 + (lon - dem_lon_min) / ETOPO1GRID);
+ h2 = etopo_array[steps_lat][steps_lon];
+
+ steps_lat = (int) ((dem_lat_max - lat) / ETOPO1GRID);
+ steps_lon = (int) ((lon - dem_lon_min) / ETOPO1GRID);
+ h3 = etopo_array[steps_lat][steps_lon];
+
+ steps_lat = (int) ((dem_lat_max - lat) / ETOPO1GRID);
+ steps_lon = (int) (1.0 + (lon - dem_lon_min) / ETOPO1GRID);
+ h4 = etopo_array[steps_lat][steps_lon];
+
+ tmp = ((1.0 - lon_frac) * (1.0 - lat_frac) * (double) h1
+ + lon_frac * (1.0 - lat_frac) * (double) h2
+ + (1.0 - lon_frac) * lat_frac * (double) h3
+ + lat_frac * lon_frac * (double) h4);
+
+ tmp = (double)((float) tmp); //This is in order to achieve identical results on x86_64 and i386
+ // Looks like Voodoo, but it can be understood: We are always sitting right on the fence
+ // rounding this way or that. If x86_64 works with different internal precision, then the
+ // rounding outcome in the cast operation (below) can go different ways...
+
+ if(tmp > 0.0){
+ alt = (short int) (0.5 + tmp);
+ } else {
+ alt = (short int) (-0.5 + tmp);
+ }
+
+ // Sanity checks
+ max = -10000;
+ min = 16000;
+ if(h1 > max) max = h1;
+ if(h2 > max) max = h2;
+ if(h3 > max) max = h3;
+ if(h4 > max) max = h4;
+ if(h1 < min) min = h1;
+ if(h2 < min) min = h2;
+ if(h3 < min) min = h3;
+ if(h4 < min) min = h4;
+ if(alt > max || alt < min || debug){
+ printf("Interpolation: h1 = %d, h2 = %d, h3 = %d, h4 = %d, alt = %d (%f), lat_frac = %f, lon_frac = %f\n",
+ h1, h2, h3, h4, alt, tmp,lat_frac, lon_frac);
+// printf("%lf\n", tmp);
+ }
+ // end sanity checks
+
+ return alt;
+}
+
+
+void failed(void)
+{
+ cout << "Some of the input files are missing, "
+ << "or we are unable to write to the output file."
+ << endl
+ <<
+ "The files WORLD.DEM should be in this directory. And for etopo1merging etopo1.i2!"
+ << endl;
+ exit(1);
+}
+
+//---------------------------------------------
+
+int main(int argc, char *argv[])
+{
+ bool ETOPOMERGING = true;
+ double minlat, maxlat, minlon, maxlon;
+ string filename;
+ string source = "WORLD.DEM";
+
+ // parsing of options...
+ for (int i = 0; i < argc; i++) {
+
+ if (strcmp(argv[i], "--latmin") == 0)
+ sscanf(argv[i + 1], "%lf", &minlat);
+ if (strcmp(argv[i], "--lonmin") == 0)
+ sscanf(argv[i + 1], "%lf", &minlon);
+ if (strcmp(argv[i], "--latmax") == 0)
+ sscanf(argv[i + 1], "%lf", &maxlat);
+ if (strcmp(argv[i], "--lonmax") == 0)
+ sscanf(argv[i + 1], "%lf", &maxlon);
+ if (strcmp(argv[i], "--out") == 0) {
+ filename = argv[i + 1];
+ ETOPOMERGING=false;
+ }
+ if (strcmp(argv[i], "--source") == 0)
+ source = argv[i+1];
+ }
+
+ if (sizeof(short int) != 2) {
+ cerr << "sizeof(short int) " << sizeof(short int) << endl;
+ cerr << "Sorry, can't help you here. Use the source, Luke."
+ << endl;
+ exit(1);
+ }
+
+ bool FAILED = false;
+
+ ifstream etopo1;
+ ifstream gtopo30;
+ ofstream world3;
+ ofstream subset;
+
+ if (ETOPOMERGING) {
+ cout << "Trying to read etopo1.i2 ... ";
+ etopo1.open("etopo1_ice_g_i2.bin", ios::binary);
+ if (!etopo1) {
+ cout << "failed." << endl;
+ FAILED = true;
+ } else {
+ cout << "ok." << endl;
+ }
+ }
+
+ cout << "trying to read " << source << " ... ";
+ gtopo30.open(source.c_str(), ios::binary);
+ if (!gtopo30) {
+ cout << "failed" << endl;
+ FAILED = true;
+ } else {
+ cout << "ok" << endl;
+ }
+
+ if (!ETOPOMERGING) {
+ cout << "Trying to open outputfile: " << filename << " ... ";
+ subset.open(filename.c_str(), ios::binary);
+ if (!subset) {
+ cout << "failed." << endl;
+ FAILED = true;
+ } else {
+ cout << "ok." << endl;
+ }
+ }
+
+ if (ETOPOMERGING) {
+ cout << "Trying to open WORLD3.DEM for writing... ";
+ world3.open("SRTM30_ETOPO1.DEM", ios::binary);
+ if (!world3) {
+ cout << "failed." << endl;
+ FAILED = true;
+ } else {
+ cout << "ok." << endl;
+ }
+ }
+
+ if (FAILED) failed();
+
+ int row, col;
+ short int alt;
+ int i1, i2;
+ int offset = 0;
+
+// main part of etopo1merging -----------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------------------
+// now read etopo into memory!
+ if (ETOPOMERGING) {
+ cout << "Reading etopo1 into RAM" << endl;
+ for (row = 0; row < 10801; row++) {
+ cout << (10801 - row) << " " << '\r' << flush;
+ for (col = 0; col < 21601; col++) {
+ i1 = etopo1.get();
+ i2 = etopo1.get();
+ etopo_array[row][col] = 256 * i2 + i1; //LSB first in etopo1!
+
+ }
+ }
+
+ cout << "Finished." << endl;
+
+ cout <<
+ "Merging and interpolating... (this may take a little time)" <<
+ endl;
+
+ for (row = 0; row < 21600; row++) {
+ cout << (21600 - row) << " " << '\r' << flush;
+ for (col = 0; col < 43200; col++) {
+ i1 = gtopo30.get();
+ i2 = gtopo30.get();
+ alt = 256 * i1 + i2;
+ if (alt == -9999) { // this is ocean surface, get bathymetry from etopo1
+ double lat = 90.0 - (GTOPO30GRID * row);
+ double lon = -180.0 + (GTOPO30GRID * col);
+ alt = getalt(lat, lon, 0);
+
+ // Sanity checks
+ //if(50473 == offset) {
+ // getalt(lat, lon, 1);
+ //// exit(1);
+ //}
+
+ // we should not loose the information, that this is covered by water!
+ // low areas might have negative elevations!
+ // the deepest place on earth is heigher than 16384 (2^14)
+ // so we will set the 2^14- bit to indicate water coverage
+
+ //I havent understand the bit-logic of negative short int..
+
+ // due to interpolation in the worse resolutioned
+ // model we might cat positive values :(
+ // they will be forced to 0
+ if (alt >= 0) alt =0;
+ alt -= 16384;
+ }
+
+ // split alt in big-endian 2 byte and write..
+ i2 = (short int) (alt & 255);
+ i1 = (short int) (alt & 65280) >> 8;
+
+ // Sanity checks
+ //if(50473 == offset) {
+ // printf("i1 = %d, i2 = %d\n", i1, i2);
+ //}
+ world3.put(i1);
+ if (!world3) {
+ cerr <<
+ "An error occured while writing the output file... (no disc space?)"
+ << endl;
+ exit(1);
+ }
+
+ world3.put(i2);
+ if (!world3) {
+ cerr <<
+ "An error occured while writing the output file... (no disc space?)"
+ << endl;
+ exit(1);
+ }
+ offset++;
+ }
+ }
+ }
+
+// main part of subset creating .-------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------------------------------------------
+
+ if (!ETOPOMERGING) {
+ cout << "Subset of " << source << " will be created" << endl;
+ cout << "Selected limits:" << endl <<
+ "Max Lat: " << maxlat << endl <<
+ "Min Lat: " << minlat << endl <<
+ "Max Lon: " << maxlon << endl <<
+ "Min Lon: " << minlon << endl << endl;
+
+ double grid_lat = 1.0 /120.0;
+ double grid_lon = 1.0 / 120.0;
+ int downscalefactor = 1;
+
+ int upsteps = int (((90 - maxlat) / grid_lat)+0.5);
+
+ int downsteps = int (((90 - minlat) / grid_lat)+0.5);
+
+ int leftsteps = int (((minlon - (-180)) / grid_lon)+0.5);
+
+ int rightsteps = int (((maxlon - (-180)) / grid_lon)+0.5);
+
+ int colums_lon = 43200;
+
+ double DEM_LAT_MAX = 90.0 -(upsteps * grid_lat);
+ double DEM_LAT_MIN = 90.0 - (downsteps * grid_lat);
+ double DEM_LON_MAX = -180.0 + (rightsteps * grid_lon);
+ double DEM_LON_MIN = -180.0 + (leftsteps * grid_lon);
+
+ int steps_lat = downsteps - upsteps ; //+ 2 *downscalefactor;
+ int steps_lon = rightsteps - leftsteps; // + 2 * downscalefactor;
+
+ cout << filename << " will be: " << (steps_lat) * (steps_lon )*2 << " bytes." << endl << endl;
+
+ cout << "DEM_FILE " << filename << endl <<
+ "DEM_LAT_MAX " << DEM_LAT_MAX << endl <<
+ "DEM_LAT_MIN " << DEM_LAT_MIN << endl <<
+ "DEM_LON_MAX " << DEM_LON_MAX << endl <<
+ "DEM_LON_MIN " << DEM_LON_MIN << endl <<
+ "DEM_ROWS " << steps_lat << endl <<
+ "DEM_COLUMNS " << steps_lon << endl;
+
+ int counter = steps_lat;
+
+ for (int zeile = 0; zeile < steps_lat; zeile += downscalefactor) {
+ cout << counter-- << " " << '\r' << flush;
+ for (int spalte = 0; spalte < steps_lon; spalte += downscalefactor) {
+
+ // fuer 1 byte daten kommentiert ///* */ !?
+
+ ///*
+ int verschieber =
+ (colums_lon * upsteps + zeile * colums_lon +
+ leftsteps + spalte) * 2;
+ //*/
+
+ /*
+ int
+ verschieber = (colums_lon * upsteps + zeile * colums_lon + leftsteps + spalte);
+ */
+
+ //cout << "vershieber : " << verschieber << endl;
+ gtopo30.seekg(verschieber, ios::beg);
+
+ ///*
+ int i1 = gtopo30.get();
+ //*/
+
+ int i2 = gtopo30.get();
+
+ subset.put(i1);
+ subset.put(i2);
+ }
+ }
+ }
+ cout << "Finished. Please check the output file." << endl;
+}
diff --git a/src/etopo2merger.cpp b/src/etopo2merger.cpp
new file mode 100644
index 0000000..3932c04
--- /dev/null
+++ b/src/etopo2merger.cpp
@@ -0,0 +1,383 @@
+/*
+ * (c) 2002-2016 Hannes Krueger
+ * This file is part of the GPLIGC/ogie package
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+/*
+This program merges a WORLD.DEM (created with createworld from the GTOPO30-tiles)
+and an etopo2.i2 into a WORLD3.DEM. (world3 is the new version with water-flag!)
+(WORLD2 was without waterflag)
+All files have 2 byte integer-values in big-endian order.
+
+Another option is to prepare subsets of GTOPO30 WORLDx.DEM file
+--latmax --latmin --lonmax --lonmin --out file
+
+*/
+
+#include <fstream>
+#include <iostream>
+#include <cstring>
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
+
+//const double GTOPO30GRID = 0.00833333333333333;
+//const double ETOPO2GRID = 0.03333333333333333;
+const double GTOPO30GRID = 1.0/120.0;
+const double ETOPO2GRID = 1.0/30.0;
+
+using namespace std;
+//const string rcsid_etopo2merger_cpp =
+// "$Id: etopo2merger.cpp 3 2014-07-31 09:59:20Z kruegerh $";
+
+short int etopo_array[5401][10801];
+
+// This function uses bilinear interpolation to map values
+// from etopo2 to gtopo30
+short int getalt(double lat, double lon, int debug)
+{
+ int steps_lat, steps_lon;
+ short int alt, h1, h2, h3, h4, max, min;
+ double lat_frac, lon_frac, tmp;
+
+ double dem_lon_min = -180.0;
+ double dem_lat_max = 90.0;
+
+ // Layout:
+ // h3 h4
+ // h1 h2
+ // lat_frac is the remaining fraction on the side h1 towards h3
+ // lon_frac is the remaining fraction on the side h1 towards h2
+
+ steps_lat = (int) (1.0 + (dem_lat_max - lat) / ETOPO2GRID);
+ steps_lon = (int) ((lon - dem_lon_min) / ETOPO2GRID);
+
+ lat_frac = -1.0 * (-steps_lat * ETOPO2GRID + dem_lat_max - lat) / ETOPO2GRID;
+ lon_frac = (-steps_lon * ETOPO2GRID - dem_lon_min + lon) / ETOPO2GRID;
+ h1 = etopo_array[steps_lat][steps_lon];
+
+ if(lat_frac < 0 || lon_frac < 0 || debug) printf("latfrac = %f, lonfrac = %f\n", lat_frac, lon_frac);
+
+ steps_lat = (int) (1.0 + (dem_lat_max - lat) / ETOPO2GRID);
+ steps_lon = (int) (1.0 + (lon - dem_lon_min) / ETOPO2GRID);
+ h2 = etopo_array[steps_lat][steps_lon];
+
+ steps_lat = (int) ((dem_lat_max - lat) / ETOPO2GRID);
+ steps_lon = (int) ((lon - dem_lon_min) / ETOPO2GRID);
+ h3 = etopo_array[steps_lat][steps_lon];
+
+ steps_lat = (int) ((dem_lat_max - lat) / ETOPO2GRID);
+ steps_lon = (int) (1.0 + (lon - dem_lon_min) / ETOPO2GRID);
+ h4 = etopo_array[steps_lat][steps_lon];
+
+ tmp = ((1.0 - lon_frac) * (1.0 - lat_frac) * (double) h1
+ + lon_frac * (1.0 - lat_frac) * (double) h2
+ + (1.0 - lon_frac) * lat_frac * (double) h3
+ + lat_frac * lon_frac * (double) h4);
+
+ tmp = (double)((float) tmp); //This is in order to achieve identical results on x86_64 and i386
+ // Looks like Voodoo, but it can be understood: We are always sitting right on the fence
+ // rounding this way or that. If x86_64 works with different internal precision, then the
+ // rounding outcome in the cast operation (below) can go different ways...
+
+ if(tmp > 0.0){
+ alt = (short int) (0.5 + tmp);
+ } else {
+ alt = (short int) (-0.5 + tmp);
+ }
+
+ // Sanity checks
+ max = -10000;
+ min = 16000;
+ if(h1 > max) max = h1;
+ if(h2 > max) max = h2;
+ if(h3 > max) max = h3;
+ if(h4 > max) max = h4;
+ if(h1 < min) min = h1;
+ if(h2 < min) min = h2;
+ if(h3 < min) min = h3;
+ if(h4 < min) min = h4;
+ if(alt > max || alt < min || debug){
+ printf("Interpolation: h1 = %d, h2 = %d, h3 = %d, h4 = %d, alt = %d (%f), lat_frac = %f, lon_frac = %f\n",
+ h1, h2, h3, h4, alt, tmp, lat_frac, lon_frac);
+ }
+ // end sanity checks
+
+ return alt;
+}
+
+
+void failed(void)
+{
+ cout << "Some of the input files are missing, "
+ << "or we are unable to write to the output file."
+ << endl
+ <<
+ "The files WORLD.DEM should be in this directory. And for etopo2merging etopo2.i2!"
+ << endl;
+ exit(1);
+}
+
+//---------------------------------------------
+
+int main(int argc, char *argv[])
+{
+ bool ETOPOMERGING = true;
+ double minlat, maxlat, minlon, maxlon;
+ string filename;
+ string source = "WORLD.DEM";
+
+ // parsing of options...
+ for (int i = 0; i < argc; i++) {
+
+ if (strcmp(argv[i], "--latmin") == 0)
+ sscanf(argv[i + 1], "%lf", &minlat);
+ if (strcmp(argv[i], "--lonmin") == 0)
+ sscanf(argv[i + 1], "%lf", &minlon);
+ if (strcmp(argv[i], "--latmax") == 0)
+ sscanf(argv[i + 1], "%lf", &maxlat);
+ if (strcmp(argv[i], "--lonmax") == 0)
+ sscanf(argv[i + 1], "%lf", &maxlon);
+ if (strcmp(argv[i], "--out") == 0) {
+ filename = argv[i + 1];
+ ETOPOMERGING=false;
+ }
+ if (strcmp(argv[i], "--source") == 0)
+ source = argv[i+1];
+ }
+
+ if (sizeof(short int) != 2) {
+ cerr << "sizeof(short int) " << sizeof(short int) << endl;
+ cerr << "Sorry, can't help you here. Use the source, Luke."
+ << endl;
+ exit(1);
+ }
+
+ bool FAILED = false;
+
+ ifstream etopo2;
+ ifstream gtopo30;
+ ofstream world3;
+ ofstream subset;
+
+ if (ETOPOMERGING) {
+ cout << "Trying to read etopo2.i2 ... ";
+ etopo2.open("etopo2.i2", ios::binary);
+ if (!etopo2) {
+ cout << "failed." << endl;
+ FAILED = true;
+ } else {
+ cout << "ok." << endl;
+ }
+ }
+
+ cout << "trying to read " << source << " ... ";
+ gtopo30.open(source.c_str(), ios::binary);
+ if (!gtopo30) {
+ cout << "failed" << endl;
+ FAILED = true;
+ } else {
+ cout << "ok" << endl;
+ }
+
+ if (!ETOPOMERGING) {
+ cout << "Trying to open outputfile: " << filename << " ... ";
+ subset.open(filename.c_str(), ios::binary);
+ if (!subset) {
+ cout << "failed." << endl;
+ FAILED = true;
+ } else {
+ cout << "ok." << endl;
+ }
+ }
+
+ if (ETOPOMERGING) {
+ cout << "Trying to open WORLD3.DEM for writing... ";
+ world3.open("WORLD3.DEM", ios::binary);
+ if (!world3) {
+ cout << "failed." << endl;
+ FAILED = true;
+ } else {
+ cout << "ok." << endl;
+ }
+ }
+
+ if (FAILED) failed();
+
+ int row, col;
+ short int alt;
+ int i1, i2;
+ int offset = 0;
+
+// main part of etopo2merging -----------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------------------
+// now read etopo into memory!
+ if (ETOPOMERGING) {
+ cout << "Reading etopo2 into RAM" << endl;
+ for (row = 0; row < 5401; row++) {
+ cout << (5401 - row) << " " << '\r' << flush;
+ for (col = 0; col < 10801; col++) {
+ i1 = etopo2.get();
+ i2 = etopo2.get();
+ etopo_array[row][col] = 256 * i1 + i2;
+
+ }
+ }
+
+ cout << "Finished." << endl;
+
+ cout <<
+ "Merging and interpolating... (this may take a little time)" <<
+ endl;
+
+ for (row = 0; row < 21600; row++) {
+ cout << (21600 - row) << " " << '\r' << flush;
+ for (col = 0; col < 43200; col++) {
+ i1 = gtopo30.get();
+ i2 = gtopo30.get();
+ alt = 256 * i1 + i2;
+ if (alt == -9999) { // this is ocean surface, get bathymetry from etopo2
+ double lat = 90.0 - (GTOPO30GRID * row);
+ double lon = -180.0 + (GTOPO30GRID * col);
+ alt = getalt(lat, lon, 0);
+
+ // Sanity checks
+ //if(50473 == offset) {
+ // getalt(lat, lon, 1);
+ //// exit(1);
+ //}
+
+ // we should not loose the information, that this is covered by water!
+ // low areas might have negative elevations!
+ // the deepest place on earth is heigher than 16384 (2^14)
+ // so we will set the 2^14- bit to indicate water coverage
+
+ //I havent understand the bit-logic of negative short int..
+
+ // due to interpolation in the worse resolutioned
+ // model we might cat positive values :(
+ // they will be forced to 0
+ if (alt >= 0) alt =0;
+ alt -= 16384;
+ }
+
+ // split alt in big-endian 2 byte and write..
+ i2 = (short int) (alt & 255);
+ i1 = (short int) (alt & 65280) >> 8;
+
+ // Sanity checks
+ //if(50473 == offset) {
+ // printf("i1 = %d, i2 = %d\n", i1, i2);
+ //}
+ world3.put(i1);
+ if (!world3) {
+ cerr <<
+ "An error occured while writing the output file... (no disc space?)"
+ << endl;
+ exit(1);
+ }
+
+ world3.put(i2);
+ if (!world3) {
+ cerr <<
+ "An error occured while writing the output file... (no disc space?)"
+ << endl;
+ exit(1);
+ }
+ offset++;
+ }
+ }
+ }
+
+// main part of subset creating .-------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------------------------------------------
+
+ if (!ETOPOMERGING) {
+ cout << "Subset of " << source << " will be created" << endl;
+ cout << "Selected limits:" << endl <<
+ "Max Lat: " << maxlat << endl <<
+ "Min Lat: " << minlat << endl <<
+ "Max Lon: " << maxlon << endl <<
+ "Min Lon: " << minlon << endl << endl;
+
+ double grid_lat = 1.0 /120.0;
+ double grid_lon = 1.0 / 120.0;
+ int downscalefactor = 1;
+
+ int upsteps = int (((90 - maxlat) / grid_lat)+0.5);
+
+ int downsteps = int (((90 - minlat) / grid_lat)+0.5);
+
+ int leftsteps = int (((minlon - (-180)) / grid_lon)+0.5);
+
+ int rightsteps = int (((maxlon - (-180)) / grid_lon)+0.5);
+
+ int colums_lon = 43200;
+
+ double DEM_LAT_MAX = 90.0 -(upsteps * grid_lat);
+ double DEM_LAT_MIN = 90.0 - (downsteps * grid_lat);
+ double DEM_LON_MAX = -180.0 + (rightsteps * grid_lon);
+ double DEM_LON_MIN = -180.0 + (leftsteps * grid_lon);
+
+ int steps_lat = downsteps - upsteps ; //+ 2 *downscalefactor;
+ int steps_lon = rightsteps - leftsteps; // + 2 * downscalefactor;
+
+ cout << filename << " will be: " << (steps_lat) * (steps_lon )*2 << " bytes." << endl << endl;
+
+ cout << "DEM_FILE " << filename << endl <<
+ "DEM_LAT_MAX " << DEM_LAT_MAX << endl <<
+ "DEM_LAT_MIN " << DEM_LAT_MIN << endl <<
+ "DEM_LON_MAX " << DEM_LON_MAX << endl <<
+ "DEM_LON_MIN " << DEM_LON_MIN << endl <<
+ "DEM_ROWS " << steps_lat << endl <<
+ "DEM_COLUMNS " << steps_lon << endl;
+
+ int counter = steps_lat;
+
+ for (int zeile = 0; zeile < steps_lat; zeile += downscalefactor) {
+ cout << counter-- << " " << '\r' << flush;
+ for (int spalte = 0; spalte < steps_lon; spalte += downscalefactor) {
+
+ // fuer 1 byte daten kommentiert ///* */ !?
+
+ ///*
+ int verschieber =
+ (colums_lon * upsteps + zeile * colums_lon +
+ leftsteps + spalte) * 2;
+ //*/
+
+ /*
+ int
+ verschieber = (colums_lon * upsteps + zeile * colums_lon + leftsteps + spalte);
+ */
+
+ //cout << "vershieber : " << verschieber << endl;
+ gtopo30.seekg(verschieber, ios::beg);
+
+ ///*
+ int i1 = gtopo30.get();
+ //*/
+
+ int i2 = gtopo30.get();
+
+ subset.put(i1);
+ subset.put(i2);
+ }
+ }
+ }
+ cout << "Finished. Please check the output file." << endl;
+}
diff --git a/src/flightdata.cpp b/src/flightdata.cpp
new file mode 100644
index 0000000..f2dba74
--- /dev/null
+++ b/src/flightdata.cpp
@@ -0,0 +1,1581 @@
+/*
+ * (c) 2002-2016 Hannes Krueger
+ * This file is part of the GPLIGC/ogie package
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "flightdata.h"
+#include "GLexplorer.h"
+#include "oglexfunc.h"
+#include "config.h"
+
+#include <iostream>
+#include <fstream>
+#include <cstdio>
+#include <cmath>
+#include <cstdlib>
+#include <string>
+#include <errno.h>
+#include <new>
+
+#ifndef __OSX__
+#include <GL/glu.h>
+#else
+#include <OpenGL/glu.h>
+#endif
+
+#ifdef HAVE_LIBGPS
+#include <libgpsmm.h>
+
+#if GPSD_API_MAJOR_VERSION != 5
+#undef HAVE_LIBGPS
+#endif
+
+#endif
+
+//const std::string rcsid_flightdata_cpp =
+// "$Id: flightdata.cpp 3 2014-07-31 09:59:20Z kruegerh $";
+//const std::string rcsid_flightdata_h = FLIGHTDATA_H;
+
+
+Flightdata::Flightdata()
+{
+ n = 0;
+ cycles = -1;
+ consecutive_valid_fixes = 1;
+ gps_interruptions = 0;
+}
+
+Flightdata::~Flightdata()
+{
+// delete gps;
+}
+
+
+void Flightdata::initgps(const char* _serv, const char* _port)
+{
+#ifdef HAVE_LIBGPS
+
+
+ if (conf_pointer->VERBOSE.get())
+ cout << "Trying to connect to gpsd at "<< _serv << ":" << _port << endl;
+
+ stringstream _servstring;
+ _servstring << _serv << ":" << _port;
+ serverstring = _servstring.str();
+
+// #if GPSD_API_MAJOR_VERSION == 5
+ //good
+// #else
+// cerr << "unsupported GPSD_API_MAJOR_VERSION == " << GPSD_API_MAJOR_VERSION << endl;
+// exit(0);
+// #endif
+
+// #if GPSD_API_MAJOR_VERSION == 5
+ // create gpsmm object
+ gps = new gpsmm (_serv, _port);
+
+
+ if (gps->stream(WATCH_ENABLE|WATCH_JSON) == NULL) {
+ cerr << "cannot connect to gpsd" << endl;
+ exit (0);
+ }
+
+ // waiting is timeout in mu-secs // blocking!
+ while (!gps->waiting(20000000)) { // 20 secs is ok at initialisation
+ cout << "no answer gps->waiting, after 20e6 mu-secs!" << endl;
+ exit (0);
+ }
+
+ // data is here, so poll it!
+ if ( (gpsdata = gps->read()) == NULL) {
+ cerr << "read error" << endl;
+ exit(0);
+ }
+
+ if (!gpsdata) {
+ cerr << "connection to gpsd failed! Error number " << errno << endl;
+ exit(0);
+
+ } else {
+
+ if (conf_pointer->VERBOSE.get())
+ cout << "connected to gpsd!"<< endl;
+ //<< gpsdata->dev.ndevices << " devices connected to gpsd" <<endl;
+
+ if (!gpsdata->set == DEVICEID_SET) {
+ cerr << "No GPS device connected to gpsd" << endl;
+ exit(0);
+ } else {
+ if (conf_pointer->DEBUG.get()) {
+ //cout << "first device connected at: " << gpsdata->devicelist[0] << endl;
+ //cout << "Device: >" << gpsdata->dev.path << "< >" << gpsdata->dev.subtype << "<" << endl;
+ // there is no device info yet...
+ cout << "gpsd API: " << gpsdata->version.proto_major << "." << gpsdata->version.proto_minor << endl;
+ cout << "external version (release): " << gpsdata->version.release << endl;
+ cout << "internal revision (rev): " << gpsdata->version.rev << endl;
+
+ cout << "Version Info from headers:" << endl <<
+ "GPSD_API_MAJOR_VERSION: "<< GPSD_API_MAJOR_VERSION << endl <<
+ "GPSD_API_MINOR_VERSION: "<< GPSD_API_MINOR_VERSION << endl <<
+ "sizeof gps_data_t (8240 on pc12): " << sizeof (gps_data_t) << endl;
+
+ }
+ }
+ }
+
+ // waiting for the first fix! (we need one before we can start)
+ // otherwise we have no idea were we are!
+ int wait=0;
+ int i, recv;
+
+ again:
+ while (gpsdata->fix.mode < 2) {
+
+ // try every second, till we get an 2D fix
+ //sleep (1);
+
+ // das parsen in gpsdata vertraegt nur 1 query-letter
+ //gpsdata = gps->query("J=1\n");
+ //gpsdata = gps->query("oyq\n");
+ while( !gps->waiting(500000) ) {};
+ gpsdata = gps->read();
+
+ recv=0;
+ if (gpsdata->satellites_visible) {
+ if (gpsdata->satellites_visible < MAXCHANNELS) { // filter bad/large satellites_visible!
+ for (i = 0; i < gpsdata->satellites_visible; i++) {
+ if (gpsdata->ss[i] > 20) recv++;
+ }
+ } //else { cerr << "sat_visible >= MAXCHANNELS/" << MAXCHANNELS << " this would cause trouble!"<< endl;}
+ }
+
+ if (conf_pointer->VERBOSE.get())
+ cout << "Waiting ("<<wait++<<" polls) for first fix (mode="<<gpsdata->fix.mode<<"). Satellites view/recv/used: "
+ << gpsdata->satellites_visible << "/"
+ << recv << "/" << gpsdata->satellites_used << " \r" << flush;
+
+ int timeout = 180;
+ if (wait > timeout) {
+ cerr <<endl<< "timeout. No 2D fix after " << timeout << " polls" << endl;
+ exit(0);
+ }
+ }
+
+
+ // now we have a fix!
+ if ( isnan(gpsdata->fix.latitude) || isnan(gpsdata->fix.longitude) || gpsdata->fix.longitude > 180.0 || gpsdata->fix.longitude < -180.0
+ || gpsdata->fix.latitude > 90.0 || gpsdata->fix.latitude < -90.0
+ ) {
+ cerr << endl << "Initfix is fscked. I'll try again!" << flush << endl;
+ goto again;
+ }
+
+ if (conf_pointer->VERBOSE.get()) {
+ cout << endl << "InitfiX: " << gpsdata->fix.latitude << " " << gpsdata->fix.longitude << flush << endl ;
+ //if (gpsdata->set & DEVICELIST_SET) { // keine ahnung warum das nicht gesetzt ist?
+ int i;
+ cout << "DEVICELIST: number of devs: " << gpsdata->devices.ndevices << endl;
+ for (i = 0; i < gpsdata->devices.ndevices; i++) {
+ cout << "no: " << gpsdata->devices.ndevices
+ << " path="<< gpsdata->devices.list[i].path
+ << " driver=" << gpsdata->devices.list[i].driver << endl;
+ }
+ //}
+ }
+
+
+ proj_pointer->set_center_lat(gpsdata->fix.latitude);
+ proj_pointer->set_center_lon(gpsdata->fix.longitude);
+
+ center_lat = gpsdata->fix.latitude;
+ center_lon = gpsdata->fix.longitude;
+ center_alt = 0;
+
+ float _alt=0;
+
+
+ if ( isnan(gpsdata->fix.altitude) || gpsdata->fix.altitude < -9000.0 || gpsdata->fix.altitude > 20000.0 ) {
+ _alt = 0;
+ if (conf_pointer->VERBOSE.get())
+ cout << "initalt not used = " << _alt << endl;
+ } else {
+ _alt = gpsdata->fix.altitude;
+ if (conf_pointer->VERBOSE.get())
+ cout << "initalt = " << _alt << endl;
+ }
+
+
+ center_gps = _alt;
+
+ latmax = center_lat;
+ latmin = center_lat;
+
+ lonmin = center_lon;
+ lonmax = center_lon;
+
+ altmax = 0;
+ altmin = 0;
+
+ gpsmax = center_gps;
+ gpsmin = center_gps;
+
+ conf_pointer->GPSALT.on();
+
+
+ xmin=0; xmax=0; ymin=0; ymax=0;
+ zmax= center_gps / 1000.0;
+ zmin= center_gps / 1000.0;
+ speedmax=0; speedmin=100; variomax=0; variomin=0;
+
+ while (querygps() != 0) {
+ // if (conf_pointer->VERBOSE.get())
+ // cout << "FIRSTFIX. read invalid...." << endl;
+ } ; //at least one fix has to be in the list before calling setinitpos etc
+
+
+ // here action after first fix
+ // set centers, projection
+
+ // was ist wenn --lat --lon gegeben sind?
+ // was ist wenn igc-file gegeben ist?
+
+ // function Flighdata::update gps (auch drawing liste)
+ // schreiben für logger...!?
+ // _> flightdata in gpsaltmode
+
+#endif
+ cerr << "Sorry. Support for gpsd wasn't included" << endl;
+ exit (1);
+
+}
+
+
+int Flightdata::querygps(void)
+{
+ // return 0, if a new fix is added
+#ifdef HAVE_LIBGPS
+ //gpsdata = gps->query("oqm\n"); //should be read in "o" as well //old from gpsd 2.39
+
+ // poll blocks! so check first if new data is available!
+ if (gps->waiting(1)) {gpsdata=gps->read();} else {return (1);}
+
+
+ // mode valid, and new time
+ if (gpsdata->fix.mode > 1 && (int)(gpsdata->fix.time+0.5) != oldgpstime) {
+
+
+ if ( isnan(gpsdata->fix.time) || isnan(gpsdata->fix.latitude) || isnan(gpsdata->fix.longitude) || gpsdata->fix.longitude > 180.0 || gpsdata->fix.longitude < -180.0
+ || gpsdata->fix.latitude > 90.0 || gpsdata->fix.latitude < -90.0) {
+ if (conf_pointer->DEBUG.get())
+ cerr << "This fix is fscked! time, lat or lon NaN! or out of range" << flush << endl;
+ // no fix, nothing to do
+ consecutive_valid_fixes = 0;
+ return (1);
+ }
+
+ // I havent found this cases...yet
+ // check .. if speed != 0, but position is the same...
+ // this should not happen, otherwise position seems to be invalid (or speed)
+ if (lat.size() > 1) {
+ if (gpsdata->fix.speed != 0 && gpsdata->fix.longitude == lon[lon.size()-1] && gpsdata->fix.latitude == lat[lat.size()-1]) {
+ if (conf_pointer->DEBUG.get())
+ cerr << "Speed != 0, but same coordinates, skipping!" << flush << endl;
+ consecutive_valid_fixes = 0;
+ return (1);
+ }
+ //cout << "New coordinates: " << gpsdata->fix.latitude << ", " << gpsdata->fix.longitude <<
+ // " Old coordinates: " << lat[lat.size()-1] << ", " << lon[lon.size()-1] << flush << endl;
+ }
+
+ // a valid position fix with 2 or less satellites is not possible.
+ // my Geko301 gives positions like that (track extrapolation) e.g. tunnel
+ int sat_limit = 2;
+ if (gpsdata->satellites_used <= sat_limit) {
+ if (conf_pointer->DEBUG.get())
+ cerr << "Satellites used <="<< sat_limit <<"!!! The GPS device is kidding us! Ignoring this fix!" << flush << endl;
+ consecutive_valid_fixes = 0;
+ return (1);
+ }
+
+ //skip first x fixes after invalids...
+ // int _skips = 1;
+ if (consecutive_valid_fixes < 1) {
+ if (conf_pointer->DEBUG.get())
+ cerr << "Skipping first fix after a series of invalids!" << flush << endl;
+ consecutive_valid_fixes++;
+ // set oldtime otherwise we end up here with the same fix again!
+ oldgpstime = (int)(gpsdata->fix.time+0.5);
+
+ // carefull here. works only with _skips==1 !!!
+ gps_interruptions++;
+
+ return (1);
+ }
+
+ consecutive_valid_fixes ++;
+
+ // Valid position fix !!!
+ n++;
+ lat.push_back(gpsdata->fix.latitude);
+ lon.push_back(gpsdata->fix.longitude);
+
+ // take the larger value of epx epy
+ if (gpsdata->fix.epy > gpsdata->fix.epx) {eph.push_back(gpsdata->fix.epy);}
+ else {eph.push_back(gpsdata->fix.epx);}
+// eph.push_back(0);
+
+
+ float _alt = 0;
+
+ // with altitude!
+ if (gpsdata->fix.mode == MODE_3D) {
+
+ // invalid altitude in 3D fix
+ if ( isnan(gpsdata->fix.altitude) || gpsdata->fix.altitude < -9000 || gpsdata->fix.altitude > 20000 ) {
+ cerr << "Mode=3d, but altitude is fscked!!!! Skipping alt." << flush << endl;
+ // _alt is = 0 already
+ vario.push_back(0);
+ epc.push_back(0);
+ epv.push_back(0);
+ } else {
+ _alt = gpsdata->fix.altitude;
+ vario.push_back(gpsdata->fix.climb);
+ epc.push_back(gpsdata->fix.epc); // rubbish!
+ epv.push_back(gpsdata->fix.epv);
+ }
+ // without alt
+ } else {
+ //
+ vario.push_back(0);
+ epc.push_back(0);
+ epv.push_back(0);
+ }
+
+
+ alt.push_back(0); // baro; always = 0 as long as there is no baro item in gps_data
+
+ gpsalt.push_back(_alt);
+ if ( _alt > gpsmax) gpsmax = _alt;
+ if ( _alt < gpsmin) gpsmin = _alt;
+
+ satused.push_back(gpsdata->satellites_used);
+ satvis.push_back(gpsdata->satellites_visible);
+ gpsmode.push_back(gpsdata->fix.mode);
+
+ float _x,_y;
+ proj_pointer->get_xy(gpsdata->fix.latitude, gpsdata->fix.longitude, _x, _y);
+ x.push_back(-_x);
+ y.push_back(-_y);
+
+ z.push_back( _alt / 1000.0);
+ if ( (_alt / 1000.0) > zmax) zmax = (_alt / 1000.0);
+ if ( (_alt / 1000.0) < zmin) zmin = (_alt / 1000.0);
+
+
+ if (conf_pointer->GPSDGNDELEV.get() && conf_pointer->DEM.get()) {
+ vector <int> _xalt;
+ vector <float> _xlat;
+ vector <float> _xlon;
+ _xalt.clear();
+ _xlon.clear();
+ _xlat.clear();
+
+ _xlat.push_back(gpsdata->fix.latitude);
+ _xlon.push_back(gpsdata->fix.longitude);
+ _xalt.push_back(0);
+
+ get_gnd_elevations(&_xalt, &_xlat, &_xlon, conf_pointer);
+ gnd_elevation.push_back(_xalt[0]);
+
+ } else {
+ gnd_elevation.push_back(0);
+ }
+
+
+ /*
+ andere min/max xy und lat lon usw, vario...
+ werden zZt nicht upgedated. ist vielleicht auch nicht noetig?!???
+ */
+
+ speed.push_back(gpsdata->fix.speed * 3.6);
+ eps.push_back( (gpsdata->fix.eps*3.6) ); // seems to be rubbish!
+ if ( (gpsdata->fix.speed*3.6) > speedmax ) speedmax = (gpsdata->fix.speed*3.6);
+ if ( (gpsdata->fix.speed*3.6) < speedmin ) speedmin = (gpsdata->fix.speed*3.6);
+
+ //cout << "spee min/max " << speedmin << " " << speedmax << endl;
+
+ struct tm *t;
+ time_t tt = (int)(gpsdata->fix.time+0.5);
+ oldgpstime = (int)(gpsdata->fix.time+0.5);
+ t = gmtime(&tt);
+
+ dectime.push_back((double) t->tm_hour +
+ ((double) t->tm_min / 60.0) +
+ ((double) t->tm_sec / 3600.0));
+ char buf[80];
+ float hh = t->tm_hour + conf_pointer->getTimeZone();
+ if (hh < 0) hh += 24;
+ if (hh >= 24 && (t->tm_min > 0 || t->tm_sec > 0)) hh -= 24;
+
+ sprintf(buf, "%02d:%02d:%02d", (int) hh, (int) t->tm_min,
+ (int) t->tm_sec);
+ time.push_back(buf);
+
+ if (conf_pointer->DEBUG.get())
+ cout << "GPS: M=" << gpsdata->fix.mode << " su=" << gpsdata->satellites_used <<
+ " " << buf << " alt=" << gpsdata->fix.altitude << "m lat=" << gpsdata->fix.latitude <<
+ " lon=" << gpsdata->fix.longitude << flush << endl;
+
+ // hier noch centers und max/min updaten!
+ // evtl verschiede return-werte für landscape update
+
+
+ return (0); //success!
+ } else {
+ if (gpsdata->fix.mode <= 1)
+ consecutive_valid_fixes=0;
+ return (1);
+ }
+#else
+return(0);
+#endif
+}
+
+
+int Flightdata::readIGCFile(string _filename, bool USE_V)
+{
+ Timecheck readigc("ReadIGC",conf_pointer);
+ ifstream igcfile;
+ igcfile.open(_filename.c_str());
+
+ if (!igcfile) { cerr << "error opening :" << _filename << endl; exit (1);}
+
+ n = 0;
+
+ // nicht noetig, oder?
+ x.clear();
+ y.clear();
+ z.clear();
+ time.clear();
+ dectime.clear();
+ gnd_elevation.clear();
+ gpsalt.clear();
+ alt.clear();
+ lat.clear();
+ lon.clear();
+ gpsmode.clear();
+ satused.clear();
+
+
+ int hh,
+ mm,
+ ss,
+ latdeg,
+ latminute,
+ latmindec, londeg, lonminute, lonmindec, _alt, _gpsalt;
+ char entryindex, northsouth, eastwest, valid;
+ double ns = 1.0;
+ double ew = 1.0;
+
+ char zeile[180];
+
+ double _latsum = 0;
+ double _lonsum = 0;
+ double _altsum = 0;
+ double _gpssum = 0;
+
+ int invalidcounter = 0;
+ int b_line_counter = 0;
+ int line_counter = 0;
+
+ while (igcfile) {
+ igcfile.getline(zeile, 180, '\n');
+
+ line_counter++;
+
+ //cout << zeile << endl;
+
+ if (sscanf(zeile, "%1s", &entryindex) == 1
+ && entryindex == 'B') {
+
+ b_line_counter++;
+
+
+ if (sscanf(zeile,
+ "%*c%2d%2d%2d%2d%2d%3d%c%3d%2d%3d%c%c%5d%5d",
+ &hh, &mm, &ss, &latdeg, &latminute,
+ &latmindec, &northsouth, &londeg,
+ &lonminute, &lonmindec, &eastwest, &valid,
+ &_alt, &_gpsalt) != 14) {
+
+ if(conf_pointer->VERBOSE.get()){
+ cout << "error parsing B record: " << zeile << endl;
+ }
+
+
+ }
+
+ if (valid == 'V')
+ invalidcounter++;
+
+ if (!USE_V) {
+ if (valid == 'V')
+ continue;
+ }
+
+ if (northsouth == 'N')
+ ns = 1.0;
+ else
+ ns = -1.0;
+ lat.push_back(ns *
+ ((double) latdeg +
+ ((double) latminute / 60.0) +
+ ((double) latmindec / 60000.0)));
+ _latsum =
+ _latsum +
+ (ns *
+ ((double) latdeg +
+ ((double) latminute / 60.0) +
+ ((double) latmindec / 60000.0)));
+ if (eastwest == 'E')
+ ew = 1.0;
+ else
+ ew = -1.0;
+ lon.push_back(ew *
+ ((double) londeg +
+ ((double) lonminute / 60.0) +
+ ((double) lonmindec / 60000.0)));
+ _lonsum =
+ _lonsum +
+ (ew *
+ ((double) londeg +
+ ((double) lonminute / 60.0) +
+ ((double) lonmindec / 60000.0)));
+ alt.push_back((double) _alt);
+ _altsum = _altsum + (double) _alt;
+ gpsalt.push_back((double) _gpsalt);
+ _gpssum = _gpssum + (double) _gpsalt;
+
+ gnd_elevation.push_back(0);
+
+ // these ones are unused in igc-file mode
+ //
+ gpsmode.push_back(0);
+ satused.push_back(0);
+ epc.push_back(0);
+ eps.push_back(0);
+ epv.push_back(0);
+ eph.push_back(0);
+
+ dectime.push_back((double) hh +
+ ((double) mm / 60.0) +
+ ((double) ss / 3600.0));
+ char buf[80];
+
+ hh += conf_pointer->getTimeZone();
+ if (hh < 0) hh += 24;
+ if (hh >= 24 && (mm > 0 || ss > 0)) hh -= 24;
+
+ sprintf(buf, "%02d:%02d:%02d", (int) hh, (int) mm,
+ (int) ss);
+ time.push_back(buf);
+
+ n++;
+ //cout << n << "debug---" << endl;
+ }
+
+ }
+ //cout << "ENDE DES EINLES" << endl;
+
+ igcfile.close();
+
+
+ if (conf_pointer->VERBOSE.get()) {
+ cout << line_counter << " lines of IGC-file read" << endl;
+ cout << b_line_counter << " lines of B-records recognized" << endl;
+ }
+
+ if (conf_pointer->VERBOSE.get() && USE_V) {
+ cout << "Invalid position fixes: " << invalidcounter << endl;
+ }
+
+ center_lat = _latsum / (double) n; //startwerte
+ center_lon = _lonsum / (double) n;
+
+ //cout << "altsum " << _altsum << endl;
+ center_alt = _altsum / (double) n;
+ //cout << "center alt " << center_alt << endl;
+ center_gps = _gpssum / (double) n;
+
+
+ //startwerte fuer maxima/minima
+ latmax = center_lat;
+ latmin = center_lat;
+ lonmin = center_lon;
+ lonmax = center_lon;
+ altmax = center_alt;
+ altmin = center_alt;
+ gpsmax = center_gps;
+ gpsmin = center_gps;
+
+ // determination of maxima and minima in original data
+ for (int _q = 0; _q < n; _q++) {
+ if (lat[_q] < latmin)
+ latmin = lat[_q];
+ if (lat[_q] > latmax)
+ latmax = lat[_q];
+ if (lon[_q] < lonmin)
+ lonmin = lon[_q];
+ if (lon[_q] > lonmax)
+ lonmax = lon[_q];
+ if (alt[_q] < altmin)
+ altmin = alt[_q];
+ if (alt[_q] > altmax)
+ altmax = alt[_q];
+ if (gpsalt[_q] < gpsmin)
+ gpsmin = gpsalt[_q];
+ if (gpsalt[_q] > gpsmax)
+ gpsmax = gpsalt[_q];
+ }
+
+ if (conf_pointer->VERBOSE.get()) {
+ cout << "IGC-File boundaries: " << latmax << " " << latmin << " " << lonmin << " " <<lonmax << endl;
+ }
+
+ //real centers
+ center_lat = (latmin + latmax) / 2;
+ center_lon = (lonmin + lonmax) / 2;
+ center_alt = (altmin + altmax) / 2;
+ center_gps = (gpsmin + gpsmax) / 2;
+
+ //set in projection object too
+ proj_pointer->set_center_lat(center_lat);
+ proj_pointer->set_center_lon(center_lon);
+
+
+ //calculate x,y and z values (now using the projection object)!
+ for (int _q = 0; _q < n; _q++) {
+
+ float _ykmdist, _xkmdist;
+ proj_pointer->get_xy(lat[_q], lon[_q], _xkmdist, _ykmdist);
+
+ x.push_back(-_xkmdist);
+ y.push_back(-_ykmdist);
+ //z is altitude in km
+ z.push_back(alt[_q] / 1000.0);
+ //cout << _q << "debuggy 3te schleife" << endl;
+ }
+
+ // startwerte fuer xyz max und minima
+ xmin = 0;
+ ymin = 0;
+ zmin = center_alt / 1000.0;
+ xmax = 0;
+ ymax = 0;
+ zmax = center_alt / 1000.0;
+
+ for (int _i = 0; _i < n; _i++) {
+ if (x[_i] < xmin) {xmin = x[_i];}
+ if (x[_i] > xmax) {xmax = x[_i];}
+ if (y[_i] < ymin) {ymin = y[_i];}
+ if (y[_i] > ymax) {ymax = y[_i];}
+ if (z[_i] < zmin) {zmin = z[_i];}
+ if (z[_i] > zmax) {zmax = z[_i];}
+ }
+
+ xcenter = (xmin + xmax) / 2;
+ ycenter = (ymin + ymax) / 2;
+ zcenter = (zmin + zmax) / 2;
+
+ // another cycle to calculate speed and vario array
+ variomax=0;
+ variomin=0;
+
+ speedmax= -1;
+ speedmin= 10000;
+
+ for (unsigned int c=0; c<x.size() ; c++) {
+ marker_pos = c;
+ vario.push_back(getvario());
+ speed.push_back(getspeed());
+
+ // get min and max's, but skip first 10 datapoints
+ if (c > 10 ) {
+ if (vario[vario.size()-1] > variomax) variomax = vario[vario.size()-1];
+ if (vario[vario.size()-1] < variomin) variomin = vario[vario.size()-1];
+ if (speed[speed.size()-1] > speedmax) speedmax =speed[speed.size()-1];
+ if (speed[speed.size()-1] < speedmin) speedmin = speed[speed.size()-1];
+ }
+
+ }
+
+ //set marker_pos
+ marker_pos = 0;
+
+
+
+ // Emergency fallback to gps-altitude!
+ if (_altsum == 0 && !n==0) {
+ cerr << "no barometric altitude found... using gps-altitude!" << endl;
+ usegps();
+ conf_pointer->GPSALT.on();
+ }
+
+
+ readigc.checknow("readigc end");
+ return 1;
+}
+
+
+void Flightdata::setglEvaluator(void)
+{
+
+ for (int _counter = 0; _counter < n - 3; _counter = _counter + 2) {
+ /*
+ GLfloat** flightarray = new GLfloat*[3];
+ for (int _j=0; _j < n-1 ; _j++)
+ {
+ flightarray[_j] = new GLfloat[3];
+ }
+ */
+ GLfloat flightarray[3][3];
+
+ for (int _j = 0; _j <= 2; _j++) {
+ flightarray[_j][0] = (GLfloat) x[_j + _counter];
+ flightarray[_j][1] = (GLfloat) y[_j + _counter];
+ flightarray[_j][2] = (GLfloat) z[_j + _counter];
+
+ cout << flightarray[_j][0] << " " << _j +
+ _counter << " " << flightarray[_j][1] << " " <<
+ _j +
+ _counter << " " << flightarray[_j][2] << " " <<
+ _j + _counter << " " << endl;
+
+ }
+
+ glMap1f(GL_MAP1_VERTEX_3, 0.0f, 20.0f, (GLint) 3,
+ (GLint) 3, &flightarray[0][0]);
+ cout << "von " << _counter *
+ 2 << " bis " << ((_counter + 3) * 2) << endl;
+
+ glEnable(GL_MAP1_VERTEX_3);
+
+ glColor3d(1.0, 1.0, 1.0);
+ glBegin(GL_LINE_STRIP);
+ for (GLfloat _j = 0; _j <= 20; _j++) {
+ glEvalCoord1f(_j);
+ //cout << "eval---" << _j << endl;
+ }
+ glEnd();
+
+ }
+ cout << "errors after eval: " << (GLenum) glGetError() << endl;
+
+
+
+}
+
+
+int Flightdata::getstartelevation(bool GPS)
+{
+ double _sum = 0;
+ for (int _z = 3; _z <= 10; _z++) {
+
+ if (!GPS) {
+ _sum = _sum + alt[_z];
+ } else {
+ _sum += gpsalt[_z];
+ }
+ //cout << "alt: " << alt[_z] << endl;
+ }
+ _sum = _sum / 8;
+
+ return (int) _sum;
+}
+
+void Flightdata::marker_head(void)
+{
+ marker_pos = int (x.size()-1) ;
+}
+
+void Flightdata::forward_marker(void)
+{
+ marker_pos++;
+ if (marker_pos >= int (x.size())) {
+ if (cycles != -1) cycles--;
+ if (conf_pointer->DEBUG.get())
+ cout << "Cycles: " << cycles << endl;
+
+ marker_pos = 0;
+ }
+}
+
+void Flightdata::fforward_marker(void)
+{
+ marker_pos += 10;
+ if (marker_pos >= int (x.size())) {
+ marker_pos = marker_pos - x.size();
+ }
+}
+
+void Flightdata::backward_marker(void)
+{
+ marker_pos--;
+ if (marker_pos < 0) {
+ marker_pos = x.size() - 1;
+ }
+}
+
+void Flightdata::fbackward_marker(void)
+{
+ marker_pos -= 10;
+ if (marker_pos < 0) {
+ marker_pos = x.size() - abs(int (marker_pos));
+ }
+}
+
+void Flightdata::setmarkerpos(int _pos)
+{
+ if (_pos >= 0 && _pos <= n) {
+ marker_pos = _pos;
+
+ } else {
+ cerr << "Marker position out of range and ignored!" <<
+ endl;
+ }
+
+}
+
+void Flightdata::setmarkertime(string _time)
+{
+ int hh,mm,ss;
+
+ if (sscanf(_time.c_str(),"%d:%d:%d", &hh, &mm, &ss) != 3) {
+ cout << "wrong format in --marker-time argument" << endl;
+ return;
+ }
+
+ float dtime = (double) hh + ((double) mm / 60.0) + ((double) ss / 3600.0);
+
+ float diff=0.3;
+ int _inx=0;
+ for (int _x=0; _x<(int)dectime.size(); _x++) {
+ if ( abs(dectime[_x] - dtime) < diff) {
+ diff = abs(dectime[_x] - dtime);
+ _inx = _x;
+ }
+ }
+
+ if (_inx != 0) {
+ setmarkerpos(_inx);
+ } else {
+ cout << "given time in --marker-time seems to be wrong" << endl;
+ }
+}
+
+
+void Flightdata::draw_marker_ortho(void)
+{
+ //glPushAttrib(GL_ENABLE_BIT);
+
+ glDisable(GL_LIGHTING);
+ glColor3f(conf_pointer->markercol_r.get(),conf_pointer->markercol_g.get(), conf_pointer->markercol_b.get());
+ glLineWidth(3.0);
+
+ glBegin(GL_LINES);
+
+ glVertex3f(x[marker_pos] - 5, y[marker_pos], 10);
+ glVertex3f(x[marker_pos] + 5, y[marker_pos], 10);
+ glVertex3f(x[marker_pos], y[marker_pos] - 5, 10);
+ glVertex3f(x[marker_pos], y[marker_pos] + 5, 10);
+
+ glVertex3f(x[marker_pos] + 1, y[marker_pos] - 0.25, 10);
+ glVertex3f(x[marker_pos] + 1, y[marker_pos] + 0.25, 10);
+ glVertex3f(x[marker_pos] + 2, y[marker_pos] - 0.25, 10);
+ glVertex3f(x[marker_pos] + 2, y[marker_pos] + 0.25, 10);
+ glVertex3f(x[marker_pos] + 3, y[marker_pos] - 0.25, 10);
+ glVertex3f(x[marker_pos] + 3, y[marker_pos] + 0.25, 10);
+ glVertex3f(x[marker_pos] + 4, y[marker_pos] - 0.25, 10);
+ glVertex3f(x[marker_pos] + 4, y[marker_pos] + 0.25, 10);
+ glVertex3f(x[marker_pos] + 5, y[marker_pos] - 0.25, 10);
+ glVertex3f(x[marker_pos] + 5, y[marker_pos] + 0.25, 10);
+
+ glVertex3f(x[marker_pos] - 0.25, y[marker_pos] + 1, 10);
+ glVertex3f(x[marker_pos] + 0.25, y[marker_pos] + 1, 10);
+ glVertex3f(x[marker_pos] - 0.25, y[marker_pos] + 2, 10);
+ glVertex3f(x[marker_pos] + 0.25, y[marker_pos] + 2, 10);
+ glVertex3f(x[marker_pos] - 0.25, y[marker_pos] + 3, 10);
+ glVertex3f(x[marker_pos] + 0.25, y[marker_pos] + 3, 10);
+ glVertex3f(x[marker_pos] - 0.25, y[marker_pos] + 4, 10);
+ glVertex3f(x[marker_pos] + 0.25, y[marker_pos] + 4, 10);
+ glVertex3f(x[marker_pos] - 0.25, y[marker_pos] + 5, 10);
+ glVertex3f(x[marker_pos] + 0.25, y[marker_pos] + 5, 10);
+
+ glEnd();
+
+ //glPopAttrib();
+ //restore our default state
+ glLineWidth(1.0);
+ glEnable(GL_LIGHTING);
+
+}
+
+
+void Flightdata::draw_marker(int _offset, float _scale, bool BW)
+{
+
+//cout << "draw marker" << endl;
+
+ //glPushAttrib(GL_ENABLE_BIT);
+ //glPushAttrib(GL_POLYGON_BIT);
+ //glEnable(GL_LIGHTING);
+ glEnable(GL_COLOR_MATERIAL);
+ //glEnable(GL_NORMALIZE);
+ glPolygonMode(GL_FRONT, GL_FILL);
+
+ float val05= 0.5 * conf_pointer->MARKER_SIZE.get();
+ float val1= 1.0 * conf_pointer->MARKER_SIZE.get();
+ float val3= 3.0 * conf_pointer->MARKER_SIZE.get();
+ float val5= 5.0 * conf_pointer->MARKER_SIZE.get();
+
+ float col[3] = { conf_pointer->markercol_r.get(),conf_pointer->markercol_g.get(), conf_pointer->markercol_b.get() };
+ if (BW) {
+ glColor3fv(graycolor(col));
+ } else {
+ glColor3fv(col);
+ }
+
+ glBegin(GL_TRIANGLES);
+
+ glNormal3f(-1, 0, -1.0 / 3.0);
+ glVertex3f(x[marker_pos], y[marker_pos],
+ z[marker_pos] + (GLfloat) (_offset / 1000.0));
+ glVertex3f(x[marker_pos] - val1, y[marker_pos] - val1,
+ z[marker_pos] + (GLfloat) (_offset / 1000.0) +
+ val3 / _scale);
+ glVertex3f(x[marker_pos] - val1, y[marker_pos] + val1,
+ z[marker_pos] + (GLfloat) (_offset / 1000.0) +
+ val3 / _scale);
+
+ glNormal3f(0, 1, -1.0 / 3.0);
+ glVertex3f(x[marker_pos], y[marker_pos],
+ z[marker_pos] + (GLfloat) (_offset / 1000.0));
+ glVertex3f(x[marker_pos] - val1, y[marker_pos] + val1,
+ z[marker_pos] + (GLfloat) (_offset / 1000.0) +
+ val3 / _scale);
+ glVertex3f(x[marker_pos] + val1, y[marker_pos] + val1,
+ z[marker_pos] + (GLfloat) (_offset / 1000.0) +
+ val3 / _scale);
+
+ glNormal3f(1, 0, -1.0 / 3.0);
+ glVertex3f(x[marker_pos], y[marker_pos],
+ z[marker_pos] + (GLfloat) (_offset / 1000.0));
+ glVertex3f(x[marker_pos] + val1, y[marker_pos] + val1,
+ z[marker_pos] + (GLfloat) (_offset / 1000.0) +
+ val3 / _scale);
+ glVertex3f(x[marker_pos] + val1, y[marker_pos] - val1,
+ z[marker_pos] + (GLfloat) (_offset / 1000.0) +
+ val3 / _scale);
+
+ glNormal3f(0, -1, -1.0 / 3.0);
+ glVertex3f(x[marker_pos], y[marker_pos],
+ z[marker_pos] + (GLfloat) (_offset / 1000.0));
+ glVertex3f(x[marker_pos] + val1, y[marker_pos] - val1,
+ z[marker_pos] + (GLfloat) (_offset / 1000.0) +
+ val3 / _scale);
+ glVertex3f(x[marker_pos] - val1, y[marker_pos] - val1,
+ z[marker_pos] + (GLfloat) (_offset / 1000.0) +
+ val3 / _scale);
+
+ glEnd();
+
+ glBegin(GL_QUADS);
+ glNormal3f(0, 0, 1);
+ glVertex3f(x[marker_pos] + val1, y[marker_pos] - val1,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+ glVertex3f(x[marker_pos] + val1, y[marker_pos] + val1,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+ glVertex3f(x[marker_pos] - val1, y[marker_pos] + val1,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+ glVertex3f(x[marker_pos] - val1, y[marker_pos] - val1,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] + val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glVertex3f(x[marker_pos] - val05, y[marker_pos] + val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glVertex3f(x[marker_pos] - val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glEnd();
+
+ glBegin(GL_QUADS);
+
+ glNormal3f(1, 0, 0);
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] + val05,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] + val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+
+ glNormal3f(0, 1, 0);
+ glVertex3f(x[marker_pos] - val05, y[marker_pos] + val05,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+ glVertex3f(x[marker_pos] - val05, y[marker_pos] + val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] + val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] + val05,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+
+ glNormal3f(-1, 0, 0);
+ glVertex3f(x[marker_pos] - val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+ glVertex3f(x[marker_pos] - val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glVertex3f(x[marker_pos] - val05, y[marker_pos] + val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glVertex3f(x[marker_pos] - val05, y[marker_pos] + val05,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+
+ glNormal3f(0, -1, 0);
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glVertex3f(x[marker_pos] - val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glVertex3f(x[marker_pos] - val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+
+ glEnd();
+
+
+ //diable lighting for black lines
+ glDisable(GL_LIGHTING);
+
+ glColor3f(0.0, 0.0, 0.0);
+ glBegin(GL_LINE_STRIP);
+
+ glVertex3f(x[marker_pos], y[marker_pos],
+ z[marker_pos] + (GLfloat) (_offset / 1000.0));
+ glVertex3f(x[marker_pos] - val1, y[marker_pos] - val1,
+ z[marker_pos] + (GLfloat) (_offset / 1000.0) +
+ val3 / _scale);
+ glVertex3f(x[marker_pos] - val1, y[marker_pos] + val1,
+ z[marker_pos] + (GLfloat) (_offset / 1000.0) +
+ val3 / _scale);
+
+ glVertex3f(x[marker_pos], y[marker_pos],
+ z[marker_pos] + (GLfloat) (_offset / 1000.0));
+ glVertex3f(x[marker_pos] - val1, y[marker_pos] + val1,
+ z[marker_pos] + (GLfloat) (_offset / 1000.0) +
+ val3 / _scale);
+ glVertex3f(x[marker_pos] + val1, y[marker_pos] + val1,
+ z[marker_pos] + (GLfloat) (_offset / 1000.0) +
+ val3 / _scale);
+
+ glVertex3f(x[marker_pos], y[marker_pos],
+ z[marker_pos] + (GLfloat) (_offset / 1000.0));
+ glVertex3f(x[marker_pos] + val1, y[marker_pos] + val1,
+ z[marker_pos] + (GLfloat) (_offset / 1000.0) +
+ val3 / _scale);
+ glVertex3f(x[marker_pos] + val1, y[marker_pos] - val1,
+ z[marker_pos] + (GLfloat) (_offset / 1000.0) +
+ val3 / _scale);
+
+ glVertex3f(x[marker_pos], y[marker_pos],
+ z[marker_pos] + (GLfloat) (_offset / 1000.0));
+ glVertex3f(x[marker_pos] + val1, y[marker_pos] - val1,
+ z[marker_pos] + (GLfloat) (_offset / 1000.0) +
+ val3 / _scale);
+ glVertex3f(x[marker_pos] - val1, y[marker_pos] - val1,
+ z[marker_pos] + (GLfloat) (_offset / 1000.0) +
+ val3 / _scale);
+
+ glEnd();
+
+ glBegin(GL_LINE_STRIP);
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] + val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glVertex3f(x[marker_pos] - val05, y[marker_pos] + val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glVertex3f(x[marker_pos] - val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glEnd();
+
+ glBegin(GL_LINE_STRIP);
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] + val05,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+ glVertex3f(x[marker_pos] - val05, y[marker_pos] + val05,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+ glVertex3f(x[marker_pos] - val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+ glEnd();
+
+ glBegin(GL_LINES);
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] + val05,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+ glVertex3f(x[marker_pos] + val05, y[marker_pos] + val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glVertex3f(x[marker_pos] - val05, y[marker_pos] + val05,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+ glVertex3f(x[marker_pos] - val05, y[marker_pos] + val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+ glVertex3f(x[marker_pos] - val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val3 / _scale);
+ glVertex3f(x[marker_pos] - val05, y[marker_pos] - val05,
+ z[marker_pos] + (_offset / 1000.0) + val5 / _scale);
+
+ glVertex3f(x[marker_pos], y[marker_pos],
+ z[marker_pos] + (_offset / 1000.0));
+ glVertex3f(x[marker_pos], y[marker_pos], -0.2);
+ glEnd();
+
+ //glPopAttrib();
+
+ //turn an lighting again (our default-state)
+ glEnable(GL_LIGHTING);
+ glDisable(GL_COLOR_MATERIAL);
+
+}
+
+
+
+void Flightdata::draw_linestrip(int _offset, bool BW,
+ float _r_up, float _g_up, float _b_up,
+ float _r_down, float _g_down,
+ float _b_down)
+{
+
+ //glEnable(GL_LIGHTING);
+ //glPushAttrib(GL_ENABLE_BIT);
+
+ //disable lighting for the linestrip
+ glDisable(GL_LIGHTING);
+ glLineWidth(conf_pointer->flightstrip_width.get()); //line width
+
+ float col[3];
+
+ int _first, _last;
+
+ if (conf_pointer->MARKER_RANGE.get()) {
+ _first = marker_pos - conf_pointer->get_marker_back();
+ _last = marker_pos + conf_pointer->get_marker_ahead();
+ if (_first < 0) {
+ _first = 0;
+ }
+ if (_last >= n) {
+ _last = n - 1;
+ }
+ } else {
+ _first = 0;
+ _last = n - 1;
+ }
+
+
+ glBegin(GL_LINE_STRIP); //all datapoints as linestrip!
+ for (int _z = _first; _z <= _last; _z++) {
+
+
+ if (conf_pointer->flightstrip_mode.get() == 0) {
+
+ //set color up or down
+ if (z[_z - 1] < z[_z]) {
+
+ col[0] = _r_up;
+ col[1] = _g_up;
+ col[2] = _b_up;
+
+ } else {
+
+ col[0] = _r_down;
+ col[1] = _g_down;
+ col[2] = _b_down;
+
+ }
+ }
+
+
+ // vario mode
+ if (conf_pointer->flightstrip_mode.get() == 3) {
+ getcolor(col,conf_pointer->flightstrip_colmap.get(), vario[_z], -10.0, +10.0);
+ }
+
+ // altitude!
+ if (conf_pointer->flightstrip_mode.get() == 1)
+ getcolor(col,conf_pointer->flightstrip_colmap.get(), z[_z], zmin, zmax);
+
+ //speed
+ if (conf_pointer->flightstrip_mode.get() == 2)
+ getcolor(col,conf_pointer->flightstrip_colmap.get(), speed[_z], speedmin, speedmax);
+
+
+ if (!BW) {
+ glColor3fv(col);
+ } else {
+ glColor3fv(graycolor(col));
+ }
+
+ if (conf_pointer->ORTHOVIEW.get() && conf_pointer->ORTHOONTOP.get()) {
+ glVertex3f((GLfloat) x[_z], (GLfloat) y[_z],
+ (GLfloat) z[_z] + 1 );
+ } else {
+ // just much higher!
+ glVertex3f((GLfloat) x[_z], (GLfloat) y[_z],
+ (GLfloat) z[_z] + (_offset / 1000.0));
+ }
+ }
+ glEnd();
+
+ //glPopAttrib();
+
+ glLineWidth(1.0);
+ glEnable(GL_LIGHTING);
+}
+
+
+void Flightdata::draw_curtain(int _offset, bool BW, float _r, float _g,
+ float _b, float _alpha)
+{
+
+ //glPushAttrib(GL_ENABLE_BIT);
+ //glPushAttrib(GL_DEPTH_BUFFER_BIT);
+ //glPushAttrib(GL_POLYGON_BIT);
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_LIGHTING);
+ glEnable(GL_COLOR_MATERIAL);
+ glDisable(GL_CULL_FACE);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ glDepthMask(GL_FALSE);
+
+ float col[4];
+
+ col[0] = _r;
+ col[1] = _g;
+ col[2] = _b;
+ col[3] = _alpha;
+
+ int _first, _last;
+
+ if (conf_pointer->MARKER_RANGE.get()) {
+ _first = marker_pos - conf_pointer->get_marker_back();
+ _last = marker_pos + conf_pointer->get_marker_ahead();
+ if (_first < 0) {
+ _first = 0;
+ }
+ if (_last >= n) {
+ _last = n - 1;
+ }
+ } else {
+ _first = 0;
+ _last = n - 1;
+ }
+
+
+ float _elev;
+
+ for (int _z = _first; _z <= _last - 1; _z++) {
+ glBegin(GL_POLYGON);
+
+ if (!BW) {
+ glColor4fv(col);
+ } else {
+ glColor4fv(graycolor(col));
+ }
+
+ if (gnd_elevation[_z] <= -16384) {_elev = gnd_elevation[_z]+16384.0-50.0;} // 50m below surface...
+ else {_elev = gnd_elevation[_z]-50.0;}
+ if (gnd_elevation[_z] <= -16384 && conf_pointer->get_sealevel2() == 0) {_elev = -50.0;}
+
+
+ glVertex3f((GLfloat) x[_z], (GLfloat) y[_z], _elev / 1000.0);
+ glVertex3f((GLfloat) x[_z], (GLfloat) y[_z],
+ (GLfloat) z[_z] + (_offset / 1000.0));
+ glVertex3f((GLfloat) x[_z + 1], (GLfloat) y[_z + 1],
+ (GLfloat) z[_z + 1] + (_offset / 1000.0));
+ glVertex3f((GLfloat) x[_z + 1], (GLfloat) y[_z + 1], _elev / 1000.0);
+ glEnd();
+ }
+
+ //glPopAttrib();
+ glDepthMask(GL_TRUE);
+ glEnable(GL_CULL_FACE);
+ glPolygonMode(GL_FRONT, GL_FILL);
+ glDisable(GL_COLOR_MATERIAL);
+ glDisable(GL_BLEND);
+ glEnable(GL_LIGHTING);
+}
+
+
+void Flightdata::draw_shadow(int _offset, bool BW, float _width, float _r,
+ float _g, float _b)
+{
+
+ //glPushAttrib(GL_ENABLE_BIT);
+ glDisable(GL_LIGHTING);
+ glLineWidth(_width);
+
+ float col[3];
+
+ col[0] = _r;
+ col[1] = _g;
+ col[2] = _b;
+
+ int _first, _last;
+
+ if (conf_pointer->MARKER_RANGE.get()) {
+ _first = marker_pos - conf_pointer->get_marker_back();
+ _last = marker_pos + conf_pointer->get_marker_ahead();
+ if (_first < 0) {
+ _first = 0;
+ }
+ if (_last >= n) {
+ _last = n - 1;
+ }
+ } else {
+ _first = 0;
+ _last = n - 1;
+ }
+
+ glBegin(GL_LINE_STRIP);
+
+ for (int _z = _first; _z <= _last; _z++) {
+
+
+ if (!BW) {
+ glColor3fv(col);
+ } else {
+ glColor3fv(graycolor(col));
+ }
+
+ glVertex3f((GLfloat) x[_z], (GLfloat) y[_z],
+ (GLfloat) zmin + (_offset / 1000.0));
+ }
+ glEnd();
+
+ glLineWidth(1.0);
+ glEnable(GL_LIGHTING);
+ //glPopAttrib();
+
+}
+
+
+void Flightdata::draw_shadow_terrain(bool BW, float _width, float _r,
+ float _g, float _b)
+{
+
+ //glPushAttrib(GL_ENABLE_BIT);
+ glDisable(GL_LIGHTING);
+ glLineWidth(_width);
+
+ float col[3];
+
+ col[0] = _r;
+ col[1] = _g;
+ col[2] = _b;
+
+ int _first, _last;
+
+ if (conf_pointer->MARKER_RANGE.get()) {
+ _first = marker_pos - conf_pointer->get_marker_back();
+ _last = marker_pos + conf_pointer->get_marker_ahead();
+ if (_first < 0) {
+ _first = 0;
+ }
+ if (_last >= n) {
+ _last = n - 1;
+ }
+
+ } else {
+ _first = 0;
+ _last = n - 1;
+ }
+
+ glBegin(GL_LINE_STRIP);
+
+ float _elev;
+
+
+ for (int _z = _first; _z <= _last; _z++) {
+
+ if (gnd_elevation[_z] <= -16384) {_elev = gnd_elevation[_z]+16384.0+5.0;} // 50m below surface...
+ else {_elev = gnd_elevation[_z]+5.0;}
+ if (gnd_elevation[_z] <= -16384 && conf_pointer->get_sealevel2() == 0) {_elev = 5.0;}
+
+ if (!BW) {
+ glColor3fv(col);
+ } else {
+ glColor3fv(graycolor(col));
+ }
+
+ glVertex3f((GLfloat) x[_z], (GLfloat) y[_z],
+ (GLfloat) (_elev / 1000.0));
+ }
+ glEnd();
+
+
+ // and another one on sealevel3
+ if (conf_pointer->get_sealevel3() != -22222) {
+ glBegin(GL_LINE_STRIP);
+
+ for (int _z = _first; _z <= _last; _z++) {
+
+ if (!BW) {
+ glColor3fv(col);
+ } else {
+ glColor3fv(graycolor(col));
+ }
+
+ glVertex3f((GLfloat) x[_z], (GLfloat) y[_z],
+ (GLfloat) (conf_pointer->get_sealevel3() / 1000.0)) ;
+ }
+ glEnd();
+ }
+
+
+ glLineWidth(1.0);
+ glEnable(GL_LIGHTING);
+ //glPopAttrib();
+
+}
+
+
+double Flightdata::getvario(void)
+{
+
+ if (marker_pos >= 1) { //< int(x.size())-1) {
+ return ((alt[marker_pos] -
+ alt[marker_pos - 1]) / ((dectime[marker_pos] -
+ dectime[marker_pos -
+ 1]) * 3600));
+ } else {
+ return 0.0;
+ }
+}
+
+double Flightdata::getgpsvario(void)
+{
+
+ if (marker_pos >= 1) { //< int(x.size())-1) {
+ return ((gpsalt[marker_pos] -
+ gpsalt[marker_pos - 1]) / ((dectime[marker_pos] -
+ dectime[marker_pos -
+ 1]) * 3600));
+ } else {
+ return 0.0;
+ }
+}
+
+double Flightdata::getintvario(int _fixes)
+{
+
+ if (marker_pos > _fixes) {
+ return ((alt[marker_pos] -
+ alt[marker_pos -
+ _fixes]) / ((dectime[marker_pos] -
+ dectime[marker_pos -
+ _fixes]) * 3600));
+ } else {
+ return 0.0;
+ }
+}
+
+
+double Flightdata::getgpsintvario(int _fixes)
+{
+
+ if (marker_pos > _fixes) {
+ return ((gpsalt[marker_pos] -
+ gpsalt[marker_pos -
+ _fixes]) / ((dectime[marker_pos] -
+ dectime[marker_pos -
+ _fixes]) * 3600));
+ } else {
+ return 0.0;
+ }
+}
+
+double Flightdata::getspeed(void)
+{
+
+ if (marker_pos >= 1) {
+
+
+ return (great_circle_dist
+ (lat[marker_pos], lon[marker_pos],
+ lat[marker_pos - 1], lon[marker_pos - 1])
+ / (dectime[marker_pos] - dectime[marker_pos - 1]));
+
+ } else {
+ return 0.0;
+ }
+
+}
+
+
+void Flightdata::usegps(void)
+{
+ z.clear();
+ vario.clear();
+
+ zmin = gpsmin / 1000.0;
+ zmax = gpsmax / 1000.0;
+
+ for (int _q = 0; _q < n; _q++) {
+ z.push_back(gpsalt[_q] / 1000.0);
+ }
+ // another cycle to calculate speed and vario array
+
+ variomax=0;
+ variomin=0;
+
+ for (unsigned int c=0; c<x.size() ; c++) {
+ marker_pos = c;
+ vario.push_back(getgpsvario());
+ //speed.push_back(getspeed());
+
+ // get min and max's, but skip first 10 datapoints
+ if (c > 10 ) {
+ if (vario[vario.size()-1] > variomax) variomax = vario[vario.size()-1];
+ if (vario[vario.size()-1] < variomin) variomin = vario[vario.size()-1];
+ //if (speed[speed.size()-1] > speedmax) speedmax =speed[speed.size()-1];
+ //if (speed[speed.size()-1] < speedmin) speedmin = speed[speed.size()-1];
+ }
+ }
+
+ //set marker_pos
+ marker_pos = 0;
+}
diff --git a/src/flightdata.h b/src/flightdata.h
new file mode 100644
index 0000000..40f8962
--- /dev/null
+++ b/src/flightdata.h
@@ -0,0 +1,236 @@
+/*
+ * (c) 2002-2016 Hannes Krueger
+ * This file is part of the GPLIGC/ogie package
+ */
+
+#ifndef FLIGHTDATA_H
+#define FLIGHTDATA_H 1
+
+#include <vector>
+#include <string>
+#include <sstream>
+
+#ifndef __OSX__
+#include <GL/gl.h>
+#else
+#include <OpenGL/gl.h>
+#endif
+
+#include "oconfig.h"
+#include "oglexfunc.h"
+#include "projection.h"
+#include "config.h"
+
+#ifdef HAVE_LIBGPS
+#include "libgpsmm.h"
+#else
+#define DEFAULT_GPSD_PORT "2497"
+#endif
+
+
+class Flightdata {
+
+ public:
+
+ Flightdata();
+ ~Flightdata();
+
+ int readIGCFile (string, bool USE_V=false); //read igc datafile
+
+ void initgps(const char* gpsdserver="localhost", const char* port=DEFAULT_GPSD_PORT);
+ string serverstring;
+
+ void readGNDElevation (Config * _config) {get_gnd_elevations(&gnd_elevation, &lat, &lon, _config);}
+ double getx (int _i) const {return x[_i];}
+ double gety (int _i) const {return y[_i];}
+ double getz (int _i) const {return z[_i];}
+
+ double getmarkerx () const {return (n!=0) ? x[marker_pos] : 0;}
+ double getmarkery () const {return (n!=0) ? y[marker_pos] : 0;}
+ double getmarkerz () const {return (n!=0) ? z[marker_pos] : 0;}
+
+ void set_proj_pointer(Projection *p) { proj_pointer = p;}
+ void set_conf_pointer(Config *c) { conf_pointer = c;}
+
+ int querygps(void);
+
+ void usegps(void);
+
+ int getstartelevation(bool GPS);
+
+ double getxcenter () const {return xcenter;}
+ void setxcenter(double x) {xcenter =x;}
+
+ double getycenter () const {return ycenter;}
+ void setycenter(double y) {ycenter =y;}
+
+ double getzcenter () const {return zcenter;}
+ void setzcenter(double z) {zcenter =z;}
+
+ double getxmax () const {return xmax;}
+ void setxmax(double x) {xmax =x;}
+
+ double getxmin () const {return xmin; }
+ void setxmin(double x) {xmin =x;}
+
+ double getymax () const {return ymax;}
+ void setymax(double y) {ymax =y;}
+
+ double getymin () const {return ymin;}
+ void setymin(double y) {ymin =y;}
+
+ double getzmax () const {return zmax; }
+ void setzmax(double z) {zmax =z;}
+
+ double getzmin () const {return zmin;}
+ void setzmin(double z) {zmin =z;}
+
+ double getcenter_lat () const {return center_lat;}
+ void setcenter_lat(double l) {center_lat =l;}
+
+ double getcenter_lon () const {return center_lon;}
+ void setcenter_lon(double l) {center_lon =l;}
+
+ double getlatmin () const {return latmin;}
+ void setlatmin(double l) {latmin =l;}
+
+ double getlatmax () const {return latmax;}
+ void setlatmax(double l) {latmax =l;}
+
+ double getlonmin () const {return lonmin;}
+ void setlonmin(double l) {lonmin =l;}
+
+ int getcycles () const {return cycles;}
+ void setcycles(int c) {cycles=c;}
+
+ double getlonmax () const {return lonmax;}
+ void setlonmax(double l) { lonmax =l;}
+
+ int getn () const {return n;}
+ void setglEvaluator (void);
+
+ int getmarker(void) const {return int(marker_pos);}
+ void setmarkerpos(int _pos);
+
+ void setmarkertime(string _time);
+
+ void forward_marker (void);
+ void fforward_marker(void);
+ void backward_marker(void);
+ void fbackward_marker(void);
+ void marker_head(void);
+
+ void draw_marker(int, float, bool);
+ void draw_marker_ortho(void);
+
+ //double getdectime(void) const {return dectime[marker_pos];}
+ string gettime(void) const {return time[marker_pos];}
+ double getalt(void) const {return alt[marker_pos];}
+ double getlat(void) const {return lat[marker_pos];}
+ double getlon(void) const {return lon[marker_pos];}
+
+ double getgpsalt(void) const {return gpsalt[marker_pos];}
+ int getgndelevation(void) const {return gnd_elevation[marker_pos];}
+
+ double getsatused (void) const {return satused[marker_pos];}
+ double getsatvis (void) const {return satvis[marker_pos];}
+ double getgpsmode (void) const {return gpsmode[marker_pos];}
+ int getgpsinterruptions(void) const {return gps_interruptions;}
+ int getvalidfix(void) const {return consecutive_valid_fixes;}
+
+
+ // estimated errors climb speed vertical horizontal
+ double getepc (void) const {return epc[marker_pos];}
+ double geteps (void) const {return eps[marker_pos];}
+ double getepv (void) const {return epv[marker_pos];}
+ double geteph (void) const {return eph[marker_pos];}
+
+ double getvario(void);
+ double getgpsvario(void);
+ double getintvario(int);
+ double getgpsintvario(int);
+ double getspeed(void);
+
+ void draw_linestrip(int _offset,bool BW, float _r_up ,float _g_up ,float _b_up ,float _r_down ,float _g_down, float _b_down);
+ // another draw linestrip...
+ void draw_curtain(int _offset, bool BW, float, float, float, float);
+ void draw_shadow(int _offset, bool BW, float _width, float _r = 0.0, float _g = 0.0, float _b = 0.0);
+ void draw_shadow_terrain(bool BW, float _width, float _r = 0.0, float _g = 0.0, float _b = 0.0);
+
+ protected:
+ int n; //number of data points
+ double xmin;
+ double xmax;
+ double xcenter;
+ double ymin;
+ double ymax;
+ double ycenter;
+ double zmin;
+ double zmax;
+ double zcenter;
+
+ double center_lat;
+ double center_lon;
+ double center_alt;
+ double center_gps;
+ double latmax;
+ double latmin;
+ double lonmax;
+ double lonmin;
+ double altmax;
+ double altmin;
+ double gpsmax;
+ double gpsmin;
+
+ vector < float > x; //km from center
+ vector < float > y;
+ vector < float > z; //height in km
+ vector < float > lat;
+ vector < float > lon;
+ vector < float > alt; //height in m
+ vector < float > gpsalt; // -"-
+ vector <int> gnd_elevation; // ground elevation at position
+ vector < float > dectime;
+ vector < string > time;
+
+ vector <int> satused;
+ vector <int> satvis;
+ vector <int> gpsmode;
+ int oldgpstime;
+ int consecutive_valid_fixes;
+ int gps_interruptions;
+
+ vector < float > speed;
+ vector < float > eps;
+ vector < float > vario;
+ vector < float > epc;
+
+ vector < float > epv;
+ vector < float > eph;
+
+ float speedmax;
+ float speedmin;
+ float variomax;
+ float variomin;
+
+ //name fdatafile
+ string filename;
+
+ Projection *proj_pointer; //the projection-class pointer
+ Config *conf_pointer; // config-pointer
+
+ int marker_pos;
+ int cycles;
+
+#ifdef HAVE_LIBGPS
+#if GPSD_API_MAJOR_VERSION == 5
+ gpsmm *gps; //("localhost", DEFAULT_GPSD_PORT);
+ struct gps_data_t *gpsdata;
+// struct gps_fix_t *gpsfix;
+#endif
+#endif
+
+
+};
+
+#endif
diff --git a/src/landscape.cpp b/src/landscape.cpp
new file mode 100644
index 0000000..29ad935
--- /dev/null
+++ b/src/landscape.cpp
@@ -0,0 +1,1266 @@
+/*
+ * (c) 2002-2016 Hannes Krueger
+ * This file is part of the GPLIGC/ogie package
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "landscape.h"
+#include "oglexfunc.h"
+#include "GLexplorer.h"
+#include <iostream>
+#include <fstream>
+#include <cstdio>
+#include <cstdlib>
+#include <algorithm>
+#include <cmath>
+#include <string>
+
+#ifndef __OSX__
+#include <GL/gl.h>
+#else
+#include <OpenGL/gl.h>
+#endif
+
+
+//const std::string rcsid_landscape_cpp =
+// "$Id: landscape.cpp 3 2014-07-31 09:59:20Z kruegerh $";
+//const std::string rcsid_landscape_h = LANDSCAPE_H;
+
+
+Landscape::Landscape()
+{
+ CLEARFLAG = true;
+ CLEARFLAG_SURFACE = false;
+}
+
+
+// read in the dem data... be sure that max_lon, min_lon, max_lat, min_lat is set before...
+// the arguments given to this function are the properties of the DEM-File!!!
+int Landscape::readDEM(string filename, int rows_lat, int colums_lon,
+ double demlatmin, double demlatmax,
+ double demlonmin, double demlonmax, bool FAST)
+{
+
+ Timecheck landtime("Landscape::readDEM", conf_pointer);
+
+ // in fast mode (only for getting max and min alt)
+ // no arrays need to be cleared in destructor...
+ if (FAST)
+ CLEARFLAG = false;
+
+
+
+ int _max = 90;
+ if (proj_pointer->get_projection() == PROJ_CYL_MERCATOR)
+ _max = MERCATOR_MAX_LAT;
+
+ if (max_lat > _max) {
+ cerr << "north border set to " << _max << " north" <<
+ endl;
+ max_lat = _max;
+ }
+
+ if (min_lat < -_max) {
+ cerr << "south border set to " << _max << " south" <<
+ endl;
+ min_lat = -_max;
+ }
+
+
+ // fuer WORLDDEM circumvent 180 -180 limits!?????? NNNNNEEEEEEEEDDDDS TO BE DONE!!!!!!!!!!!!
+
+ // check, if the requested borders partially outside of DEM, then set to DEMs limits...
+ if (max_lat > demlatmax) {
+ max_lat = demlatmax;
+ cerr << "maximum latitude exceeds available DEM. set to DEMs max!" << endl;
+ }
+
+ if ( min_lat < demlatmin) {
+ min_lat = demlatmin;
+ cerr << "minimum latitude exceeds available DEM. set to DEMs min!" << endl;
+ }
+
+ if ( max_lon > demlonmax && demlonmax != 180) {
+ max_lon = demlonmax;
+ cerr << "maximum longitude exceeds available DEM. set to DEMs max!" << endl;
+ }
+
+ if (min_lon < demlonmin && demlonmin != -180) {
+ min_lon = demlonmin;
+ cerr << "minimum longitude exceeds available DEM. set to DEMs min!" << endl;
+ }
+
+ // Check if the requested are completely outside of DEM, then exit
+ if (max_lat <= demlatmin || min_lat >= demlatmax || max_lon <= demlonmin || min_lon >= demlonmax) {
+ cerr << "Area outside of available DEM was requested..." << endl;
+ exit (1);
+ }
+
+
+ ifstream demfile;
+ demfile.open(filename.c_str(), ios::binary);
+ if (!demfile) {
+ cerr << "Error opening DEM file: >" << filename << "<" <<
+ endl;
+ exit(1);
+ }
+
+
+ // check size of demfile:
+ demfile.seekg(0, ios::end);
+ int fsize = demfile.tellg();
+ if (fsize != rows_lat * colums_lon * 2 ) {
+ cerr << "Size of " << filename << " doesnt agree with definition in configuration file" << endl;
+ exit(1);
+ }
+ demfile.seekg(0, ios::beg);
+
+
+calc_start:
+ short int h;
+ int upsteps = int (floor((demlatmax - max_lat) / grid_lat));
+ int downsteps = int (ceil((demlatmax - min_lat) / grid_lat));
+ int leftsteps = int (floor((min_lon - demlonmin) / grid_lon));
+ int rightsteps = int (ceil((max_lon - demlonmin) / grid_lon));
+
+
+ // why 2* downscalefactor?
+ // changed to 1*downscalefact on 20100826, to check limits for landscape rebuild in gpsd mode
+ // seems to be good. check with maps needed (and with dsf) !
+ steps_lat = downsteps - upsteps + 1 * downscalefactor;
+ steps_lon = rightsteps - leftsteps + 1 * downscalefactor;
+
+ if (conf_pointer->DEBUG.get())
+ cerr << "stepslta / stepslon" << steps_lat << " / " << steps_lon << endl;
+
+ // if upscalefactor is given ( >1), multiply steps with upscalefac
+ if (conf_pointer->getupscalefactor() > 1) {
+ steps_lat = steps_lat * conf_pointer->getupscalefactor();
+ steps_lon = steps_lon * conf_pointer->getupscalefactor();
+ }
+
+
+ // now we calculate the number of triangles before reading data:
+ // so that we can prevent DoS in online functions!
+ int latsteps = (int) (((float) (steps_lat -
+ 3 * downscalefactor)/
+ (float) downscalefactor) +
+ 0.5);
+ int lonsteps = (int) (((float) (steps_lon -
+ 2 * downscalefactor - 1) /
+ (float) downscalefactor) +
+ 0.5);
+
+ int triangles = latsteps * lonsteps * 2;
+
+ if (conf_pointer->VERBOSE.get()) {
+ cout << "Triangles to be used: " << (double) triangles << " Maximum allowed: " << conf_pointer->MAXTRIANGLES.get() << endl;
+ if (conf_pointer->QUADS.get())
+ cout << "Quadrilaterals are used instead of triangles. Above number is not correct!" <<endl;
+ }
+
+ if ((float) triangles > conf_pointer->MAXTRIANGLES.get()) {
+ if (conf_pointer->VERBOSE.get())
+ cerr << "Maximum allowed triangles exceeded !!!" << endl << flush;
+
+ if (!conf_pointer->AUTOREDUCE.get()) {
+ if (conf_pointer->VERBOSE.get())
+ cerr << "Terrain will be switched off!" << endl;
+ conf_pointer->LANDSCAPE.off();
+ CLEARFLAG = false;
+ demfile.close();
+ return (99);
+ } else {
+ if (conf_pointer->VERBOSE.get())
+ cerr << "Autoreduce DEM resolution..." << endl;
+ if (conf_pointer->getupscalefactor() > 1) {
+ conf_pointer->setupscalefactor(conf_pointer->getupscalefactor()-1);
+ if (conf_pointer->VERBOSE.get())
+ cerr << "Upscalefactor reduced to " << conf_pointer->getupscalefactor() << endl;
+ } else {
+ // stupidly I have 2 doenscalefactors!!! one in conf and one on landscape :-(
+ conf_pointer->setdownscalefactor(conf_pointer->getdownscalefactor()+1);
+ downscalefactor++;
+ if (conf_pointer->VERBOSE.get())
+ cerr << "Downscalefactor increased to " << conf_pointer->getdownscalefactor() << endl;
+ }
+ goto calc_start;
+ }
+
+ }
+
+
+ // the surface altitude array is needed in fast mode too
+
+ CLEARFLAG_SURFACE = true;
+
+ surface_h = new short int *[steps_lat];
+ for (int i = 0; i < steps_lat; i += downscalefactor) {
+ surface_h[i] = new short int[steps_lon];
+ }
+
+ // these are not required in fast mode
+ if (!FAST) {
+ surface_x = new float *[steps_lat];
+ surface_y = new float *[steps_lat];
+
+ for (int i = 0; i < steps_lat; i += downscalefactor) {
+ surface_x[i] = new float[steps_lon];
+ surface_y[i] = new float[steps_lon];
+ }
+ }
+
+ vector<int>altitudes;
+ altitudes.reserve(steps_lat*steps_lon);
+ vector<float>latitudes;
+ latitudes.reserve(steps_lat*steps_lon);
+ vector<float>longitudes;
+ longitudes.reserve(steps_lat*steps_lon);
+
+ landtime.checknow("beforereadingDEM");
+
+ for (int zeile = 0; zeile < steps_lat; zeile += downscalefactor) {
+ for (int spalte = 0; spalte < steps_lon;
+ spalte += downscalefactor) {
+
+
+
+ if (conf_pointer->getupscalefactor() == 1) {
+ int verschieber =
+ (colums_lon * upsteps + zeile * colums_lon +
+ leftsteps + spalte) * 2;
+
+ demfile.seekg(verschieber, ios::beg);
+
+ ///*
+ int i1 = demfile.get();
+ //*/
+
+ int i2 = demfile.get();
+
+ if (conf_pointer->BIGENDIAN.get()) {
+ h = 256 * i1 + i2;
+ } else {
+ h = 256 * i2 + i1;
+ }
+
+ if (conf_pointer->input_dem_factor.get() != 1.0) {
+ h = (int) ( (float)h * conf_pointer->input_dem_factor.get()+0.5);
+ }
+
+ // -32768 is the ocean flag in srtm3 v 4.1 from cgiar (http://www.cgiar-csi.org/data/srtm-90m-digital-elevation-database-v4-1)
+ if (h == -32768) {
+ h = -22222;
+ } else // ELSE!!! otherwise fsckup!
+
+ // this is the water flag in WORLD3.DEM
+ if (h <= -16384) {
+ h += 16384;
+ if (sealevel2 == 0)
+ h = -22222;
+ }
+
+ if (h == -9999) // -9999 is the index for water in GTOPO30
+ h = -22222; //water index! (in openGLIGCexplorer)
+
+ // if sealevel2 is set (!=-22222)
+ // if exact equal zero, we will take the waterflags!
+ if (sealevel2 != -22222 && sealevel2 != 0) {
+ if (h <= sealevel2)
+ h = -22222;
+ }
+ surface_h[zeile][spalte] = (int) h;
+ } else {
+ // hier
+
+ altitudes.push_back(0);
+
+ // This was wrong and caused a shift!
+ //longitudes.push_back(min_lon+spalte*((max_lon-min_lon)/steps_lon));
+ //latitudes.push_back(max_lat-zeile*((max_lat-min_lat)/steps_lat));
+
+ latitudes.push_back(demlatmax - ((double) upsteps) * (grid_lat) -
+ ((double) zeile) * (grid_lat/(double)conf_pointer->getupscalefactor()));
+ longitudes.push_back(demlonmin + ((double) leftsteps) * (grid_lon) +
+ ((double) spalte) * (grid_lon/(double)conf_pointer->getupscalefactor()));
+
+
+
+
+ //cout << latitudes.back() << " " << longitudes.back() << endl;
+
+
+ }
+ }
+ }
+
+ landtime.checknow("afterreadingDEM");
+// if (conf_pointer->getupscalefactor() == 1) {
+ demfile.close();
+
+ // for upscaling (???)
+ if (conf_pointer->getupscalefactor() > 1) {
+ // get_gnd_elevation does interpolation (needed for upscaling)
+ get_gnd_elevations(&altitudes,&latitudes,&longitudes,conf_pointer);
+
+ landtime.checknow("afterget_gnd_elev");
+
+ int _x;
+ std::reverse(altitudes.begin(), altitudes.end());
+ for (int zeile = 0; zeile < steps_lat; zeile += downscalefactor) {
+ for (int spalte = 0; spalte < steps_lon;
+ spalte += downscalefactor) {
+
+ // das scheint sehr langsam zu sein.. deque besser?
+ _x = altitudes.back();
+ altitudes.pop_back();
+ //altitudes.erase(altitudes.begin());
+
+ // CHECK SPECIAL CASES also for srtm3 with -32768
+ // also see get_gnd_elevtions in oglexfunc.cpp
+
+ if (_x <= -16384) {
+ _x += 16384;
+ if (sealevel2 == 0)
+ _x = -22222;
+
+ }
+
+ if (_x == -9999) // -9999 is the index for water in GTOPO30
+ _x = -22222; //water index! (in openGLIGCexplorer)
+
+ // if sealevel2 is set (!=-22222)
+ // if exact equal zero, we will take the waterflags!
+ if (sealevel2 != -22222 && sealevel2 != 0) {
+ if (_x <= sealevel2)
+ _x = -22222;
+ }
+ surface_h[zeile][spalte] = _x;
+
+ //cout << _x << " " ;
+
+ }
+ //cout << endl;
+ }
+
+ landtime.checknow("after remapping altitudes to surface_h");
+/* for (int zeile = 0; zeile < steps_lat; zeile += downscalefactor) {
+ for (int spalte = 0; spalte < steps_lon;
+ spalte += downscalefactor) { }}
+ landtime.checknow("afterEMPTYloop");*/
+
+ }
+
+
+
+// Calculation of the x and y distances from center (we plot in kilometers)
+// and maximum and minimum height
+ max_h = surface_h[0][0];
+ if (max_h == -22222)
+ max_h = (short int) sealevel;
+ min_h = surface_h[0][0];
+ if (min_h == -22222)
+ min_h = (short int) sealevel;
+ for (int zeile = 0; zeile < steps_lat; zeile += downscalefactor)
+ for (int spalte = 0; spalte < steps_lon;
+ spalte += downscalefactor) {
+ double pointlat =
+ demlatmax - ((double) upsteps) * (grid_lat) -
+ ((double) zeile) * (grid_lat/(double)conf_pointer->getupscalefactor());
+ double pointlon =
+ demlonmin + ((double) leftsteps) * (grid_lon) +
+ ((double) spalte) * (grid_lon/(double)conf_pointer->getupscalefactor());
+
+
+ float _xkmdist, _ykmdist;
+
+ if (!FAST) {
+
+
+ proj_pointer->get_xy(pointlat, pointlon, _xkmdist,
+ _ykmdist);
+
+ //cout << _xkmdist << " " << _ykmdist << " KMDISTA" << endl;
+ surface_x[zeile][spalte] = -_xkmdist;
+ surface_y[zeile][spalte] = -_ykmdist;
+ }
+
+ //min and max
+ if (surface_h[zeile][spalte] != -22222) {
+
+ if ( !(conf_pointer->IGNORE_ELEV_RANGE.get() && surface_h[zeile][spalte] >= conf_pointer->ignore_elev_min.get() && surface_h[zeile][spalte] <= conf_pointer->ignore_elev_max.get() )) {
+
+ if (surface_h[zeile][spalte] < min_h)
+ min_h = surface_h[zeile][spalte];
+
+ if (surface_h[zeile][spalte] > max_h)
+ max_h = surface_h[zeile][spalte];
+ }
+ }
+
+
+ }
+
+
+
+if (FAST)
+ return 0;
+
+// remapping the edges to desired values:=========================================
+// to avoid overhanging textures
+if (conf_pointer->MAP.get()) {
+
+ cout << "MAPS used, terrain edges remapping active!" << endl;
+ for (int zeile = 0; zeile < steps_lat; zeile += downscalefactor) {
+ float _xkmdist, _ykmdist;
+ double pointlat =
+ demlatmax - ((double) upsteps) * (grid_lat) -
+ ((double) zeile) * (grid_lat/(double)conf_pointer->getupscalefactor());
+ //double pointlon =
+ // demlonmin + ((double) leftsteps) * (grid_lon) +
+ //((double) spalte) * (grid_lon/(double)conf_pointer->getupscalefactor());
+
+ proj_pointer->get_xy(pointlat, min_lon, _xkmdist,
+ _ykmdist);
+
+ surface_x[zeile][0]=-_xkmdist;
+
+ proj_pointer->get_xy(pointlat, max_lon, _xkmdist,
+ _ykmdist);
+
+ surface_x[zeile][steps_lon-1]=-_xkmdist;
+
+ vector<int> _alt;
+ vector<float>_lat;
+ vector<float>_lon;
+
+ _lat.push_back(pointlat);_lat.push_back(pointlat);
+ _lon.push_back(min_lon);_lon.push_back(max_lon);
+ _alt.push_back(0);_alt.push_back(0);
+
+ get_gnd_elevations(&_alt,&_lat,&_lon,conf_pointer);
+ surface_h[zeile][0]=_alt[0];
+ surface_h[zeile][steps_lon-1]=_alt[1];
+
+ }
+
+ for (int spalte = 0; spalte < steps_lon; spalte += downscalefactor) {
+ float _xkmdist, _ykmdist;
+ //double pointlat =
+ // demlatmax - ((double) upsteps) * (grid_lat) -
+ // ((double) zeile) * (grid_lat/(double)conf_pointer->getupscalefactor());
+ double pointlon =
+ demlonmin + ((double) leftsteps) * (grid_lon) +
+ ((double) spalte) * (grid_lon/(double)conf_pointer->getupscalefactor());
+
+ proj_pointer->get_xy(max_lat, pointlon, _xkmdist,
+ _ykmdist);
+
+ surface_y[0][spalte]=-_ykmdist;
+
+ proj_pointer->get_xy(min_lat, pointlon, _xkmdist,
+ _ykmdist);
+
+ surface_y[steps_lat-1][spalte]=-_ykmdist;
+
+ vector<int> _alt;
+ vector<float>_lat;
+ vector<float>_lon;
+
+ _lat.push_back(max_lat);_lat.push_back(min_lat);
+ _lon.push_back(pointlon);_lon.push_back(pointlon);
+ _alt.push_back(0);_alt.push_back(0);
+
+ get_gnd_elevations(&_alt,&_lat,&_lon,conf_pointer);
+ surface_h[0][spalte]=_alt[0];
+ surface_h[steps_lat-1][spalte]=_alt[1];
+
+ }
+}
+//===================================================================================
+
+
+//if (conf_pointer->DEBUG.get() ) {cout << "entering normal-vector" << endl << flush ;}
+Timecheck normaltime("Calc Normalvectors",conf_pointer);
+//Calculation of normalvectors
+//resize the array for normal vectors
+ normalvectors = new float **[steps_lat];
+ for (int i = 0; i < steps_lat; i += downscalefactor)
+ normalvectors[i] = new float *[steps_lon];
+
+ for (int i = 0; i < steps_lat; i += downscalefactor)
+ for (int j = 0; j < steps_lon; j += downscalefactor)
+ normalvectors[i][j] = new float[3];
+
+ // reset normalvektor at the edges
+ for (int zeile = 0; zeile < steps_lat; zeile += downscalefactor) {
+
+ normalvectors[zeile][0][0] = 0;
+ normalvectors[zeile][0][1] = 0;
+ normalvectors[zeile][0][2] = 1.;
+ normalvectors[zeile][steps_lon-1][0] = 0;
+ normalvectors[zeile][steps_lon-1][1] = 0;
+ normalvectors[zeile][steps_lon-1][2] = 1.;
+ }
+ for (int spalte = 0; spalte < steps_lon; spalte += downscalefactor) {
+
+ normalvectors[0][spalte][0]=0;
+ normalvectors[0][spalte][1]=0;
+ normalvectors[0][spalte][2]=1.;
+ normalvectors[steps_lat-1][spalte][0]=0;
+ normalvectors[steps_lat-1][spalte][1]=0;
+ normalvectors[steps_lat-1][spalte][2]=1.;
+ }
+
+
+//Do the calculation
+//ZZZZ here we should basically go the full range of the array und then we need i-1 and i+1 interpolated...
+//
+ for (int i = downscalefactor; i < steps_lat - downscalefactor;
+ i += downscalefactor) {
+ for (int j = downscalefactor;
+ j < steps_lon - downscalefactor;
+ j += downscalefactor) {
+//every point (i,j) has six neighbours (with common planes)
+//dv are the difference vectors to these neighbours
+ double dv_W[3];
+ double dv_N[3];
+ double dv_NE[3];
+ double dv_E[3];
+ double dv_S[3];
+ double dv_SW[3];
+
+ dv_W[0] =
+ surface_x[i][j] - surface_x[i][j -
+ downscalefactor];
+ if (dv_W[0] < 0)
+ dv_W[0] = dv_W[0] * -1.0;
+ dv_W[1] = 0;
+ dv_W[2] =
+ ((double) surface_h[i][j] -
+ surface_h[i][j - downscalefactor]) / 1000;
+ if (dv_W[2] < 0)
+ dv_W[2] = dv_W[2] * -1.0;
+
+ dv_N[0] = 0;
+ dv_N[1] =
+ surface_y[i - downscalefactor][j] -
+ surface_y[i][j];
+ if (dv_N[1] < 0)
+ dv_N[1] = dv_N[1] * -1.0;
+ dv_N[2] =
+ ((double) surface_h[i - downscalefactor][j] -
+ surface_h[i][j]) / 1000;
+ if (dv_N[2] < 0)
+ dv_N[2] = dv_N[2] * -1.0;
+
+ dv_NE[0] =
+ surface_x[i - downscalefactor][j +
+ downscalefactor]
+ - surface_x[i][j];
+ if (dv_NE[0] < 0)
+ dv_NE[0] = dv_NE[0] * -1.0;
+ dv_NE[1] =
+ surface_y[i - downscalefactor][j +
+ downscalefactor]
+ - surface_y[i][j];
+ if (dv_NE[1] < 0)
+ dv_NE[1] = dv_NE[1] * -1.0;
+ dv_NE[2] = ((double)
+ surface_h[i + downscalefactor][j +
+ downscalefactor]
+ - surface_h[i][j]) / 1000;
+ if (dv_NE[2] < 0)
+ dv_NE[2] = dv_NE[2] * -1.0;
+
+ dv_E[0] =
+ surface_x[i][j + downscalefactor] -
+ surface_x[i][j];
+ if (dv_E[0] < 0)
+ dv_E[0] = dv_E[0] * -1.0;
+ dv_E[1] = 0;
+ dv_E[2] =
+ ((double) surface_h[i][j + downscalefactor] -
+ surface_h[i][j]) / 1000;
+ if (dv_E[2] < 0)
+ dv_E[2] = dv_E[2] * -1.0;
+
+ dv_S[0] = 0;
+ dv_S[1] =
+ surface_y[i + downscalefactor][j] -
+ surface_y[i][j];
+ if (dv_S[1] < 0)
+ dv_S[1] = dv_S[1] * -1.0;
+ dv_S[2] =
+ ((double) surface_h[i + downscalefactor][j] -
+ surface_h[i][j]) / 1000;
+ if (dv_S[2] < 0)
+ dv_S[2] = dv_S[2] * -1.0;
+
+ dv_SW[0] =
+ surface_x[i + downscalefactor][j -
+ downscalefactor]
+ - surface_x[i][j];
+ if (dv_SW[0] < 0)
+ dv_SW[0] = dv_SW[0] * -1.0;
+ dv_SW[1] =
+ surface_y[i + downscalefactor][j -
+ downscalefactor]
+ - surface_y[i][j];
+ if (dv_SW[1] < 0)
+ dv_SW[1] = dv_SW[1] * -1.0;
+ dv_SW[2] = ((double)
+ surface_h[i + downscalefactor][j -
+ downscalefactor]
+ - surface_h[i][j]) / 1000;
+ if (dv_SW[2] < 0)
+ dv_SW[2] = dv_SW[2] * -1.0;
+
+//the normalvectors for the 6 neighbour triangles are
+//or 4 neighbour "triangles" in the case of quads
+
+ double nv_NW[3];
+ double nv_NNE[3];
+ double nv_ENE[3];
+ double nv_SE[3];
+ double nv_SSW[3];
+ double nv_WSW[3];
+
+ double nv_NE[3];
+ double nv_SW[3];
+
+ double nv_sum[3];
+
+ vectorproduct(dv_N[0], dv_N[1], dv_N[2],
+ dv_W[0], dv_W[1], dv_W[2], nv_NW[0],
+ nv_NW[1], nv_NW[2]);
+ norm(nv_NW[0], nv_NW[1], nv_NW[2]);
+
+ vectorproduct(dv_S[0], dv_S[1], dv_S[2],
+ dv_E[0], dv_E[1], dv_E[2], nv_SE[0],
+ nv_SE[1], nv_SE[2]);
+ norm(nv_SE[0], nv_SE[1], nv_SE[2]);
+
+ if (conf_pointer->QUADS.get()) {
+ vectorproduct(dv_W[0], dv_W[1], dv_W[2],
+ dv_S[0], dv_S[1], dv_S[2], nv_SW[0],
+ nv_SW[1], nv_SW[2]);
+ norm(nv_SW[0], nv_SW[1], nv_SW[2]);
+
+ vectorproduct(dv_E[0], dv_E[1], dv_E[2],
+ dv_N[0], dv_N[1], dv_N[2], nv_NE[0],
+ nv_NE[1], nv_NE[2]);
+ norm(nv_NE[0], nv_NE[1], nv_NE[2]);
+ }
+
+ if (!conf_pointer->QUADS.get()) {
+ vectorproduct(dv_NE[0], dv_NE[1], dv_NE[2],
+ dv_N[0], dv_N[1], dv_N[2], nv_NNE[0],
+ nv_NNE[1], nv_NNE[2]);
+ norm(nv_NNE[0], nv_NNE[1], nv_NNE[2]);
+
+ vectorproduct(dv_E[0], dv_E[1], dv_E[2],
+ dv_NE[0], dv_NE[1], dv_NE[2],
+ nv_ENE[0], nv_ENE[1], nv_ENE[2]);
+ norm(nv_ENE[0], nv_ENE[1], nv_ENE[2]);
+
+ vectorproduct(dv_SW[0], dv_SW[1], dv_SW[2],
+ dv_S[0], dv_S[1], dv_S[2], nv_SSW[0],
+ nv_SSW[1], nv_SSW[2]);
+ norm(nv_SSW[0], nv_SSW[1], nv_SSW[2]);
+
+ vectorproduct(dv_W[0], dv_W[1], dv_W[2],
+ dv_SW[0], dv_SW[1], dv_SW[2],
+ nv_WSW[0], nv_WSW[1], nv_WSW[2]);
+ norm(nv_WSW[0], nv_WSW[1], nv_WSW[2]);
+ }
+
+
+ for (int k = 0; k < 3; k++) {
+
+ if (!conf_pointer->QUADS.get()) {
+ nv_sum[k] =
+ nv_NW[k] + nv_NNE[k] + nv_ENE[k] +
+ nv_SE[k] + nv_SSW[k] + nv_WSW[k];
+ } else {
+ nv_sum[k] =
+ nv_NW[k] + nv_NE[k] +
+ nv_SE[k] + nv_SW[k];
+ }
+ }
+ norm(nv_sum[0],nv_sum[1],nv_sum[2]);
+ normalvectors[i][j][0] = nv_sum[0];
+ normalvectors[i][j][1] = nv_sum[1];
+ normalvectors[i][j][2] = nv_sum[2];
+
+
+ }}
+ normaltime.checknow("End of Normalvectors");
+ landtime.checknow("End of LandscapeReadDEM");
+ //if (conf_pointer->DEBUG.get() ) {cout << "leaving remapping vector" << endl << flush ;}
+ return 0;
+
+}
+
+
+
+// this is a wrapper for the oglxfunc - function getcolor...
+void Landscape::getlandcolor(float *colorpointer, short int height,
+ int colormap)
+{
+// we use 2 colorscales. One beneath sealevel and one above.
+// to use different colormaps (e.g. No.1 beneath, No.2 above)
+// we need to choose before getcolor is called.
+
+// h value -22222 means: surface of ocean... (always blue)
+
+// colormap 1
+// For a start, this implements MATLABS eye-burning 'Jet'
+// colormap with extension red->white for large values.
+// Ripped out of GPEsim from Jan.Krueger@uni-konstanz.de
+
+ int minValue, maxValue;
+ //int maxValue = max_h;
+ //int sealevel = -22222;
+
+ maxValue = max_h;
+ minValue = min_h;
+
+ // sealevel between max and min -> then use 2 ranges : (min-sealevel, and sealevel-max)
+ if (sealevel < maxValue && sealevel > minValue) {
+ if (height <= (short int) sealevel) {
+ minValue = min_h;
+ maxValue = (short int) sealevel;
+ }
+ if (height > (short int) sealevel) {
+ minValue = (short int) sealevel;
+ maxValue = max_h;
+ }
+ }
+
+ getcolor(colorpointer, colormap, (float)height, (float)minValue, (float)maxValue);
+
+
+}
+
+
+void Landscape::setgltrianglestrip_tex(int _colmapnr, int _colmapnr2, bool BW)
+{
+ proj_pointer->get_xy(max_lat, max_lon, tex_right_top_km,
+ tex_top_km);
+ proj_pointer->get_xy(max_lat, min_lon, tex_left_top_km,
+ tex_top_km);
+ proj_pointer->get_xy(min_lat, max_lon, tex_right_bottom_km,
+ tex_bottom_km);
+ proj_pointer->get_xy(min_lat, min_lon, tex_left_bottom_km,
+ tex_bottom_km);
+
+ tex_right_top_km *= -1.0;
+ tex_left_top_km *= -1.0;
+ tex_right_bottom_km *= -1.0;
+ tex_left_bottom_km *= -1.0;
+ tex_top_km *= -1.0;
+ tex_bottom_km *= -1.0;
+
+ //setgltrianglestrip (false, 3, true);
+ setgltrianglestrip(false, _colmapnr, _colmapnr2, BW, true);
+}
+
+void Landscape::shadecolor(float *color, int zeile, int spalte, int downscalefactor)
+{
+
+ int n,s,w,e,nw,ne,sw,se;
+
+ if (conf_pointer->shadedirection.get() == 8) { nw= 0.5; n= 1.0; ne= 0.0;
+ w= 1.0; e=-1.0;
+ sw= 0.0; s=-1.0; se=-0.5;}
+
+ if (conf_pointer->shadedirection.get() == 7) { nw= 0.75; n= 0.0; ne=-0.75;
+ w= 1.0; e=-1.0;
+ sw= 0.75; s= 0.0; se=-0.75;}
+
+ if (conf_pointer->shadedirection.get() == 6) { nw= 0.0; n=-1.0; ne=-0.5;
+ w= 1.0; e=-1.0;
+ sw= 0.5; s= 1.0; se=-0.0;}
+
+ if (conf_pointer->shadedirection.get() == 5) { nw=-0.75; n=-1.0; ne=-0.75;
+ w= 0.0; e= 0.0;
+ sw= 0.75; s= 1.0; se= 0.75;}
+
+ if (conf_pointer->shadedirection.get() == 4) { nw=-0.5; n=-1.0; ne= 0.0;
+ w=-1.0; e= 1.0;
+ sw= 0.0; s= 1.0; se= 0.5;}
+
+ if (conf_pointer->shadedirection.get() == 3) { nw=-0.75; n= 0.0; ne= 0.75;
+ w=-1.0; e= 1.0;
+ sw=-0.75; s= 0.0; se= 0.75;}
+
+ if (conf_pointer->shadedirection.get() == 2) { nw= 0.0; n= 1.0; ne= 0.5;
+ w=-1.0; e= 1.0;
+ sw=-0.5; s=-1.0; se= 0.0;}
+
+ if (conf_pointer->shadedirection.get() == 1) { nw= 0.75; n= 1.0; ne= 0.75;
+ w= 0.0; e= 0.0;
+ sw=-0.75; s=-1.0; se=-0.75;}
+
+
+ float _diff;
+ if (zeile-downscalefactor >= 0 && spalte-downscalefactor >=0
+ && zeile+downscalefactor < steps_lat - 1*downscalefactor
+ && spalte+downscalefactor < steps_lon -1 * downscalefactor
+ ) {
+ _diff = (
+ nw*surface_h[zeile-downscalefactor][spalte-downscalefactor] +
+ se*surface_h[zeile+downscalefactor][spalte+downscalefactor] +
+ w*surface_h[zeile][spalte-downscalefactor] +
+ s*surface_h[zeile+downscalefactor][spalte] +
+ n*surface_h[zeile-downscalefactor][spalte] +
+ e*surface_h[zeile][spalte+downscalefactor] +
+ sw*surface_h[zeile+downscalefactor][spalte-downscalefactor]+
+ ne*surface_h[zeile-downscalefactor][spalte+downscalefactor]
+ ) / 5.0 ;
+ } else {
+ _diff =0;
+ }
+
+// if (_diff > shade_max) {shade_max = _diff;}
+// if (_diff < shade_min) {shade_min = _diff;}
+
+ if (conf_pointer->getshadescale() == 0.0) {
+ conf_pointer->setshadescale( (max_h - min_h) / 7.0 );
+ if (conf_pointer->DEBUG.get()) cout << "shadescale: " << conf_pointer->getshadescale() << endl;
+ }
+
+ float shade = 1;
+ if (_diff > 0) {shade= 1.0-(_diff / conf_pointer->getshadescale() * conf_pointer->getupscalefactor()); }
+
+
+ //cout << "("<<color[0]<<";"<<color[1]<<";"<<color[2]<<")===>(";
+
+ color[0] = color[0]*shade;
+ color[1] = color[1]*shade;
+ color[2] = color[2]*shade;
+
+ //cout << "("<<color[0]<<";"<<color[1]<<";"<<color[2]<<")";
+ //cout << shade << " ";
+
+}
+
+void Landscape::setgltrianglestrip(bool _WIRE, int _colmapnumber, int _colmapnr2, bool BW, bool _TEXMAP)
+{
+ Timecheck tstime("setgltrianglestrip", conf_pointer);
+
+ if (!conf_pointer->MODULATE.get() && conf_pointer->MAP.get() && !conf_pointer->MAPS_UNLIGHTED.get()) {
+ if (conf_pointer->DEBUG.get())
+ cout << "Map mode without modulation!!! -> using colormap7 (white) with modulation)" << endl << flush;
+ _colmapnumber=7;
+ _colmapnr2 = 7;
+
+ }
+ //glPushAttrib(GL_ENABLE_BIT);
+ //glPushAttrib(GL_POLYGON_BIT);
+ //glPushAttrib(GL_LINE_BIT);
+
+// float shade_max = 0;
+// float shade_min = 0;
+// float shade = 1;
+
+ //float *color = new float[3];
+ float color[3];
+ if (!_WIRE) {
+ glEnable(GL_COLOR_MATERIAL);
+
+ if (conf_pointer->NOLIGHTING.get())
+ glDisable(GL_LIGHTING);
+ //glPolygonMode(GL_FRONT, GL_FILL);
+ } else {
+ glLineWidth(1.0);
+ glPolygonMode(GL_FRONT, GL_LINE);
+ glDisable(GL_LIGHTING);
+ glColor3f(0.5, 0.5, 0.5);
+ //cout << "color ist set !!!!!!"<< endl;
+ }
+
+ //glEnable(GL_CULL_FACE);
+ glCullFace(GL_BACK);
+
+
+ float _full_y, _x_left_delta, _x_delta, _full_x_bottom,
+ _full_x_top = 0;
+
+ if (_TEXMAP) {
+
+ glEnable(GL_TEXTURE_2D);
+ glEnable(GL_LIGHTING);
+
+
+ // width of the top-edge
+ _full_x_top = tex_right_top_km - tex_left_top_km;
+
+ // width of the bottom-edge
+ _full_x_bottom = tex_right_bottom_km - tex_left_bottom_km;
+
+ // difference between width of top and bottom edge
+ _x_delta = _full_x_bottom - _full_x_top;
+
+ // difference in x between left top and left bottom....
+ // this may differ from _x_right_delta and from 1/2*_x_delta, because
+ // the center may not be in the center of the texture...
+ _x_left_delta = tex_left_bottom_km - tex_left_top_km;
+
+ // height of texture in km (bottom<->top)
+ _full_y = tex_top_km - tex_bottom_km;
+
+ }
+
+
+ //cout << _x_left_delta << "<-left delta .... x_delta->" << _x_delta << endl;
+
+ // normal vector dummy
+ float replacing_nv[] = { 0.0, 0.0, 1.0};
+
+ // hier ist noch ARBEIT fr downscaling mit maps
+
+
+ for (int zeile = 0;//downscalefactor;
+ zeile < steps_lat - 1 * downscalefactor; // 2*
+ zeile += downscalefactor) {
+
+ if (conf_pointer->QUADS.get()) {
+ glBegin(GL_QUAD_STRIP); }
+ else {
+ glBegin(GL_TRIANGLE_STRIP);
+ }
+
+ for (int spalte = 0;//downscalefactor;
+ spalte < (steps_lon); // - downscalefactor);
+ spalte += downscalefactor) {
+
+ if (!_WIRE) {
+
+
+ if (surface_h[zeile][spalte] > sealevel) {
+ getlandcolor(color,
+ surface_h[zeile][spalte],
+ _colmapnumber);
+ } else {
+ getlandcolor(color,
+ surface_h[zeile][spalte],
+ _colmapnr2);
+ }
+
+ //getcolor(color, surface_h[zeile][spalte],_colmapnumber);
+ //cout << color[0] <<", " << color[1] << ", " << color[2] << endl;
+
+ if (surface_h[zeile][spalte] != -22222) {
+ glNormal3fv(normalvectors[zeile][spalte]);
+ } else {
+ glNormal3fv(replacing_nv);
+ }
+// glNormal3fv(replacing_nv);
+
+
+ // use terrainshading
+ if (conf_pointer->TERRAINSHADING.get()) {
+ shadecolor(color,zeile,spalte,downscalefactor);
+ }
+
+
+ if (!BW) {
+ glColor3f(color[0], color[1],
+ color[2]);
+ } else {
+ glColor3fv(graycolor(color));
+ }
+ }
+
+ if (_TEXMAP) {
+
+
+
+ float _y_tex_km =
+ surface_y[zeile][spalte] -
+ tex_bottom_km;
+ float _tex_y = 1 - _y_tex_km / _full_y;
+
+ float _x_tex_km =
+ surface_x[zeile][spalte] -
+ (tex_left_top_km +
+ _tex_y * _x_left_delta);
+
+ float _tex_x =
+ _x_tex_km / (_full_x_top +
+ _tex_y * _x_delta);
+
+ glTexCoord2f(_tex_x, _tex_y); //}
+
+ //cout << _tex_x << " " << _tex_y << endl;
+ if (_tex_x < -0.5 || _tex_x > 1.5
+ || _tex_y < -0.5 || _tex_y > 1.5) {
+ cerr <<
+ "seriously wrong texture coordinates.... contact author: "
+ << MAIL << endl;
+ cerr << _tex_x << " " << _tex_y
+ << endl;
+ }
+
+
+ }
+ //if (surface_x[zeile][spalte] < -190) cout << surface_x[zeile][spalte] << " " << endl;
+
+ float _alt;
+ if (surface_h[zeile][spalte] == -22222) {
+ _alt = sealevel2 / 1000.0;
+ } else {
+ _alt = surface_h[zeile][spalte] / 1000.0;
+ }
+
+ // this is a exception. no sealevel2 is set and h is watersurface....
+ if (surface_h[zeile][spalte] == -22222
+ && sealevel2 == -22222) {
+ _alt = 0;
+ }
+
+
+ glVertex3f(surface_x[zeile][spalte],
+ surface_y[zeile][spalte], _alt);
+
+ //cout << surface_x[zeile][spalte] << " " <<surface_y[zeile][spalte] << " " << surface_h[zeile][spalte]/1000.0 << endl;
+ if (!_WIRE) {
+
+ if (surface_h[zeile + downscalefactor]
+ [spalte] > sealevel) {
+ getlandcolor(color,
+ surface_h[zeile +
+ downscalefactor]
+ [spalte], _colmapnumber);
+ } else {
+ getlandcolor(color,
+ surface_h[zeile +
+ downscalefactor]
+ [spalte], _colmapnr2);
+ }
+
+
+
+ if (surface_h[zeile][spalte] != -22222) {
+ glNormal3fv(normalvectors[zeile +downscalefactor][spalte]);
+ } else {
+ glNormal3fv(replacing_nv);
+ }
+
+ if (conf_pointer->TERRAINSHADING.get()) {
+ shadecolor(color,zeile+downscalefactor,spalte,downscalefactor);
+ }
+
+ //glColor3f (color[0], color[1], color[2]);
+ if (!BW) {
+ glColor3f(color[0], color[1],
+ color[2]);
+ } else {
+ glColor3fv(graycolor(color));
+ }
+ }
+
+ if (_TEXMAP) {
+
+
+ float _y_tex_km =
+ surface_y[zeile +
+ downscalefactor][spalte] -
+ tex_bottom_km;
+ float _tex_y = 1 - _y_tex_km / _full_y;
+
+ float _x_tex_km =
+ surface_x[zeile +
+ downscalefactor][spalte] -
+ (tex_left_top_km +
+ _tex_y * _x_left_delta);
+
+ float _tex_x =
+ _x_tex_km / (_full_x_top +
+ _tex_y * _x_delta);
+
+ glTexCoord2f(_tex_x, _tex_y); //}
+
+ if (_tex_x < -0.5 || _tex_x > 1.5
+ || _tex_y < -0.5 || _tex_y > 1.5) {
+ cerr <<
+ "seriously wrong texture coordinates.... contact author: "
+ << MAIL << endl;
+ cerr << _tex_x << " " << _tex_y
+ << endl;
+ }
+ }
+
+ if (surface_h[zeile + downscalefactor][spalte] == -22222) {
+ _alt = sealevel2 / 1000.0;
+ } else {
+ _alt = surface_h[zeile + downscalefactor][spalte] /
+ 1000.0;
+ }
+
+ // this is a exception. no sealevel2 is set and h is watersurface....
+ if (surface_h[zeile + downscalefactor][spalte] ==
+ -22222 && sealevel2 == -22222) {
+ _alt = 0;
+ }
+
+ glVertex3f(surface_x[zeile + downscalefactor]
+ [spalte],
+ surface_y[zeile +
+ downscalefactor][spalte],
+ _alt);
+
+ }
+ glEnd();
+
+ }
+
+ //glPopAttrib();
+ glEnable(GL_LIGHTING);
+
+ if (_TEXMAP) {
+ glDisable(GL_TEXTURE_2D);
+ }
+
+ glPolygonMode(GL_FRONT, GL_FILL);
+ glDisable(GL_COLOR_MATERIAL);
+
+
+ // here comes sealvel3
+
+ if (conf_pointer->DEBUG.get()) {
+ cout << "Sealevel3:" << sealevel3 << endl << flush;
+
+ //cout << "Terrainshading: Max:" << shade_max << " Min: " << shade_min << endl << flush;
+ }
+
+ if (sealevel3 != -22222) {
+
+ if (conf_pointer->DEBUG.get())
+ cout << "Sealevel3 is given" << endl << flush;
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_LIGHTING);
+ glEnable(GL_COLOR_MATERIAL);
+ glDisable(GL_CULL_FACE);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ glDepthMask(GL_FALSE);
+
+ float col[4];
+ float xlim,ylim;
+
+ col[0] = 0;
+ col[1] = 0;
+ col[2] = 1;
+ col[3] = 0.6;
+
+ glBegin(GL_POLYGON);
+
+ if (!conf_pointer->BW.get()) {
+ glColor4fv(col);
+ } else {
+ glColor4fv(graycolor(col));
+ }
+
+ double sloffset = 0.5;
+ proj_pointer->get_xy(max_lat,min_lon, xlim,ylim);
+ cout << xlim << " " << ylim << " " << endl;
+ glVertex3f((GLfloat) -xlim, (GLfloat) -ylim, ((sealevel3+sloffset)/1000.0));
+
+ proj_pointer->get_xy(max_lat,max_lon, xlim,ylim);
+ cout << xlim << " " << ylim << " " << endl;
+ glVertex3f((GLfloat) -xlim, (GLfloat) -ylim, ((sealevel3+sloffset)/1000.0));
+
+ proj_pointer->get_xy(min_lat,max_lon, xlim,ylim);
+ cout << xlim << " " << ylim << " " << endl;
+ glVertex3f((GLfloat) -xlim, (GLfloat) -ylim, ((sealevel3+sloffset)/1000.0));
+
+ proj_pointer->get_xy(min_lat,min_lon, xlim,ylim);
+ cout << xlim << " " << ylim << " " << endl;
+ glVertex3f((GLfloat) -xlim, (GLfloat) -ylim, ((sealevel3+sloffset)/1000.0));
+
+ glEnd();
+
+ glDepthMask(GL_TRUE);
+ glEnable(GL_CULL_FACE);
+ glPolygonMode(GL_FRONT, GL_FILL);
+ glDisable(GL_COLOR_MATERIAL);
+ glDisable(GL_BLEND);
+ glEnable(GL_LIGHTING);
+
+ }
+ tstime.checknow("end trianglestrip");
+}
+
+
+void Landscape::vectorproduct(double a1, double a2, double a3, double b1,
+ double b2, double b3, double &c1, double &c2,
+ double &c3)
+{
+ c1 = a2 * b3 - a3 * b2;
+ c2 = a3 * b1 - a1 * b3;
+ c3 = a1 * b2 - a2 * b1;
+}
+
+void Landscape::norm(double &a1, double &a2, double &a3)
+{
+ double l = sqrt(a1 * a1 + a2 * a2 + a3 * a3);
+ a1 = a1 / l;
+ a2 = a2 / l;
+ a3 = a3 / l;
+}
+
+
+
+
+Landscape::~Landscape()
+{
+
+ //cout << "entering destructor of Landscape class" << endl << flush;
+
+ if (CLEARFLAG) {
+ for (int _i = 0; _i < steps_lat; _i += downscalefactor) {
+ delete[]surface_h[_i];
+
+ //if (CLEARFLAG) {
+
+ delete[]surface_x[_i];
+ delete[]surface_y[_i];
+ //}
+ }
+ }
+
+ if (CLEARFLAG_SURFACE)
+ delete[]surface_h;
+ if (CLEARFLAG) {
+ delete[]surface_x;
+ delete[]surface_y;
+ }
+ //cout << "3 * 2d cleared .." << endl << flush;
+ if (CLEARFLAG) {
+ for (int i = 0; i < steps_lat; i += downscalefactor)
+ for (int j = 0; j < steps_lon;
+ j += downscalefactor)
+ delete[]normalvectors[i][j];
+
+ for (int i = 0; i < steps_lat; i += downscalefactor)
+ delete[]normalvectors[i];
+
+ delete[]normalvectors;
+ }
+}
diff --git a/src/landscape.h b/src/landscape.h
new file mode 100644
index 0000000..4a8295e
--- /dev/null
+++ b/src/landscape.h
@@ -0,0 +1,116 @@
+/*
+ * (c) 2002-2016 Hannes Krueger
+ * This file is part of the GPLIGC/ogie package
+ */
+
+#ifndef LANDSCAPE_H
+#define LANDSCAPE_H 1
+
+#include <string>
+#include <vector>
+
+#include "projection.h"
+#include "oconfig.h"
+
+
+inline int runden(double a){return ((int)(a + 0.5));}
+
+class Landscape {
+ public:
+ int readDEM (string filename, int rows_lat, int colums_lon, double demlatmin,
+ double demlatmax, double demlonmin, double demlonmax, bool FAST = false);
+
+ Landscape();
+ ~Landscape ();
+ void setgltrianglestrip (bool _WIRE, int _colmapnumber, int _colmapnr2, bool BW, bool _TEXMAP= false);
+ void setgltrianglestrip_tex (int _colmapnr, int _colmapnr2, bool BW);
+ void shadecolor (float*, int, int, int);
+ void setcenter_lat (double _lat) {center_lat = _lat;}
+ void setcenter_lon (double _lon) {center_lon = _lon;}
+ void setmin_lon (double _lon) {min_lon = _lon; }
+ void setmax_lon (double _lon) {max_lon = _lon;}
+ void setmin_lat (double _lat) {min_lat = _lat;}
+ void setmax_lat (double _lat) {max_lat = _lat;}
+
+ double getmin_lon (void) {return min_lon;}
+ double getmax_lon (void) {return max_lon;}
+ double getmin_lat (void) {return min_lat;}
+ double getmax_lat (void) {return max_lat;}
+
+ void setgrid_lat (double _lat) {grid_lat = _lat;}
+ void setgrid_lon (double _lon) {grid_lon = _lon; }
+ void setdownscalefactor(int _d) {downscalefactor=_d;}
+// void setupscalefactor(int _up) {upscalefactor=_up;}
+
+ int getsteps_lat (void) const {return steps_lat;}
+ int getsteps_lon (void) const {return steps_lon; }
+
+ //int getnoftriangles (void);
+
+ short int getmax_h(void) const {return max_h;}
+ void setmax_h(int m) {max_h = m;}
+ short int getmin_h(void) const {return min_h;}
+ void setmin_h(int m) {min_h= m;}
+
+ void set_proj_pointer(Projection *p) { proj_pointer = p;}
+ void set_conf_pointer(Config *c) { conf_pointer = c;}
+ void set_sealevel(double sl) {sealevel = sl;}
+ void set_sealevel2(double sl) {sealevel2 = sl;}
+ void set_sealevel3(double sl) {sealevel3 = sl;}
+
+ protected:
+
+ bool CLEARFLAG;
+ bool CLEARFLAG_SURFACE;
+
+ void getlandcolor(float *, short int, int );
+ double center_lat;
+ double center_lon;
+
+ // borders for the piece of terrain to be displayed
+ double min_lon;
+ double max_lon;
+ double min_lat;
+ double max_lat;
+
+ short int **surface_h; // -22222 means this is watersurface at NN
+
+ short int max_h;
+ short int min_h;
+
+
+ // maybe these should come from conf ?
+ double sealevel; //this is the border between the upper and lower colormap
+ double sealevel2; //if this is set (!= -22222) then the blue ocean surface is set to this alt
+ // if set to "0" water will be plotted, where the water-flag is set in dem
+ double sealevel3; // if this is set (!= -22222) then a transparent blue surface will be plottet
+
+ float **surface_x;
+ float **surface_y;
+ float ***normalvectors;
+ int steps_lat;
+ int steps_lon;
+
+ double grid_lat;
+ double grid_lon;
+
+ int downscalefactor;
+// int upscalefactor;
+
+ float tex_top_km;
+ float tex_bottom_km;
+ float tex_right_bottom_km;
+ float tex_right_top_km;
+ float tex_left_top_km;
+ float tex_left_bottom_km;
+
+ void vectorproduct (double a1, double a2, double a3, double b1, double b2, double b3, double &c1, double &c2,
+ double &c3);
+ void norm (double &a1, double &a2, double &a3);
+
+ Projection *proj_pointer; //the projection-class pointer
+ Config *conf_pointer; // config-pointer
+
+};
+
+#endif
diff --git a/src/map.cpp b/src/map.cpp
new file mode 100644
index 0000000..14448c0
--- /dev/null
+++ b/src/map.cpp
@@ -0,0 +1,374 @@
+/*
+ * (c) 2002-2016 Hannes Krueger
+ * This file is part of the GPLIGC/ogie package
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "map.h"
+#include "projection.h"
+#include <iostream>
+#include <fstream>
+#include <cstdio>
+#include <cmath>
+#include <cstdlib>
+#include <string>
+#include <jpeglib.h>
+
+#ifndef __OSX__
+#include <GL/gl.h>
+#include <GL/glu.h>
+#include <GL/glext.h>
+#else
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
+#include <OpenGL/glext.h>
+#endif
+
+#include "GLexplorer.h"
+
+
+//const std::string rcsid_map_cpp =
+// "$Id: map.cpp 3 2014-07-31 09:59:20Z kruegerh $";
+//const std::string rcsid_map_h = MAP_H;
+
+void
+ Map::readMap(string filename, int _width, int _height)
+{
+
+ file = filename;
+
+ width = _width;
+ height = _height;
+
+ if (width == 0 || height == 0) {
+ cerr << "Width or Height for a map-tile is not set!" <<
+ endl;
+ cerr << filename << endl;
+ exit(1);
+ }
+
+ int _max;
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint*)&_max);
+
+ //cout << "max is: " << _max << endl;
+
+ if (_width > _max || _height > _max) {
+ cerr << "Map tile \"" << filename <<
+ "\" ist too big. Maximum size for your openGL implementation is "
+ << _max << endl;
+ exit(1);
+ }
+
+ map = new GLubyte[_width * _height * 3];
+
+ ifstream mapfile;
+ mapfile.open(filename.c_str(), ios::binary);
+ if (!mapfile) {
+ cerr << "Error opening Map file: >" << filename << "<" <<
+ endl;
+ exit(1);
+ }
+
+ for (int nr = 0; nr < _width * _height * 3; nr++) {
+ map[nr] = mapfile.get();
+ //cout << map[nr] << endl;
+ }
+ mapfile.close();
+}
+
+void Map::readMap_jpeg(string filename, int _width, int _height)
+{
+
+ // width and height should be 0, and will be read from jpeg image, and internally rescaled (if necessary)
+ // if width and height != 0 -> warning message, read from image -> rescaling
+ // if width or height = -1 no rescaling!
+
+ width = _width;
+ height = _height;
+ file = filename;
+
+ bool RESCALE = true;
+
+ // in logo conf_pointer will not be defined....
+ if (conf_pointer)
+ if (conf_pointer->DEBUG.get())
+ cout << "readMap_jpeg(" << file << ", " << _width << ", " << _height << ")" << endl << flush; ;
+
+
+ if (width == -1 && height == -1) RESCALE = false;
+
+ if ( (width != 0 || height != 0) && (width != -1 || height != -1) ) {
+
+ cerr <<
+ "Width or Height is specified for a jpeg-texture map..."
+ << endl;
+ cerr << "This is not needed and will be ignored." << endl;
+ cerr << filename << endl;
+ width = 0;
+ height = 0;
+ }
+
+
+ int _max;
+
+ GLubyte *tmpmap;
+
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint*)&_max);
+
+ if (conf_pointer)
+ if (conf_pointer->DEBUG.get())
+ cout << "GL_MAX_TEXTURE_SIZE: " << _max << endl;
+
+
+ map = read_jpg(&width, &height, (char*) filename.c_str()); //, (unsigned char *) map);
+
+ if (conf_pointer)
+ if (conf_pointer->DEBUG.get())
+ cout << file << " is " << width << "x" << height << endl;
+
+
+
+ // AND HERE WE NEED TO CALCULATE THE NEXT POWER OF 2
+ // AND CHECK IF THE SIZE ISNT ALREADY A POWER OF 2
+ // THE NEXT POWER OF 2 SHOULD BE SMALLER THAN _max
+
+ // check if the width and height of image is a power of 2
+ double lbw = log((double) width) / log(2.0);
+ double lbh = log((double) height) / log(2.0);
+
+ // log of max allowed size
+ double lmax = log((double) _max) / log(2.0);
+
+ int lbw_i = (int) (lbw + 0.5);
+ int lbh_i = (int) (lbh + 0.5);
+
+ //cout << lbw_i << " " << lbh_i << endl;
+
+ //cout << "log_2 ("<<width<<") = "<<lbw<<endl;
+ //cout << "log_2 ("<<height<<") = "<<lbh<<endl;
+
+ if (RESCALE)
+ if (lbw != (double) lbw_i || lbh != (double) lbh_i || lbw > lmax || lbh > lmax) {
+ cerr << "Resizing is needed for " << filename << endl;
+
+ // calculate new width and height
+ // aufrunden (+1) abrunden -1 (eine potenz kleiner)
+ int power_w = (int) lbw; // - 1;
+ int power_h = (int) lbh; // -1;
+
+ // bis <= max erniedrigen
+ while (pow(2.0, power_w) > _max) {
+ power_w--;
+ }
+ while (pow(2.0, power_h) > _max) {
+ power_h--;
+ }
+
+ int new_width = (int) pow(2.0, power_w);
+ int new_height = (int) pow(2.0, power_h);
+
+ cout << "New width x height: " << new_width << "x" <<
+ new_height << " (old: " << width << "x" << height << ")" << endl;
+
+ tmpmap = new GLubyte[new_width * new_height * 3];
+ copy_resample_image_buffer((unsigned char *) tmpmap,
+ (unsigned char *) map, 0, 0, 0,
+ 0, new_width, new_height, width,
+ height, width, new_width);
+ /*
+ copy_resample_image_buffer( unsigned char* destination, unsigned char* source,
+ int destination_x, int destination_y, int source_x, int source_y,
+ int destination_width, int destination_height, int source_width, int source_height,
+ int source_dimw, int destination_dimw);
+ */
+ delete map;
+ map = tmpmap;
+ width = new_width;
+ height = new_height;
+
+ }
+
+
+}
+
+// _MODULATE = MAPS_UNLIGHTED (whether maps should be lighted or not, in !(not)coloured map mode
+void Map::setglmap(double _altitude_of_map, bool COMPRESSION,
+ bool _MAPS_UNLIGHTED, bool BW, bool TEXCOOR)
+{
+
+ if (conf_pointer)
+ if (conf_pointer->DEBUG.get())
+ cout << "setglmap: " << file << endl;
+
+ // this works much better than the internal format LUMINANCE... because of the better col->gray model
+ // but its slower :(
+ if (BW) {
+ this->grayscale_map();
+ }
+
+
+ // first of all: load the texture
+ if (!COMPRESSION) {
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_R3_G3_B2, width, height,
+ 0, GL_RGB, GL_UNSIGNED_BYTE, map);
+ } else {
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_ARB,
+ width, height, 0, GL_RGB, GL_UNSIGNED_BYTE,
+ map);
+ }
+
+
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+
+
+ // we use modulate in any case!
+ // The unmodulated case needs lighting aswell, therefore colormap 7 (white)
+ // is used with modulation!
+
+ if (_MAPS_UNLIGHTED) {
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ } else {
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,
+ GL_MODULATE);
+ }
+
+// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,
+// GL_MODULATE);
+
+
+ if (conf_pointer)
+ if (conf_pointer->DEBUG.get())
+ cout << "glGetError: " << gluErrorString(glGetError()) << endl;
+
+
+
+ // the texture coordinates dont need to be set here (in landscape mode)
+ // in landscape mode they will be set in landscape glsettrianglestrip_tex...
+ if (TEXCOOR) {
+ float top_km, bottom_km, right_top_km, left_top_km,
+ right_bottom_km, left_bottom_km;
+
+ proj_pointer->get_xy(top, right, right_top_km, top_km);
+ proj_pointer->get_xy(top, left, left_top_km, top_km);
+ proj_pointer->get_xy(bottom, right, right_bottom_km, bottom_km);
+ proj_pointer->get_xy(bottom, left, left_bottom_km, bottom_km);
+
+ right_top_km *= -1.0;
+ left_top_km *= -1.0;
+ right_bottom_km *= -1.0;
+ left_bottom_km *= -1.0;
+ top_km *= -1.0;
+ bottom_km *= -1.0;
+
+ glEnable(GL_TEXTURE_2D);
+ //glEnable(GL_LIGHTING);
+ glDisable(GL_LIGHTING);
+ //glPolygonMode(GL_FRONT, GL_FILL);
+ glBegin(GL_POLYGON);
+ //glColor3f(1.0,0,0);
+
+ // unten links
+ glTexCoord2f(0.0, 1.0);
+ glVertex3f(left_bottom_km, bottom_km, _altitude_of_map);
+
+ // unten rechts
+ glTexCoord2f(1.0, 1.0);
+ glVertex3f(right_bottom_km, bottom_km, _altitude_of_map);
+
+ // oben rechts
+ glTexCoord2f(1.0, 0.0);
+ glVertex3f(right_top_km, top_km, _altitude_of_map);
+
+ // oben links
+ glTexCoord2f(0.0, 0.0);
+ glVertex3f(left_top_km, top_km, _altitude_of_map);
+
+ glEnd();
+
+ glDisable(GL_TEXTURE_2D);
+ glEnable(GL_LIGHTING);
+ }
+}
+
+
+void Map::grayscale_map(void)
+{
+
+ for (int _x = 0; _x <= (width * height * 3) - 3; _x += 3) {
+
+ GLubyte col =
+ (GLubyte) ((float) map[_x] * 0.3 +
+ (float) map[_x + 1] * 0.59 +
+ (float) map[_x + 2] * 0.11);
+
+ map[_x] = col;
+ map[_x + 1] = col;
+ map[_x + 2] = col;
+
+ }
+
+}
+
+void Map::map_to_colBuffer(int x, int y, int dx, int dy)
+{
+ // this function scales the map to dx, dy
+ // the put it to screen coordinates x,y
+
+ GLubyte *tmpmap;
+ GLubyte *flipmap;
+
+ tmpmap = new GLubyte[dx * dy * 3];
+ flipmap = new GLubyte[dx*dy*3];
+
+ //cout << "vorher" << endl << flush;
+ copy_resample_image_buffer((unsigned char *) tmpmap,
+ (unsigned char *) map, 0, 0, 0,
+ 0, dx, dy, width,
+ height, width, dx);
+
+ // flip up-down
+ for (int z=0; z< dy; z++) {
+ for (int s=0; s < dx*3 ; s++) {
+ flipmap[(((dy-1)-z)*dx*3)+s] = tmpmap[(z*dx*3)+s];
+ }
+ }
+
+ if (conf_pointer)
+ if (conf_pointer->DEBUG.get()) {
+ cout << "writing logo_image to color buffer" << endl << flush;
+ }
+
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT,1);
+ glWindowPos2fMESAemulate((GLfloat) x, (GLfloat)y );
+ glDrawPixels(dx,dy, GL_RGB, GL_UNSIGNED_BYTE, flipmap);
+
+ //free array
+ delete[]tmpmap;
+ delete[]flipmap;
+
+}
+
+
+Map::~Map()
+{
+ delete[]map;
+}
diff --git a/src/map.h b/src/map.h
new file mode 100644
index 0000000..cd2141b
--- /dev/null
+++ b/src/map.h
@@ -0,0 +1,77 @@
+/*
+ * (c) 2002-2016 Hannes Krueger
+ * This file is part of the GPLIGC/ogie package
+ */
+
+#ifndef MAP_H
+#define MAP_H 1
+
+#ifndef __OSX__
+#include <GL/gl.h>
+#else
+#include <OpenGL/gl.h>
+#endif
+
+#include <string>
+
+#include "projection.h"
+#include "oglexfunc.h"
+#include "oconfig.h"
+
+using namespace std;
+
+class Map {
+
+ public:
+ void readMap (string filename, int height, int width);
+ void readMap_jpeg (string filename, int height, int width);
+
+
+
+ void settop (float _top) { top = _top; }
+ void setbottom (float _bottom) { bottom = _bottom; }
+
+ void setright (float _right) { right = _right; }
+ void setleft (float _left) { left = _left; }
+
+ void setcenter_lat (double _lat) { center_lat = _lat; }
+ void setcenter_lon (double _lon) { center_lon = _lon; }
+
+ unsigned char *getMap (void) const { return map; }
+ int getHeight (void) const { return height; }
+ int getWidth (void) const { return width; }
+ void set_proj_pointer (Projection * p) { proj_pointer = p; }
+ void set_conf_pointer (Config * c) { conf_pointer = c;}
+
+ void grayscale_map (void);
+
+ void map_to_colBuffer(int x, int y, int dx, int dy);
+
+ void setglmap (double _altitude_of_map, bool COMPRESSION, bool _MODULATE, bool BW, bool TEXCOOR=true);
+ ~Map ();
+
+ protected:
+
+
+ float top;
+ float right;
+ float left;
+ float bottom;
+
+ double center_lat;
+ double center_lon;
+
+ string file; // only used for information output...
+
+ int width;
+ int height;
+
+ GLubyte *map;
+
+ Projection *proj_pointer; //the projection-class pointer
+ Config *conf_pointer; //pointer to config
+
+
+};
+
+#endif
diff --git a/src/merger.cpp b/src/merger.cpp
new file mode 100644
index 0000000..6d5be59
--- /dev/null
+++ b/src/merger.cpp
@@ -0,0 +1,469 @@
+/*
+ * (c) 2002-2016 Hannes Krueger
+ * This file is part of the GPLIGC/ogie package
+ *
+ * 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 3 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