private void WriteFile(StreamWriter sw, navTable subTable) { int i = 1; // have to count to avoid the last comma ??!! foreach (var rec in subTable) { sw.WriteLine(rec.Value.AsGeoJson( ) + ((i++ < subTable.Count) ? "," : "")); // adds commas but not for the last one } }
/// <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(navTable subtable) { string ret = ""; foreach (var rec in subtable) { try { ret += this.Add(rec.Value); } catch { } } return(ret); }
/// <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> /// <param name="navTypes">Type of nav items to include</param> /// <returns>A table with selected records</returns> public navTable GetSubtable(double rangeLimitNm, double Lat, double Lon, NavTypes[] navTypes = null) { if (navTypes == null) { navTypes = new NavTypes[] { NavTypes.All } } ; var nT = new navTable( ); var myLoc = new LatLon(Lat, Lon); foreach (var rec in this) { var dist = myLoc.DistanceTo(new LatLon(double.Parse(rec.Value.lat), double.Parse(rec.Value.lon)), ConvConsts.EarthRadiusNm); if ((dist <= rangeLimitNm) && (rec.Value.IsTypeOf(navTypes))) { nT.Add(rec.Value); } } return(nT); } }
/// <summary> /// cTor: init the database /// </summary> public navDatabase() { m_db = new navTable( ); }
/// <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 navTable(navTable table) { this.AddSubtable(table); }