Upfront of refs #369

* consolidated ICoordinateGeodetic (e.g. fixed nested properties)
* shifted common functionality for objects/containers with callsign into interface
* shifted common functionality for objects/containers with geo position into interface
* shifted common functionality for objects/containers with timestamp into interface
* updated corresponding value objects / specialized lists
* adjusted all places where renamed functions are used
This commit is contained in:
Klaus Basan
2015-01-27 03:27:01 +01:00
parent ea68170202
commit ce86c902b5
45 changed files with 1257 additions and 790 deletions

View File

@@ -203,7 +203,7 @@ namespace BlackCore
CAtcStationList stations = this->m_atcStationsOnline.findIfComUnitTunedIn25KHz(comSystem);
if (!stations.isEmpty())
{
stations.sortBy(&CAtcStation::getDistanceToPlane);
stations.sortBy(&CAtcStation::getDistanceToOwnAircraft);
station = stations.front();
}
return station;
@@ -488,7 +488,7 @@ namespace BlackCore
station.setFrequency(frequency);
station.setPosition(position);
station.setOnline(true);
station.calculcateDistanceToPlane(this->m_ownAircraft.getPosition());
station.calculcateDistanceAndBearingToOwnAircraft(this->m_ownAircraft.getPosition());
this->m_vatsimDataFileReader->getAtcStations().updateFromVatsimDataFileStation(station); // prefill
this->m_atcStationsOnline.push_back(station);
@@ -634,7 +634,7 @@ namespace BlackCore
aircraft.setCallsign(callsign);
aircraft.setSituation(situation);
aircraft.setTransponder(transponder);
aircraft.setCalculcatedDistanceToPosition(this->m_ownAircraft.getPosition()); // distance from myself
aircraft.calculcateDistanceAndBearingToOwnAircraft(this->m_ownAircraft.getPosition()); // distance from myself
// ICAO from cache if avialable
bool setIcao = false;
@@ -683,12 +683,12 @@ namespace BlackCore
else // not exists yet
{
// update
CLength distance = this->m_ownAircraft.calculcateDistanceToPosition(situation.getPosition());
CLength distance = this->m_ownAircraft.calculateGreatCircleDistance(situation.getPosition());
distance.switchUnit(CLengthUnit::NM());
CPropertyIndexVariantMap vm;
vm.addValue(CAircraft::IndexTransponder, transponder);
vm.addValue(CAircraft::IndexSituation, situation);
vm.addValue(CAircraft::IndexDistance, distance);
vm.addValue(CAircraft::IndexDistanceToOwnAircraft, distance);
// here I expect always a changed value
this->m_aircraftInRange.applyIfCallsign(callsign, vm);

View File

@@ -1,7 +1,13 @@
/* Copyright (C) 2013 VATSIM Community / contributors
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Copyright (C) 2014
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKCORE_INTERPOLATOR_H
#define BLACKCORE_INTERPOLATOR_H
@@ -34,9 +40,9 @@ namespace BlackCore
virtual BlackMisc::Aviation::CAircraftSituation getCurrentSituation() = 0;
//! Get timestamp of the last received aircraft situation
virtual const QDateTime &getTimeOfLastReceivedSituation() const = 0;
virtual QDateTime getTimeOfLastReceivedSituation() const = 0;
};
} // namespace BlackCore
} // namespace
#endif // guard

View File

@@ -1,7 +1,11 @@
/* Copyright (C) 2013 VATSIM Community / contributors
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Copyright (C) 2014
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "interpolator_linear.h"
#include "blackmisc/avaircraftsituation.h"
@@ -61,25 +65,25 @@ namespace BlackCore
CCoordinateGeodetic currentPosition;
// Time between start and end packet
double deltaTime = beginSituation.getTimestamp().msecsTo(endSituation.getTimestamp());
double deltaTime = beginSituation.msecsToAbs(endSituation);
// Fraction of the deltaTime [0.0 - 1.0]
double simulationTime = beginSituation.getTimestamp().msecsTo(currentTime) / deltaTime;
double simulationTimeFraction = beginSituation.getUtcTimestamp().msecsTo(currentTime) / deltaTime;
// Interpolate latitude: Lat = (LatB - LatA) * t + LatA
currentPosition.setLatitude((endSituation.getPosition().latitude() - beginSituation.getPosition().latitude())
* simulationTime
* simulationTimeFraction
+ beginSituation.getPosition().latitude());
// Interpolate latitude: Lon = (LonB - LonA) * t + LonA
currentPosition.setLongitude((endSituation.getPosition().longitude() - beginSituation.getPosition().longitude())
* simulationTime
* simulationTimeFraction
+ beginSituation.getPosition().longitude());
currentSituation.setPosition(currentPosition);
// Interpolate altitude: Alt = (AltB - AltA) * t + AltA
currentSituation.setAltitude(CAltitude((endSituation.getAltitude() - beginSituation.getAltitude())
* simulationTime
* simulationTimeFraction
+ beginSituation.getAltitude(),
beginSituation.getAltitude().getReferenceDatum()));
@@ -94,7 +98,7 @@ namespace BlackCore
headingEnd -= CHeading(360, CHeading::Magnetic, CAngleUnit::deg());
currentSituation.setHeading(CHeading((headingEnd - headingBegin)
* simulationTime
* simulationTimeFraction
+ headingBegin,
headingBegin.getReferenceNorth()));
@@ -102,7 +106,7 @@ namespace BlackCore
CAngle pitchBegin = beginSituation.getPitch();
CAngle pitchEnd = endSituation.getPitch();
CAngle pitch = (pitchEnd - pitchBegin) * simulationTime + pitchBegin;
CAngle pitch = (pitchEnd - pitchBegin) * simulationTimeFraction + pitchBegin;
// TODO: According to the specification, pitch above horizon should be negative.
// But somehow we get positive pitches from the network.
@@ -113,7 +117,7 @@ namespace BlackCore
CAngle bankBegin = beginSituation.getBank();
CAngle bankEnd = endSituation.getBank();
CAngle bank = (bankEnd - bankBegin) * simulationTime + bankBegin;
CAngle bank = (bankEnd - bankBegin) * simulationTimeFraction + bankBegin;
// TODO: According to the specification, banks to the right should be negative.
// But somehow we get positive banks from the network.
@@ -121,14 +125,14 @@ namespace BlackCore
currentSituation.setBank(bank);
currentSituation.setGroundspeed((endSituation.getGroundSpeed() - beginSituation.getGroundSpeed())
* simulationTime
* simulationTimeFraction
+ beginSituation.getGroundSpeed());
return currentSituation;
}
const QDateTime &CInterpolatorLinear::getTimeOfLastReceivedSituation() const
QDateTime CInterpolatorLinear::getTimeOfLastReceivedSituation() const
{
return m_aircraftSituationList.back().getTimestamp();
return m_aircraftSituationList.back().getUtcTimestamp();
}
}

View File

@@ -1,7 +1,13 @@
/* Copyright (C) 2013 VATSIM Community / contributors
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Copyright (C) 2014
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKCORE_INTERPOLATOR_LINEAR_H
#define BLACKCORE_INTERPOLATOR_LINEAR_H
@@ -37,7 +43,7 @@ namespace BlackCore
virtual BlackMisc::Aviation::CAircraftSituation getCurrentSituation() override;
//! \copydoc IInterpolator::getTimeOfLastReceivedSituation()
virtual const QDateTime &getTimeOfLastReceivedSituation() const override;
virtual QDateTime getTimeOfLastReceivedSituation() const override;
private:
BlackMisc::Aviation::CAircraftSituationList m_aircraftSituationList;