public void WriteParkingDef() { string filename = Path.Combine(Settings.WorldTrafficParkingDefs, _airport.ICAO, Name) + ".txt"; using (InvariantWriter sw = new InvariantWriter(filename, Encoding.ASCII)) { int military = (Operation == OperationType.Military) ? 1 : 0; int cargo = (Operation == OperationType.Cargo) ? 1 : 0; sw.WriteLine($"Auto Generated by GRG \n<{_airport.ICAO}.{Name}> Ops: <{Operation}> Cat: <{MaxSize}> XpTypes: <{string.Join(" ", XpTypes)}>\n"); sw.WriteLine("START"); sw.WriteLine($"Name {Name}"); sw.WriteLine($"Types {string.Join(" ", PossibleWtTypes.Select(w => (int)w).OrderBy(w => w))}"); sw.WriteLine($"Operators {string.Join(" ", Operators).ToUpper()}"); sw.WriteLine($"AcName "); sw.WriteLine($"Tailnum "); sw.WriteLine($"Cargo {cargo}"); sw.WriteLine($"Military {military}"); sw.WriteLine($"Lat {Latitude * VortexMath.Rad2Deg}"); sw.WriteLine($"Lon {Longitude * VortexMath.Rad2Deg}"); sw.WriteLine($"AdjLat {Latitude * VortexMath.Rad2Deg}"); sw.WriteLine($"AdjLon {Longitude * VortexMath.Rad2Deg}"); sw.WriteLine($"HdgDegT {((Bearing * VortexMath.Rad2Deg)+360) % 360:0}"); sw.WriteLine($"ParkCenter {Settings.ParkingReference}"); sw.WriteLine($"PushBackDist1_ft 0"); // Push is part of route sw.WriteLine($"PushBackTurnHdg 0"); sw.WriteLine($"PushBackDist2_ft 0"); sw.WriteLine($"Has1300_data 1"); sw.WriteLine($"Priority 0"); sw.WriteLine($"International 1"); sw.WriteLine($"SmallPropAllowed 1"); sw.WriteLine($"LightPropAllowed 1"); sw.WriteLine($"Enabled 1"); sw.WriteLine("END"); } }
internal void DebugAtcNodes() { using (InvariantWriter sw = new InvariantWriter(Path.Combine(Settings.DataFolder, "atcnodes.csv"), Encoding.UTF8)) { sw.WriteLine("latitude,longitude,name\n"); foreach (TaxiNode node in _taxiNodes) { sw.WriteLine($"{node.Latitude * VortexMath.Rad2Deg},{node.Longitude * VortexMath.Rad2Deg},{node.Id}"); } } }
internal void Write(string icao) { string operationFile = Path.Combine(Settings.WorldTrafficOperations, $"{icao}.txt"); using (InvariantWriter sw = new InvariantWriter(operationFile, Encoding.ASCII)) { sw.WriteLine(" Start End"); sw.WriteLine("INDEX Low Wind Speed High Wind Speed Low Wind Dir High Wind Dir Time Time Comments (not parsed)"); sw.WriteLine("---------------------------------------------------------------------------------------------------------------------"); sw.WriteLine("START_OPERATIONS"); foreach (string op in _operations) { sw.WriteLine(op); } sw.WriteLine("END_OPERATIONS\n\n"); sw.WriteLine("Ops 1 2 Start End"); sw.WriteLine("Index Active Runway Arr Dep Time Time Comments (not parsed)"); sw.WriteLine("-------------------------------------------------------------------------------------------------"); sw.WriteLine("START_RUNWAY_OPS"); foreach (string rwop in _runwayOps) { sw.WriteLine(rwop); } sw.WriteLine("END_RUNWAY_OPS\n\n"); sw.WriteLine(" Supported AC Types Supported Approaches"); sw.WriteLine("Runway 0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8"); sw.WriteLine("---------------------------------------------------------------------------"); sw.WriteLine("START_RUNWAYS"); IEnumerable <IGrouping <string, RunwayUse> > uses = TrafficRules.SelectMany(tr => tr.RunwayUses).GroupBy(ru => ru.Designator); foreach (IGrouping <string, RunwayUse> use in uses) { IEnumerable <XPlaneAircraftType> types = use.SelectMany(u => u.XpTypes).Distinct(); IEnumerable <WorldTrafficAircraftType> wtTypes = AircraftTypeConverter.WTTypesFromXPlaneTypes(types); List <int> onOffs = new List <int>(); for (WorldTrafficAircraftType t = WorldTrafficAircraftType.Fighter; t < WorldTrafficAircraftType.Ground; t++) { onOffs.Add(wtTypes.Contains(t) ? 1 : 0); } sw.WriteLine($"{use.Key,-7} {string.Join(" ", onOffs)} 1 1 1 1 1 1 1 0"); } sw.WriteLine("END_RUNWAYS"); } }
public void Serialize(object value, Stream s) { StreamWriter sw; var cms = s as ChunkedMemoryStream; if (cms != null) { sw = cms.GetWriter(); } else { sw = new InvariantWriter(s); } SharedSerializer.Serialize(sw, value); sw.Flush(); }
internal void DebugParkings() { using (InvariantWriter sw = new InvariantWriter(Path.Combine(Settings.DataFolder, "starts.csv"), Encoding.UTF8)) { sw.WriteLine("latitude,longitude,name\n"); foreach (Parking parking in _parkings) { sw.WriteLine($"{parking.Latitude * VortexMath.Rad2Deg},{parking.Longitude * VortexMath.Rad2Deg},{parking.Name}"); } } using (InvariantWriter sw = new InvariantWriter(Path.Combine(Settings.DataFolder, "pushback.csv"), Encoding.UTF8)) { sw.WriteLine("latitude,longitude,name\n"); foreach (Parking parking in _parkings) { sw.WriteLine($"{parking.PushBackLatitude * VortexMath.Rad2Deg},{parking.PushBackLongitude * VortexMath.Rad2Deg},{parking.Name}"); } } }
public void SerializeJsonObject(object value, Stream s) { StreamWriter sw; var cms = s as ChunkedMemoryStream; if (cms != null) { sw = cms.GetWriter(); } else { sw = new InvariantWriter(s); } var jo = value as IJsonObject; if (jo != null) { jo.Serialize(sw, SharedSerializer.Serialize); } else { var array = value as IJsonObject[]; if (array != null) { sw.Write('['); if (array.Length > 0) { for (int i = 0; i < array.Length - 1; i++) { if (array[i] != null) { array[i].Serialize(sw, SharedSerializer.Serialize); } else { sw.Write("null"); } sw.Write(','); } if (array[array.Length - 1] != null) { array[array.Length - 1].Serialize(sw, SharedSerializer.Serialize); } else { sw.Write("null"); } } sw.Write(']'); } else if (value is IList <IJsonObject> ) { var list = value as IList <IJsonObject>; sw.Write('['); if (list.Count > 0) { for (int i = 0; i < list.Count - 1; i++) { if (list[i] != null) { list[i].Serialize(sw, SharedSerializer.Serialize); } else { sw.Write("null"); } sw.Write(','); } if (list[list.Count - 1] != null) { list[list.Count - 1].Serialize(sw, SharedSerializer.Serialize); } else { sw.Write("null"); } } sw.Write(']'); } else if (value is ICollection <IJsonObject> ) { var col = value as ICollection <IJsonObject>; sw.Write('['); var total = col.Count - 1; if (total > 0) { var enumerator = col.GetEnumerator(); IJsonObject item; for (var i = 0; enumerator.MoveNext() && i < total; i++) { item = enumerator.Current; if (item != null) { item.Serialize(sw, SharedSerializer.Serialize); } else { sw.Write("null"); } sw.Write(','); } item = enumerator.Current; if (item != null) { item.Serialize(sw, SharedSerializer.Serialize); } else { sw.Write("null"); } } sw.Write(']'); } else { SharedSerializer.Serialize(sw, value); } } sw.Flush(); }
public void Serialize(object value, Stream s, bool minimal) { TextWriter sw; var cms = s as ChunkedMemoryStream; if (cms != null) { sw = cms.GetWriter(); } else { sw = new InvariantWriter(s); } var jo = value as IJsonObject; if (jo != null) { jo.Serialize(sw, minimal, SharedSerializer.Serialize); } else { var array = value as IJsonObject[]; if (array != null) { sw.Write('['); if (array.Length > 0) { if (array[0] != null) { array[0].Serialize(sw, minimal, SharedSerializer.Serialize); } else { sw.Write("null"); } for (int i = 1; i < array.Length; i++) { sw.Write(','); if (array[i] != null) { array[i].Serialize(sw, minimal, SharedSerializer.Serialize); } else { sw.Write("null"); } } } sw.Write(']'); } else if (value is IList <IJsonObject> ) { var list = value as IList <IJsonObject>; sw.Write('['); if (list.Count > 0) { if (list[0] != null) { list[0].Serialize(sw, minimal, SharedSerializer.Serialize); } else { sw.Write("null"); } for (int i = 1; i < list.Count; i++) { sw.Write(','); if (list[i] != null) { list[i].Serialize(sw, minimal, SharedSerializer.Serialize); } else { sw.Write("null"); } } } sw.Write(']'); } else if (value is IEnumerable <IJsonObject> ) { var col = value as IEnumerable <IJsonObject>; sw.Write('['); var total = col.Count() - 1; if (total >= 0) { var enumerator = col.GetEnumerator(); IJsonObject item; for (var i = 0; enumerator.MoveNext() && i < total; i++) { item = enumerator.Current; if (item != null) { item.Serialize(sw, minimal, SharedSerializer.Serialize); } else { sw.Write("null"); } sw.Write(','); } item = enumerator.Current; if (item != null) { item.Serialize(sw, minimal, SharedSerializer.Serialize); } else { sw.Write("null"); } } sw.Write(']'); } else { var jw = new JsonTextWriter(sw); SharedSerializer.Serialize(jw, value); jw.Flush(); } } sw.Flush(); }