| 1 | #include "config.h" |
| 2 | |
| 3 | #include <Main/globals.hxx> |
| 4 | #include <Navaids/NavDataCache.hxx> |
| 5 | #include <Scenery/scenery.hxx> |
| 6 | |
| 7 | #include "gnnode.hxx" |
| 8 | #include "groundnetwork.hxx" |
| 9 | |
| 10 | using namespace flightgear; |
| 11 | |
| 12 | |
| 13 | /************************************************************************** |
| 14 | * FGTaxiNode |
| 15 | *************************************************************************/ |
| 16 | |
| 17 | FGTaxiNode::FGTaxiNode(FGPositioned::Type ty, int index, const SGGeod& pos, |
| 18 | bool aOnRunway, int aHoldType, |
| 19 | const std::string& ident) : FGPositioned(NavDataCache::instance()->createTransientID(), ty, ident, pos), |
| 20 | m_index(index), |
| 21 | isOnRunway(aOnRunway), |
| 22 | holdType(aHoldType), |
| 23 | m_isPushback(false) |
| 24 | { |
| 25 | } |
| 26 | |
| 27 | void FGTaxiNode::setElevation(double val) |
| 28 | { |
| 29 | // ignored for the moment |
| 30 | } |
| 31 | |
| 32 | double FGTaxiNode::getElevationFt() |
| 33 | { |
| 34 | const SGGeod& pos = geod(); |
| 35 | if (pos.getElevationFt() == 0.0) { |
| 36 | SGGeod center2 = pos; |
| 37 | FGScenery* local_scenery = globals->get_scenery(); |
| 38 | center2.setElevationM(SG_MAX_ELEVATION_M); |
| 39 | if (local_scenery) { |
| 40 | double elevationEnd = -100; |
| 41 | if (local_scenery->get_elevation_m(center2, elevationEnd, NULL)) { |
| 42 | SGGeod newPos = pos; |
| 43 | newPos.setElevationM(elevationEnd); |
| 44 | // this will call modifyPosition to update mPosition |
| 45 | modifyPosition(newPos); |
| 46 | } |
| 47 | } else { |
| 48 | SG_LOG(SG_TERRAIN, SG_ALERT, "Terrain not inited"); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | return pos.getElevationFt(); |
| 53 | } |
| 54 | |
| 55 | int FGTaxiNode::getIndex() const |
| 56 | { |
| 57 | return m_index; |
| 58 | } |
| 59 | |
| 60 | void FGTaxiNode::setIsPushback() |
| 61 | { |
| 62 | m_isPushback = true; |
| 63 | } |
| 64 | |
| 65 | double FGTaxiNode::getElevationM() |
| 66 | { |
| 67 | return getElevationFt() * SG_FEET_TO_METER; |
| 68 | } |