GIScience/openrouteservice-js

Bug: Impossible to set avoidables for directions

Semurak opened this issue · 0 comments

After updating the package openrouteservice-js from version 0.1.16 to 0.1.20, following error occurs

TypeError: Cannot set property 'avoid_features' of undefined
    at OrsDirections.getBody (/home/FILEPATH/node_modules/openrouteservice-js/npm_distribution/OrsDirections.js:100:37)
    at /home/FILEPATH/node_modules/openrouteservice-js/npm_distribution/OrsDirections.js:130:29
    at Promise._execute (/home/FILEPATH/node_modules/bluebird/js/release/debuggability.js:384:9)
    at Promise._resolveFromExecutor (/home/FILEPATH/node_modules/bluebird/js/release/promise.js:518:18)
    at new Promise (/home/FILEPATH/node_modules/bluebird/js/release/promise.js:103:10)
    at OrsDirections.calculate (/home/FILEPATH/node_modules/openrouteservice-js/npm_distribution/OrsDirections.js:121:14)
    at /home/FILEPATH/models/openrouteservice.js:32:32
    at /home/FILEPATH/plugins/outbound/wallboard/service.js:270:45
    at /home/FILEPATH/models/openrouteservice.js:31:7
    at Statement.<anonymous> (/home/FILEPATH/models/configuration.js:50:28)
TypeError: Cannot set property 'avoid_features' of undefined
    at OrsDirections.getBody (/home/FILEPATH/node_modules/openrouteservice-js/npm_distribution/OrsDirections.js:100:37)
    at /home/FILEPATH/node_modules/openrouteservice-js/npm_distribution/OrsDirections.js:130:29
    at Promise._execute (/home/FILEPATH/node_modules/bluebird/js/release/debuggability.js:384:9)
    at Promise._resolveFromExecutor (/home/FILEPATH/node_modules/bluebird/js/release/promise.js:518:18)
    at new Promise (/home/FILEPATH/node_modules/bluebird/js/release/promise.js:103:10)
    at OrsDirections.calculate (/home/FILEPATH/node_modules/openrouteservice-js/npm_distribution/OrsDirections.js:121:14)
    at /home/FILEPATH/models/openrouteservice.js:32:32
    at /home/FILEPATH/plugins/outbound/wallboard/service.js:270:45
    at /home/FILEPATH/models/openrouteservice.js:31:7
    at Statement.<anonymous> (/home/FILEPATH/models/configuration.js:50:28)

Here is my code snippet to reproduce the error:

 this.directions = new openrouteservice.Directions({
        api_key: apiKey
      });
      callback(() => {
        return this.directions.calculate({
          coordinates: [start, destination],
          profile: 'driving-car',
          extra_info: ['waytype', 'steepness'],
          avoidables: ['tollways', 'ferries', 'fords'],
          format: 'geojson'
        })
      })

After removing the line avoidables: ['tollways', 'ferries', 'fords'], the package works as intented.