/// <summary> /// 显示edge的详细信息 /// </summary> /// <param name="eid">edge id</param> public void showEdgeInfo(int eid) { Edge e = graph.Edges[eid]; if (e != null) { double length = LayerTools.GetDistance(e.Start.Point, e.End.Point); //double cost = e.Cost; double cost = 0; MessageBox.Show(string.Format("{0} --> {1} : {2}m\nCost:{3},Length/Cost:{4}", e.Start.ID, e.End.ID, length, cost, length / cost)); } }
/// <summary> /// /// </summary> /// <param name="inputfile"></param> /// <param name="file"></param> /// <param name="stdFile"></param> //private void cmpFile(string inputfile, string file, string stdFile) //{ // StreamReader inSr = new StreamReader(inputfile); // StreamReader sr = new StreamReader(file); // StreamReader stdSr = new StreamReader(stdFile); // int lineNumber = 0; // int correctNumber = 0; // String line, stdLine, inLine; // List<Record> list = new List<Record>(); // while (!sr.EndOfStream && !stdSr.EndOfStream) // { // inLine = inSr.ReadLine(); // line = sr.ReadLine(); // stdLine = stdSr.ReadLine(); // lineNumber++; // Record rec = new Record(); // String[] fields = inLine.Split(','); // rec.Time = int.Parse(fields[0]); // rec.Lat = double.Parse(fields[1]); // rec.Lng = double.Parse(fields[2]); // //output // fields = line.Split(','); // int time = int.Parse(fields[0]); // if (time != rec.Time) // { // MessageBox.Show(String.Format("time fields at Line {0} in the input file and the output file should be the same.", lineNumber)); // return; // } // rec.EdgeId = int.Parse(fields[1]); // rec.Confidence = double.Parse(fields[2]); // //stdoutput // fields = stdLine.Split(','); // time = int.Parse(fields[0]); // if (time != rec.Time) // { // MessageBox.Show(String.Format("time fields at Line {0} in the input file and the stdoutput file should be the same.", lineNumber)); // return; // } // rec.StdEdgeId = int.Parse(fields[1]); // if (rec.EdgeId == rec.StdEdgeId) // { // rec.Correct = true; // correctNumber++; // } // else // { // rec.Correct = false; // } // if (lineNumber > 1) // { // Record prev = list[lineNumber - 2]; // rec.Distance = LayerTools.GetDistance(rec.Lng, rec.Lat, prev.Lng, prev.Lat); // } // else // { // rec.Distance = 0; // } // list.Add(rec); // } // inSr.Close(); // sr.Close(); // stdSr.Close(); // //显示正确率 // lbCorrectRate.Text = (correctNumber * 1.0 / lineNumber).ToString(); // dgvCmp.AutoGenerateColumns = true; // dgvCmp.DataSource = list; // //更改背景颜色 // DataGridViewRowCollection rows = dgvCmp.Rows; // //int correct_idx = dgvCmp.Columns.Count - 2; // int correct_idx = dgvCmp.Columns["Correct"].Index; // for (int i = 0; i < rows.Count; i++) // { // bool correct = (bool)rows[i].Cells[correct_idx].Value; // if (!correct) // { // rows[i].DefaultCellStyle.BackColor = Color.Red; // } // } // dgvCmp.Columns["Time"].Width = 50; // dgvCmp.Columns["Lat"].Width = 100; // dgvCmp.Columns["Lng"].Width = 100; // dgvCmp.Columns["EdgeId"].Width = 60; // dgvCmp.Columns["StdEdgeId"].Width = 60; // dgvCmp.Columns["Distance"].Width = 60; // dgvCmp.Columns["Confidence"].Width = 30; // dgvCmp.Columns["Correct"].Width = 40; // dgvCmp.Refresh(); //} /// <summary> /// Read the matched trajectory file /// </summary> /// <param name="inputfile"></param> private void cmpFile(string inputfile) { StreamReader inSr = new StreamReader(inputfile); int lineNumber = 0; String inLine; List <Record> list = new List <Record>(); while (!inSr.EndOfStream) { inLine = inSr.ReadLine(); lineNumber++; Record rec = new Record(); String[] fields = inLine.Split(','); rec.Time = fields[0]; //rec.Time = int.Parse(fields[0]); rec.Lat = double.Parse(fields[1]); rec.Lng = double.Parse(fields[2]); rec.EdgeId = int.Parse(fields[3]); if (lineNumber > 1) { Record prev = list[lineNumber - 2]; rec.Distance = LayerTools.GetDistance(rec.Lng, rec.Lat, prev.Lng, prev.Lat); } else { rec.Distance = 0; } list.Add(rec); } inSr.Close(); dgvCmp.AutoGenerateColumns = true; dgvCmp.DataSource = list; dgvCmp.Columns["Time"].Width = 100; dgvCmp.Columns["Lat"].Width = 100; dgvCmp.Columns["Lng"].Width = 100; dgvCmp.Columns["EdgeId"].Width = 60; dgvCmp.Columns["StdEdgeId"].Width = 60; dgvCmp.Columns["Distance"].Width = 60; //dgvCmp.Columns["Confidence"].Width = 30; dgvCmp.Columns["Correct"].Width = 40; dgvCmp.Refresh(); }