1
/*-------------------------------------------------------------------------
4
Written by Per Liedman, started July 2000.
6
Copyright (C) 2000 Per Liedman, liedman@home.se
8
This program is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 2 of the License, or
11
(at your option) any later version.
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with this program; if not, write to the Free Software
20
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
---------------------------------------------------------------------------*/
23
#include "FlightTrack.hxx"
26
FlightTrack::FlightTrack( unsigned int max_buffer ) :
27
max_buffer(max_buffer) {
31
FlightTrack::~FlightTrack() {
32
for (list<FlightData*>::iterator i = track.begin(); i != track.end(); i++) {
37
void FlightTrack::clear() {
38
while (!track.empty()) {
39
delete *(track.begin());
44
void FlightTrack::addPoint( FlightData *data ) {
45
// TOLERANCE is set to 1 arc second
46
static const float TOLERANCE = SG_DEGREES_TO_RADIANS / 3600.0f;
48
float lastlat, lastlon;
60
if (fabs(lastlat - data->lat) > TOLERANCE ||
61
fabs(lastlon - data->lon) > TOLERANCE) {
62
if (track.size() > max_buffer) {
67
track.push_back(data);
71
void FlightTrack::firstPoint() {
72
track_pos = track.begin();
75
FlightData *FlightTrack::getNextPoint() {
76
if (track_pos != track.end()) {
77
return *(track_pos++);