/// <summary> /// shortest_path����ʹ�õ���Dijkstra�㷨 /// �������ٸĽ����룬ѡ�в�ͬ���㷨ʱ��ʾ��ͬ�IJ������ý��� /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnGetSPath_Click(object sender, EventArgs e) { string ftablename; string tablename; string geoColumn; string algorithm; ftablename = layerName + "_newlines"; geoColumn = "geom"; tablename = ""; string start = this.textBoxStartPoint.Text.Trim(); string end = this.textBoxEndPoint.Text.Trim(); algorithm = cbxAlgorithm.SelectedItem.ToString().Trim(); SetRoadLength(ftablename, geoColumn, "2345"); ShortestPath spath = new ShortestPath(postDB); Timing timeRecorder = new Timing(); switch (algorithm) { case "Dijkstra": timeRecorder.Start(); spath.ComputePath(algorithm,ftablename,start,end); tablename = layerName + "_dijkstra"; timeRecorder.Stop(); TimeCost = timeRecorder.Result(); break; case "Astar": SetCoordinate(ftablename, geoColumn); timeRecorder.Start(); spath.ComputePath(algorithm, ftablename, start, end); tablename = layerName + "_astar"; timeRecorder.Stop(); TimeCost = timeRecorder.Result(); break; case "BdDijkstra": timeRecorder.Start(); spath.ComputePath(algorithm, ftablename, start, end); tablename = layerName + "_bddijkstra"; timeRecorder.Stop(); TimeCost = timeRecorder.Result(); break; case "BdAstar": SetCoordinate(ftablename, geoColumn); timeRecorder.Start(); spath.ComputePath(algorithm,ftablename,start,end); tablename = layerName + "_bdastar"; timeRecorder.Stop(); TimeCost = timeRecorder.Result(); break; default: break; /* case "ShootingStar": start = this.txtStartEdge.Text.ToString(); end = this.txtEndEdge.Text.ToString(); SetCoordinate(ftablename, geoColumn); SetCostColumn(ftablename); spath.ShootingStar(ftablename, start, end); tablename = layerName + "_shootingstar"; UpdateShortestResult(ftablename, tablename); break; * */ } this.txtCostTime.Text = TimeCost.ToString(); GvwData.DataSource = GetData(tablename); }
//private void btnMetisPolygon_Click(object sender, EventArgs e) //{ // //���ɷ����ĵ����������һ�ַ����Ķ���ν��жԱ� // string sqlstr, tablename,metisColName,partitionNum,geomTxt,resultTable; // DataTable tmpdt; // int pNum; // tablename=layerName+"_vertex_adjaction"; // metisColName="metispartition_" + algorithmName; // //metisColName = "metispartition_rb"; // sqlstr = "select count(" + metisColName + ") from " + tablename; // tmpdt=postDB.DoQueryEx(sqlstr); // partitionNum = tmpdt.Rows[0]["count"].ToString(); // pNum = int.Parse(partitionNum); // //��������Ƿ���� // resultTable = layerName + "_polygon_metis_" + algorithmName; // //resultTable = layerName + "_polygon_metis_rb"; // //gid��Ϊ�����Ƶĵ�ķ������ // sqlstr = "create table " + resultTable + " " + "(gid integer,geom geometry)"; // postDB.CheckCreateTable(resultTable, sqlstr); // for (int i = 0; i < pNum;i++ ) // { // sqlstr = "select st_astext(st_convexhull(st_collect(geom))) as geom from " + tablename + " " + "where " + metisColName + "=" + i.ToString(); // tmpdt = postDB.DoQueryEx(sqlstr); // geomTxt = tmpdt.Rows[0]["geom"].ToString(); // sqlstr = "INSERT INTO" + " " + resultTable + " " + "(gid,geom) values (" + i.ToString() + "," + "st_geomfromtext('" + geomTxt + "', 4326))"; // postDB.ExecNonQuery(sqlstr); // } // GvwData.DataSource = GetData(resultTable); //} private void btnHierarchyAlgorthm_Click(object sender, EventArgs e) { string ftablename, start, end, algorithm, tablename; ftablename = layerName + "_newlines"; start = this.textBoxStartPoint.Text.Trim(); end = this.textBoxEndPoint.Text.Trim(); algorithm = cbxAlgorithm.SelectedItem.ToString().Trim(); tablename = ""; HierarchyAlgorithms ha = new HierarchyAlgorithms(postDB); Timing timeRecorder = new Timing(); switch (algorithm) { case "Dijkstra": timeRecorder.Start(); ha.Dijkstra(ftablename, start, end); tablename = layerName + "_hierarchydijkstra"; timeRecorder.Stop(); TimeCost = timeRecorder.Result(); UpdateShortestResult(ftablename, tablename); break; case "Astar": timeRecorder.Start(); ha.Astar(ftablename, start, end); tablename = layerName + "_hierarchyastar"; timeRecorder.Stop(); TimeCost = timeRecorder.Result(); UpdateShortestResult(ftablename, tablename); break; default: break; } this.txtCostTime.Text = TimeCost.ToString(); GvwData.DataSource = GetData(tablename); }
private void btnBDAlgorithm_Click(object sender, EventArgs e) { string ftablename, start, end, algorithm, tablename, geoColumn; ftablename = layerName + "_newlines"; start = this.textBoxStartPoint.Text.Trim(); end = this.textBoxEndPoint.Text.Trim(); algorithm = cbxBdAlgorithms.SelectedItem.ToString().Trim(); tablename = ""; geoColumn = "geom"; BiHiAlgorithms bh = new BiHiAlgorithms(postDB); Timing timeRecorder = new Timing(); switch (algorithm) { case "BdDijkstra": timeRecorder.Start(); bh.ComputePath(algorithm, ftablename, start, end); tablename = layerName + "_hierarchy_bddijkstra"; timeRecorder.Stop(); TimeCost = timeRecorder.Result(); break; case "BdAstar": SetCoordinate(ftablename, geoColumn); timeRecorder.Start(); bh.ComputePath(algorithm, ftablename, start, end); tablename = layerName + "_hierarchy_bdastar"; timeRecorder.Stop(); TimeCost = timeRecorder.Result(); break; default: break; } this.txtCostTime.Text = TimeCost.ToString(); GvwData.DataSource = GetData(tablename); }