void InitAirLines() { if (!File.Exists("Airlines.txt")) return; airDirections = new List<AirDirection>(); var sr = new StreamReader("Airlines.txt"); var dir = new AirDirection(); while (!sr.EndOfStream) { var line = sr.ReadLine(); if(line.Length == 0) continue; var lines = line.Split(new char[] {':', '\'', ' ', ','}, StringSplitOptions.RemoveEmptyEntries); switch (lines[0]) { case "id": { dir.Id = int.Parse(lines[1]); break; } case "type": { dir.Type = int.Parse(lines[1]); break; } case "name": { dir.Name = lines[1]; break; } case "latitude": { dir.Latitude = double.Parse(lines[1]); break; } case "longitude": { dir.Longitude = double.Parse(lines[1]); airDirections.Add(dir); dir = new AirDirection(); break; } } } sr.Close(); airLines = new GeoVert[2 * airDirections.Count(x => x.Type == 1)]; airLinesVB = new VertexBuffer(Game.GraphicsDevice, typeof(GeoVert), airLines.Length); var saintPetersburgPos = new DVector2(DMathUtil.DegreesToRadians(30.270424), DMathUtil.DegreesToRadians(59.800073)); var saintVert = new GeoVert { Lon = saintPetersburgPos.X, Lat = saintPetersburgPos.Y, Position = Vector3.Zero, Tex = new Vector4(1.0f, 0.0f, 0, 0), Color = new Color(0.01f, 0.01f, 0.01f, 0.01f) }; int i = 0; foreach(var airDir in airDirections.Where(x => x.Type == 1)) { airLines[2*i + 0] = saintVert; airLines[2*i + 1] = new GeoVert { Lon = DMathUtil.DegreesToRadians(airDir.Longitude), Lat = DMathUtil.DegreesToRadians(airDir.Latitude), Position = Vector3.Zero, Tex = new Vector4(10.0f, 0.0f, 0, 0), Color = new Color(0.8f, 0.8f, 0.8f, 0.8f) }; i++; } airLinesVB.SetData(airLines, 0, airLines.Length); }
void InitAirLines() { if (!File.Exists("Airlines.txt")) { return; } airDirections = new List <AirDirection>(); var sr = new StreamReader("Airlines.txt"); var dir = new AirDirection(); while (!sr.EndOfStream) { var line = sr.ReadLine(); if (line.Length == 0) { continue; } var lines = line.Split(new char[] { ':', '\'', ' ', ',' }, StringSplitOptions.RemoveEmptyEntries); switch (lines[0]) { case "id": { dir.Id = int.Parse(lines[1]); break; } case "type": { dir.Type = int.Parse(lines[1]); break; } case "name": { dir.Name = lines[1]; break; } case "latitude": { dir.Latitude = double.Parse(lines[1]); break; } case "longitude": { dir.Longitude = double.Parse(lines[1]); airDirections.Add(dir); dir = new AirDirection(); break; } } } sr.Close(); airLines = new GeoVert[2 * airDirections.Count(x => x.Type == 1)]; airLinesVB = new VertexBuffer(Game.GraphicsDevice, typeof(GeoVert), airLines.Length); var saintPetersburgPos = new DVector2(DMathUtil.DegreesToRadians(30.270424), DMathUtil.DegreesToRadians(59.800073)); var saintVert = new GeoVert { Lon = saintPetersburgPos.X, Lat = saintPetersburgPos.Y, Position = Vector3.Zero, Tex = new Vector4(1.0f, 0.0f, 0, 0), Color = new Color(0.01f, 0.01f, 0.01f, 0.01f) }; int i = 0; foreach (var airDir in airDirections.Where(x => x.Type == 1)) { airLines[2 * i + 0] = saintVert; airLines[2 * i + 1] = new GeoVert { Lon = DMathUtil.DegreesToRadians(airDir.Longitude), Lat = DMathUtil.DegreesToRadians(airDir.Latitude), Position = Vector3.Zero, Tex = new Vector4(10.0f, 0.0f, 0, 0), Color = new Color(0.8f, 0.8f, 0.8f, 0.8f) }; i++; } airLinesVB.SetData(airLines, 0, airLines.Length); }