// Content Manager Update Script // Currently not a WebMethod as incomplete public void UpdateMaps() { //GET AND PROCESS DATA INTO WaypointData dataSource AND SortedList<int, WaypointData> data // FAKE DATA - FAILS DUE TO EMPTY WaypointData dataSource = new WaypointData(); SortedList<int, WaypointData> data = new SortedList<int, WaypointData>(); // Initialise test variables SortedList<int, WaypointData> dataEdges = new SortedList<int, WaypointData>(); SortedList<int, WaypointData> dataEdgesDis = new SortedList<int, WaypointData>(); // Set min path dist to 0 for source node dataSource.minDist = 0f; // Add source node to process que dataEdges.Add(dataSource.waypointID, dataSource); // Until the path que is empty while (dataEdges.Count != 0) { // Get the waypointID of the current node int key = dataEdges.First().Key; // Then get the current node WaypointData current = dataEdges[key]; // For every node that current is linked to foreach (int i in current.edgeKeys) { // Find the edge node WaypointData edge = data[i]; // Get dist using Tan(adj/opp) double distX = current.coordX - edge.coordX; double distY = current.coordY - edge.coordY; double dist = Math.Tan(distX / distY); // Get total distance from source to edge node double edgeDist = current.minDist + dist; // If the distance along this path is shorter than the current path for the edge node if (edgeDist < edge.minDist) { // Remove the edge node from the que dataEdges.Remove(i); // Update the local-stored edge node edge.minDist = edgeDist; edge.waypointIDPrev = key; // Update global node data[i] = edge; // Reinsert edge node to que with updated values dataEdges.Add(i, edge); } } // When all processing for the current node is done remove from the processing que dataEdges.Remove(key); } // Set min disabled path dist to 0 for source node dataSource.minDistDis = 0f; // Add source node to disabled process que dataEdgesDis.Add(dataSource.waypointID, dataSource); // Until the disabled path que is empty while (dataEdgesDis.Count != 0) { // Get the waypointID of the current node int key = dataEdgesDis.First().Key; // Then get the current node WaypointData current = dataEdgesDis[key]; // For every node that current is linked to foreach (int i in current.edgeKeys) { // Find the edge node WaypointData edge = data[i]; // Get dist using Tan(adj/opp) double distX = current.coordX - edge.coordX; double distY = current.coordY - edge.coordY; double dist = Math.Tan(distX / distY); // Get total distance from source to edge node double edgeDist = current.minDistDis + dist; // If the distance along this path is shorter than the current path for the edge node if (edgeDist < edge.minDistDis) { // Remove the edge node from the que dataEdgesDis.Remove(i); // Update the local-stored edge node edge.minDist = edgeDist; edge.waypointIDPrevDis = key; // Update global node data[i] = edge; // Reinsert edge node to que with updated values dataEdgesDis.Add(i, edge); } } // When all processing for the current node is done remove from the processing que dataEdgesDis.Remove(key); } // Transform all the WaypointData objects to regular Waypoints List<Waypoint> result = new List<Waypoint>(); foreach (WaypointData wd in data.Values) { result.Add(wd.ToWaypoint()); } //UPDATE DATABASE }
// Content Manager Update Script // Currently not a WebMethod as incomplete public void UpdateMaps() { //GET AND PROCESS DATA INTO WaypointData dataSource AND SortedList<int, WaypointData> data // FAKE DATA - FAILS DUE TO EMPTY WaypointData dataSource = new WaypointData(); SortedList <int, WaypointData> data = new SortedList <int, WaypointData>(); // Initialise test variables SortedList <int, WaypointData> dataEdges = new SortedList <int, WaypointData>(); SortedList <int, WaypointData> dataEdgesDis = new SortedList <int, WaypointData>(); // Set min path dist to 0 for source node dataSource.minDist = 0f; // Add source node to process que dataEdges.Add(dataSource.waypointID, dataSource); // Until the path que is empty while (dataEdges.Count != 0) { // Get the waypointID of the current node int key = dataEdges.First().Key; // Then get the current node WaypointData current = dataEdges[key]; // For every node that current is linked to foreach (int i in current.edgeKeys) { // Find the edge node WaypointData edge = data[i]; // Get dist using Tan(adj/opp) double distX = current.coordX - edge.coordX; double distY = current.coordY - edge.coordY; double dist = Math.Tan(distX / distY); // Get total distance from source to edge node double edgeDist = current.minDist + dist; // If the distance along this path is shorter than the current path for the edge node if (edgeDist < edge.minDist) { // Remove the edge node from the que dataEdges.Remove(i); // Update the local-stored edge node edge.minDist = edgeDist; edge.waypointIDPrev = key; // Update global node data[i] = edge; // Reinsert edge node to que with updated values dataEdges.Add(i, edge); } } // When all processing for the current node is done remove from the processing que dataEdges.Remove(key); } // Set min disabled path dist to 0 for source node dataSource.minDistDis = 0f; // Add source node to disabled process que dataEdgesDis.Add(dataSource.waypointID, dataSource); // Until the disabled path que is empty while (dataEdgesDis.Count != 0) { // Get the waypointID of the current node int key = dataEdgesDis.First().Key; // Then get the current node WaypointData current = dataEdgesDis[key]; // For every node that current is linked to foreach (int i in current.edgeKeys) { // Find the edge node WaypointData edge = data[i]; // Get dist using Tan(adj/opp) double distX = current.coordX - edge.coordX; double distY = current.coordY - edge.coordY; double dist = Math.Tan(distX / distY); // Get total distance from source to edge node double edgeDist = current.minDistDis + dist; // If the distance along this path is shorter than the current path for the edge node if (edgeDist < edge.minDistDis) { // Remove the edge node from the que dataEdgesDis.Remove(i); // Update the local-stored edge node edge.minDist = edgeDist; edge.waypointIDPrevDis = key; // Update global node data[i] = edge; // Reinsert edge node to que with updated values dataEdgesDis.Add(i, edge); } } // When all processing for the current node is done remove from the processing que dataEdgesDis.Remove(key); } // Transform all the WaypointData objects to regular Waypoints List <Waypoint> result = new List <Waypoint>(); foreach (WaypointData wd in data.Values) { result.Add(wd.ToWaypoint()); } //UPDATE DATABASE }