Пример #1
0
        public static List <ObstacleModel> GetObsFromFile(string fileName)
        {
            var runways = App.RunwayRepsitory.GetAll();

            string[]             readText          = File.ReadAllLines(fileName);
            int                  NumberOfLines     = readText.Length;
            List <ObstacleModel> ObstaclesWithin30 = new List <ObstacleModel>();

            for (int i = 4; i < NumberOfLines; i++)
            {
                string obsRecLine = readText[i];
                if (obsRecLine.Substring(0, 3) == "ADD")
                {
                    double ObsLat = Conversions.ConvertPosition(double.Parse(obsRecLine.Substring(45, 2) + obsRecLine.Substring(48, 2) + obsRecLine.Substring(51, 5)));
                    double ObsLon = Conversions.ConvertPosition(double.Parse(obsRecLine.Substring(58, 3) + obsRecLine.Substring(62, 2) + obsRecLine.Substring(65, 5)));



                    foreach (var rwy in runways)
                    {
                        double result = Inverse.invcalc(rwy.Lat, rwy.Long, ObsLat, ObsLon).xmeters / 1852;
                        if (result < 30)
                        {
                            ObstacleModel NewObstacle = new ObstacleModel()
                            {
                                ObsStudy               = obsRecLine.Substring(10, 9),
                                ObsType                = obsRecLine.Substring(72, 18).TrimEnd(),
                                ObsAglHeight           = int.Parse(obsRecLine.Substring(93, 5)),
                                ObsMslHeight           = int.Parse(obsRecLine.Substring(99, 5)),
                                ObsLatitudeHemisphere  = obsRecLine.Substring(56, 1),
                                ObsLongitudeHemisphere = obsRecLine.Substring(70, 1),
                                ObsLatitudeDms         = double.Parse(obsRecLine.Substring(45, 2) + obsRecLine.Substring(48, 2) + obsRecLine.Substring(51, 5)),
                                ObsLongitudeDms        = double.Parse(obsRecLine.Substring(58, 3) + obsRecLine.Substring(62, 2) + obsRecLine.Substring(65, 5)),
                                ObsStatus              = obsRecLine.Substring(0, 3),
                                ObsIcao                = rwy.Icao
                            };

                            NewObstacle.ObsLatitudeDd  = Conversions.ConvertPosition(NewObstacle.ObsLatitudeDms);
                            NewObstacle.ObsLongitudeDd = Conversions.ConvertPosition(NewObstacle.ObsLongitudeDms);

                            ObstaclesWithin30.Add(NewObstacle);
                            break;
                        }
                    }
                }
            }
            return(ObstaclesWithin30);
        }
Пример #2
0
        public static void printToGoogleEarth(ObstacleModel obstacle)
        {
            string ObsStudy     = obstacle.ObsStudy;
            string ObsType      = obstacle.ObsType;
            int    ObsAglHeight = obstacle.ObsAglHeight;
            int    ObsMslHeight = obstacle.ObsMslHeight;
            double ObsLatDd     = obstacle.ObsLatitudeDd;
            double ObsLonDd     = obstacle.ObsLongitudeDd;


            printObstacle.AppendLine(
                "<?xml version=\"1.0\" encoding = \"UTF-8\"?>"
                + "<kml xmlns=\"http://www.opengis.net/kml/2.2\">"
                + $"<Document> <Placemark><name>{ObsStudy}</name>"
                + $"<description><![CDATA[<h1>{ObsType}</h1>"
                + $"<p>AGL: {ObsAglHeight} </p>"
                + $"<p>MSL: {ObsMslHeight}</p>]]></description>"
                + $"<Point><coordinates>-{ObsLonDd}, {ObsLatDd}</coordinates></Point>"
                + "</Placemark></Document></kml>"
                );

            string         fileName = string.Format($"Obstacle-{ObsStudy}.kml");
            SaveFileDialog SaveFile = new SaveFileDialog();

            SaveFile.Filter           = "Google Earth files (*.kml)|*.kml|All files (*.*)|*.*";
            SaveFile.FileName         = fileName;
            SaveFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            string Mypath   = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            string filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);



            if (SaveFile.ShowDialog() == true)
            {
                using (StreamWriter sw = new StreamWriter(SaveFile.FileName, false))
                {
                    sw.Write(printObstacle.ToString());
                    printObstacle.Clear();
                }
                Process myProcess = new Process();
                myProcess.StartInfo.UseShellExecute = true;
                myProcess.StartInfo.FileName        = SaveFile.FileName;
                myProcess.StartInfo.CreateNoWindow  = true;
                myProcess.Start();
            }
        }
Пример #3
0
        public static ObstacleModel ToModel(ObstacleRepository.ObstacleModel repositoryModel)
        {
            var obstacleModel = new ObstacleModel
            {
                ObsStudy               = repositoryModel.ObsStudy,
                ObsType                = repositoryModel.ObsType,
                ObsLatitudeDms         = repositoryModel.ObsLatitudeDms,
                ObsLongitudeDms        = repositoryModel.ObsLongitudeDms,
                ObsLatitudeHemisphere  = repositoryModel.ObsLatitudeHemisphere,
                ObsLongitudeHemisphere = repositoryModel.ObsLongitudeHemisphere,
                ObsAglHeight           = repositoryModel.ObsAglHeight,
                ObsMslHeight           = repositoryModel.ObsMslHeight,
                ObstLatitudeDd         = repositoryModel.ObstLatitudeDd,
                ObsLongitudeDd         = repositoryModel.ObsLongitudeDd,
                ObsIcao                = repositoryModel.ObsIcao
            };

            return(obstacleModel);
        }