/// <summary> /// Constructs an instance of ExtendedCalculator. By constructing /// an object of type ExtendedCalculator, you automatically initiate /// the calculation of a path between two points, according to a given /// planning mode (shortest, quickest, etc.). /// </summary> public ExtendedCalculator(double range, Battery battery, int fromID, int toID) { LocationCtr locCtr = new LocationCtr(); this.From = locCtr.FindLocation(fromID); this.To = locCtr.FindLocation(toID); Console.WriteLine("[DEBUG MESSAGE]: ExtendedCalculator() Start "); // Initializes graph field along with Distance and Path properties. // Finds the most compatible locations based on the given coordinates // and initializes the From and To properties with the existing locations. InitializeCalculator(range, 10, 5, 10, 5); // Initialize the graph used for calculating the path // TODO: Implement planningMode. batteryType irrelevant here, it's not used? GenerateGraph("plan", battery.BatteryType); try { CalculatePath(From, To); } catch (Exception e) { Console.WriteLine("[DEBUG MESSAGE]: Error occured in CalculatePath(): {0}", e.Message); } Console.WriteLine("[DEBUG MESSAGE]: ExtendedCalculator() End"); }
public Route PlanRoute(int fromID, int toID, int batteryID) { LocationCtr locationCtr = new LocationCtr(); this.From = locationCtr.FindLocation(fromID); this.To = locationCtr.FindLocation(toID); To.GeoCoordinate.Longitude = To.Longitude; To.GeoCoordinate.Latitude = To.Latitude; GenerateGraph(); this.queue = new PriorityQueue(graph.Count()); route.Range = new BatteryCtr().CalculateRange(batteryID); route.Path = CalculatePath(); route.Distance = GetDistanceList(route.Path); return route; }
public Route PlanRoute(int fromID, int toID, int batteryID) { BatteryCtr batteryCtr = new BatteryCtr(); LocationCtr locationCtr = new LocationCtr(); this.From = locationCtr.FindLocation(fromID); this.To = locationCtr.FindLocation(toID); // Initialize graph GenerateGraph(); // Calculate distance the vehicle can travel before recharging route.Range = batteryCtr.CalculateRange(batteryID); // Determine shortest path using Dijsktras Shortest Path Algorithm route.Path = CalculatePath(); route.Distance = GetDistanceList(route.Path); return route; }
public string GetMapRouteUrl(List<int> routePath) { string mapUrl = "http://www.google.com/maps/dir/"; LocationCtr locationCtr = new LocationCtr(); List<Location> routeLocations = routePath.Select(i => locationCtr.FindLocation(i)).ToList(); foreach (var i in routeLocations) { mapUrl += i.Latitude.ToString().Replace(',', '.') + "," + i.Longitude.ToString().Replace(',', '.') + "/"; } return mapUrl; }