Exemplo n.º 1
0
 //public string ProductRoute(DataSet ds)
 //{
 //    string route = "";
 //    if (ds.Tables[0].Rows.Count > 1)
 //    {
 //        for (int i = 0; i < ds.Tables[0].Rows.Count - 1; i++)
 //        {
 //            string from = Convert.ToString(int.Parse(ds.Tables[0].Rows[i]["StationX"].ToString()) + 25) + "," + Convert.ToString(int.Parse(ds.Tables[0].Rows[i]["StationY"].ToString()) + 20);
 //            string to = Convert.ToString(int.Parse(ds.Tables[0].Rows[i + 1]["StationX"].ToString()) + 25) + "," + Convert.ToString(int.Parse(ds.Tables[0].Rows[i + 1]["StationY"].ToString()) + 20);
 //            if (route == "")
 //            {
 //                route = route + GetRoutePath(from, to);
 //            }
 //            else 
 //            {
 //                string routetemp = GetRoutePath(from, to);
 //                route = route + "," + routetemp.Substring(routetemp.IndexOf("||"));
 //            }
 //        }
 //    }
 //    return route;
 //}
 public string ProductRoutePoint(System.Windows.Forms.Form form,System.Windows.Forms.ProgressBar pgb)
 {
     if (new RouteDAL().GetNumOfRoute() > 0)
     {
         ZzhaStationDAL zzhastationdal = new ZzhaStationDAL();
         zzhastationdal.DelAllPoint();
         List<ZzhaStation> list = zzhastationdal.GetAllStations();
         if (list.Count > 0)
         {
             //for (int i = 0; i < list.Count; i++)
             //{
             //    for (int j = i + 1; j < list.Count; j++)
             //    {
             //        string routepath = GetRoutePath(list[i].Position, list[j].Position);
             //        string[] point = routepath.Split('|');
             //        for (int k = 0; k < point.Length; k++)
             //        {
             //            string[] xy = point[k].Split(',');
             //            if (!new ZzhaStationDAL().InsertPoint(list[i].StationAddressNum + "," + list[j].StationAddressNum, double.Parse(xy[0]), double.Parse(xy[1])))
             //                flag = false;
             //        }
             //    }
             //}
             Hashtable ht = this.GetRouteTable(list,form, pgb);
             if (ht.Count > 0)
             {
                 //float step = 100 /(float) ht.Count;
                 //float value = 0;
                 string savestring = "begin ";
                 foreach (DictionaryEntry de in ht)
                 {
                     string pointid = de.Key.ToString();
                     string[] routepoints = ((RouteLength)de.Value).RouteList.Split('|');                            
                     for (int i = 0; i < routepoints.Length; i++)
                     {
                         string[] xy = routepoints[i].Split(',');
                         savestring = savestring + zzhastationdal.InsertPoint(pointid, double.Parse(xy[0]), double.Parse(xy[1]));
                     }
                     //value += step;
                     //pgb.Value = Convert.ToInt32(value);
                 }
                 savestring = savestring + " end";
                 zzhastationdal.SavePoint(savestring);
                 return "生成路径点成功";
             }
             else
             {
                 return "生成路径点失败";
             }
         }
         else
         {
             return "基站尚未配置";
         }
     }
     else
     {
         return "路径尚未配置";
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 生成路径点集合的哈希表 
        /// </summary>
        /// <param name="stationlist"></param>
        /// <param name="form"></param>
        /// <param name="pgb"></param>
        /// <param name="fileid"></param>
        /// <returns></returns>
        public Hashtable CzltGetRouteTable(List<ZzhaStation> stationlist, System.Windows.Forms.Form form, System.Windows.Forms.ProgressBar pgb, string fileid)
        {
            Hashtable nowRoulentable = new Hashtable();
            Hashtable roulentable = new Hashtable();
            Hashtable stationmap = new ZzhaStationDAL().GetStationAddress();
            List<RouteModel> routelist = this.GetAllRoute(fileid);
            float value = 0;
            float step = 100 / (float)stationlist.Count;
            for (int i = 0; i < stationlist.Count - 1; i++)
            {
                form.Refresh();
                CzltSerachRoute(roulentable, routelist, stationlist[i].Position, 0, stationlist[i].Position, stationlist[i].Position, stationmap);
                value += step;
                pgb.Value = Convert.ToInt32(value);
            }


            if (roulentable.Count > 0)
            {
                nowRoulentable = GetHashStation(roulentable, stationlist, form, pgb, step);

            }

            return nowRoulentable;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 寻找路径点
        /// </summary>
        /// <param name="strStationAddress"></param>
        /// <param name="endStationAddress"></param>
        /// <param name="fileid"></param>
        /// <returns></returns>
        private string GetWayByStaIDT(string strStationAddress, string endStationAddress, string fileid)
        {
            string strPath = string.Empty;
            Hashtable ht = new Hashtable();
            List<ZzhaStation> list = zzhastationdal.GetAllStations();
            Hashtable stationmap = new ZzhaStationDAL().GetStationAddress();
            List<RouteModel> routelist = this.GetAllRoute(fileid);
            List<RouteLength> newRouteLengthList = new List<RouteLength>();
            List<RouteLength> oldRouteLengthList = new List<RouteLength>();
           // Hashtable nowRoulentable = CzltGetRouteTable(list, new Form(), new ProgressBar(), fileid);
            for (int i = 0; i < list.Count - 1; i++)
            {
               // form.Refresh();
                CzltSerachRoute(oldRouteLengthList, routelist, list[i].Position, 0, list[i].Position, list[i].Position, stationmap);
                //value += step;
                //pgb.Value = Convert.ToInt32(value);
            }
            bool tempFlag1 = false;
            SerachRoute20110226(oldRouteLengthList, newRouteLengthList, strStationAddress, endStationAddress, "", strStationAddress, "", 0, "", 0, false, ref tempFlag1);

            if (newRouteLengthList.Count > 0)
            {
                for (int j = 0; j < newRouteLengthList.Count; j++)
                {
                    ht.Add(newRouteLengthList[j].Key, newRouteLengthList[j].RouteList);
                    strPath = strPath + newRouteLengthList[j].RouteList + "|";
                }
            }

            //插入数据库
            SqlBulkInsert(ht, fileid);        


             return strPath;
        }
Exemplo n.º 4
0
 public Hashtable GetRouteTable(List<ZzhaStation> stationlist)
 {
     Hashtable roulentable = new Hashtable();
     Hashtable stationmap = new ZzhaStationDAL().GetStationAddress();
     List<RouteModel> routelist = this.GetAllRoute();
     for (int i = 0; i < stationlist.Count - 1; i++)
     {
         SerachRoute(roulentable, routelist, stationlist[i].Position, 0, stationlist[i].Position, stationlist[i].Position, stationmap);
     }
     return roulentable;
 }
Exemplo n.º 5
0
 public string ProductRoutePoint()
 {
     if (new RouteDAL().GetNumOfRoute() > 0)
     {
         ZzhaStationDAL zzhastationdal = new ZzhaStationDAL();
         zzhastationdal.DelAllPoint();
         List<ZzhaStation> list = zzhastationdal.GetAllStations();
         if (list.Count > 0)
         {
             //for (int i = 0; i < list.Count; i++)
             //{
             //    for (int j = i + 1; j < list.Count; j++)
             //    {
             //        string routepath = GetRoutePath(list[i].Position, list[j].Position);
             //        string[] point = routepath.Split('|');
             //        for (int k = 0; k < point.Length; k++)
             //        {
             //            string[] xy = point[k].Split(',');
             //            if (!new ZzhaStationDAL().InsertPoint(list[i].StationAddressNum + "," + list[j].StationAddressNum, double.Parse(xy[0]), double.Parse(xy[1])))
             //                flag = false;
             //        }
             //    }
             //}
             Hashtable ht=this.GetRouteTable(list);
             if (ht.Count > 0)
             {
                 foreach(DictionaryEntry de in ht)
                 {
                     string pointid = de.Key.ToString();
                     string[] routepoints = ((RouteLength)de.Value).RouteList.Split('|');
                     for (int i = 0; i < routepoints.Length; i++)
                     {
                         string[] xy = routepoints[i].Split(',');
                         zzhastationdal.InsertPoint(pointid, double.Parse(xy[0]), double.Parse(xy[1]));
                     }
                 }
                 return "生成路径点成功";
             }
             else
             {
                 return "生成路径点失败";
             }
         }
         else
         {
             return "基站尚未配置";
         }
     }
     else
     {
         return "路径尚未配置";
     }
 }