private async void SetupRouteTask() { try { _routeTask = new OnlineRouteTask(new Uri(OnlineRoutingService)); _routeParams = await _routeTask.GetDefaultParametersAsync(); } catch (Exception ex) { var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync(); } }
private async void SetupRouteTask() { try { _routeTask = new OnlineRouteTask(new Uri(OnlineRoutingService)); _routeParams = await _routeTask.GetDefaultParametersAsync(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void Should_support_dynamic_casting_of_properties_to_ints() { //Given dynamic parameters = new RouteParameters(); parameters.test = "10"; // When var value = (int)parameters.test; // Then value.ShouldEqual(10); }
public void Should_support_dynamic_properties() { //Given dynamic parameters = new RouteParameters(); parameters.test = 10; // When var value = (int)parameters.test; // Then value.ShouldEqual(10); }
public void Should_support_dynamic_casting_of_properties_to_guids() { //Given dynamic parameters = new RouteParameters(); var guid = Guid.NewGuid(); parameters.test = guid.ToString(); // When var value = (Guid)parameters.test; // Then value.ShouldEqual(guid); }
public void Should_support_dynamic_casting_of_properties_to_datetimes() { //Given dynamic parameters = new RouteParameters(); parameters.test = new DateTime(2001, 3, 4); // When var value = (DateTime)parameters.test; // Then value.ShouldEqual(new DateTime(2001, 3, 4)); }
public void Should_support_casting_when_using_indexer_to_set_values() { // Given dynamic parameters = new RouteParameters(); parameters["test"] = "10"; // When int value = parameters.test; // Then value.ShouldEqual(10); }
public void Should_set_paramters_property_when_instantiated() { //Given, When Func<dynamic, Response> action = x => null; dynamic parameters = new RouteParameters(); parameters.foo = 10; parameters.bar = "value"; var route = new Route("/", parameters, null, action); // Then ((object)route.Parameters).ShouldBeSameAs((object)parameters); }
public Route(string path, RouteParameters parameters, Func<object, Response> action) { if (path == null) { throw new ArgumentNullException("path", "The path parameter cannot be null."); } if (action == null) { throw new ArgumentNullException("action", "The action parameter cannot be null."); } this.Path = path; this.Parameters = parameters; this.Action = action; }
public RoutingDirectionsTaskAsync() { InitializeComponent(); _locator = new Locator("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"); _routeTask = new RouteTask("http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/NAServer/Route"); _routeParams = new RouteParameters() { ReturnRoutes = false, ReturnDirections = true, DirectionsLengthUnits = esriUnits.esriMiles, Stops = _stops, UseTimeWindows = false, }; _routeGraphicsLayer = (MyMap.Layers["MyRouteGraphicsLayer"] as GraphicsLayer); }
public async Task FindRoute_Stop() { var mockResponse = await TestUtils.GetMockResponse("Route_Klaneettitie_Liisankatu.json"); var mockHandler = new MockHttpMessageHandler(mockResponse); var target = new ReittiopasClient("", "", mockHandler); var request = new RouteParameters() { From = new Coordinates(24.876620087474, 60.237461895493), To = new Coordinates(24.959322353265, 60.174058109457) }; IEnumerable<Route> routes = await target.FindRoute(request); routes.Should().HaveCount(3); var firstRoute = routes.ElementAt(0); firstRoute.Duration.TotalSeconds.Should().Be(2040); var firstLeg = firstRoute.Legs.First(); var legStart = firstLeg.Locations.First(); legStart.Coord.ShouldBeEquivalentTo(request.From); }
public void Should_invoke_action_with_parameters_when_invoked() { //Given RouteParameters capturedParameters = null; Func<dynamic, Response> action = x => { capturedParameters = x; return null; }; dynamic parameters = new RouteParameters(); parameters.foo = 10; parameters.bar = "value"; var route = new Route("/", parameters, null, action); // When route.Invoke(); // Then capturedParameters.ShouldBeSameAs((object)parameters); }
private static RouteParameters GetParameters(RouteDescription description, GroupCollection groups) { var segments = new ReadOnlyCollection<string>( description.Path.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries).ToList()); var parameters = from segment in segments where segment.IsParameterized() select segment.GetParameterName(); dynamic data = new RouteParameters(); foreach (var parameter in parameters) { data[parameter] = groups[parameter].Value; } return data; }
public RoutingDirections() { InitializeComponent(); _routeParams = new RouteParameters() { ReturnRoutes = false, ReturnDirections = true, DirectionsLengthUnits = esriUnits.esriMiles, Stops = _stops, UseTimeWindows = false }; _routeTask = new RouteTask("http://tasks.arcgisonline.com/ArcGIS/rest/services/NetworkAnalysis/ESRI_Route_NA/NAServer/Route"); _routeTask.SolveCompleted += routeTask_SolveCompleted; _routeTask.Failed += task_Failed; _locator = new Locator("http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Address_NA/GeocodeServer"); _locator.AddressToLocationsCompleted += locator_AddressToLocationsCompleted; _locator.Failed += task_Failed; }
public RoutingDirections() { InitializeComponent(); _routeParams = new RouteParameters() { ReturnRoutes = false, ReturnDirections = true, DirectionsLengthUnits = esriUnits.esriMiles, Stops = _stops, UseTimeWindows = false, }; _routeTask = new RouteTask("http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/NAServer/Route"); _routeTask.SolveCompleted += routeTask_SolveCompleted; _routeTask.Failed += task_Failed; _locator = new Locator("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"); _locator.FindCompleted += locator_FindCompleted; _locator.Failed += task_Failed; }
public override Link BuildLink(RouteParameters parameters) { Link l = this.Url.Clone() as Link; string formatString = "/{0:0000}/{1:00}/{2:00}/{3}"; Route r = this.GetRoute(); if (parameters["Slug"] != null) { formatString = (r != null) ? r.FormatString : formatString; } else if (parameters["Day"] != null) { formatString = "/{0:0000}/{1:00}/{2:00}"; } else if (parameters["Month"] != null) { formatString = "/{0:0000}/{1:00}"; } else if (parameters["Year"] != null) { formatString = "/{0:0000}"; } else { formatString = ""; } l.Extra = string.Format( formatString, parameters.Get("Year", DateTime.Now.Year), parameters.Get("Month", DateTime.Now.Month), parameters.Get("Day", DateTime.Now.Day), parameters["Slug"] ); return l; }
private async void SolveRouteClick(object sender, EventArgs e) { // Create a new route task using the San Diego route service URI RouteTask solveRouteTask = await RouteTask.CreateAsync(_sanDiegoRouteServiceUri); // Get the default parameters from the route task (defined with the service) RouteParameters routeParams = await solveRouteTask.CreateDefaultParametersAsync(); // Make some changes to the default parameters routeParams.ReturnStops = true; routeParams.ReturnDirections = true; // Set the list of route stops that were defined at startup routeParams.SetStops(_routeStops); // Solve for the best route between the stops and store the result RouteResult solveRouteResult = await solveRouteTask.SolveRouteAsync(routeParams); // Get the first (should be only) route from the result Route firstRoute = solveRouteResult.Routes.FirstOrDefault(); // Get the route geometry (polyline) Polyline routePolyline = firstRoute.RouteGeometry; // Create a thick purple line symbol for the route SimpleLineSymbol routeSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.Purple, 8.0); // Create a new graphic for the route geometry and add it to the graphics overlay Graphic routeGraphic = new Graphic(routePolyline, routeSymbol); _routeGraphicsOverlay.Graphics.Add(routeGraphic); // Get a list of directions for the route and display it in the list box var directions = from d in firstRoute.DirectionManeuvers select d.DirectionText; DirectionsListBox.ItemsSource = directions; }
/// <summary> /// Solves routing problem for given input parameters /// </summary> /// <returns></returns> public async Task <RouteUtilityResult> Solve() { routeTask = (routeTask) ?? await RouteTask.CreateAsync(RouteServiceUri); var routInfo = routeTask.RouteTaskInfo; // get the default route parameters routeParams = (routeParams) ?? await routeTask.CreateDefaultParametersAsync(); // explicitly set values for some params // routeParams.ReturnDirections = true; // routeParams.ReturnRoutes = true; routeParams.OutputSpatialReference = SpatialRef; routeParams.SetStops(stopPoints); routeParams.SetPointBarriers(pointBarriers); var routeResult = await routeTask.SolveRouteAsync(routeParams); return(new RouteUtilityResult { RouteName = routeResult.Routes[0].RouteName, TotalTime = routeResult.Routes[0].TotalTime }); }
private async void Initialize() { //Exercise 1: Create new Map with basemap and initial location myMap = new Map(Basemap.CreateNationalGeographic()); //Exercise 1: Assign the map to the MapView mapView.Map = myMap; //Exercise 3: Add mobile map package to the map var mmpk = await MobileMapPackage.OpenAsync(MMPK_PATH); if (mmpk.Maps.Count >= 0) { myMap = mmpk.Maps[0]; //Exercise 3: Mobile map package does not contain a basemap so must add one. myMap.Basemap = Basemap.CreateNationalGeographic(); mapView.Map = myMap; } mapView.GraphicsOverlays.Add(bufferAndQueryMapGraphics); mapView.GraphicsOverlays.Add(mapRouteGraphics); Uri routeServiceUri = new Uri("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World"); TokenCredential credentials = await AuthenticationManager.Current.GenerateCredentialAsync(routeServiceUri, "username", "password"); routeTask = await RouteTask.CreateAsync(routeServiceUri, credentials); try { routeParameters = await routeTask.GenerateDefaultParametersAsync(); } catch (Exception error) { Console.WriteLine(error.Message); } }
private dynamic GetFormData() { var ret = new RouteParameters(); if (this.Headers.Keys.Any(x => x.Equals("content-type", StringComparison.OrdinalIgnoreCase))) { var contentType = this.Headers["content-type"].First(); if (contentType.Equals("application/x-www-form-urlencoded", StringComparison.OrdinalIgnoreCase)) { var position = this.Body.Position; var reader = new StreamReader(this.Body); var coll = HttpUtility.ParseQueryString(reader.ReadToEnd()); this.Body.Position = position; foreach (var key in coll.AllKeys) { ret[key] = coll[key]; } } } return ret; }
public string UrlFor(Type modelType, string category, RouteParameters parameters) { var chain = resolver.FindUniqueByInputType(modelType, category); return(chain.Route.Input.CreateUrlFromParameters(parameters)); }
public string UrlFor <TInput>(RouteParameters parameters, string category) { Type modelType = typeof(TInput); return(UrlFor(modelType, category, parameters)); }
public string UrlFor <TInput>(RouteParameters parameters) { return(UrlFor(typeof(TInput), parameters)); }
public DataObject SingleDriverRoute10Stops() { // Create the manager with the api key Route4MeManager route4Me = new Route4MeManager(c_ApiKey); // Prepare the addresses Address[] addresses = new Address[] { #region Addresses new Address() { AddressString = "151 Arbor Way Milledgeville GA 31061", //indicate that this is a departure stop //single depot routes can only have one departure depot IsDepot = true, //required coordinates for every departure and stop on the route Latitude = 33.132675170898, Longitude = -83.244743347168, //the expected time on site, in seconds. this value is incorporated into the optimization engine //it also adjusts the estimated and dynamic eta's for a route Time = 0, //input as many custom fields as needed, custom data is passed through to mobile devices and to the manifest CustomFields = new Dictionary <string, string>() { { "color", "red" }, { "size", "huge" } } }, new Address() { AddressString = "230 Arbor Way Milledgeville GA 31061", Latitude = 33.129695892334, Longitude = -83.24577331543, Time = 0 }, new Address() { AddressString = "148 Bass Rd NE Milledgeville GA 31061", Latitude = 33.143497, Longitude = -83.224487, Time = 0 }, new Address() { AddressString = "117 Bill Johnson Rd NE Milledgeville GA 31061", Latitude = 33.141784667969, Longitude = -83.237518310547, Time = 0 }, new Address() { AddressString = "119 Bill Johnson Rd NE Milledgeville GA 31061", Latitude = 33.141086578369, Longitude = -83.238258361816, Time = 0 }, new Address() { AddressString = "131 Bill Johnson Rd NE Milledgeville GA 31061", Latitude = 33.142036437988, Longitude = -83.238845825195, Time = 0 }, new Address() { AddressString = "138 Bill Johnson Rd NE Milledgeville GA 31061", Latitude = 33.14307, Longitude = -83.239334, Time = 0 }, new Address() { AddressString = "139 Bill Johnson Rd NE Milledgeville GA 31061", Latitude = 33.142734527588, Longitude = -83.237442016602, Time = 0 }, new Address() { AddressString = "145 Bill Johnson Rd NE Milledgeville GA 31061", Latitude = 33.143871307373, Longitude = -83.237342834473, Time = 0 }, new Address() { AddressString = "221 Blake Cir Milledgeville GA 31061", Latitude = 33.081462860107, Longitude = -83.208511352539, Time = 0 } #endregion }; // Set parameters RouteParameters parameters = new RouteParameters() { AlgorithmType = AlgorithmType.TSP, StoreRoute = false, RouteName = "Single Driver Route 10 Stops", RouteDate = R4MeUtils.ConvertToUnixTimestamp(DateTime.UtcNow.Date.AddDays(1)), RouteTime = 60 * 60 * 7, Optimize = Optimize.Distance.Description(), DistanceUnit = DistanceUnit.MI.Description(), DeviceType = DeviceType.Web.Description() }; OptimizationParameters optimizationParameters = new OptimizationParameters() { Addresses = addresses, Parameters = parameters }; // Run the query string errorString; DataObject dataObject = route4Me.RunOptimization(optimizationParameters, out errorString); // Output the result PrintExampleOptimizationResult("SingleDriverRoute10Stops", dataObject, errorString); return(dataObject); }
public async Task <IEnumerable <Route> > GetAll([FromQuery] RouteParameters routeParameters) { return(await _service.GetAll(routeParameters)); }
private async void Initialize() { try { // Create the map view. _myMapView.Map = new Map(BasemapStyle.ArcGISNavigation); // Create the route task, using the routing service. _routeTask = await RouteTask.CreateAsync(_networkGeodatabasePath, "Streets_ND"); // Get the default route parameters. _routeParams = await _routeTask.CreateDefaultParametersAsync(); // Explicitly set values for parameters. _routeParams.ReturnDirections = true; _routeParams.ReturnStops = true; _routeParams.ReturnRoutes = true; _routeParams.OutputSpatialReference = SpatialReferences.Wgs84; // Create stops for each location. Stop stop1 = new Stop(_conventionCenter) { Name = "San Diego Convention Center" }; Stop stop2 = new Stop(_aerospaceMuseum) { Name = "RH Fleet Aerospace Museum" }; // Assign the stops to the route parameters. List <Stop> stopPoints = new List <Stop> { stop1, stop2 }; _routeParams.SetStops(stopPoints); // Get the route results. _routeResult = await _routeTask.SolveRouteAsync(_routeParams); _route = _routeResult.Routes[0]; // Add a graphics overlay for the route graphics. _myMapView.GraphicsOverlays.Add(new GraphicsOverlay()); // Add graphics for the stops. SimpleMarkerSymbol stopSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Diamond, Color.OrangeRed, 20); _myMapView.GraphicsOverlays[0].Graphics.Add(new Graphic(_conventionCenter, stopSymbol)); _myMapView.GraphicsOverlays[0].Graphics.Add(new Graphic(_aerospaceMuseum, stopSymbol)); // Create a graphic (with a dashed line symbol) to represent the route. _routeAheadGraphic = new Graphic(_route.RouteGeometry) { Symbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.BlueViolet, 5) }; // Create a graphic (solid) to represent the route that's been traveled (initially empty). _routeTraveledGraphic = new Graphic { Symbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.LightBlue, 3) }; // Add the route graphics to the map view. _myMapView.GraphicsOverlays[0].Graphics.Add(_routeAheadGraphic); _myMapView.GraphicsOverlays[0].Graphics.Add(_routeTraveledGraphic); // Set the map viewpoint to show the entire route. await _myMapView.SetViewpointGeometryAsync(_route.RouteGeometry, 100); // Enable the navigation button. _navigateButton.Enabled = true; } catch (Exception e) { new UIAlertView("Error", e.Message, (IUIAlertViewDelegate)null, "OK", null).Show(); } }
public DataObject MultipleDepotMultipleDriverTimeWindow() { // Create the manager with the api key Route4MeManager route4Me = new Route4MeManager(c_ApiKey); // Prepare the addresses Address[] addresses = new Address[] { #region Addresses new Address() { AddressString = "455 S 4th St, Louisville, KY 40202", IsDepot = true, Latitude = 38.251698, Longitude = -85.757308, Time = 300, TimeWindowStart = 28800, TimeWindowEnd = 30477 }, new Address() { AddressString = "1604 PARKRIDGE PKWY, Louisville, KY, 40214", Latitude = 38.141598, Longitude = -85.793846, Time = 300, TimeWindowStart = 30477, TimeWindowEnd = 33406 }, new Address() { AddressString = "1407 א53MCCOY, Louisville, KY, 40215", Latitude = 38.202496, Longitude = -85.786514, Time = 300, TimeWindowStart = 33406, TimeWindowEnd = 36228 }, new Address() { AddressString = "4805 BELLEVUE AVE, Louisville, KY, 40215", Latitude = 38.178844, Longitude = -85.774864, Time = 300, TimeWindowStart = 36228, TimeWindowEnd = 37518 }, new Address() { AddressString = "730 CECIL AVENUE, Louisville, KY, 40211", Latitude = 38.248684, Longitude = -85.821121, Time = 300, TimeWindowStart = 37518, TimeWindowEnd = 39550 }, new Address() { AddressString = "650 SOUTH 29TH ST UNIT 315, Louisville, KY, 40211", Latitude = 38.251923, Longitude = -85.800034, Time = 300, TimeWindowStart = 39550, TimeWindowEnd = 41348 }, new Address() { AddressString = "4629 HILLSIDE DRIVE, Louisville, KY, 40216", Latitude = 38.176067, Longitude = -85.824638, Time = 300, TimeWindowStart = 41348, TimeWindowEnd = 42261 }, new Address() { AddressString = "4738 BELLEVUE AVE, Louisville, KY, 40215", Latitude = 38.179806, Longitude = -85.775558, Time = 300, TimeWindowStart = 42261, TimeWindowEnd = 45195 }, new Address() { AddressString = "318 SO. 39TH STREET, Louisville, KY, 40212", Latitude = 38.259335, Longitude = -85.815094, Time = 300, TimeWindowStart = 45195, TimeWindowEnd = 46549 }, new Address() { AddressString = "1324 BLUEGRASS AVE, Louisville, KY, 40215", Latitude = 38.179253, Longitude = -85.785118, Time = 300, TimeWindowStart = 46549, TimeWindowEnd = 47353 }, new Address() { AddressString = "7305 ROYAL WOODS DR, Louisville, KY, 40214", Latitude = 38.162472, Longitude = -85.792854, Time = 300, TimeWindowStart = 47353, TimeWindowEnd = 50924 }, new Address() { AddressString = "1661 W HILL ST, Louisville, KY, 40210", Latitude = 38.229584, Longitude = -85.783966, Time = 300, TimeWindowStart = 50924, TimeWindowEnd = 51392 }, new Address() { AddressString = "3222 KINGSWOOD WAY, Louisville, KY, 40216", Latitude = 38.210606, Longitude = -85.822594, Time = 300, TimeWindowStart = 51392, TimeWindowEnd = 52451 }, new Address() { AddressString = "1922 PALATKA RD, Louisville, KY, 40214", Latitude = 38.153767, Longitude = -85.796783, Time = 300, TimeWindowStart = 52451, TimeWindowEnd = 55631 }, new Address() { AddressString = "1314 SOUTH 26TH STREET, Louisville, KY, 40210", Latitude = 38.235847, Longitude = -85.796852, Time = 300, TimeWindowStart = 55631, TimeWindowEnd = 58516 }, new Address() { AddressString = "2135 MCCLOSKEY AVENUE, Louisville, KY, 40210", Latitude = 38.218662, Longitude = -85.789032, Time = 300, TimeWindowStart = 58516, TimeWindowEnd = 61080 }, new Address() { AddressString = "1409 PHYLLIS AVE, Louisville, KY, 40215", Latitude = 38.206154, Longitude = -85.781387, Time = 100, TimeWindowStart = 61080, TimeWindowEnd = 61504 }, new Address() { AddressString = "4504 SUNFLOWER AVE, Louisville, KY, 40216", Latitude = 38.187511, Longitude = -85.839149, Time = 300, TimeWindowStart = 61504, TimeWindowEnd = 62061 }, new Address() { AddressString = "2512 GREENWOOD AVE, Louisville, KY, 40210", Latitude = 38.241405, Longitude = -85.795059, Time = 300, TimeWindowStart = 62061, TimeWindowEnd = 65012 }, new Address() { AddressString = "5500 WILKE FARM AVE, Louisville, KY, 40216", Latitude = 38.166065, Longitude = -85.863319, Time = 300, TimeWindowStart = 65012, TimeWindowEnd = 67541 }, new Address() { AddressString = "3640 LENTZ AVE, Louisville, KY, 40215", Latitude = 38.193283, Longitude = -85.786201, Time = 300, TimeWindowStart = 67541, TimeWindowEnd = 69120 }, new Address() { AddressString = "1020 BLUEGRASS AVE, Louisville, KY, 40215", Latitude = 38.17952, Longitude = -85.780037, Time = 300, TimeWindowStart = 69120, TimeWindowEnd = 70572 }, new Address() { AddressString = "123 NORTH 40TH ST, Louisville, KY, 40212", Latitude = 38.26498, Longitude = -85.814156, Time = 300, TimeWindowStart = 70572, TimeWindowEnd = 73177 }, new Address() { AddressString = "7315 ST ANDREWS WOODS CIRCLE UNIT 104, Louisville, KY, 40214", Latitude = 38.151072, Longitude = -85.802867, Time = 300, TimeWindowStart = 73177, TimeWindowEnd = 75231 }, new Address() { AddressString = "3210 POPLAR VIEW DR, Louisville, KY, 40216", Latitude = 38.182594, Longitude = -85.849937, Time = 300, TimeWindowStart = 75231, TimeWindowEnd = 77663 }, new Address() { AddressString = "4519 LOUANE WAY, Louisville, KY, 40216", Latitude = 38.1754, Longitude = -85.811447, Time = 300, TimeWindowStart = 77663, TimeWindowEnd = 79796 }, new Address() { AddressString = "6812 MANSLICK RD, Louisville, KY, 40214", Latitude = 38.161839, Longitude = -85.798279, Time = 300, TimeWindowStart = 79796, TimeWindowEnd = 80813 }, new Address() { AddressString = "1524 HUNTOON AVENUE, Louisville, KY, 40215", Latitude = 38.172031, Longitude = -85.788353, Time = 300, TimeWindowStart = 80813, TimeWindowEnd = 83956 }, new Address() { AddressString = "1307 LARCHMONT AVE, Louisville, KY, 40215", Latitude = 38.209663, Longitude = -85.779816, Time = 300, TimeWindowStart = 83956, TimeWindowEnd = 84365 }, new Address() { AddressString = "434 N 26TH STREET #2, Louisville, KY, 40212", Latitude = 38.26844, Longitude = -85.791962, Time = 300, TimeWindowStart = 84365, TimeWindowEnd = 85367 }, new Address() { AddressString = "678 WESTLAWN ST, Louisville, KY, 40211", Latitude = 38.250397, Longitude = -85.80629, Time = 300, TimeWindowStart = 85367, TimeWindowEnd = 86400 }, new Address() { AddressString = "2308 W BROADWAY, Louisville, KY, 40211", Latitude = 38.248882, Longitude = -85.790421, Time = 300, TimeWindowStart = 86400, TimeWindowEnd = 88703 }, new Address() { AddressString = "2332 WOODLAND AVE, Louisville, KY, 40210", Latitude = 38.233579, Longitude = -85.794257, Time = 300, TimeWindowStart = 88703, TimeWindowEnd = 89320 }, new Address() { AddressString = "1706 WEST ST. CATHERINE, Louisville, KY, 40210", Latitude = 38.239697, Longitude = -85.783928, Time = 300, TimeWindowStart = 89320, TimeWindowEnd = 90054 }, new Address() { AddressString = "1699 WATHEN LN, Louisville, KY, 40216", Latitude = 38.216465, Longitude = -85.792397, Time = 300, TimeWindowStart = 90054, TimeWindowEnd = 91150 }, new Address() { AddressString = "2416 SUNSHINE WAY, Louisville, KY, 40216", Latitude = 38.186245, Longitude = -85.831787, Time = 300, TimeWindowStart = 91150, TimeWindowEnd = 91915 }, new Address() { AddressString = "6925 MANSLICK RD, Louisville, KY, 40214", Latitude = 38.158466, Longitude = -85.798355, Time = 300, TimeWindowStart = 91915, TimeWindowEnd = 93407 }, new Address() { AddressString = "2707 7TH ST, Louisville, KY, 40215", Latitude = 38.212438, Longitude = -85.785082, Time = 300, TimeWindowStart = 93407, TimeWindowEnd = 95992 }, new Address() { AddressString = "2014 KENDALL LN, Louisville, KY, 40216", Latitude = 38.179394, Longitude = -85.826668, Time = 300, TimeWindowStart = 95992, TimeWindowEnd = 99307 }, new Address() { AddressString = "612 N 39TH ST, Louisville, KY, 40212", Latitude = 38.273354, Longitude = -85.812012, Time = 300, TimeWindowStart = 99307, TimeWindowEnd = 102906 }, new Address() { AddressString = "2215 ROWAN ST, Louisville, KY, 40212", Latitude = 38.261703, Longitude = -85.786781, Time = 300, TimeWindowStart = 102906, TimeWindowEnd = 106021 }, new Address() { AddressString = "1826 W. KENTUCKY ST, Louisville, KY, 40210", Latitude = 38.241611, Longitude = -85.78653, Time = 300, TimeWindowStart = 106021, TimeWindowEnd = 107276 }, new Address() { AddressString = "1810 GREGG AVE, Louisville, KY, 40210", Latitude = 38.224716, Longitude = -85.796211, Time = 300, TimeWindowStart = 107276, TimeWindowEnd = 107948 }, new Address() { AddressString = "4103 BURRRELL DRIVE, Louisville, KY, 40216", Latitude = 38.191753, Longitude = -85.825836, Time = 300, TimeWindowStart = 107948, TimeWindowEnd = 108414 }, new Address() { AddressString = "359 SOUTHWESTERN PKWY, Louisville, KY, 40212", Latitude = 38.259903, Longitude = -85.823463, Time = 200, TimeWindowStart = 108414, TimeWindowEnd = 108685 }, new Address() { AddressString = "2407 W CHESTNUT ST, Louisville, KY, 40211", Latitude = 38.252781, Longitude = -85.792109, Time = 300, TimeWindowStart = 108685, TimeWindowEnd = 110109 }, new Address() { AddressString = "225 S 22ND ST, Louisville, KY, 40212", Latitude = 38.257616, Longitude = -85.786658, Time = 300, TimeWindowStart = 110109, TimeWindowEnd = 111375 }, new Address() { AddressString = "1404 MCCOY AVE, Louisville, KY, 40215", Latitude = 38.202122, Longitude = -85.786072, Time = 300, TimeWindowStart = 111375, TimeWindowEnd = 112120 }, new Address() { AddressString = "117 FOUNT LANDING CT, Louisville, KY, 40212", Latitude = 38.270061, Longitude = -85.799438, Time = 300, TimeWindowStart = 112120, TimeWindowEnd = 114095 }, new Address() { AddressString = "5504 SHOREWOOD DRIVE, Louisville, KY, 40214", Latitude = 38.145851, Longitude = -85.7798, Time = 300, TimeWindowStart = 114095, TimeWindowEnd = 115743 }, new Address() { AddressString = "1406 CENTRAL AVE, Louisville, KY, 40208", Latitude = 38.211025, Longitude = -85.780251, Time = 300, TimeWindowStart = 115743, TimeWindowEnd = 117716 }, new Address() { AddressString = "901 W WHITNEY AVE, Louisville, KY, 40215", Latitude = 38.194115, Longitude = -85.77494, Time = 300, TimeWindowStart = 117716, TimeWindowEnd = 119078 }, new Address() { AddressString = "2109 SCHAFFNER AVE, Louisville, KY, 40210", Latitude = 38.219699, Longitude = -85.779363, Time = 300, TimeWindowStart = 119078, TimeWindowEnd = 121147 }, new Address() { AddressString = "2906 DIXIE HWY, Louisville, KY, 40216", Latitude = 38.209278, Longitude = -85.798653, Time = 300, TimeWindowStart = 121147, TimeWindowEnd = 124281 }, new Address() { AddressString = "814 WWHITNEY AVE, Louisville, KY, 40215", Latitude = 38.193596, Longitude = -85.773521, Time = 300, TimeWindowStart = 124281, TimeWindowEnd = 124675 }, new Address() { AddressString = "1610 ALGONQUIN PWKY, Louisville, KY, 40210", Latitude = 38.222153, Longitude = -85.784187, Time = 300, TimeWindowStart = 124675, TimeWindowEnd = 127148 }, new Address() { AddressString = "3524 WHEELER AVE, Louisville, KY, 40215", Latitude = 38.195293, Longitude = -85.788643, Time = 300, TimeWindowStart = 127148, TimeWindowEnd = 130667 }, new Address() { AddressString = "5009 NEW CUT RD, Louisville, KY, 40214", Latitude = 38.165905, Longitude = -85.779701, Time = 300, TimeWindowStart = 130667, TimeWindowEnd = 131980 }, new Address() { AddressString = "3122 ELLIOTT AVE, Louisville, KY, 40211", Latitude = 38.251213, Longitude = -85.804199, Time = 300, TimeWindowStart = 131980, TimeWindowEnd = 134402 }, new Address() { AddressString = "911 GAGEL AVE, Louisville, KY, 40216", Latitude = 38.173512, Longitude = -85.807854, Time = 300, TimeWindowStart = 134402, TimeWindowEnd = 136787 }, new Address() { AddressString = "4020 GARLAND AVE #lOOA, Louisville, KY, 40211", Latitude = 38.246181, Longitude = -85.818901, Time = 300, TimeWindowStart = 136787, TimeWindowEnd = 138073 }, new Address() { AddressString = "5231 MT HOLYOKE DR, Louisville, KY, 40216", Latitude = 38.169369, Longitude = -85.85704, Time = 300, TimeWindowStart = 138073, TimeWindowEnd = 141407 }, new Address() { AddressString = "1339 28TH S #2, Louisville, KY, 40211", Latitude = 38.235275, Longitude = -85.800156, Time = 300, TimeWindowStart = 141407, TimeWindowEnd = 143561 }, new Address() { AddressString = "836 S 36TH ST, Louisville, KY, 40211", Latitude = 38.24651, Longitude = -85.811234, Time = 300, TimeWindowStart = 143561, TimeWindowEnd = 145941 }, new Address() { AddressString = "2132 DUNCAN STREET, Louisville, KY, 40212", Latitude = 38.262135, Longitude = -85.785172, Time = 300, TimeWindowStart = 145941, TimeWindowEnd = 148296 }, new Address() { AddressString = "3529 WHEELER AVE, Louisville, KY, 40215", Latitude = 38.195057, Longitude = -85.787949, Time = 300, TimeWindowStart = 148296, TimeWindowEnd = 150177 }, new Address() { AddressString = "2829 DE MEL #11, Louisville, KY, 40214", Latitude = 38.171662, Longitude = -85.807271, Time = 300, TimeWindowStart = 150177, TimeWindowEnd = 150981 }, new Address() { AddressString = "1325 EARL AVENUE, Louisville, KY, 40215", Latitude = 38.204556, Longitude = -85.781555, Time = 300, TimeWindowStart = 150981, TimeWindowEnd = 151854 }, new Address() { AddressString = "3632 MANSLICK RD #10, Louisville, KY, 40215", Latitude = 38.193542, Longitude = -85.801147, Time = 300, TimeWindowStart = 151854, TimeWindowEnd = 152613 }, new Address() { AddressString = "637 S 41ST ST, Louisville, KY, 40211", Latitude = 38.253632, Longitude = -85.81897, Time = 300, TimeWindowStart = 152613, TimeWindowEnd = 156131 }, new Address() { AddressString = "3420 VIRGINIA AVENUE, Louisville, KY, 40211", Latitude = 38.238693, Longitude = -85.811386, Time = 300, TimeWindowStart = 156131, TimeWindowEnd = 157212 }, new Address() { AddressString = "3501 MALIBU CT APT 6, Louisville, KY, 40216", Latitude = 38.166481, Longitude = -85.825928, Time = 300, TimeWindowStart = 157212, TimeWindowEnd = 158655 }, new Address() { AddressString = "4912 DIXIE HWY, Louisville, KY, 40216", Latitude = 38.170728, Longitude = -85.826817, Time = 300, TimeWindowStart = 158655, TimeWindowEnd = 159145 }, new Address() { AddressString = "7720 DINGLEDELL RD, Louisville, KY, 40214", Latitude = 38.162472, Longitude = -85.792854, Time = 300, TimeWindowStart = 159145, TimeWindowEnd = 161831 }, new Address() { AddressString = "2123 RATCLIFFE AVE, Louisville, KY, 40210", Latitude = 38.21978, Longitude = -85.797615, Time = 300, TimeWindowStart = 161831, TimeWindowEnd = 163705 }, new Address() { AddressString = "1321 OAKWOOD AVE, Louisville, KY, 40215", Latitude = 38.17704, Longitude = -85.783829, Time = 300, TimeWindowStart = 163705, TimeWindowEnd = 164953 }, new Address() { AddressString = "2223 WEST KENTUCKY STREET, Louisville, KY, 40210", Latitude = 38.242516, Longitude = -85.790695, Time = 300, TimeWindowStart = 164953, TimeWindowEnd = 166189 }, new Address() { AddressString = "8025 GLIMMER WAY #3308, Louisville, KY, 40214", Latitude = 38.131981, Longitude = -85.77935, Time = 300, TimeWindowStart = 166189, TimeWindowEnd = 166640 }, new Address() { AddressString = "1155 S 28TH ST, Louisville, KY, 40211", Latitude = 38.238621, Longitude = -85.799911, Time = 300, TimeWindowStart = 166640, TimeWindowEnd = 168147 }, new Address() { AddressString = "840 IROQUOIS AVE, Louisville, KY, 40214", Latitude = 38.166355, Longitude = -85.779396, Time = 300, TimeWindowStart = 168147, TimeWindowEnd = 170385 }, new Address() { AddressString = "5573 BRUCE AVE, Louisville, KY, 40214", Latitude = 38.145222, Longitude = -85.779205, Time = 300, TimeWindowStart = 170385, TimeWindowEnd = 171096 }, new Address() { AddressString = "1727 GALLAGHER, Louisville, KY, 40210", Latitude = 38.239334, Longitude = -85.784882, Time = 300, TimeWindowStart = 171096, TimeWindowEnd = 171951 }, new Address() { AddressString = "1309 CATALPA ST APT 204, Louisville, KY, 40211", Latitude = 38.236524, Longitude = -85.801619, Time = 300, TimeWindowStart = 171951, TimeWindowEnd = 172393 }, new Address() { AddressString = "1330 ALGONQUIN PKWY, Louisville, KY, 40208", Latitude = 38.219846, Longitude = -85.777344, Time = 300, TimeWindowStart = 172393, TimeWindowEnd = 175337 }, new Address() { AddressString = "823 SUTCLIFFE, Louisville, KY, 40211", Latitude = 38.246956, Longitude = -85.811569, Time = 300, TimeWindowStart = 175337, TimeWindowEnd = 176867 }, new Address() { AddressString = "4405 CHURCHMAN AVENUE #2, Louisville, KY, 40215", Latitude = 38.177768, Longitude = -85.792545, Time = 300, TimeWindowStart = 176867, TimeWindowEnd = 178051 }, new Address() { AddressString = "3211 DUMESNIL ST #1, Louisville, KY, 40211", Latitude = 38.237789, Longitude = -85.807968, Time = 300, TimeWindowStart = 178051, TimeWindowEnd = 179083 }, new Address() { AddressString = "3904 WEWOKA AVE, Louisville, KY, 40212", Latitude = 38.270367, Longitude = -85.813118, Time = 300, TimeWindowStart = 179083, TimeWindowEnd = 181543 }, new Address() { AddressString = "660 SO. 42ND STREET, Louisville, KY, 40211", Latitude = 38.252865, Longitude = -85.822624, Time = 300, TimeWindowStart = 181543, TimeWindowEnd = 184193 }, new Address() { AddressString = "3619 LENTZ AVE, Louisville, KY, 40215", Latitude = 38.193249, Longitude = -85.785492, Time = 300, TimeWindowStart = 184193, TimeWindowEnd = 185853 }, new Address() { AddressString = "4305 STOLTZ CT, Louisville, KY, 40215", Latitude = 38.178707, Longitude = -85.787292, Time = 300, TimeWindowStart = 185853, TimeWindowEnd = 187252 } #endregion }; // Set parameters RouteParameters parameters = new RouteParameters() { AlgorithmType = AlgorithmType.CVRP_TW_MD, RouteName = "Multiple Depot, Multiple Driver, Time Window", StoreRoute = false, RouteDate = R4MeUtils.ConvertToUnixTimestamp(DateTime.UtcNow.Date.AddDays(1)), RouteTime = 60 * 60 * 7, RT = true, RouteMaxDuration = 86400 * 3, VehicleCapacity = "99", VehicleMaxDistanceMI = "99999", Optimize = Optimize.Time.Description(), DistanceUnit = DistanceUnit.MI.Description(), DeviceType = DeviceType.Web.Description(), TravelMode = TravelMode.Driving.Description(), Metric = Metric.Geodesic }; OptimizationParameters optimizationParameters = new OptimizationParameters() { Addresses = addresses, Parameters = parameters }; // Run the query string errorString; DataObject dataObject = route4Me.RunOptimization(optimizationParameters, out errorString); // Output the result PrintExampleOptimizationResult("MultipleDepotMultipleDriverTimeWindow", dataObject, errorString); return(dataObject); }
/// <summary> /// The example refers to the process of creating an optimization /// with slow-down parameters. /// </summary> public void RouteSlowdown() { var route4Me = new Route4MeManager(ActualApiKey); // Prepare the addresses var addresses = new Address[] { #region Addresses new Address() { AddressString = "754 5th Ave New York, NY 10019", Alias = "Bergdorf Goodman", IsDepot = true, Latitude = 40.7636197, Longitude = -73.9744388, Time = 0 }, new Address() { AddressString = "717 5th Ave New York, NY 10022", //Alias = "Giorgio Armani", Latitude = 40.7669692, Longitude = -73.9693864, Time = 0 }, new Address() { AddressString = "888 Madison Ave New York, NY 10014", //Alias = "Ralph Lauren Women's and Home", Latitude = 40.7715154, Longitude = -73.9669241, Time = 0 }, new Address() { AddressString = "1011 Madison Ave New York, NY 10075", Alias = "Yigal Azrou'l", Latitude = 40.7772129, Longitude = -73.9669, Time = 0 }, new Address() { AddressString = "440 Columbus Ave New York, NY 10024", Alias = "Frank Stella Clothier", Latitude = 40.7808364, Longitude = -73.9732729, Time = 0 }, new Address() { AddressString = "324 Columbus Ave #1 New York, NY 10023", Alias = "Liana", Latitude = 40.7803123, Longitude = -73.9793079, Time = 0 }, new Address() { AddressString = "110 W End Ave New York, NY 10023", Alias = "Toga Bike Shop", Latitude = 40.7753077, Longitude = -73.9861529, Time = 0 }, new Address() { AddressString = "555 W 57th St New York, NY 10019", Alias = "BMW of Manhattan", Latitude = 40.7718005, Longitude = -73.9897716, Time = 0 }, new Address() { AddressString = "57 W 57th St New York, NY 10019", Alias = "Verizon Wireless", Latitude = 40.7558695, Longitude = -73.9862019, Time = 0 }, #endregion }; // Set parameters var parameters = new RouteParameters() { AlgorithmType = AlgorithmType.TSP, RouteName = "Single Driver Round Trip", RouteDate = R4MeUtils.ConvertToUnixTimestamp(DateTime.UtcNow.Date.AddDays(1)), RouteTime = 60 * 60 * 7, RouteMaxDuration = 86400, VehicleCapacity = 1, VehicleMaxDistanceMI = 10000, Optimize = Optimize.Time.Description(), DistanceUnit = DistanceUnit.MI.Description(), DeviceType = DeviceType.Web.Description(), TravelMode = TravelMode.Driving.Description(), Slowdowns = new SlowdownParams(15, 20) }; var optimizationParameters = new OptimizationParameters() { Addresses = addresses, Parameters = parameters }; // Run the query var dataObject = route4Me.RunOptimization( optimizationParameters, out string errorString); OptimizationsToRemove = new List <string>() { dataObject?.OptimizationProblemId ?? null }; PrintExampleOptimizationResult(dataObject, errorString); Console.WriteLine(""); Console.WriteLine( "RouteServiceTimeMultiplier: " + (dataObject?.Parameters?.RouteServiceTimeMultiplier ?? null) ); Console.WriteLine( "RouteTimeMultiplier: " + (dataObject?.Parameters?.RouteTimeMultiplier ?? null) ); RemoveTestOptimizations(); }
public void Should_support_implicit_casting() { // Given dynamic parameters = new RouteParameters(); parameters.test = "10"; // When int value = parameters.test; // Then value.ShouldEqual(10); }
void SolveRoute(MapPoint start, MapPoint end) { // The Esri World Network Analysis Services requires an ArcGIS Online Subscription. // In this sample use the North America only service on tasks.arcgisonline.com. var routeTask = new RouteTask("http://tasks.arcgisonline.com/ArcGIS/rest/services/NetworkAnalysis/ESRI_Route_NA/NAServer/Route"); // Create a new list of graphics to send to the route task. Note don't use the graphcis returned from find // as the attributes cause issues with the route finding. var stops = new List<Graphic>() { new Graphic() { Geometry = start}, new Graphic() { Geometry = end} }; var routeParams = new RouteParameters() { Stops = stops, UseTimeWindows = false, OutSpatialReference = MyMap.SpatialReference, ReturnDirections = false, IgnoreInvalidLocations = true }; routeTask.Failed += (s, e) => { MessageBox.Show("Route Task failed:" + e.Error); }; // Register an inline handler for the SolveCompleted event. routeTask.SolveCompleted += (s, e) => { // Add the returned route to the Map var myRoute = new Graphic() { Geometry = e.RouteResults[0].Route.Geometry, Symbol = new SimpleLineSymbol() { Width = 10, Color = new SolidColorBrush(Color.FromArgb(127, 0, 0, 255)) } }; // Add a MapTip decimal totalTime = (decimal)e.RouteResults[0].Route.Attributes["Total_Time"]; string tip = string.Format("{0} minutes", totalTime.ToString("#0.0")); myRoute.Attributes.Add("TIP", tip); MyRoutesGraphicsLayer.Graphics.Add(myRoute); }; // Call the SolveAsync method routeTask.SolveAsync(routeParams); }
public bool RunSingleDriverRoundTrip() { var route4Me = new Route4MeManagerV5(c_ApiKey); // Prepare the addresses Address[] addresses = new Address[] { #region Addresses new Address() { AddressString = "754 5th Ave New York, NY 10019", Alias = "Bergdorf Goodman", IsDepot = true, Latitude = 40.7636197, Longitude = -73.9744388, Time = 0 }, new Address() { AddressString = "717 5th Ave New York, NY 10022", Alias = "Giorgio Armani", Latitude = 40.7669692, Longitude = -73.9693864, Time = 0 }, new Address() { AddressString = "888 Madison Ave New York, NY 10014", Alias = "Ralph Lauren Women's and Home", Latitude = 40.7715154, Longitude = -73.9669241, Time = 0 }, new Address() { AddressString = "1011 Madison Ave New York, NY 10075", Alias = "Yigal Azrou'l", Latitude = 40.7772129, Longitude = -73.9669, Time = 0 }, new Address() { AddressString = "440 Columbus Ave New York, NY 10024", Alias = "Frank Stella Clothier", Latitude = 40.7808364, Longitude = -73.9732729, Time = 0 }, new Address() { AddressString = "324 Columbus Ave #1 New York, NY 10023", Alias = "Liana", Latitude = 40.7803123, Longitude = -73.9793079, Time = 0 }, new Address() { AddressString = "110 W End Ave New York, NY 10023", Alias = "Toga Bike Shop", Latitude = 40.7753077, Longitude = -73.9861529, Time = 0 }, new Address() { AddressString = "555 W 57th St New York, NY 10019", Alias = "BMW of Manhattan", Latitude = 40.7718005, Longitude = -73.9897716, Time = 0 }, new Address() { AddressString = "57 W 57th St New York, NY 10019", Alias = "Verizon Wireless", Latitude = 40.7558695, Longitude = -73.9862019, Time = 0 }, #endregion }; // Set parameters var parameters = new RouteParameters() { AlgorithmType = AlgorithmType.TSP, //StoreRoute = false, RouteName = "Single Driver Round Trip", RouteDate = R4MeUtils.ConvertToUnixTimestamp(DateTime.UtcNow.Date.AddDays(1)), RouteTime = 60 * 60 * 7, RouteMaxDuration = 86400, VehicleCapacity = 1, VehicleMaxDistanceMI = 10000, RT = true, Optimize = Optimize.Distance.Description(), DistanceUnit = DistanceUnit.MI.Description(), DeviceType = DeviceType.Web.Description(), TravelMode = TravelMode.Driving.Description(), }; var optimizationParameters = new OptimizationParameters() { Addresses = addresses, Parameters = parameters }; // Run the query //string errorString; try { dataObjectSDRT = route4Me.RunOptimization(optimizationParameters, out ResultResponse resultResponse); SDRT_optimization_problem_id = dataObjectSDRT.OptimizationProblemId; SDRT_route = (dataObjectSDRT != null && dataObjectSDRT.Routes != null && dataObjectSDRT.Routes.Length > 0) ? dataObjectSDRT.Routes[0] : null; SDRT_route_id = (SDRT_route != null) ? SDRT_route.RouteID : null; return(true); } catch (Exception ex) { Console.WriteLine("Single Driver Round Trip generation failed. " + ex.Message); return(false); } }
/// <summary> /// The example refers to the process of creating an optimization /// with multi-depot, multi-driver options, and fine-tuning. /// </summary> public void MultipleDepotMultipleDriverFineTuning() { var route4Me = new Route4MeManager(ActualApiKey); // Prepare the addresses Address[] addresses = new Address[] { #region Addresses new Address() { AddressString = "3634 W Market St, Fairlawn, OH 44333", IsDepot = true, Latitude = 41.135762259364, Longitude = -81.629313826561, Time = 300, TimeWindowStart = 28800, TimeWindowEnd = 29465 }, new Address() { AddressString = "1218 Ruth Ave, Cuyahoga Falls, OH 44221", Latitude = 41.143505096435, Longitude = -81.46549987793, Time = 300, TimeWindowStart = 29465, TimeWindowEnd = 30529 }, new Address() { AddressString = "512 Florida Pl, Barberton, OH 44203", IsDepot = true, Latitude = 41.003671512008, Longitude = -81.598461046815, Time = 300, TimeWindowStart = 33479, TimeWindowEnd = 33944 }, new Address() { AddressString = "3495 Purdue St, Cuyahoga Falls, OH 44221", Latitude = 41.162971496582, Longitude = -81.479049682617, Time = 300, TimeWindowStart = 33944, TimeWindowEnd = 34801 }, new Address() { AddressString = "1659 Hibbard Dr, Stow, OH 44224", Latitude = 41.194505989552, Longitude = -81.443351581693, Time = 300, TimeWindowStart = 34801, TimeWindowEnd = 36366 }, new Address() { AddressString = "2705 N River Rd, Stow, OH 44224", Latitude = 41.145240783691, Longitude = -81.410247802734, Time = 300, TimeWindowStart = 36366, TimeWindowEnd = 39173 }, new Address() { AddressString = "10159 Bissell Dr, Twinsburg, OH 44087", Latitude = 41.340042114258, Longitude = -81.421226501465, Time = 300, TimeWindowStart = 39173, TimeWindowEnd = 41617 }, new Address() { AddressString = "367 Cathy Dr, Munroe Falls, OH 44262", Latitude = 41.148578643799, Longitude = -81.429229736328, Time = 300, TimeWindowStart = 41617, TimeWindowEnd = 43660 }, new Address() { AddressString = "367 Cathy Dr, Munroe Falls, OH 44262", Latitude = 41.148579, Longitude = -81.42923, Time = 300, TimeWindowStart = 43660, TimeWindowEnd = 46392 }, new Address() { AddressString = "512 Florida Pl, Barberton, OH 44203", Latitude = 41.003671512008, Longitude = -81.598461046815, Time = 300, TimeWindowStart = 46392, TimeWindowEnd = 48089 }, new Address() { AddressString = "559 W Aurora Rd, Northfield, OH 44067", Latitude = 41.315116882324, Longitude = -81.558746337891, Time = 300, TimeWindowStart = 48089, TimeWindowEnd = 48449 }, new Address() { AddressString = "3933 Klein Ave, Stow, OH 44224", Latitude = 41.169467926025, Longitude = -81.429420471191, Time = 300, TimeWindowStart = 48449, TimeWindowEnd = 50152 }, new Address() { AddressString = "2148 8th St, Cuyahoga Falls, OH 44221", Latitude = 41.136692047119, Longitude = -81.493492126465, Time = 300, TimeWindowStart = 50152, TimeWindowEnd = 51682 }, new Address() { AddressString = "3731 Osage St, Stow, OH 44224", Latitude = 41.161357879639, Longitude = -81.42293548584, Time = 300, TimeWindowStart = 51682, TimeWindowEnd = 54379 }, new Address() { AddressString = "3862 Klein Ave, Stow, OH 44224", Latitude = 41.167895123363, Longitude = -81.429973393679, Time = 300, TimeWindowStart = 54379, TimeWindowEnd = 54879 }, new Address() { AddressString = "138 Northwood Ln, Tallmadge, OH 44278", Latitude = 41.085464134812, Longitude = -81.447411775589, Time = 300, TimeWindowStart = 54879, TimeWindowEnd = 56613 }, new Address() { AddressString = "3401 Saratoga Blvd, Stow, OH 44224", Latitude = 41.148849487305, Longitude = -81.407363891602, Time = 300, TimeWindowStart = 56613, TimeWindowEnd = 57052 }, new Address() { AddressString = "5169 Brockton Dr, Stow, OH 44224", Latitude = 41.195003509521, Longitude = -81.392700195312, Time = 300, TimeWindowStart = 57052, TimeWindowEnd = 59004 }, new Address() { AddressString = "5169 Brockton Dr, Stow, OH 44224", Latitude = 41.195003509521, Longitude = -81.392700195312, Time = 300, TimeWindowStart = 59004, TimeWindowEnd = 60027 }, new Address() { AddressString = "458 Aintree Dr, Munroe Falls, OH 44262", Latitude = 41.1266746521, Longitude = -81.445808410645, Time = 300, TimeWindowStart = 60027, TimeWindowEnd = 60375 }, new Address() { AddressString = "512 Florida Pl, Barberton, OH 44203", Latitude = 41.003671512008, Longitude = -81.598461046815, Time = 300, TimeWindowStart = 60375, TimeWindowEnd = 63891 }, new Address() { AddressString = "2299 Tyre Dr, Hudson, OH 44236", Latitude = 41.250511169434, Longitude = -81.420433044434, Time = 300, TimeWindowStart = 63891, TimeWindowEnd = 65277 }, new Address() { AddressString = "2148 8th St, Cuyahoga Falls, OH 44221", Latitude = 41.136692047119, Longitude = -81.493492126465, Time = 300, TimeWindowStart = 65277, TimeWindowEnd = 68545 } #endregion }; // Set parameters var parameters = new RouteParameters() { AlgorithmType = AlgorithmType.CVRP_TW_MD, RouteName = "Multiple Depot, Multiple Driver Fine Tuning, Time Window", RouteDate = R4MeUtils.ConvertToUnixTimestamp(DateTime.UtcNow.Date.AddDays(1)), RouteTime = 60 * 60 * 7, RouteMaxDuration = 86400 * 3, VehicleCapacity = 5, VehicleMaxDistanceMI = 10000, Optimize = Optimize.TimeWithTraffic.Description(), DistanceUnit = DistanceUnit.MI.Description(), DeviceType = DeviceType.Web.Description(), TravelMode = TravelMode.Driving.Description(), Metric = Metric.Matrix, TargetDistance = 100, TargetDuration = 1, WaitingTime = 1 }; var optimizationParameters = new OptimizationParameters() { Addresses = addresses, Parameters = parameters }; // Run the query var dataObjectFineTuning = route4Me .RunOptimization(optimizationParameters, out string errorString); PrintExampleOptimizationResult(dataObjectFineTuning, errorString); OptimizationsToRemove = new List <string>() { dataObjectFineTuning?.OptimizationProblemId ?? null }; Console.WriteLine(""); Console.WriteLine("TargetDistance: " + (dataObjectFineTuning?.Parameters?.TargetDistance ?? null)); Console.WriteLine("TargetDuration: " + (dataObjectFineTuning?.Parameters?.TargetDuration ?? null)); Console.WriteLine("WaitingTime: " + (dataObjectFineTuning?.Parameters?.WaitingTime ?? null)); RemoveTestOptimizations(); }
public string UrlFor(Type modelType, RouteParameters parameters) { return("url for {0} with parameters {1}".ToFormat(modelType.FullName, parameters)); }
public string UrlFor(Type modelType, RouteParameters parameters, string categoryOrHttpMethod) { return("url for {0}/{1} with parameters {2}".ToFormat(modelType.FullName, categoryOrHttpMethod, parameters)); }
public void StartRouteCalculation(RouteParameters routeParameters, string routeName) { routeParameters.DirectionsLanguage = new CultureInfo("nl-NL"); routeParameters.ReturnDirections = true; routeParameters.FindBestSequence = true; routeParameters.PreserveFirstStop = true; routeParameters.PreserveLastStop = true; routeParameters.ReturnStops = true; routeParameters.DirectionsLengthUnits = esriUnits.esriKilometers; routeTask.Failed += (s, a) => { string errorMessage = "Routing error: "; errorMessage += a.Error.Message; foreach (string detail in (a.Error as ServiceException).Details) errorMessage += "," + detail; messageBoxCustom.Show(errorMessage, "Error"); }; routeTask.SolveCompleted += RouteSolvedComplete; routeTask.SolveAsync(routeParameters, routeName); }
public DataObject MultipleDepotMultipleDriver() { // Create the manager with the api key Route4MeManager route4Me = new Route4MeManager(c_ApiKey); // Prepare the addresses Address[] addresses = new Address[] { #region Addresses new Address() { AddressString = "3634 W Market St, Fairlawn, OH 44333", //all possible originating locations are depots, should be marked as true //stylistically we recommend all depots should be at the top of the destinations list IsDepot = true, Latitude = 41.135762259364, Longitude = -81.629313826561, //the number of seconds at destination Time = 300, //together these two specify the time window of a destination //seconds offset relative to the route start time for the open availability of a destination TimeWindowStart = 28800, //seconds offset relative to the route end time for the open availability of a destination TimeWindowEnd = 29465 }, new Address() { AddressString = "1218 Ruth Ave, Cuyahoga Falls, OH 44221", Latitude = 41.135762259364, Longitude = -81.629313826561, Time = 300, TimeWindowStart = 29465, TimeWindowEnd = 30529 }, new Address() { AddressString = "512 Florida Pl, Barberton, OH 44203", Latitude = 41.003671512008, Longitude = -81.598461046815, Time = 300, TimeWindowStart = 30529, TimeWindowEnd = 33779 }, new Address() { AddressString = "512 Florida Pl, Barberton, OH 44203", Latitude = 41.003671512008, Longitude = -81.598461046815, Time = 100, TimeWindowStart = 33779, TimeWindowEnd = 33944 }, new Address() { AddressString = "3495 Purdue St, Cuyahoga Falls, OH 44221", Latitude = 41.162971496582, Longitude = -81.479049682617, Time = 300, TimeWindowStart = 33944, TimeWindowEnd = 34801 }, new Address() { AddressString = "1659 Hibbard Dr, Stow, OH 44224", Latitude = 41.194505989552, Longitude = -81.443351581693, Time = 300, TimeWindowStart = 34801, TimeWindowEnd = 36366 }, new Address() { AddressString = "2705 N River Rd, Stow, OH 44224", Latitude = 41.145240783691, Longitude = -81.410247802734, Time = 300, TimeWindowStart = 36366, TimeWindowEnd = 39173 }, new Address() { AddressString = "10159 Bissell Dr, Twinsburg, OH 44087", Latitude = 41.340042114258, Longitude = -81.421226501465, Time = 300, TimeWindowStart = 39173, TimeWindowEnd = 41617 }, new Address() { AddressString = "367 Cathy Dr, Munroe Falls, OH 44262", Latitude = 41.148578643799, Longitude = -81.429229736328, Time = 300, TimeWindowStart = 41617, TimeWindowEnd = 43660 }, new Address() { AddressString = "367 Cathy Dr, Munroe Falls, OH 44262", Latitude = 41.148578643799, Longitude = -81.429229736328, Time = 300, TimeWindowStart = 43660, TimeWindowEnd = 46392 }, new Address() { AddressString = "512 Florida Pl, Barberton, OH 44203", Latitude = 41.003671512008, Longitude = -81.598461046815, Time = 300, TimeWindowStart = 46392, TimeWindowEnd = 48389 }, new Address() { AddressString = "559 W Aurora Rd, Northfield, OH 44067", Latitude = 41.315116882324, Longitude = -81.558746337891, Time = 50, TimeWindowStart = 48389, TimeWindowEnd = 48449 }, new Address() { AddressString = "3933 Klein Ave, Stow, OH 44224", Latitude = 41.169467926025, Longitude = -81.429420471191, Time = 300, TimeWindowStart = 48449, TimeWindowEnd = 50152 }, new Address() { AddressString = "2148 8th St, Cuyahoga Falls, OH 44221", Latitude = 41.136692047119, Longitude = -81.493492126465, Time = 300, TimeWindowStart = 50152, TimeWindowEnd = 51982 }, new Address() { AddressString = "3731 Osage St, Stow, OH 44224", Latitude = 41.161357879639, Longitude = -81.42293548584, Time = 100, TimeWindowStart = 51982, TimeWindowEnd = 52180 }, new Address() { AddressString = "3731 Osage St, Stow, OH 44224", Latitude = 41.161357879639, Longitude = -81.42293548584, Time = 300, TimeWindowStart = 52180, TimeWindowEnd = 54379 } #endregion }; // Set parameters RouteParameters parameters = new RouteParameters() { //specify capacitated vehicle routing with time windows and multiple depots, with multiple drivers AlgorithmType = AlgorithmType.CVRP_TW_MD, //set an arbitrary route name //this value shows up in the website, and all the connected mobile device RouteName = "Multiple Depot, Multiple Driver", //the route start date in UTC, unix timestamp seconds (Tomorrow) RouteDate = R4MeUtils.ConvertToUnixTimestamp(DateTime.UtcNow.Date.AddDays(1)), //the time in UTC when a route is starting (7AM) RouteTime = 60 * 60 * 7, //the maximum duration of a route RouteMaxDuration = 86400, VehicleCapacity = "1", VehicleMaxDistanceMI = "10000", Optimize = Optimize.Distance.Description(), DistanceUnit = DistanceUnit.MI.Description(), DeviceType = DeviceType.Web.Description(), TravelMode = TravelMode.Driving.Description(), Metric = Metric.Geodesic }; OptimizationParameters optimizationParameters = new OptimizationParameters() { Addresses = addresses, Parameters = parameters }; // Run the query string errorString; DataObject dataObject = route4Me.RunOptimization(optimizationParameters, out errorString); // Output the result PrintExampleOptimizationResult("MultipleDepotMultipleDriver", dataObject, errorString); return(dataObject); }
/// <summary> /// See interface docs. /// </summary> /// <param name="owinEnvironment"></param> /// <param name="route"></param> /// <param name="routeParameters"></param> /// <returns></returns> public object CallRoute(IDictionary <string, object> owinEnvironment, Route route, RouteParameters routeParameters) { if (owinEnvironment == null) { throw new ArgumentNullException(nameof(owinEnvironment)); } if (route == null) { throw new ArgumentNullException(nameof(route)); } if (routeParameters == null) { throw new ArgumentNullException(nameof(routeParameters)); } object result; if (route.Method.IsStatic) { result = route.Method.Invoke(null, routeParameters.Parameters); } else { var controller = (IApiController)Activator.CreateInstance(route.ControllerType.Type); try { controller.OwinEnvironment = owinEnvironment; result = route.Method.Invoke(controller, routeParameters.Parameters); } finally { if (controller is IDisposable disposableController) { disposableController.Dispose(); } } } return(result); }
public void Should_support_GetDynamicMemberNames() { // Given dynamic parameters = new RouteParameters(); parameters["test"] = "10"; parameters["rest"] = "20"; // When var names = ((RouteParameters) parameters).GetDynamicMemberNames(); // Then Assert.True(names.SequenceEqual(new[] {"test", "rest"})); }
private void OnRouteStartCommandClicked(object arg) { DeleteInfoWindow(); // Verify a number of selections has been done if (locationInputViewModel.LocationsSelected.Count < 2) { ShowMessagebox.Raise(new Notification { Content = Silverlight.UI.Esri.JTToolbarCommon.Resources.ToolbarCommon.SelectMin2Locations, Title = Silverlight.UI.Esri.JTToolbarCommon.Resources.ToolbarCommon.Warning }); return; } gisRouting.SetFinishedEvent(RouteCompleted); IList<Graphic> stopPoints = new List<Graphic>(); foreach (var item in locationInputViewModel.LocationsSelected) { stopPoints.Add(new Graphic() { Geometry = item.Location }); } RouteParameters routeParameters = new RouteParameters() { Stops = stopPoints }; const string routeName = "Route"; gisRouting.StartRouteCalculation(routeParameters, routeName); }
private async void Initialize() { try { // Get the paths to resources used by the sample. string basemapTilePath = DataManager.GetDataFolder("567e14f3420d40c5a206e5c0284cf8fc", "streetmap_SD.tpk"); string networkGeodatabasePath = DataManager.GetDataFolder("567e14f3420d40c5a206e5c0284cf8fc", "sandiego.geodatabase"); // Create the tile cache representing the offline basemap. TileCache tiledBasemapCache = new TileCache(basemapTilePath); // Create a tiled layer to display the offline tiles. ArcGISTiledLayer offlineTiledLayer = new ArcGISTiledLayer(tiledBasemapCache); // Create a basemap based on the tile layer. Basemap offlineBasemap = new Basemap(offlineTiledLayer); // Create a new map with the offline basemap. Map theMap = new Map(offlineBasemap); // Set the initial viewpoint to show the routable area. theMap.InitialViewpoint = new Viewpoint(_routableArea); // Show the map in the map view. _myMapView.Map = theMap; // Create overlays for displaying the stops and the calculated route. _stopsOverlay = new GraphicsOverlay(); _routeOverlay = new GraphicsOverlay(); // Create a symbol and renderer for symbolizing the calculated route. SimpleLineSymbol routeSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Blue, 2); _routeOverlay.Renderer = new SimpleRenderer(routeSymbol); // Add the stops and route overlays to the map. _myMapView.GraphicsOverlays.Add(_stopsOverlay); _myMapView.GraphicsOverlays.Add(_routeOverlay); // Create the route task, referring to the offline geodatabase with the street network. _offlineRouteTask = await RouteTask.CreateAsync(networkGeodatabasePath, "Streets_ND"); // Get the list of available travel modes. _availableTravelModes = _offlineRouteTask.RouteTaskInfo.TravelModes.ToList(); // Update the UI with the travel modes list. ArrayAdapter <string> spinnerListAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, _availableTravelModes.Select(travelMode => travelMode.Name).ToArray()); _travelModeSpinner.Adapter = spinnerListAdapter; _travelModeSpinner.SetSelection(0); // Create the default parameters. _offlineRouteParameters = await _offlineRouteTask.CreateDefaultParametersAsync(); // Display the extent of the road network on the map. DisplayBoundaryMarker(); // Now that the sample is ready, hook up the tapped and hover events. _myMapView.GeoViewTapped += MapView_Tapped; _travelModeSpinner.ItemSelected += TravelMode_SelectionChanged; } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); ShowMessage("Couldn't start sample", "There was a problem starting the sample. See debug output for details."); } }
protected IGrammar BrowserIsAt(Type modelType, RouteParameters parameters, string title, string categoryOrHttpMethod = null) { return(BrowserIsAt(x => x.UrlFor(modelType, parameters, categoryOrHttpMethod), title)); }
public bool MultipleDepotMultipleDriverWith24StopsTimeWindowTest() { var route4Me = new Route4MeManagerV5(c_ApiKey); // Prepare the addresses Address[] addresses = new Address[] { #region Addresses new Address() { AddressString = "3634 W Market St, Fairlawn, OH 44333", IsDepot = true, Latitude = 41.135762259364, Longitude = -81.629313826561, Time = 300, TimeWindowStart = 28800, TimeWindowEnd = 29465 }, new Address() { AddressString = "1218 Ruth Ave, Cuyahoga Falls, OH 44221", Latitude = 41.143505096435, Longitude = -81.46549987793, Time = 300, TimeWindowStart = 29465, TimeWindowEnd = 30529 }, new Address() { AddressString = "512 Florida Pl, Barberton, OH 44203", Latitude = 41.003671512008, Longitude = -81.598461046815, Time = 300, TimeWindowStart = 30529, TimeWindowEnd = 33479 }, new Address() { AddressString = "512 Florida Pl, Barberton, OH 44203", IsDepot = true, Latitude = 41.003671512008, Longitude = -81.598461046815, Time = 300, TimeWindowStart = 33479, TimeWindowEnd = 33944 }, new Address() { AddressString = "3495 Purdue St, Cuyahoga Falls, OH 44221", Latitude = 41.162971496582, Longitude = -81.479049682617, Time = 300, TimeWindowStart = 33944, TimeWindowEnd = 34801 }, new Address() { AddressString = "1659 Hibbard Dr, Stow, OH 44224", Latitude = 41.194505989552, Longitude = -81.443351581693, Time = 300, TimeWindowStart = 34801, TimeWindowEnd = 36366 }, new Address() { AddressString = "2705 N River Rd, Stow, OH 44224", Latitude = 41.145240783691, Longitude = -81.410247802734, Time = 300, TimeWindowStart = 36366, TimeWindowEnd = 39173 }, new Address() { AddressString = "10159 Bissell Dr, Twinsburg, OH 44087", Latitude = 41.340042114258, Longitude = -81.421226501465, Time = 300, TimeWindowStart = 39173, TimeWindowEnd = 41617 }, new Address() { AddressString = "367 Cathy Dr, Munroe Falls, OH 44262", Latitude = 41.148578643799, Longitude = -81.429229736328, Time = 300, TimeWindowStart = 41617, TimeWindowEnd = 43660 }, new Address() { AddressString = "367 Cathy Dr, Munroe Falls, OH 44262", Latitude = 41.148579, Longitude = -81.42923, Time = 300, TimeWindowStart = 43660, TimeWindowEnd = 46392 }, new Address() { AddressString = "512 Florida Pl, Barberton, OH 44203", Latitude = 41.003671512008, Longitude = -81.598461046815, Time = 300, TimeWindowStart = 46392, TimeWindowEnd = 48089 }, new Address() { AddressString = "559 W Aurora Rd, Northfield, OH 44067", Latitude = 41.315116882324, Longitude = -81.558746337891, Time = 300, TimeWindowStart = 48089, TimeWindowEnd = 48449 }, new Address() { AddressString = "3933 Klein Ave, Stow, OH 44224", Latitude = 41.169467926025, Longitude = -81.429420471191, Time = 300, TimeWindowStart = 48449, TimeWindowEnd = 50152 }, new Address() { AddressString = "2148 8th St, Cuyahoga Falls, OH 44221", Latitude = 41.136692047119, Longitude = -81.493492126465, Time = 300, TimeWindowStart = 50152, TimeWindowEnd = 51682 }, new Address() { AddressString = "3731 Osage St, Stow, OH 44224", Latitude = 41.161357879639, Longitude = -81.42293548584, Time = 300, TimeWindowStart = 51682, TimeWindowEnd = 54379 }, new Address() { AddressString = "3862 Klein Ave, Stow, OH 44224", Latitude = 41.167895123363, Longitude = -81.429973393679, Time = 300, TimeWindowStart = 54379, TimeWindowEnd = 54879 }, new Address() { AddressString = "138 Northwood Ln, Tallmadge, OH 44278", Latitude = 41.085464134812, Longitude = -81.447411775589, Time = 300, TimeWindowStart = 54879, TimeWindowEnd = 56613 }, new Address() { AddressString = "3401 Saratoga Blvd, Stow, OH 44224", Latitude = 41.148849487305, Longitude = -81.407363891602, Time = 300, TimeWindowStart = 56613, TimeWindowEnd = 57052 }, new Address() { AddressString = "5169 Brockton Dr, Stow, OH 44224", Latitude = 41.195003509521, Longitude = -81.392700195312, Time = 300, TimeWindowStart = 57052, TimeWindowEnd = 59004 }, new Address() { AddressString = "5169 Brockton Dr, Stow, OH 44224", Latitude = 41.195003509521, Longitude = -81.392700195312, Time = 300, TimeWindowStart = 59004, TimeWindowEnd = 60027 }, new Address() { AddressString = "458 Aintree Dr, Munroe Falls, OH 44262", Latitude = 41.1266746521, Longitude = -81.445808410645, Time = 300, TimeWindowStart = 60027, TimeWindowEnd = 60375 }, new Address() { AddressString = "512 Florida Pl, Barberton, OH 44203", Latitude = 41.003671512008, Longitude = -81.598461046815, Time = 300, TimeWindowStart = 60375, TimeWindowEnd = 63891 }, new Address() { AddressString = "2299 Tyre Dr, Hudson, OH 44236", Latitude = 41.250511169434, Longitude = -81.420433044434, Time = 300, TimeWindowStart = 63891, TimeWindowEnd = 65277 }, new Address() { AddressString = "2148 8th St, Cuyahoga Falls, OH 44221", Latitude = 41.136692047119, Longitude = -81.493492126465, Time = 300, TimeWindowStart = 65277, TimeWindowEnd = 68545 } #endregion }; // Set parameters var parameters = new RouteParameters() { AlgorithmType = AlgorithmType.CVRP_TW_MD, RouteName = "Multiple Depot, Multiple Driver with 24 Stops, Time Window", //StoreRoute = false, RouteDate = R4MeUtils.ConvertToUnixTimestamp(DateTime.UtcNow.Date.AddDays(1)), RouteTime = 60 * 60 * 7, RouteMaxDuration = 86400, VehicleCapacity = 5, VehicleMaxDistanceMI = 10000, Optimize = Optimize.Distance.Description(), DistanceUnit = DistanceUnit.MI.Description(), DeviceType = DeviceType.Web.Description(), TravelMode = TravelMode.Driving.Description(), Metric = Metric.Matrix }; var optimizationParameters = new OptimizationParameters() { Addresses = addresses, Parameters = parameters }; // Run the query try { dataObjectMDMD24 = route4Me.RunOptimization(optimizationParameters, out ResultResponse resultResponse); MDMD24_route_id = (dataObjectMDMD24 != null && dataObjectMDMD24.Routes != null && dataObjectMDMD24.Routes.Length > 0) ? dataObjectMDMD24.Routes[0].RouteID : null; MDMD24_optimization_problem_id = dataObjectMDMD24.OptimizationProblemId; MDMD24_route = (dataObjectMDMD24 != null && dataObjectMDMD24.Routes != null && dataObjectMDMD24.Routes.Length > 0) ? dataObjectMDMD24.Routes[0] : null; MDMD24_route_id = (MDMD24_route != null) ? MDMD24_route.RouteID : null; return(true); } catch (Exception ex) { Console.WriteLine("Generation of the Multiple Depot, Multiple Driver with 24 Stops optimization problem failed. " + ex.Message); return(false); } }
public virtual Link BuildLink(RouteParameters parameters) { Link l = new Link(this.Url.Path, null, this.Url.Title); if (parameters.ContainsKey("Page")) { l.Extra = string.Format("/p{0}", parameters["Page"]); } return l; }
public void Should_support_dynamic_casting_of_properties_to_timespans() { //Given dynamic parameters = new RouteParameters(); parameters.test = new TimeSpan(1, 2, 3, 4).ToString(); // When var value = (TimeSpan)parameters.test; // Then value.ShouldEqual(new TimeSpan(1, 2, 3, 4)); }
public bool RunOptimizationSingleDriverRoute10Stops() { var r4mm = new Route4MeManagerV5(c_ApiKey); // Prepare the addresses Address[] addresses = new Address[] { #region Addresses new Address() { AddressString = "151 Arbor Way Milledgeville GA 31061", //indicate that this is a departure stop //single depot routes can only have one departure depot IsDepot = true, //required coordinates for every departure and stop on the route Latitude = 33.132675170898, Longitude = -83.244743347168, //the expected time on site, in seconds. this value is incorporated into the optimization engine //it also adjusts the estimated and dynamic eta's for a route Time = 0, //input as many custom fields as needed, custom data is passed through to mobile devices and to the manifest CustomFields = new Dictionary <string, string>() { { "color", "red" }, { "size", "huge" } } }, new Address() { AddressString = "230 Arbor Way Milledgeville GA 31061", Latitude = 33.129695892334, Longitude = -83.24577331543, Time = 0 }, new Address() { AddressString = "148 Bass Rd NE Milledgeville GA 31061", Latitude = 33.143497, Longitude = -83.224487, Time = 0 }, new Address() { AddressString = "117 Bill Johnson Rd NE Milledgeville GA 31061", Latitude = 33.141784667969, Longitude = -83.237518310547, Time = 0 }, new Address() { AddressString = "119 Bill Johnson Rd NE Milledgeville GA 31061", Latitude = 33.141086578369, Longitude = -83.238258361816, Time = 0 }, new Address() { AddressString = "131 Bill Johnson Rd NE Milledgeville GA 31061", Latitude = 33.142036437988, Longitude = -83.238845825195, Time = 0 }, new Address() { AddressString = "138 Bill Johnson Rd NE Milledgeville GA 31061", Latitude = 33.14307, Longitude = -83.239334, Time = 0 }, new Address() { AddressString = "139 Bill Johnson Rd NE Milledgeville GA 31061", Latitude = 33.142734527588, Longitude = -83.237442016602, Time = 0 }, new Address() { AddressString = "145 Bill Johnson Rd NE Milledgeville GA 31061", Latitude = 33.143871307373, Longitude = -83.237342834473, Time = 0 }, new Address() { AddressString = "221 Blake Cir Milledgeville GA 31061", Latitude = 33.081462860107, Longitude = -83.208511352539, Time = 0 } #endregion }; // Set parameters var parameters = new RouteParameters() { AlgorithmType = AlgorithmType.TSP, //StoreRoute = false, RouteName = "Single Driver Route 10 Stops Test", RouteDate = R4MeUtils.ConvertToUnixTimestamp(DateTime.UtcNow.Date.AddDays(1)), RouteTime = 60 * 60 * 7, Optimize = Optimize.Distance.Description(), DistanceUnit = DistanceUnit.MI.Description(), DeviceType = DeviceType.Web.Description() }; var optimizationParameters = new OptimizationParameters() { Addresses = addresses, Parameters = parameters }; // Run the query //string errorString; try { dataObjectSD10Stops = r4mm.RunOptimization(optimizationParameters, out ResultResponse resultResponse); SD10Stops_optimization_problem_id = dataObjectSD10Stops.OptimizationProblemId; SD10Stops_route = (dataObjectSD10Stops != null && dataObjectSD10Stops.Routes != null && dataObjectSD10Stops.Routes.Length > 0) ? dataObjectSD10Stops.Routes[0] : null; SD10Stops_route_id = SD10Stops_route != null ? SD10Stops_route.RouteID : null; return(true); } catch (Exception ex) { Console.WriteLine("Single Driver Route 10 Stops generation failed. " + ex.Message); return(false); } }
public DataObject SingleDriverMultipleTimeWindows() { // Create the manager with the api key Route4MeManager route4Me = new Route4MeManager(c_ApiKey); // Prepare the addresses Address[] addresses = new Address[] { #region Addresses new Address() { AddressString = "3634 W Market St, Fairlawn, OH 44333", //all possible originating locations are depots, should be marked as true //stylistically we recommend all depots should be at the top of the destinations list IsDepot = true, Latitude = 41.135762259364, Longitude = -81.629313826561, TimeWindowStart = null, TimeWindowEnd = null, TimeWindowStart2 = null, TimeWindowEnd2 = null, Time = null }, new Address() { AddressString = "1218 Ruth Ave, Cuyahoga Falls, OH 44221", Latitude = 41.135762259364, Longitude = -81.629313826561, //together these two specify the time window of a destination //seconds offset relative to the route start time for the open availability of a destination TimeWindowStart = 6 * 3600 + 00 * 60, //seconds offset relative to the route end time for the open availability of a destination TimeWindowEnd = 6 * 3600 + 30 * 60, // Second 'TimeWindowStart' TimeWindowStart2 = 7 * 3600 + 00 * 60, // Second 'TimeWindowEnd' TimeWindowEnd2 = 7 * 3600 + 20 * 60, //the number of seconds at destination Time = 300 }, new Address() { AddressString = "512 Florida Pl, Barberton, OH 44203", Latitude = 41.003671512008, Longitude = -81.598461046815, TimeWindowStart = 7 * 3600 + 30 * 60, TimeWindowEnd = 7 * 3600 + 40 * 60, TimeWindowStart2 = 8 * 3600 + 00 * 60, TimeWindowEnd2 = 8 * 3600 + 10 * 60, Time = 300 }, new Address() { AddressString = "512 Florida Pl, Barberton, OH 44203", Latitude = 41.003671512008, Longitude = -81.598461046815, TimeWindowStart = 8 * 3600 + 30 * 60, TimeWindowEnd = 8 * 3600 + 40 * 60, TimeWindowStart2 = 8 * 3600 + 50 * 60, TimeWindowEnd2 = 9 * 3600 + 00 * 60, Time = 100 }, new Address() { AddressString = "3495 Purdue St, Cuyahoga Falls, OH 44221", Latitude = 41.162971496582, Longitude = -81.479049682617, TimeWindowStart = 9 * 3600 + 00 * 60, TimeWindowEnd = 9 * 3600 + 15 * 60, TimeWindowStart2 = 9 * 3600 + 30 * 60, TimeWindowEnd2 = 9 * 3600 + 45 * 60, Time = 300 }, new Address() { AddressString = "1659 Hibbard Dr, Stow, OH 44224", Latitude = 41.194505989552, Longitude = -81.443351581693, TimeWindowStart = 10 * 3600 + 00 * 60, TimeWindowEnd = 10 * 3600 + 15 * 60, TimeWindowStart2 = 10 * 3600 + 30 * 60, TimeWindowEnd2 = 10 * 3600 + 45 * 60, Time = 300 }, new Address() { AddressString = "2705 N River Rd, Stow, OH 44224", Latitude = 41.145240783691, Longitude = -81.410247802734, TimeWindowStart = 11 * 3600 + 00 * 60, TimeWindowEnd = 11 * 3600 + 15 * 60, TimeWindowStart2 = 11 * 3600 + 30 * 60, TimeWindowEnd2 = 11 * 3600 + 45 * 60, Time = 300 }, new Address() { AddressString = "10159 Bissell Dr, Twinsburg, OH 44087", Latitude = 41.340042114258, Longitude = -81.421226501465, TimeWindowStart = 12 * 3600 + 00 * 60, TimeWindowEnd = 12 * 3600 + 15 * 60, TimeWindowStart2 = 12 * 3600 + 30 * 60, TimeWindowEnd2 = 12 * 3600 + 45 * 60, Time = 300 }, new Address() { AddressString = "367 Cathy Dr, Munroe Falls, OH 44262", Latitude = 41.148578643799, Longitude = -81.429229736328, TimeWindowStart = 13 * 3600 + 00 * 60, TimeWindowEnd = 13 * 3600 + 15 * 60, TimeWindowStart2 = 13 * 3600 + 30 * 60, TimeWindowEnd2 = 13 * 3600 + 45 * 60, Time = 300 }, new Address() { AddressString = "367 Cathy Dr, Munroe Falls, OH 44262", Latitude = 41.148578643799, Longitude = -81.429229736328, TimeWindowStart = 14 * 3600 + 00 * 60, TimeWindowEnd = 14 * 3600 + 15 * 60, TimeWindowStart2 = 14 * 3600 + 30 * 60, TimeWindowEnd2 = 14 * 3600 + 45 * 60, Time = 300 }, new Address() { AddressString = "512 Florida Pl, Barberton, OH 44203", Latitude = 41.003671512008, Longitude = -81.598461046815, TimeWindowStart = 15 * 3600 + 00 * 60, TimeWindowEnd = 15 * 3600 + 15 * 60, TimeWindowStart2 = 15 * 3600 + 30 * 60, TimeWindowEnd2 = 15 * 3600 + 45 * 60, Time = 300 }, new Address() { AddressString = "559 W Aurora Rd, Northfield, OH 44067", Latitude = 41.315116882324, Longitude = -81.558746337891, TimeWindowStart = 16 * 3600 + 00 * 60, TimeWindowEnd = 16 * 3600 + 15 * 60, TimeWindowStart2 = 16 * 3600 + 30 * 60, TimeWindowEnd2 = 17 * 3600 + 00 * 60, Time = 50 } #endregion }; // Set parameters RouteParameters parameters = new RouteParameters() { AlgorithmType = AlgorithmType.TSP, StoreRoute = false, RouteName = "Single Driver Multiple TimeWindows 12 Stops", RouteDate = R4MeUtils.ConvertToUnixTimestamp(DateTime.UtcNow.Date.AddDays(1)), RouteTime = 5 * 3600 + 30 * 60, Optimize = Optimize.Distance.Description(), DistanceUnit = DistanceUnit.MI.Description(), DeviceType = DeviceType.Web.Description() }; OptimizationParameters optimizationParameters = new OptimizationParameters() { Addresses = addresses, Parameters = parameters }; // Run the query string errorString; DataObject dataObject = route4Me.RunOptimization(optimizationParameters, out errorString); // Output the result PrintExampleOptimizationResult("SingleDriverMultipleTimeWindows", dataObject, errorString); return(dataObject); }
/// <summary> /// Add Orders to an Optimization Problem object /// </summary> /// <returns> Optimization Problem object </returns> public void AddOrdersToOptimization() { // Create the manager with the api key Route4MeManager route4Me = new Route4MeManager(c_ApiKey); OptimizationParameters rQueryParams = new OptimizationParameters() { OptimizationProblemID = "7988378F70C533283BAD5024E6E37201", Redirect = false }; #region Addresses Address[] addresses = new Address[] { new Address { AddressString = "273 Canal St, New York, NY 10013, USA", Latitude = 40.7191558, Longitude = -74.0011966, Alias = "", CurbsideLatitude = 40.7191558, CurbsideLongitude = -74.0011966, IsDepot = true }, new Address { AddressString = "106 Liberty St, New York, NY 10006, USA", Alias = "BK Restaurant #: 2446", Latitude = 40.709637, Longitude = -74.011912, CurbsideLatitude = 40.709637, CurbsideLongitude = -74.011912, Email = "", Phone = "(917) 338-1887", FirstName = "", LastName = "", CustomFields = new Dictionary <string, string> { { "icon", null } }, Time = 0, TimeWindowStart = 1472544000, TimeWindowEnd = 1472544300, OrderId = 7205705 }, new Address { AddressString = "325 Broadway, New York, NY 10007, USA", Alias = "BK Restaurant #: 20333", Latitude = 40.71615, Longitude = -74.00505, CurbsideLatitude = 40.71615, CurbsideLongitude = -74.00505, Email = "", Phone = "(212) 227-7535", FirstName = "", LastName = "", CustomFields = new Dictionary <string, string> { { "icon", null } }, Time = 0, TimeWindowStart = 1472545000, TimeWindowEnd = 1472545300, OrderId = 7205704 }, new Address { AddressString = "106 Fulton St, Farmingdale, NY 11735, USA", Alias = "BK Restaurant #: 17871", Latitude = 40.73073, Longitude = -73.459283, CurbsideLatitude = 40.73073, CurbsideLongitude = -73.459283, Email = "", Phone = "(212) 566-5132", FirstName = "", LastName = "", CustomFields = new Dictionary <string, string> { { "icon", null } }, Time = 0, TimeWindowStart = 1472546000, TimeWindowEnd = 1472546300, OrderId = 7205703 } }; #endregion RouteParameters rParams = new RouteParameters() { RouteName = "Wednesday 15th of June 2016 07:01 PM (+03:00)", RouteDate = 1465948800, RouteTime = 14400, Optimize = "Time", RouteType = "single", AlgorithmType = AlgorithmType.TSP, RT = false, LockLast = false, MemberId = "1", VehicleId = "", DisableOptimization = false }; // Run the query string errorString = ""; DataObject dataObject = route4Me.AddOrdersToOptimization(rQueryParams, addresses, rParams, out errorString); Console.WriteLine(""); if (dataObject != null) { Console.WriteLine("AddOrdersToOptimization executed successfully"); Console.WriteLine("Optmization Problem ID: {0}", dataObject.OptimizationProblemId); } else { Console.WriteLine("AddOrdersToOptimization error: {0}", errorString); } }
private async Task <int> RunRouting() { try { _networkingToolView.ViewModel.PanelResultsVisibility = Visibility.Collapsed; _networkingToolView.ViewModel.ProgressVisibility = Visibility.Visible; RouteParameters routeParams = await _routeTask.GetDefaultParametersAsync(); routeParams.OutSpatialReference = _mapView.SpatialReference; routeParams.ReturnDirections = true; routeParams.DirectionsLengthUnit = LinearUnits.Miles; routeParams.DirectionsLanguage = new CultureInfo("en-Us"); // CultureInfo.CurrentCulture; routeParams.SetStops(_stopsOverlay.Graphics); var routeResult = await _routeTask.SolveAsync(routeParams); if (routeResult == null || routeResult.Routes == null || !routeResult.Routes.Any()) { throw new Exception("No route could be calculated"); } var route = routeResult.Routes.First(); _routesOverlay.Graphics.Add(new Graphic(route.RouteFeature.Geometry)); _directionsOverlay.GraphicsSource = route.RouteDirections.Select(rd => GraphicFromRouteDirection(rd)); _networkingToolView.ViewModel.Graphics = _directionsOverlay.Graphics; var totalTime = route.RouteDirections.Select(rd => rd.Time).Aggregate(TimeSpan.Zero, (p, v) => p.Add(v)); var totalLength = route.RouteDirections.Select(rd => rd.GetLength(LinearUnits.Miles)).Sum(); _networkingToolView.ViewModel.RouteTotals = string.Format("Time: {0:h':'mm':'ss} / Length: {1:0.00} mi", totalTime, totalLength); if (!route.RouteFeature.Geometry.IsEmpty) { await _mapView.SetViewAsync(route.RouteFeature.Geometry.Extent.Expand(1.25)); } } catch (AggregateException ex) { var innermostExceptions = ex.Flatten().InnerExceptions; if (innermostExceptions != null && innermostExceptions.Count > 0) { MessageBox.Show(innermostExceptions[0].Message, "Sample Error"); } else { MessageBox.Show(ex.Message, "Sample Error"); } Reset(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Sample Error"); Reset(); } finally { _networkingToolView.ViewModel.ProgressVisibility = Visibility.Collapsed; if (_directionsOverlay.Graphics.Any()) { _networkingToolView.ViewModel.PanelResultsVisibility = Visibility.Visible; } } return(0); }
public string UrlFor(Type modelType, RouteParameters parameters) { return("http://something.com/{0}/{1}".ToFormat(modelType.Name, parameters)); }
private async Task ProcessRouteRequest(MapPoint tappedPoint) { // Clear any existing overlays. _routeOverlay.Graphics.Clear(); _myMapView.DismissCallout(); // Return if there is no network available for routing. if (_networkDataset == null) { await ShowGeocodeResult(tappedPoint); return; } // Set the start point if it hasn't been set. if (_startPoint == null) { _startPoint = tappedPoint; await ShowGeocodeResult(tappedPoint); // Show the start point. _waypointOverlay.Graphics.Add(await GraphicForPoint(_startPoint)); return; } if (_endPoint == null) { await ShowGeocodeResult(tappedPoint); // Show the end point. _endPoint = tappedPoint; _waypointOverlay.Graphics.Add(await GraphicForPoint(_endPoint)); // Create the route task from the local network dataset. RouteTask routingTask = await RouteTask.CreateAsync(_networkDataset); // Configure route parameters for the route between the two tapped points. RouteParameters routingParameters = await routingTask.CreateDefaultParametersAsync(); List <Stop> stops = new List <Stop> { new Stop(_startPoint), new Stop(_endPoint) }; routingParameters.SetStops(stops); // Get the first route result. RouteResult result = await routingTask.SolveRouteAsync(routingParameters); Route firstRoute = result.Routes.First(); // Show the route on the map. Note that symbology for the graphics overlay is defined in Initialize(). Polyline routeLine = firstRoute.RouteGeometry; _routeOverlay.Graphics.Add(new Graphic(routeLine)); return; } // Reset graphics and route. _routeOverlay.Graphics.Clear(); _waypointOverlay.Graphics.Clear(); _startPoint = null; _endPoint = null; }
public string UrlFor(Type modelType, string category, RouteParameters parameters) { throw new NotImplementedException(); }
private async Task SetupRouteTask() { if (!IsOnline) { _routeTask = new LocalRouteTask(_localRoutingDatabase, _networkName); } else { _routeTask = new OnlineRouteTask(new Uri(_onlineRoutingService)); } if (_routeTask != null) _routeParams = await _routeTask.GetDefaultParametersAsync(); }
// Calculate the route private async void MyMapView_MapViewDoubleTapped(object sender, Esri.ArcGISRuntime.Controls.MapViewInputEventArgs e) { if (!_isMapReady || _stopsOverlay.Graphics.Count() < 2) { return; } try { e.Handled = true; panelResults.Visibility = Visibility.Collapsed; progress.Visibility = Visibility.Visible; if (_routeTask == null) { _routeTask = await Task.Run <LocalRouteTask>(() => new LocalRouteTask(_localRoutingDatabase, _networkName)); } RouteParameters routeParams = await _routeTask.GetDefaultParametersAsync(); routeParams.OutSpatialReference = MyMapView.SpatialReference; routeParams.ReturnDirections = true; routeParams.DirectionsLengthUnit = LinearUnits.Miles; routeParams.DirectionsLanguage = new CultureInfo("en-US"); routeParams.SetStops(_stopsOverlay.Graphics); var routeResult = await _routeTask.SolveAsync(routeParams); if (routeResult == null || routeResult.Routes == null || routeResult.Routes.Count() == 0) { throw new ApplicationException("No route could be calculated"); } var route = routeResult.Routes.First(); _routesOverlay.Graphics.Add(new Graphic(route.RouteFeature.Geometry)); _directionsOverlay.GraphicsSource = route.RouteDirections.Select(rd => GraphicFromRouteDirection(rd)); var totalTime = route.RouteDirections.Select(rd => rd.Time).Aggregate(TimeSpan.Zero, (p, v) => p.Add(v)); var totalLength = route.RouteDirections.Select(rd => rd.GetLength(LinearUnits.Miles)).Sum(); txtRouteTotals.Text = string.Format("Time: {0:h':'mm':'ss} / Length: {1:0.00} mi", totalTime, totalLength); await MyMapView.SetViewAsync(route.RouteFeature.Geometry.Extent.Expand(1.2)); } catch (AggregateException ex) { var innermostExceptions = ex.Flatten().InnerExceptions; if (innermostExceptions != null && innermostExceptions.Count > 0) { MessageBox.Show(innermostExceptions[0].Message, "Sample Error"); } else { MessageBox.Show(ex.Message, "Sample Error"); } } catch (System.Exception ex) { MessageBox.Show(ex.Message, "Sample Error"); } finally { progress.Visibility = Visibility.Collapsed; if (_directionsOverlay.Graphics.Count() > 0) { panelResults.Visibility = Visibility.Visible; } } }