Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

osrm

Package Overview
Dependencies
Maintainers
6
Versions
184
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

osrm

Open Source Routing Machine

  • 5.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
495
increased by34.15%
Maintainers
6
Weekly downloads
 
Created
Source

node-osrm

Provides read-only bindings to the Open Source Routing Machine - OSRM, a routing engine for OpenStreetMap data implementing high-performance algorithms for shortest paths in road networks.

build configstatus
Linux/OS X Build Status Coverage Status

Documentation

See docs/api.md for extensive API documentation. You can find a simple example in example/server.js.

Depends

  • Node.js v0.10.x or v4.x
  • Modern C++ runtime libraries supporting C++11

C++11 capable platforms include:

  • Mac OS X >= 10.8
  • Ubuntu Linux >= 14.04 or other Linux distributions with g++ >= 4.8 toolchain (>= GLIBC_2.17 from libc and >= GLIBCXX_3.4.17 from libstdc++)

An installation error like below indicates your system does not have a modern enough g++ toolchain:

Error: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.17' not found (required by /node_modules/osrm/lib/binding/osrm.node)

If you are running Ubuntu older than 14.04 you can easily upgrade your g++ toolchain like:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.8

Installing

By default, binaries are provided for:

  • 64 bit OS X and 64 bit Linux
  • Node v4.x

On those platforms no external dependencies are needed.

Just do:

npm install osrm

However other platforms will fall back to a source compile: see Source Build for details.

Setup

The node-osrm module consumes data processed by OSRM core.

This repository contains a Makefile that does this automatically:

  • Downloads an OSM extract
  • Runs osrm tools to prepare data

Just run:

make test

Once that is done then you can calculate routes in Javascript like:

Source Build

Using Mason

You can build from source by using mason. Just go to your node-osrm folder and run:

make

This will download and build the current version of osrm-backend and set all needed variables.

Then you can test like

make test

To rebuild node-osrm after any source code changes to src/node_osrm.cpp simply type again:

make

If you wish to have a different version of osrm-backend build on the fly, change the osrm_release variable in package.json and rebuild:

make clean
make && make test

Using an existing local osrm-backend

If you do not wish to build node-osrm against an existing osrm-backend that you have on your system you will need:

  • OSRM develop branch cloned, built from source, and installed
  • The test data initialized: make -C test/data inside the osrm-backend directory

See Project-OSRM wiki for details.

Once Project-OSRM is built you should be able to run:

pkg-config libosrm --variable=prefix

Which should return the path to where you installed Project-OSRM.

Now you can build node-osrm:

git clone https://github.com/Project-OSRM/node-osrm.git
cd node-osrm
npm install --build-from-source

To run the tests against your local osrm-backend's data you will need to set the OSRM_DATA_PATH variable:

export OSRM_DATA_PATH=/path/to/osrm-backend/test/data

Then you can run npm test.

To recap, here is a full example of building against an osrm-backend that is cloned beside node-osrm but installed into a custom location:

export PATH=/opt/osrm/bin:${PATH}
export PKG_CONFIG_PATH=/opt/osrm/lib/pkgconfig
pkg-config libosrm --variable=prefix
# if boost headers are in a custom location give a hint about that
# here we assume the are in `/opt/boost`
export CXXFLAGS="-I/opt/boost/include"
npm install --build-from-source
# build the osrm-backend test data
make -C ../osrm-backend/test/data
export OSRM_DATA_PATH=../osrm-backend/test/data
npm test

Developing

After setting up a Source Build you can make changes to the code and rebuild like:

npm install --build-from-source

But that will trigger a full re-configure if any changes occurred to dependencies.

However you can optionally use the Makefile which simplifies some common needs.

To rebuild using cached data:

make

If you want to see all the arguments sent to the compiler do:

make verbose

If you want to build in debug mode (-DDEBUG -O0) then do:

make debug

Under the hood this uses node-pre-gyp (which itself used node-gyp) to compile the source code.

Testing

Run the tests like:

make test

Keywords

FAQs

Package last updated on 13 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc