From a2401ea94b61989238eac9bfe38ed86817cbf2ff Mon Sep 17 00:00:00 2001 From: daveluff Date: Sun, 18 Oct 2009 00:32:47 +0000 Subject: [PATCH] Add a hardwired instrument approach for testing. This will be removed and read from file shortly --- src/Instrumentation/dclgps.cxx | 92 ++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/src/Instrumentation/dclgps.cxx b/src/Instrumentation/dclgps.cxx index af232d70b..da43c4970 100644 --- a/src/Instrumentation/dclgps.cxx +++ b/src/Instrumentation/dclgps.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -238,6 +239,97 @@ void DCLGPS::init() { // Not sure if this should be here, but OK for now. CreateDefaultFlightPlans(); + + // Hack - hardwire some instrument approaches for development. + // These will shortly be replaced by a routine to read ARINC data from file instead. + FGNPIAP* iap; + GPSWaypoint* wp; + GPSFlightPlan* fp; + const GPSWaypoint* cwp; + + iap = new FGNPIAP; + iap->_id = "KHAF"; + iap->_name = "RNAV (GPS) Y RWY 12"; + iap->_abbrev = "R12-Y"; + iap->_rwyStr = "12"; + iap->_approachRoutes.clear(); + iap->_IAP.clear(); + iap->_MAP.clear(); + // ------- + wp = new GPSWaypoint; + wp->id = "GOBBS"; + // Nasty using the find any function here, but it saves converting data from FGFix etc. + cwp = FindFirstByExactId(wp->id); + if(cwp) { + *wp = *cwp; + wp->appType = GPS_IAF; + fp = new GPSFlightPlan; + fp->waypoints.push_back(wp); + } else { + //cout << "Unable to find waypoint " << wp->id << '\n'; + } + // ------- + wp = new GPSWaypoint; + wp->id = "FUJCE"; + cwp = FindFirstByExactId(wp->id); + if(cwp) { + *wp = *cwp; + wp->appType = GPS_IAP; + fp->waypoints.push_back(wp); + iap->_approachRoutes.push_back(fp); + iap->_IAP.push_back(wp); + } else { + //cout << "Unable to find waypoint " << wp->id << '\n'; + } + // ------- + wp = new GPSWaypoint; + wp->id = "JEVXY"; + cwp = FindFirstByExactId(wp->id); + if(cwp) { + *wp = *cwp; + wp->appType = GPS_FAF; + iap->_IAP.push_back(wp); + } else { + //cout << "Unable to find waypoint " << wp->id << '\n'; + } + // ------- + wp = new GPSWaypoint; + wp->id = "RW12"; + wp->appType = GPS_MAP; + if(wp->id.substr(0, 2) == "RW" && wp->appType == GPS_MAP) { + // Assume that this is a missed-approach point based on the runway number, which appears to be standard for most approaches. + const FGAirport* apt = fgFindAirportID(iap->_id); + if(apt) { + // TODO - sanity check the waypoint ID to ensure we have a double digit number + FGRunway* rwy = apt->getRunwayByIdent(wp->id.substr(2, 2)); + if(rwy) { + wp->lat = rwy->begin().getLatitudeRad(); + wp->lon = rwy->begin().getLongitudeRad(); + } + } + } else { + cwp = FindFirstByExactId(wp->id); + if(cwp) { + *wp = *cwp; + wp->appType = GPS_MAP; + } else { + //cout << "Unable to find waypoint " << wp->id << '\n'; + } + } + iap->_IAP.push_back(wp); + // ------- + wp = new GPSWaypoint; + wp->id = "SEEMS"; + cwp = FindFirstByExactId(wp->id); + if(cwp) { + *wp = *cwp; + wp->appType = GPS_MAHP; + iap->_MAP.push_back(wp); + } else { + //cout << "Unable to find waypoint " << wp->id << '\n'; + } + // ------- + _np_iap[iap->_id].push_back(iap); } void DCLGPS::bind() { -- 2.39.5