// Returns SOAP-Parsed Object with all map-generation data public SOAP_ResolvePath ResolvePath(int WaypointID, bool Disability) { // Get objects containing source Waypoint source = db.GetWaypoints("Waypoint_ID = '" + WaypointID + "'")[WaypointID]; Building sourceBuilding = db.GetBuildings("Building_ID = '" + source.buildingID + "'")[source.buildingID]; Campus sourceCampus = db.GetCampuses("Campus_ID = '" + sourceBuilding.campusID + "'")[sourceBuilding.campusID]; int isService = db.ServiceColor(WaypointID); // Get all collection of objects to be searched once to avoid continious Database queries SortedList <int, Waypoint> searchable = db.GetWaypoints("Building_ID = '" + source.buildingID + "'"); List <Floor> searchableFloors = db.GetFloors("Building_ID = '" + sourceBuilding.buildingID + "'"); // Initialise loop variables List <Waypoint> sequence = new List <Waypoint>(); Waypoint current = source; // While current node to be processed exists while (current != null) { // Add the current node to the sequence sequence.Add(current); // If Disabled, and the current nodes disabled-previous node is not -1 (aka an int null) if (Disability && (current.waypointIDPrevDis != -1)) { // Set the diabled-previous node to current, by searching for node in SortedList with int key current = searchable[current.waypointIDPrevDis]; } // If Not Disabled, and the current nodes previous node is not -1 (aka an int null) else if (!Disability && (current.waypointIDPrev != -1)) { // Set the previous node to current, by searching for node in SortedList with int key current = searchable[current.waypointIDPrev]; } // Else if a previous node cant be found, then set current to null, to escape as the loop is finished else { current = null; } } // Reverse the sequence to start at enterance sequence.Reverse(); // Divide the sequence into thier floors // Initialise the loop variables List <List <Waypoint> > floorSequence = new List <List <Waypoint> >(); List <Waypoint> temp = new List <Waypoint>(); int currentFloor = sequence.First().floorID; // Foreach waypoint in the sequence foreach (Waypoint w in sequence) { // If the currents node floor is the same as the test-floor if (w.floorID == currentFloor) { // Add the node to the current floors List<Waypoint> w.roomName = w.roomName.Trim(); temp.Add(w); } // Otherwise the new node is on a new floor else { temp.Add(w); // Add the current floor-list to the list of floors floorSequence.Add(temp); // Create a new floor List<Waypoint> temp = new List <Waypoint>(); // Change the test floor ID currentFloor = w.floorID; } } // At the end, if the temp List<Waypoint> is not empty there is one last floor to add if (temp.Count != 0) { // Add the last floor floorSequence.Add(temp); } // Generate responses, and prepare images // Initialise response variables string[][] mapData = new string[floorSequence.Count][]; int i = 0; //** JACK, THIS SECTION REFERS TO YOU **// // For each floors List<Waypoint> foreach (List <Waypoint> floorList in floorSequence) { // Loop to find floor // NOTE: this is CPU inefficient to reduce DB queries to find floor Floor tempFloor = null; foreach (Floor f in searchableFloors) { if (f.floorID == floorList.First().floorID) { tempFloor = f; } } // Generate the floor-map name string buildingTitle = sourceBuilding.buildingName.Trim(); string floorTitle = "Floor " + tempFloor.floorID.ToString().Trim(); string mapTitle = buildingTitle + ", " + floorTitle; // returns the final image //string imagePath = ""; string room = source.roomName; if (isService != -1) { room = "X0" + isService; } string imagePath = new ImageProccessor().GenerateImage(tempFloor.floorMap, tempFloor.floorColorMap, room, floorList, 0, 0, 1); // Add return data mapData[i] = new string[] { mapTitle.Trim(), imagePath.Trim() }; // Increment index i++; } // Create return object SOAP_ResolvePath result = new SOAP_ResolvePath(sourceBuilding.buildingLat, sourceBuilding.buildingLong, sourceBuilding.buildingAddress, sourceBuilding.buildingPath, mapData); //Return return(result); }