예제 #1
0
        public static StormType2 Export_GetStormType(string NodeType)
        {
            RealStormType RST = ATCFHelperMethods.Export_IdentifyRealType(NodeType);

#if PRISCILLA
            MainWindow       MnWindow = (MainWindow)Application.Current.MainWindow;
            StormTypeManager STM      = MnWindow.ST2Manager;
#else
            StormTypeManager STM = MnWindow.GetST2Manager();
#endif
            StormType2 ST2 = STM.GetStormTypeWithRealStormTypeName(RST);

            return(ST2);
        }
예제 #2
0
        // pre-globalstate...refactor this in Dano to not have that passed to it
        // this code is terrible
        public Project ImportCore(StormTypeManager ST2M, string FolderName)
        {
            // this is one of the worst f*****g file formats I have ever laid my f*****g eyes on, NOAA are a bunch of f*****g wanker twats, nobody should use this pile of crap

            string[] Storms = Directory.GetFiles(FolderName);

            // this is terrible design
            Project Proj = new Project();

            Proj.FileName = $"{FolderName}/*.*";
            Basin Bas = new Basin();

            // this is still a mess for now
            // not foreach as we can use it for setting up the basin
            for (int i = 0; i < Storms.Count(); i++)
            {
                string StormFileName = Storms[i];

                string[] ATCFLines = File.ReadAllLines(StormFileName);

                // holy f*****g shit i hate the ATCF format so f*****g muc
                Layer Lyr = new Layer();

                Storm Sto = new Storm();

                StormType2 StormType        = new StormType2();
                DateTime   StormFormationDT = new DateTime(1959, 3, 10);

                // XML OR JSON OR F*****G ANYTHING PLS
                // not foreach because it makes it slightly easier to set the date
                for (int j = 0; j < ATCFLines.Length; j++)
                {
                    string ATCFLine = ATCFLines[j];

                    string[] Components = ATCFLine.Split(',');

                    string _StrAbbreviation = Components[0];
                    // get the stuff we actually need
                    string _StrId   = Components[1];
                    string _StrTime = Components[2];
                    string _StrTimeSinceFormation = Components[3];
                    string _StrCoordX             = Components[6];
                    string _StrCoordY             = Components[7];
                    string _StrIntensity          = Components[8];
                    string _StrPressure           = Components[9];
                    string _StrCategory           = Components[10];
                    string _StrName = Components[28]; // bleh

                    // trim it
                    _StrAbbreviation       = _StrAbbreviation.Trim();
                    _StrId                 = _StrId.Trim();
                    _StrTime               = _StrTime.Trim();
                    _StrTimeSinceFormation = _StrTimeSinceFormation.Trim();
                    _StrPressure           = _StrPressure.Trim();
                    _StrCoordX             = _StrCoordX.Trim();
                    _StrCoordY             = _StrCoordY.Trim();
                    _StrIntensity          = _StrIntensity.Trim();
                    _StrCategory           = _StrCategory.Trim();
                    _StrName               = _StrName.Trim();

                    // initialise the basin with the abbreviation loaded from XML
                    // we just use the name if there is no abbreviation specified in XML
                    int Intensity = 0;
                    // first iteration...
                    if (j == 0)
                    {
                        if (i == 0)
                        {
                            Bas = Proj.GetBasinWithAbbreviation(_StrAbbreviation);

                            if (Bas.CoordsHigher == null || Bas.CoordsLower == null)
                            {
                                Error.Throw("Error!", "This basin is not supported by the ATCF format as it does not have defined borders in Basins.xml.", ErrorSeverity.Error, 249);
                                return(null);
                            }
                        }

                        Lyr.Name = _StrName;
                    }

                    Intensity = Convert.ToInt32(_StrIntensity);

                    Sto.FormationDate = ParsingUtil.ParseATCFDateTime(_StrTime, CoordinateFormat.ATCF);

                    if (_StrName == null)
                    {
                        Error.Throw("Error!", "Attempted to load storm with an invalid name!", ErrorSeverity.Error, 245);
                        return(null);
                    }
                    else
                    {
                        Sto.Name = _StrName;
                    }

                    int        Id    = Convert.ToInt32(_StrId);
                    Coordinate Coord = Coordinate.FromSplitCoordinate(_StrCoordX, _StrCoordY);

                    // create a node and add it

                    Node Nod = new Node();
                    Nod.Id        = Id;
                    Nod.Intensity = Intensity;

                    Nod.Position = Bas.FromCoordinateToRelativeNodePosition(Coord, new Point(MnWindow.Width, MnWindow.Height));
                    Nod.NodeType = ATCFHelperMethods.Export_GetStormType(_StrCategory);
                    Nod.Pressure = Convert.ToInt32(_StrPressure);

                    Sto.AddNode(Nod);
                }

                Lyr.AddStorm(Sto);
                Bas.AddLayer(Lyr);
            }

            Proj.AddBasin(Bas);

            return(Proj);
        }