1
0
Fork 0

Remove PositionedBinding (which no one ever used), Nasal is better for this jobs.

This commit is contained in:
James Turner 2012-04-26 00:37:47 +01:00
parent de975699fe
commit 2d267a5782
14 changed files with 4 additions and 343 deletions

View file

@ -2,8 +2,6 @@
#include <map>
#include <Navaids/PositionedBinding.hxx>
namespace {
typedef std::multimap<int, flightgear::CommStation*> FrequencyMap;
@ -36,12 +34,6 @@ double CommStation::freqMHz() const
return mFreqKhz / 100.0;
}
PositionedBinding*
CommStation::createBinding(SGPropertyNode* nd) const
{
return new CommStationBinding(this, nd);
}
CommStation*
CommStation::findByFreq(int freqKhz, const SGGeod& pos, FGPositioned::Filter* filt)
{

View file

@ -15,8 +15,6 @@ public:
void setAirport(FGAirport* apt);
FGAirport* airport() const { return mAirport; }
virtual flightgear::PositionedBinding* createBinding(SGPropertyNode* nd) const;
int rangeNm() const
{ return mRangeNM; }

View file

@ -40,7 +40,6 @@
#include <Airports/simple.hxx>
#include <Navaids/procedure.hxx>
#include <Navaids/navrecord.hxx>
#include <Navaids/PositionedBinding.hxx>
using std::string;
@ -199,9 +198,3 @@ std::vector<flightgear::STAR*> FGRunway::getSTARs()
return result;
}
flightgear::PositionedBinding*
FGRunway::createBinding(SGPropertyNode* nd) const
{
return new flightgear::RunwayBinding(this, nd);
}

View file

@ -115,9 +115,7 @@ public:
FGRunway* reciprocalRunway() const
{ return _reciprocal; }
void setReciprocalRunway(FGRunway* other);
virtual flightgear::PositionedBinding* createBinding(SGPropertyNode* nd) const;
/**
* Helper to process property data loaded from an ICAO.threshold.xml file
*/

View file

@ -47,7 +47,6 @@
#include <Airports/xmlloader.hxx>
#include <Navaids/procedure.hxx>
#include <Navaids/waypoint.hxx>
#include <Navaids/PositionedBinding.hxx>
#include <ATC/CommStation.hxx>
using std::vector;
@ -667,41 +666,6 @@ Approach* FGAirport::getApproachByIndex(unsigned int aIndex) const
return mApproaches[aIndex];
}
class AirportNodeListener : public SGPropertyChangeListener
{
public:
AirportNodeListener()
{
SGPropertyNode* airports = fgGetNode("/sim/airport");
airports->addChangeListener(this, false);
}
virtual void valueChanged(SGPropertyNode*)
{
}
virtual void childAdded(SGPropertyNode* pr, SGPropertyNode* child)
{
FGAirport* apt = FGAirport::findByIdent(child->getName());
if (!apt) {
return;
}
flightgear::PositionedBinding::bind(apt, child);
}
};
void FGAirport::installPropertyListener()
{
new AirportNodeListener;
}
flightgear::PositionedBinding*
FGAirport::createBinding(SGPropertyNode* nd) const
{
return new flightgear::AirportBinding(this, nd);
}
void FGAirport::setCommStations(CommStationList& comms)
{
mCommStations.swap(comms);

View file

@ -188,8 +188,6 @@ public:
unsigned int numApproaches() const;
flightgear::Approach* getApproachByIndex(unsigned int aIndex) const;
static void installPropertyListener();
/**
* Syntactic wrapper around FGPositioned::findClosest - find the closest
@ -233,9 +231,7 @@ public:
* returns (NULL, NULL) is no suitable STAR is exists
*/
std::pair<flightgear::STAR*, flightgear::WayptRef> selectSTAR(const SGGeod& aOrigin, FGRunway* aRwy);
virtual flightgear::PositionedBinding* createBinding(SGPropertyNode* nd) const;
void setCommStations(flightgear::CommStationList& comms);
flightgear::CommStationList commStationsOfType(FGPositioned::Type aTy) const;

View file

@ -823,7 +823,6 @@ fgInitNav ()
p_metar.append( "Airports/metar.dat" );
fgAirportDBLoad( aptdb.str(), p_metar.str() );
FGAirport::installPropertyListener();
FGNavList *navlist = new FGNavList;
FGNavList *loclist = new FGNavList;

View file

@ -12,8 +12,7 @@ set(SOURCES
route.cxx
routePath.cxx
waypoint.cxx
PositionedBinding.cxx
)
)
set(HEADERS
airways.hxx
@ -27,7 +26,6 @@ set(HEADERS
route.hxx
routePath.hxx
waypoint.hxx
PositionedBinding.hxx
)
)
flightgear_component(Navaids "${SOURCES}" "${HEADERS}")

View file

@ -1,188 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "PositionedBinding.hxx"
#include <map>
#include <simgear/props/props.hxx>
#include <simgear/debug/logstream.hxx>
#include <simgear/structure/exception.hxx>
#include <Main/fg_props.hxx>
#include <Navaids/navrecord.hxx>
#include <Airports/simple.hxx>
#include <Airports/runways.hxx>
#include <ATC/CommStation.hxx>
typedef std::map<SGPropertyNode*, flightgear::PositionedBinding*> BindingMap;
static BindingMap static_bindings;
namespace {
class PropertyDeleteObserver : public SGPropertyChangeListener
{
public:
virtual void childRemoved(SGPropertyNode*, SGPropertyNode* node)
{
BindingMap::iterator it = static_bindings.find(node);
if (it != static_bindings.end()) {
SG_LOG(SG_GENERAL, SG_INFO, "saw remove of:" << node->getPath() << ", deleting binding");
delete it->second;
static_bindings.erase(it);
}
}
};
static PropertyDeleteObserver* static_deleteObserver = NULL;
} // of anonymous namespace
namespace flightgear
{
PositionedBinding::PositionedBinding(const FGPositioned* pos, SGPropertyNode* nd) :
p(const_cast<FGPositioned*>(pos)),
tied(nd)
{
if (!static_deleteObserver) {
static_deleteObserver = new PropertyDeleteObserver;
globals->get_props()->addChangeListener(static_deleteObserver, false);
}
nd->setDoubleValue("latitude-deg", p->latitude());
nd->setDoubleValue("longitude-deg", p->longitude());
if (p->elevation() > -1000) {
nd->setDoubleValue("elevation-ft", p->elevation());
}
nd->setStringValue("ident", p->ident());
if (!p->name().empty()) {
nd->setStringValue("name", p->name());
}
nd->setStringValue("type", FGPositioned::nameForType(p->type()));
}
PositionedBinding::~PositionedBinding()
{
tied.Untie();
}
void PositionedBinding::bind(FGPositioned* pos, SGPropertyNode* node)
{
BindingMap::iterator it = static_bindings.find(node);
if (it != static_bindings.end()) {
throw sg_exception("duplicate positioned binding", node->getPath());
}
PositionedBinding* binding = pos->createBinding(node);
static_bindings.insert(it, std::make_pair(node, binding));
}
NavaidBinding::NavaidBinding(const FGNavRecord* nav, SGPropertyNode* nd) :
PositionedBinding(nav, nd)
{
FGPositioned::Type ty = nav->type();
if (ty == FGPositioned::NDB) {
nd->setDoubleValue("frequency-khz", nav->get_freq() / 100.0);
} else {
nd->setDoubleValue("frequency-mhz", nav->get_freq() / 100.0);
}
if ((ty == FGPositioned::LOC) || (ty == FGPositioned::ILS)) {
nd->setDoubleValue("loc-course-deg", nav->get_multiuse());
}
if (ty == FGPositioned::GS) {
nd->setDoubleValue("gs-angle-deg", nav->get_multiuse());
}
nd->setDoubleValue("range-nm", nav->get_range());
if (nav->runway()) {
// don't want to create a cycle in the graph, so we don't re-bind
// the airport/runway node here - just expose the IDs
nd->setStringValue("airport", nav->runway()->airport()->ident());
nd->setStringValue("runway", nav->runway()->ident());
}
};
RunwayBinding::RunwayBinding(const FGRunway* rwy, SGPropertyNode* nd) :
PositionedBinding(rwy, nd)
{
nd->setDoubleValue("length-ft", rwy->lengthFt());
nd->setDoubleValue("length-m", rwy->lengthM());
nd->setDoubleValue("width-ft", rwy->widthFt());
nd->setDoubleValue("width-m", rwy->widthM());
nd->setDoubleValue("heading-deg", rwy->headingDeg());
nd->setBoolValue("hard-surface", rwy->isHardSurface());
nd->setDoubleValue("threshold-displacement-m", rwy->displacedThresholdM());
nd->setDoubleValue("stopway-m", rwy->stopwayM());
if (rwy->ILS()) {
SGPropertyNode* ilsNode = nd->getChild("ils", 0, true);
PositionedBinding::bind(rwy->ILS(), ilsNode);
}
}
AirportBinding::AirportBinding(const FGAirport* apt, SGPropertyNode* nd) :
PositionedBinding(apt, nd)
{
nd->setIntValue("num-runways", apt->numRunways());
SGGeod tower = apt->getTowerLocation();
nd->setDoubleValue("tower/latitude-deg", tower.getLatitudeDeg());
nd->setDoubleValue("tower/longitude-deg", tower.getLongitudeDeg());
nd->setDoubleValue("tower/elevation-ft", tower.getElevationFt());
for (unsigned int r=0; r<apt->numRunways(); ++r) {
SGPropertyNode* rn = nd->getChild("runway", r, true);
FGRunway* rwy = apt->getRunwayByIndex(r);
PositionedBinding::bind(rwy, rn);
}
for (unsigned int c=0; c<apt->commStations().size(); ++c) {
flightgear::CommStation* comm = apt->commStations()[c];
std::string tynm = FGPositioned::nameForType(comm->type());
// for some standard frequence types, we don't care about the ident,
// so just list the frequencies under one group.
if ((comm->type() == FGPositioned::FREQ_ATIS) ||
(comm->type() == FGPositioned::FREQ_AWOS) ||
(comm->type() == FGPositioned::FREQ_TOWER) ||
(comm->type() == FGPositioned::FREQ_GROUND))
{
SGPropertyNode* commNode = nd->getChild(tynm, 0, true);
int count = nd->getChildren("frequency-mhz").size();
SGPropertyNode* freqNode = commNode->getChild("frequency-mhz", count, true);
freqNode->setDoubleValue(comm->freqMHz());
} else {
// for other kinds of frequency, there's more variation, so list the ID too
int count = nd->getChildren(tynm).size();
SGPropertyNode* commNode = nd->getChild(tynm, count, true);
commNode->setStringValue("ident", comm->ident());
commNode->setDoubleValue("frequency-mhz", comm->freqMHz());
}
} // of airprot comm stations iteration
}
CommStationBinding::CommStationBinding(const CommStation* sta, SGPropertyNode* node) :
PositionedBinding(sta, node)
{
node->setIntValue("range-nm", sta->rangeNm());
node->setDoubleValue("frequency-mhz", sta->freqMHz());
if (sta->airport()) {
// don't want to create a cycle in the graph, so we don't re-bind
// the airport/runway node here - just expose the IDs
node->setStringValue("airport", sta->airport()->ident());
}
}
} // of namespace flightgear

View file

@ -1,63 +0,0 @@
#ifndef FG_POSITIONED_BINDING_HXX
#define FG_POSITIONED_BINDING_HXX
#include <simgear/props/tiedpropertylist.hxx>
#include "positioned.hxx"
// forward decls
class FGNavRecord;
class FGRunway;
class FGAirport;
namespace flightgear
{
// forward decls
class CommStation;
class PositionedBinding
{
public:
virtual ~PositionedBinding();
static void bind(FGPositioned* pos, SGPropertyNode* node);
PositionedBinding(const FGPositioned* pos, SGPropertyNode* node);
protected:
FGPositionedRef p; // bindings own a reference to their positioned
simgear::TiedPropertyList tied;
private:
};
class NavaidBinding : public PositionedBinding
{
public:
NavaidBinding(const FGNavRecord* nav, SGPropertyNode* node);
};
class RunwayBinding : public PositionedBinding
{
public:
RunwayBinding(const FGRunway* rwy, SGPropertyNode* node);
};
class AirportBinding : public PositionedBinding
{
public:
AirportBinding(const FGAirport* apt, SGPropertyNode* node);
};
class CommStationBinding : public PositionedBinding
{
public:
CommStationBinding(const CommStation* sta, SGPropertyNode* node);
};
} // of namespace flightgear
#endif // of FG_POSITIONED_BINDING_HXX

View file

@ -39,9 +39,7 @@
#include <Airports/runways.hxx>
#include <Airports/simple.hxx>
#include <Airports/xmlloader.hxx>
#include <Main/fg_props.hxx>
#include <Navaids/PositionedBinding.hxx>
FGNavRecord::FGNavRecord(Type aTy, const std::string& aIdent,
const std::string& aName, const SGGeod& aPos,
@ -187,13 +185,6 @@ double FGNavRecord::localizerWidth() const
}
flightgear::PositionedBinding*
FGNavRecord::createBinding(SGPropertyNode* nd) const
{
return new flightgear::NavaidBinding(this, nd);
}
FGTACANRecord::FGTACANRecord(void) :
channel(""),
freq(0)

View file

@ -88,8 +88,6 @@ public:
*/
FGRunway* runway() const { return mRunway; }
virtual flightgear::PositionedBinding* createBinding(SGPropertyNode* nd) const;
/**
* return the localizer width, in degrees
* computation is based up ICAO stdandard width at the runway threshold

View file

@ -43,7 +43,6 @@
#include <simgear/sg_inlines.h>
#include <simgear/structure/commands.hxx>
#include "PositionedBinding.hxx"
#include "Airports/simple.hxx"
#include "Main/fg_props.hxx"
@ -701,12 +700,6 @@ const char* FGPositioned::nameForType(Type aTy)
}
}
flightgear::PositionedBinding*
FGPositioned::createBinding(SGPropertyNode* node) const
{
return new flightgear::PositionedBinding(this, node);
}
///////////////////////////////////////////////////////////////////////////////
// search / query functions

View file

@ -32,11 +32,6 @@ class SGPropertyNode;
typedef SGSharedPtr<FGPositioned> FGPositionedRef;
namespace flightgear
{
class PositionedBinding;
}
class FGPositioned : public SGReferenced
{
public:
@ -109,9 +104,6 @@ public:
double elevation() const
{ return mPosition.getElevationFt(); }
virtual flightgear::PositionedBinding* createBinding(SGPropertyNode* nd) const;
/**
* Predicate class to support custom filtering of FGPositioned queries
* Default implementation of this passes any FGPositioned instance.