C# sdk for route optimization

Do you have any c# sdk for route optimization ?

Not directly. But you have plenty of options.

  1. Use the optimization directly from our public API and query it from within your C# code. You can generate examples directly in our API playground Dashboard | ORS.
    Just click on “Show Example Code” to receive ready code in e.g. C#:
//Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses.
//System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

//Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line.
using System;
using System.Net.Http;

var baseAddress = new Uri("https://api.openrouteservice.org");

using (var httpClient = new HttpClient{ BaseAddress = baseAddress })
  httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8");
  httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8");
  httpClient.DefaultRequestHeaders.Authorization =
      new AuthenticationHeaderValue("Bearer", "your-api-key");
    // quotes might have to be escaped
    using (var content = new StringContent("{"jobs":[{"id":1,"service":300,"delivery":[1],"location":[1.98465,48.70329],"skills":[1],"time_windows":[[32400,36000]]},{"id":2,"service":300,"delivery":[1],"location":[2.03655,48.61128],"skills":[1]},{"id":3,"service":300,"delivery":[1],"location":[2.39719,49.07611],"skills":[2]},{"id":4,"service":300,"delivery":[1],"location":[2.41808,49.22619],"skills":[2]},{"id":5,"service":300,"delivery":[1],"location":[2.28325,48.5958],"skills":[14]},{"id":6,"service":300,"delivery":[1],"location":[2.89357,48.90736],"skills":[14]}],"vehicles":[{"id":1,"profile":"driving-car","start":[2.35044,48.71764],"end":[2.35044,48.71764],"capacity":[4],"skills":[1,14],"time_window":[28800,43200]},{"id":2,"profile":"driving-car","start":[2.35044,48.71764],"end":[2.35044,48.71764],"capacity":[4],"skills":[2,14],"time_window":[28800,43200]}]}"))
      using (var response = await httpClient.PostAsync("/optimization", content))
        string responseData = await response.Content.ReadAsStringAsync();
        var data = JsonConvert.DeserializeObject(responseData);
  1. If our quota doesn’t fit your needs, have a look at GitHub - VROOM-Project/vroom: Vehicle Routing Open-source Optimization Machine. We’re integrated into that optimizer, and this is also what runs behind our /optimization API. You can compile and run it on any machine, or just set it up in a container together with ORS and have unlimited quota locally.

Thanks for your reply.

I have been looking for a great product like this for years.

  1. Do you have a sdk instead of an api ?

2)Do you have a price for commercial use ?

3)I am using it for delivery optimization by including both pick up and delivery. Let’s say a package has to be picked up from point D and delivered to A.

The drive has to go to points : A,B,C,D,E,F .

Can the optimization take in consideration that D(Pick up place) needs to be visited before A (Delivery place) ?


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.