private static void PrepareNode(NodeDisabledMovementDTO n) { n.PreviousNode = null; n.CurrentDistance = Double.MaxValue; n.EstimateDistanceToEnd = Double.MaxValue; n.FScore = Double.MaxValue; n.PreviousNodeR = null; n.CurrentDistanceR = Double.MaxValue; n.MultiLabelMark.Clear(); n.Settled = false; n.Unsettled = false; n.SettledR = false; n.UnsettledR = false; }
public static void PrepareDisabledMovementGraph() { DisabledMovementGraph = new Dictionary <Node, NodeGraphDTO>(NodesGraph); NodesTempEnd = new Dictionary <Node, List <KeyValuePair <NodeDisabledMovementDTO, double> > >(); NodesTempStart = new Dictionary <Node, List <KeyValuePair <NodeDisabledMovementDTO, double> > >(); foreach (var n in NodesGraph) { foreach (Edge e in n.Key.EdgeStartNodeNavigation) { NodeDisabledMovementDTO ndm = new NodeDisabledMovementDTO() { NodeFirst = n.Key, Node = new Node() { IdNode = e.EndNodeNavigation.IdNode, Lat = e.EndNodeNavigation.Lat, Lon = e.EndNodeNavigation.Lon }, }; ndm.Node.NodeGraphDTO = ndm; DisabledMovementGraph.Add(ndm.Node, ndm); if (!NodesTempEnd.Keys.Contains(e.EndNodeNavigation)) { NodesTempEnd.Add(e.EndNodeNavigation, new List <KeyValuePair <NodeDisabledMovementDTO, double> >()); } NodesTempEnd[e.EndNodeNavigation].Add(new KeyValuePair <NodeDisabledMovementDTO, double>(ndm, e.DistanceInMeters)); if (!NodesTempStart.Keys.Contains(n.Key)) { NodesTempStart.Add(n.Key, new List <KeyValuePair <NodeDisabledMovementDTO, double> >()); } NodesTempStart[n.Key].Add(new KeyValuePair <NodeDisabledMovementDTO, double>(ndm, e.DistanceInMeters)); } } foreach (var n in NodesGraph) { if (NodesTempEnd.Keys.Contains(n.Key)) { foreach (KeyValuePair <NodeDisabledMovementDTO, double> ndmEnd in NodesTempEnd[n.Key]) { if (NodesTempStart.Keys.Contains(n.Key)) { foreach (KeyValuePair <NodeDisabledMovementDTO, double> ndmStart in NodesTempStart[n.Key]) { bool disMov = false; if (DisabledMovement.Keys.Contains(n.Key)) { foreach (DisabledMovement dm in DisabledMovement[n.Key]) { if (ndmEnd.Key.NodeFirst.Equals(dm.StartEdgeNavigation.StartNodeNavigation) && ndmStart.Key.Node.IdNode.Equals(dm.EndEdgeNavigation.EndNodeNavigation.IdNode)) { disMov = true; break; } } } if (!disMov) { Edge edge = new Edge() { DistanceInMeters = ndmStart.Value, EndNodeNavigation = ndmStart.Key.Node, StartNodeNavigation = ndmEnd.Key.Node }; ndmEnd.Key.Node.EdgeStartNodeNavigation.Add(edge); ndmStart.Key.Node.EdgeEndNodeNavigation.Add(edge); } } } } } } }