Esempio n. 1
0
 //Update hurricane detail if selected hurricane changes
 private void gridHur_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         Hur hur = (Hur)gridHur.Rows[e.RowIndex].DataBoundItem;
         gridHurDetail.DataSource = hur.Details;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 2
0
        //Update hurricane detail if selected hurricane changes
        private void gridHur_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            Hur hur = (Hur)gridHur.Rows[e.RowIndex].DataBoundItem;

            gridHurDetail.DataSource = hur.Details;
        }
Esempio n. 3
0
        public List <Hur> ParseHurDat(out string errors)
        {
            if (!ValidateHurDat(out errors))
            {
                return(null);
            }

            string line;

            System.IO.StreamReader file    = new System.IO.StreamReader(hurdatFile);
            List <Hur>             hurList = new List <Hur>();
            int         hurId      = 0;
            Hur         currentHur = new Hur();
            StateLookup sl         = new StateLookup();

            while ((line = file.ReadLine()) != null)
            {
                string[] blocks = line.Split(',');

                //Header line
                if (blocks.Length == 4)
                {
                    string basin         = blocks[0].Substring(0, 2);
                    string strCycloneNum = blocks[0].Substring(2, 2);
                    string strYear       = blocks[0].Substring(4, 4);

                    int cycloneNum;
                    int year;

                    int.TryParse(strCycloneNum, out cycloneNum);
                    int.TryParse(strYear, out year);
                    string hurName         = blocks[1].Trim();
                    string strTrackEntries = blocks[2];
                    int    trackEntries;
                    int.TryParse(strTrackEntries, out trackEntries);

                    hurId++;

                    Hur hur = new Hur();
                    hur.Id         = hurId;
                    hur.Basin      = basin;
                    hur.CycloneNum = cycloneNum;
                    hur.Year       = year;
                    hur.Name       = hurName;
                    hur.NumEntries = trackEntries;
                    hur.Details    = new List <HurDetail>();
                    hurList.Add(hur);
                    currentHur = hur;
                }
                //Data line
                else if (blocks.Length == 21)
                {
                    string strYear  = blocks[0].Substring(0, 4);
                    string strMonth = blocks[0].Substring(4, 2);
                    string strDay   = blocks[0].Substring(6, 2);

                    int year;
                    int month;
                    int day;

                    int.TryParse(strYear, out year);
                    int.TryParse(strMonth, out month);
                    int.TryParse(strDay, out day);

                    string strHour    = blocks[0].Substring(0, 2);
                    string strMinutes = blocks[0].Substring(2, 2);

                    int hour;
                    int minutes;

                    int.TryParse(strHour, out hour);
                    int.TryParse(strMinutes, out minutes);

                    string recordId = blocks[2].Trim();
                    string status   = blocks[3].Trim();

                    string strLat  = blocks[4].Substring(0, blocks[4].Length - 1).Trim();
                    char   latHemi = blocks[4][blocks[4].Length - 1];

                    decimal lat;
                    decimal.TryParse(strLat, out lat);

                    if (latHemi == 'S')
                    {
                        lat = lat * -1;
                    }

                    string strLng  = blocks[5].Substring(0, blocks[5].Length - 1).Trim();
                    char   lngHemi = blocks[5][blocks[5].Length - 1];

                    decimal lng;
                    decimal.TryParse(strLng, out lng);

                    if (lngHemi == 'W')
                    {
                        lng = lng * -1;
                    }

                    string strMaxWind = blocks[6].Trim();
                    int    maxWind;
                    int.TryParse(strMaxWind, out maxWind);

                    HurDetail detail = new HurDetail();
                    detail.HurId      = currentHur.Id;
                    detail.Year       = year;
                    detail.Month      = month;
                    detail.Day        = day;
                    detail.Hour       = hour;
                    detail.Minute     = minutes;
                    detail.RecordId   = recordId;
                    detail.Status     = status;
                    detail.Latitude   = lat;
                    detail.Longtitude = lng;
                    detail.MaxWind    = maxWind;
                    detail.State      = sl.GetStateFromCor(lng, lat);

                    currentHur.Details.Add(detail);
                }
            }

            file.Close();

            return(hurList);
        }