openrouteservice-js icon indicating copy to clipboard operation
openrouteservice-js copied to clipboard

Add Optimization Service support

Open damian66 opened this issue 3 years ago • 2 comments

Added support for Optimization Service, requested in #38. I tried to match the code style with other files. I also decided to keep it as simple as possible - feel free to suggest changes. Service arguments are saved in the class instance to match the behavior of the rest of the repository.

  • Created OrsOptimization class based on other files to match the style of the repository.
  • Test coverage above 80%
  • Added an example of the usage to the README file (sample data taken from ORS docs)

Usage

Example of how the optimization service could be consumed. It was included in the README.md file as well.

var openrouteservice = require("openrouteservice-js");

// Add your api_key here
var Optimization = new openrouteservice.Optimization({api_key: "XYZ"});

Optimization.optimize({
  jobs: [
    {
      id: 1,
      service: 300,
      amount: [1],
      location: [2.03655, 48.61128],
      skills: [1]
    },
    {
      id: 2,
      service: 300,
      amount: [1],
      location: [2.03655, 48.61128],
      skills: [2]
    },
  ],
  vehicles: [
    {
      id: 1,
      profile: 'driving-car',
      start: [2.35044, 48.71764],
      end: [2.35044, 48.71764],
      capacity: [3],
      skills: [1, 2],
    }
  ],
})
.then(function(response) {
  // Add your own result handling here
  console.log('response', JSON.stringify(response));
})
.catch(function(err) {
  var str = 'An error occurred: ' + err;
  console.log(str)
});

damian66 avatar May 18 '22 21:05 damian66

Hi @damian66,

thanks a lot for the contribution!

I'll see if i can find some time within the next weeks to review, can't promise anything though. Until then, if people want to use this please use damian's fork.

TheGreatRefrigerator avatar Jun 02 '22 14:06 TheGreatRefrigerator

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
19.3% 19.3% Duplication

sonarqubecloud[bot] avatar Jun 17 '22 09:06 sonarqubecloud[bot]

superseded by https://github.com/GIScience/openrouteservice-js/pull/56

TheGreatRefrigerator avatar Nov 14 '22 16:11 TheGreatRefrigerator