Пример #1
0
        public Setup(TextBox Logs)
        {
            textBox = Logs;
            PrintLog("Wczytywanie");
            cars          = new List <Car>();
            crossings     = new List <Crossing>();
            trafficLights = new List <Node>();
            genSum        = new List <long>();
            genChangeTime = new List <double[]>();

            new Task(() =>
            {
                loadMapNodes = new LoadMapNodes();
                PrintLog("Wczytano");
            }).Start();
        }
Пример #2
0
        public static List <Node> GetRoad(Point begining, Point ending)
        {
            string         osrmResponse = "";
            string         beginPointX  = begining.X.ToString().Replace(",", ".");
            string         beginPointY  = begining.Y.ToString().Replace(",", ".");
            string         endingPointX = ending.X.ToString().Replace(",", ".");
            string         endingPointY = ending.Y.ToString().Replace(",", ".");
            string         url          = Variables.OSRM_URL + beginPointX + "," + beginPointY + ";" + endingPointX + "," + endingPointY + "?annotations=nodes";
            HttpWebRequest request      = (HttpWebRequest)WebRequest.Create(url);

            request.AutomaticDecompression = DecompressionMethods.GZip;

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                {
                    osrmResponse = reader.ReadToEnd();
                }
            JObject     j     = JObject.Parse(osrmResponse);
            List <long> ids   = GetRoadNodes(j);
            List <Node> nodes = LoadMapNodes.LoadNodesFromRouteId(ids);

            return(nodes);
        }