Add Optimization Service support
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)
});
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.
SonarCloud Quality Gate failed. 
0 Bugs
0 Vulnerabilities
0 Security Hotspots
0 Code Smells
No Coverage information
19.3% Duplication
superseded by https://github.com/GIScience/openrouteservice-js/pull/56