Пример #1
0
        public void GenerateFCM(ConnectionsXMLModel connectionsXmlModel, EdgesXMLModel edgesXmlModel, NodesXMLModel nodesXmlModel)
        {
            _fcmNodes = new List<FCMNode>();
            _fcmEdges = new List<FCMEdge>();

            _connectionsXmlModel = connectionsXmlModel;
            _edgesXmlModel = edgesXmlModel;
            _nodesXmlModel = nodesXmlModel;

            foreach (var sumoConnection in connectionsXmlModel.connection)
            {
                var fcmNodeFrom = GetFcmNode(sumoConnection.from);
                fcmNodeFrom.Id = sumoConnection.from;

                var fcmNodeTo = GetFcmNode(sumoConnection.to);
                fcmNodeTo.Id = sumoConnection.to;

                var newFcmEdge = new FCMEdge();
                newFcmEdge.From = fcmNodeFrom;
                newFcmEdge.To = fcmNodeTo;
                newFcmEdge.Id = sumoConnection.from + sumoConnection.to;

                fcmNodeFrom.OutEdges.Add(newFcmEdge);
                fcmNodeTo.InEdges.Add(newFcmEdge);

                _fcmEdges.Add(newFcmEdge);
            }
        }
Пример #2
0
        /// <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);
                }
            }
        }