Ejemplo n.º 1
0
        private List <TxtPoint> stringsToPoints(List <string[]> ss, string trackName = "UnKnown", string StationName = "UnKnown", string Overlayname = "UnKnown")
        {
            List <TxtPoint> points = new List <TxtPoint>();

            //
            foreach (string[] s in ss)
            {
                TxtPoint p = string2point(s, trackName, StationName, Overlayname);
                //只设置了经纬高,里程和备注
                p.Id = ss.IndexOf(s) + 1;
                //赋值index
                points.Add(p);
            }
            //赋值Bear
            for (int i = 0; i < ss.Count - 1; i++)
            {
                double LatA = Convert.ToDouble(ss[i][1]);
                double LatB = Convert.ToDouble(ss[i + 1][1]);
                double LngA = Convert.ToDouble(ss[i][0]);
                double LngB = Convert.ToDouble(ss[i + 1][0]);
                points[i].Bear = GetBear(LatA, LatB, LngA, LngB);
            }
            //赋值DeltaBear
            for (int i = 0; i < points.Count - 1; i++)
            {
                points[i].DeltaBear = points[i + 1].Bear - points[i].Bear;
            }
            return(points);
        }
Ejemplo n.º 2
0
        //通用
        private TxtPoint string2point(string[] s, string trackName, string StationName, string overlayname)
        {
            TxtPoint t = new TxtPoint();

            t.Longtitude  = Convert.ToInt32(Convert.ToDouble(s[0]) * 3600000);
            t.Latitude    = Convert.ToInt32(Convert.ToDouble(s[1]) * 3600000);
            t.Height      = Convert.ToInt32(Convert.ToDouble(s[2]) * 100);
            t.KiloPos     = Convert.ToDouble(s[3]);
            t.TrackName   = trackName;
            t.StationName = StationName;
            t.OverlayName = overlayname;
            if (s.Length >= 5)
            {
                t.Tag = s[4].ToString();
            }
            return(t);
        }
Ejemplo n.º 3
0
        //Import Data Form txtPoints
        //轨道地理信息表
        private void ImportData(DevExpress.Spreadsheet.Worksheet sheet, int tableHeader, List <TxtPoint> txtPoints)
        {
            int j = 0;

            for (int i = tableHeader; i < tableHeader + txtPoints.Count; i++)
            {
                TxtPoint t = txtPoints[j];
                sheet.Cells[i, 0].SetValue(j + 1);         //数据编号
                sheet.Cells[i, 1].SetValue(t.StationName); //车站名称
                //sheet.Cells[i, 2].SetValue();//车站编号
                sheet.Cells[i, 3].SetValue(t.TrackName);   //轨道名称
                //sheet.Cells[i,4].SetValue();//轨道编号
                sheet.Cells[i, 5].SetValue(t.Longtitude);  //经度(毫秒)
                sheet.Cells[i, 6].SetValue(t.Latitude);    //纬度(单位毫秒)
                sheet.Cells[i, 7].SetValue(t.Height);      //高程(厘米)
                sheet.Cells[i, 8].SetValue(t.KiloPos);     //里程
                sheet.Cells[i, 9].SetValue(t.Bear);        //航向角
                sheet.Cells[i, 10].SetValue(t.DeltaBear);  //增量航向角
                j++;
            }
        }
Ejemplo n.º 4
0
        private List <TxtPoint> OpenCSV(string filePath)
        {
            List <TxtPoint> points   = new List <TxtPoint>();
            Encoding        encoding = Encoding.ASCII;
            FileStream      fs       = new FileStream(filePath, FileMode.Open, FileAccess.Read);
            StreamReader    sr       = new StreamReader(fs, encoding);
            //记录每行读取的一行记录
            string strLine = "";

            string[] aryLine   = null;
            string[] tableHead = null;
            //标示行数
            int  columnCount = 0;
            bool isFirst     = true;
            int  lineCount   = 0;

            while ((strLine = sr.ReadLine()) != null)
            {
                if (isFirst)
                {
                    tableHead   = strLine.Split(',');
                    isFirst     = false;
                    columnCount = tableHead.Length;
                }
                else
                {
                    lineCount++;
                    aryLine = strLine.Split(',');
                    TxtPoint point = new TxtPoint();
                    point.Id         = lineCount;
                    point.Longtitude = Convert.ToDouble(aryLine[0]) * 3600000;
                    point.Latitude   = Convert.ToDouble(aryLine[1]) * 3600000;
                }
            }
            return(points);
        }