mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 04:25:42 +08:00
refs #484 Added value class for working with X-Plane nav data, CNavDataReference.
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
#include "blackmisc/aviation/atcstationlist.h"
|
#include "blackmisc/aviation/atcstationlist.h"
|
||||||
#include "blackmisc/aviation/airportlist.h"
|
#include "blackmisc/aviation/airportlist.h"
|
||||||
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
||||||
|
#include "blackmisc/simulation/xplane/navdatareference.h"
|
||||||
|
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
|
|
||||||
@@ -115,6 +116,7 @@ namespace BlackMisc
|
|||||||
template class IGeoObjectList<BlackMisc::Aviation::CAtcStation, BlackMisc::Aviation::CAtcStationList>;
|
template class IGeoObjectList<BlackMisc::Aviation::CAtcStation, BlackMisc::Aviation::CAtcStationList>;
|
||||||
template class IGeoObjectList<BlackMisc::Aviation::CAirport, BlackMisc::Aviation::CAirportList>;
|
template class IGeoObjectList<BlackMisc::Aviation::CAirport, BlackMisc::Aviation::CAirportList>;
|
||||||
template class IGeoObjectList<BlackMisc::Simulation::CSimulatedAircraft, BlackMisc::Simulation::CSimulatedAircraftList>;
|
template class IGeoObjectList<BlackMisc::Simulation::CSimulatedAircraft, BlackMisc::Simulation::CSimulatedAircraftList>;
|
||||||
|
template class IGeoObjectList<BlackMisc::Simulation::XPlane::CNavDataReference, BlackMisc::Simulation::XPlane::CNavDataReferenceList>;
|
||||||
|
|
||||||
template class IGeoObjectWithRelativePositionList<BlackMisc::Aviation::CAtcStation, BlackMisc::Aviation::CAtcStationList>;
|
template class IGeoObjectWithRelativePositionList<BlackMisc::Aviation::CAtcStation, BlackMisc::Aviation::CAtcStationList>;
|
||||||
template class IGeoObjectWithRelativePositionList<BlackMisc::Aviation::CAirport, BlackMisc::Aviation::CAirportList>;
|
template class IGeoObjectWithRelativePositionList<BlackMisc::Aviation::CAirport, BlackMisc::Aviation::CAirportList>;
|
||||||
|
|||||||
@@ -32,6 +32,12 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
class CSimulatedAircraft;
|
class CSimulatedAircraft;
|
||||||
class CSimulatedAircraftList;
|
class CSimulatedAircraftList;
|
||||||
|
|
||||||
|
namespace XPlane
|
||||||
|
{
|
||||||
|
class CNavDataReference;
|
||||||
|
class CNavDataReferenceList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Geo
|
namespace Geo
|
||||||
@@ -41,7 +47,6 @@ namespace BlackMisc
|
|||||||
class IGeoObjectList
|
class IGeoObjectList
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Find 0..n objects within range of given coordinate
|
* Find 0..n objects within range of given coordinate
|
||||||
* \param coordinate other position
|
* \param coordinate other position
|
||||||
@@ -71,6 +76,7 @@ namespace BlackMisc
|
|||||||
extern template class BLACKMISC_EXPORT_TEMPLATE IGeoObjectList<BlackMisc::Aviation::CAircraft, BlackMisc::Aviation::CAircraftList>;
|
extern template class BLACKMISC_EXPORT_TEMPLATE IGeoObjectList<BlackMisc::Aviation::CAircraft, BlackMisc::Aviation::CAircraftList>;
|
||||||
extern template class BLACKMISC_EXPORT_TEMPLATE IGeoObjectList<BlackMisc::Aviation::CAirport, BlackMisc::Aviation::CAirportList>;
|
extern template class BLACKMISC_EXPORT_TEMPLATE IGeoObjectList<BlackMisc::Aviation::CAirport, BlackMisc::Aviation::CAirportList>;
|
||||||
extern template class BLACKMISC_EXPORT_TEMPLATE IGeoObjectList<BlackMisc::Simulation::CSimulatedAircraft, BlackMisc::Simulation::CSimulatedAircraftList>;
|
extern template class BLACKMISC_EXPORT_TEMPLATE IGeoObjectList<BlackMisc::Simulation::CSimulatedAircraft, BlackMisc::Simulation::CSimulatedAircraftList>;
|
||||||
|
extern template class BLACKMISC_EXPORT_TEMPLATE IGeoObjectList<BlackMisc::Simulation::XPlane::CNavDataReference, BlackMisc::Simulation::XPlane::CNavDataReferenceList>;
|
||||||
//! \endcond
|
//! \endcond
|
||||||
|
|
||||||
//! List of objects with geo coordinates.
|
//! List of objects with geo coordinates.
|
||||||
|
|||||||
58
src/blackmisc/simulation/xplane/navdatareference.cpp
Normal file
58
src/blackmisc/simulation/xplane/navdatareference.cpp
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/* Copyright (C) 2015
|
||||||
|
* 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
|
||||||
|
|
||||||
|
#include "blackmisc/simulation/xplane/navdatareference.h"
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Simulation
|
||||||
|
{
|
||||||
|
namespace XPlane
|
||||||
|
{
|
||||||
|
CNavDataReference::CNavDataReference() = default;
|
||||||
|
|
||||||
|
CNavDataReference::CNavDataReference(int id, const Geo::CLatitude &latitude, const Geo::CLongitude &longitude) :
|
||||||
|
m_id(id),
|
||||||
|
m_position(latitude, longitude, {})
|
||||||
|
{}
|
||||||
|
|
||||||
|
CNavDataReference::CNavDataReference(int id, float latitudeDegrees, float longitudeDegrees) :
|
||||||
|
m_id(id),
|
||||||
|
m_position(latitudeDegrees, longitudeDegrees, 0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
CVariant CNavDataReference::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||||
|
{
|
||||||
|
if (index.isMyself()) { return CVariant::from(*this); }
|
||||||
|
return ICoordinateGeodetic::canHandleIndex(index) ?
|
||||||
|
ICoordinateGeodetic::propertyByIndex(index) :
|
||||||
|
CValueObject::propertyByIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNavDataReference::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||||
|
{
|
||||||
|
if (index.isMyself()) { (*this) = variant.to<CNavDataReference>(); return; }
|
||||||
|
CValueObject::setPropertyByIndex(variant, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CNavDataReference::convertToQString(bool i18n) const
|
||||||
|
{
|
||||||
|
return QString::number(id()) + ":" + m_position.convertToQString(i18n);
|
||||||
|
}
|
||||||
|
|
||||||
|
CNavDataReferenceList::CNavDataReferenceList() = default;
|
||||||
|
|
||||||
|
CNavDataReferenceList::CNavDataReferenceList(const CSequence<CNavDataReference> &other) :
|
||||||
|
CSequence<CNavDataReference>(other)
|
||||||
|
{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
94
src/blackmisc/simulation/xplane/navdatareference.h
Normal file
94
src/blackmisc/simulation/xplane/navdatareference.h
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
/* Copyright (C) 2015
|
||||||
|
* 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 BLACKMISC_SIMULATION_XPLANE_NAVDATAREFERENCE_H
|
||||||
|
#define BLACKMISC_SIMULATION_XPLANE_NAVDATAREFERENCE_H
|
||||||
|
|
||||||
|
#include "blackmisc/sequence.h"
|
||||||
|
#include "blackmisc/geo/geoobjectlist.h"
|
||||||
|
#include "blackmisc/geo/coordinategeodetic.h"
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Simulation
|
||||||
|
{
|
||||||
|
namespace XPlane
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* Reference to an entry in X-Plane's navigation data (airport, navaid, fix, etc.) with its position.
|
||||||
|
*/
|
||||||
|
class BLACKMISC_EXPORT CNavDataReference : public CValueObject<CNavDataReference>, public Geo::ICoordinateGeodetic
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Default constructor.
|
||||||
|
CNavDataReference();
|
||||||
|
|
||||||
|
//! Construct from a navdata reference ID and position.
|
||||||
|
CNavDataReference(int id, const Geo::CLatitude &latitude, const Geo::CLongitude &longitude);
|
||||||
|
|
||||||
|
//! Construct from a navdata reference ID and position.
|
||||||
|
CNavDataReference(int id, float latitudeDegrees, float longitudeDegrees);
|
||||||
|
|
||||||
|
//! Return the navdata reference ID.
|
||||||
|
int id() const { return m_id; }
|
||||||
|
|
||||||
|
virtual Geo::CLatitude latitude() const override { return m_position.latitude(); }
|
||||||
|
virtual Geo::CLongitude longitude() const override { return m_position.longitude(); }
|
||||||
|
virtual const PhysicalQuantities::CLength &geodeticHeight() const override { return m_position.geodeticHeight(); }
|
||||||
|
virtual QVector3D normalVector() const override { return m_position.normalVector(); }
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::propertyByIndex
|
||||||
|
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::setPropertyByIndex
|
||||||
|
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::convertToQString
|
||||||
|
QString convertToQString(bool i18n = false) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
BLACK_ENABLE_TUPLE_CONVERSION(CNavDataReference)
|
||||||
|
int m_id = 0;
|
||||||
|
Geo::CCoordinateGeodetic m_position;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* List of X-Plane navigation data entries (airports, navaids, fixes, etc) with their positions.
|
||||||
|
*/
|
||||||
|
class BLACKMISC_EXPORT CNavDataReferenceList :
|
||||||
|
public CSequence<CNavDataReference>,
|
||||||
|
public Geo::IGeoObjectList<CNavDataReference, CNavDataReferenceList>,
|
||||||
|
public Mixin::MetaType<CNavDataReferenceList>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CNavDataReferenceList)
|
||||||
|
|
||||||
|
//! Default constructor.
|
||||||
|
CNavDataReferenceList();
|
||||||
|
|
||||||
|
//! Construct from a base class object.
|
||||||
|
CNavDataReferenceList(const CSequence<CNavDataReference> &other);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::Simulation::XPlane::CNavDataReference)
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::Simulation::XPlane::CNavDataReferenceList)
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Simulation::XPlane::CNavDataReference>)
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Simulation::XPlane::CNavDataReference>)
|
||||||
|
|
||||||
|
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Simulation::XPlane::CNavDataReference, (
|
||||||
|
attr(o.m_id),
|
||||||
|
attr(o.m_position)
|
||||||
|
))
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user