/// <summary>
        /// Generuje pelny graf na podstawie danych wygenerowanych przez sumo do xml
        /// Dane z SUMO to output laneData.
        /// </summary>
        /// <param name="lanesFromXmlOutputData"></param>
        public void GenerateFcm(LanesFromXmlOutput lanesFromXmlOutputData)
        {
            _fcmNodes = new List<FCMNode>();
            _fcmEdges = new List<FCMEdge>();
            FCMNode tempFcmNode;

            var edgesFromFirstInterval = lanesFromXmlOutputData.Items.First().edges;
            int counter = 0;
            foreach (var edge in edgesFromFirstInterval)
            {
                foreach (var simpleLane in edge.lane)
                {
                    tempFcmNode = new FCMNode();
                    tempFcmNode.Id = simpleLane.id;
                    _fcmNodes.Add(tempFcmNode);//[counter++] = tempFcmNode;
                }
            }

            FCMNode toFcmNode;
            FCMNode fromFcmNode;
            FCMEdge fcmEdge;
            for (int fromIndex = 0; fromIndex < _fcmNodes.Count; fromIndex++)
            {
                fromFcmNode = _fcmNodes[fromIndex];
                for (int toIndex = 0; toIndex < _fcmNodes.Count; toIndex++)
                {
                    if(fromIndex == toIndex)
                        continue;

                    toFcmNode = _fcmNodes[toIndex];

                    fcmEdge = new FCMEdge();
                    fcmEdge.From = fromFcmNode;
                    fcmEdge.To = toFcmNode;
                    fcmEdge.Id = fromFcmNode.Id + "_" + toFcmNode.Id;

                    fromFcmNode.OutEdges.Add(fcmEdge);
                    toFcmNode.InEdges.Add(fcmEdge);
                    _fcmEdges.Add(fcmEdge);
                }
            }
        }
Esempio n. 2
0
        private FCMNode GetFcmNode(string sumoConnectionId)
        {
            FCMNode resultFcmNode;
            var sumoEdgeFromOrTo = _edgesXmlModel.edge.First(edge => edge.id.Equals(sumoConnectionId));
            if (!sumoEdgeFromOrTo.Visited)//czyli jeszcze nie bylo narysowane
            {
                resultFcmNode = new FCMNode();
                resultFcmNode.Coordinates = ComputeSectionCenter(sumoEdgeFromOrTo);
                _fcmNodes.Add(resultFcmNode);//zrefaktoryzowac!!

                sumoEdgeFromOrTo.Visited = true;
            }
            else
            {
                resultFcmNode = _fcmNodes.First(x => x.Id.Equals(sumoEdgeFromOrTo.id));
            }

            return resultFcmNode;
        }