Comments (3)
@amoncaldas this is included in https://www.npmjs.com/package/openrouteservice-js/v/0.1.2 and can be set with the service
parameter, e.g.
Directions.calculate({
coordinates: [[8.690958, 49.404662], [8.687868, 49.390139]],
profile: 'driving-hgv',
service: 'pdirections',
restrictions: { height: 10, weight: 5 },
extra_info: ['waytype', 'steepness'],
avoidables: ['highways', 'tollways', 'ferries', 'fords'],
avoid_polygons: {
type: 'Polygon',
coordinates: [
[
[8.683533668518066, 49.41987949639816],
[8.680272102355957, 49.41812070066643],
[8.683919906616211, 49.4132348262363],
[8.689756393432617, 49.41806486484901],
[8.683533668518066, 49.41987949639816]
]
]
},
format: 'json',
mime_type: 'application/json'
})
.then(function(response) {
console.log('response', JSON.stringify(response))
})
.catch(function(err) {
var str = 'An error occured: ' + err
console.log(str)
})
from openrouteservice-js.
Thanks for the reply.
So, at least in the client intended to be used with api version 2, it is not working properly.
In OrsDirections.js the request url is built using the following code:
var requestSettings = orsUtil.prepareRequest(that.args, 'directions'); // directions is hard coded
ar url = [requestSettings.meta.host, requestSettings.meta.apiVersion, requestSettings.meta.service, requestSettings.meta.profile, requestSettings.meta.format].join('/')
and in OrsUtil.js, the arg.service
value is not used. Instead it is used the hard coded one passed in OrsDirections.js:
key: 'prepareRequest',
value: function prepareRequest(args, service) {
var request = {
meta: {
host: args.host,
apiVersion: args.api_version,
profile: args.profile,
format: args.format,
service: service, // here should be args.service || service
apiKey: args.api_key,
mimeType: args.mime_type
}
};
[...]
}```
A similar issue occurs in ORSIsochones.js and OrsMatrix.js
from openrouteservice-js.
@amoncaldas are you sure? Look here:
https://github.com/GIScience/openrouteservice-js/blob/master/src/OrsDirections.js#L88
&
https://github.com/GIScience/openrouteservice-js/blob/master/src/OrsUtil.js#L58
This request is working for me:
Directions.calculate({
coordinates: [[8.690958, 49.404662], [8.687868, 49.390139]],
profile: 'driving-hgv',
service: 'directions',
restrictions: { height: 10, weight: 5 },
extra_info: ['waytype', 'steepness'],
avoidables: ['highways', 'tollways', 'ferries', 'fords'],
avoid_polygons: {
type: 'Polygon',
coordinates: [
[
[8.683533668518066, 49.41987949639816],
[8.680272102355957, 49.41812070066643],
[8.683919906616211, 49.4132348262363],
[8.689756393432617, 49.41806486484901],
[8.683533668518066, 49.41987949639816]
]
]
},
format: 'json',
mime_type: 'application/json'
})
.then(function(response) {
console.log('response', JSON.stringify(response))
})
.catch(function(err) {
var str = 'An error occured: ' + err
console.log(str)
})
from openrouteservice-js.
Related Issues (20)
- Interval has incorrect value or format (JS API) HOT 1
- not found HOT 1
- how can connect to my custom instance of ORS? HOT 1
- Adding alternative routes for Directions HOT 1
- Support to Optimization Api HOT 2
- Adding support for optimization? HOT 1
- Bug: Impossible to set avoidables for directions
- bug: Cannot get geocoding for some adresses HOT 2
- feature request: Add optimization endpoint HOT 1
- URL for Matrix Service is wrong HOT 1
- vulnerability issue: http-server dependency
- Extract base class for services
- Fixup README.md
- TypeScript support HOT 3
- use native promises instead of bluebird
- use fetch API instead of superagent HOT 2
- Allow to use self-hosted ORS HOT 2
- how to use this with leaflet routing machine HOT 1
- [Bug] Missing twitter tweet link from website HOT 1
- Alternative Routes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openrouteservice-js.