/// <summary> /// Adds a table to this table (omitting key dupes) /// </summary> /// <param name="subtable">A table to add to this table</param> public string AddSubtable(awyTable subtable) { string ret = ""; foreach (var rec in subtable) { try { ret += this.Add(rec.Value); } catch { } } return(ret); }
/// <summary> /// Return an Airway subtable where either start or end ICAO designator matches /// </summary> /// <param name="icao_key">The icao to match</param> /// <returns>An awyTable</returns> public awyTable GetSubtable(string icao_key) { var nT = new awyTable( ); foreach (var rec in this) { // key = ident => "icao_region_icao_region" (so find is Contains(icao), which is expensive...) if (rec.Key.Contains(icao_key)) { nT.Add(rec.Value); } } return(nT); }
/// <summary> /// Returns a subtable with items that match the given criteria /// </summary> /// <param name="rangeLimitNm">Range Limit in nm</param> /// <param name="Lat">Center Lat (decimal)</param> /// <param name="Lon">Center Lon (decimal)</param> /// <returns>A table with selected records</returns> public awyTable GetSubtable(navDatabase ndb, double rangeLimitNm = -1.0, double Lat = 0, double Lon = 0) { var nT = new awyTable( ); // Navs and Fixes in range var NAVTAB = ndb.GetSubtable(rangeLimitNm, Lat, Lon); // for each item in NDB get the airway(s) that is using it foreach (var rec in NAVTAB) { var AWYTAB = this.GetSubtable(rec.Key); // for each item then find it's counterpart and write an airway segment foreach (var awRec in AWYTAB) { // expected layer (hi or lo) if (rec.Key == awRec.Value.startID) { if (ndb.GetTable( ).ContainsKey(awRec.Value.startID) && ndb.GetTable( ).ContainsKey(awRec.Value.endID)) { var endNav = ndb.GetTable( )[awRec.Value.endID]; if (!nT.ContainsKey(awRec.Key)) { nT.Add(awRec.Key, awRec.Value); } } } else if (rec.Key == awRec.Value.endID) { if (ndb.GetTable( ).ContainsKey(awRec.Value.startID) && ndb.GetTable( ).ContainsKey(awRec.Value.endID)) { var startNav = ndb.GetTable( )[awRec.Value.endID]; if (!nT.ContainsKey(awRec.Key)) { nT.Add(awRec.Key, awRec.Value); } } } else { ; //ERROR - DEBUG BREAK } } } return(nT); }
/// <summary> /// Create an ICAO table from the given table /// </summary> /// <param name="prefix">The prefix of the table</param> /// <param name="table">The source to fill from</param> public awyTable(awyTable table) { this.AddSubtable(table); }
/// <summary> /// cTor: init the database /// </summary> public awyDatabase() { m_db = new awyTable( ); }