Exemplo n.º 1
0
        public _prop_Closest FindRouteID(_prop_Closest input)
        {
            double sumOfDis     = 0;
            string routeID      = "";
            int    countRouteID = 0;

            for (int i = 0; i < input.lat.Count - 1; i++)
            {
                double tmp_dis = 0;

                if (input.flag[i] != 0)
                {
                    tmp_dis = Distance(input.lat[i], input.lon[i], input.lat[i + 1], input.lon[i + 1]);
                }
                else
                {
                    string tmpEngine = Routing(input.lat[i].ToString(), input.lon[i].ToString(), input.lat[i + 1].ToString(), input.lon[i + 1].ToString());


                    string tmp_1Route = "";

                    if (!string.IsNullOrEmpty(tmpEngine.Trim()))
                    {
                        string[] tmpRes_arr = tmpEngine.Split(';');

                        // tmpDis (Km.) / Engine return (m.)
                        tmp_dis = Convert.ToDouble(tmpRes_arr[0]) / 1000.0;


                        for (int j = 1; j < tmpRes_arr.Length; j++)
                        {
                            tmp_1Route += tmpRes_arr[j].ToString().Trim() + " ";
                            countRouteID++;
                        }
                        routeID += " " + tmp_1Route;
                        //routeID = ClearSpace(routeID);
                        //if( routeID.Split(' ').Length >1000)
                        //{
                        //    break;
                        //}
                        if (countRouteID > 1000)
                        {
                            break;
                        }
                    }
                    else
                    {
                        tmp_dis = Distance(input.lat[i], input.lon[i], input.lat[i + 1], input.lon[i + 1]);
                    }
                }
                sumOfDis += tmp_dis;
                if (sumOfDis >= LIMIT_DIS)
                {
                    break;
                }
            }

            input.routeID = routeID;
            return(input);
        }
Exemplo n.º 2
0
        public _prop_Closest Format(_prop_Closest input, string turnNode)
        {
            try
            {
                string[] tmpAll = turnNode.Split('|');

                for (int i = 0; i < tmpAll.Length; i++)
                {
                    string[] tmpnode = tmpAll[i].Split(',');

                    input.lat.Add(Convert.ToDouble(tmpnode[0]));
                    input.lon.Add(Convert.ToDouble(tmpnode[1]));

                    input.flag.Add(Convert.ToInt32(tmpnode[2]));
                }

                return(input);
            }
            catch
            { return(null); }
        }