-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build with cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_NODE_BINDINGS=On -DENABLE_MASON=On
- Loading branch information
1 parent
07221f5
commit b2ac9dc
Showing
27 changed files
with
3,518 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
* | ||
!README.md | ||
!CHANGELOG.md | ||
!CONTRIBUTING.MD | ||
!LICENCE.TXT | ||
!package.json | ||
!example | ||
!lib/*.js | ||
!profiles/* | ||
!profiles/lib/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Releasing | ||
|
||
Releasing a new version of `node-osrm` is mostly automated using Travis CI. | ||
|
||
The version of `node-osrm` is locked to the same version as `osrm-backend`. Every `node-osrm` should have a `osrm-backend` release of the same version. Of course, only release a `node-osrm` after the release has been tagged in `osrm-backend`. | ||
|
||
These steps all happen on `master`. After the release is out, create a branch using the MAJOR.MINOR version of the release to document code changes made for that version. | ||
|
||
### Steps to release | ||
|
||
1. Update the `osrm_release` field in `package.json` to the corresonding git tag in `osrm-backend.` | ||
|
||
Confirm the desired OSRM branch and commit to `master`. | ||
|
||
1. Bump node-osrm version | ||
|
||
Update the `CHANGELOG.md` and the `package.json` version if needed. | ||
|
||
1. Check that Travis CI [builds are passing](https://travis-ci.org/Project-OSRM/node-osrm) for the latest commit on `master`. | ||
|
||
1. Publishing binaries | ||
|
||
If travis builds are passing then it's time to publish binaries by committing with a message containing `[publish binary]`. Use an empty commit for this. | ||
|
||
``` | ||
git commit --allow-empty -m "[publish binary] vMAJOR.MINOR.PATCH" | ||
``` | ||
|
||
1. Test | ||
|
||
Locally you can now test binaries. Cleanup, re-install, and run the tests like: | ||
|
||
``` | ||
make clean | ||
npm install # will pull remote binaries | ||
npm ls # confirm deps are correct | ||
make test | ||
``` | ||
|
||
1. Tag | ||
|
||
Once binaries are published for Linux and OS X then its time to tag a new release and add the changelog to the tag: | ||
|
||
``` | ||
git tag vMAJOR.MINOR.PATCH -a | ||
git push --tags | ||
``` | ||
|
||
1. Publish node-osrm. **we only do this for stable releases** | ||
|
||
First ensure your local `node-pre-gyp` is up to date: | ||
|
||
``` | ||
npm ls | ||
``` | ||
|
||
This is important because it is bundled during packaging. | ||
|
||
If you see any errors then do: | ||
|
||
``` | ||
rm -rf node_modules/node-pre-gyp | ||
npm install node-pre-gyp | ||
``` | ||
|
||
Now we're ready to publish `node-osrm` to <https://www.npmjs.org/package/osrm>: | ||
|
||
``` | ||
npm publish | ||
``` | ||
|
||
Dependent apps can now pull from the npm registry like: | ||
|
||
``` | ||
"dependencies": { | ||
"osrm": "^MAJOR.MINOR.PATCH" | ||
} | ||
``` | ||
|
||
Or can still pull from the github tag like: | ||
|
||
``` | ||
"dependencies": { | ||
"osrm": "https://github.com/Project-OSRM/node-osrm/archive/vMAJOR.MINOR.PATCH.tar.gz" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
process.env.UV_THREADPOOL_SIZE = Math.ceil(require('os').cpus().length * 1.5); | ||
|
||
var express = require('express'); | ||
var OSRM = require('..'); | ||
var path = require('path'); | ||
|
||
var app = express(); | ||
var osrm = new OSRM(path.join(__dirname,"../test/data/monaco.osrm")); | ||
|
||
// Accepts a query like: | ||
// http://localhost:8888?start=13.438640,52.519930&end=13.415852,52.513191 | ||
app.get('/', function(req, res) { | ||
if (!req.query.start || !req.query.end) { | ||
return res.json({"error":"invalid start and end query"}); | ||
} | ||
var coordinates = []; | ||
var start = req.query.start.split(','); | ||
coordinates.push([+start[0],+start[1]]); | ||
var end = req.query.end.split(','); | ||
coordinates.push([+end[0],+end[1]]); | ||
var query = { | ||
coordinates: coordinates, | ||
alternateRoute: req.query.alternatives !== 'false' | ||
}; | ||
osrm.route(query, function(err, result) { | ||
if (err) return res.json({"error":err.message}); | ||
return res.json(result); | ||
}); | ||
}); | ||
|
||
console.log('Listening on port: ' + 8888); | ||
app.listen(8888); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#ifndef OSRM_BINDINGS_NODE_JSON_V8_RENDERER_HPP | ||
#define OSRM_BINDINGS_NODE_JSON_V8_RENDERER_HPP | ||
|
||
#include "osrm/json_container.hpp" | ||
|
||
#include <nan.h> | ||
|
||
#include <functional> | ||
|
||
namespace node_osrm | ||
{ | ||
|
||
struct V8Renderer | ||
{ | ||
explicit V8Renderer(v8::Local<v8::Value> &_out) : out(_out) {} | ||
|
||
void operator()(const osrm::json::String &string) const | ||
{ | ||
out = Nan::New(std::cref(string.value)).ToLocalChecked(); | ||
} | ||
|
||
void operator()(const osrm::json::Number &number) const { out = Nan::New(number.value); } | ||
|
||
void operator()(const osrm::json::Object &object) const | ||
{ | ||
v8::Local<v8::Object> obj = Nan::New<v8::Object>(); | ||
for (const auto &keyValue : object.values) | ||
{ | ||
v8::Local<v8::Value> child; | ||
mapbox::util::apply_visitor(V8Renderer(child), keyValue.second); | ||
obj->Set(Nan::New(keyValue.first).ToLocalChecked(), child); | ||
} | ||
out = obj; | ||
} | ||
|
||
void operator()(const osrm::json::Array &array) const | ||
{ | ||
v8::Local<v8::Array> a = Nan::New<v8::Array>(array.values.size()); | ||
for (auto i = 0u; i < array.values.size(); ++i) | ||
{ | ||
v8::Local<v8::Value> child; | ||
mapbox::util::apply_visitor(V8Renderer(child), array.values[i]); | ||
a->Set(i, child); | ||
} | ||
out = a; | ||
} | ||
|
||
void operator()(const osrm::json::True &) const { out = Nan::New(true); } | ||
|
||
void operator()(const osrm::json::False &) const { out = Nan::New(false); } | ||
|
||
void operator()(const osrm::json::Null &) const { out = Nan::Null(); } | ||
|
||
private: | ||
v8::Local<v8::Value> &out; | ||
}; | ||
|
||
inline void renderToV8(v8::Local<v8::Value> &out, const osrm::json::Object &object) | ||
{ | ||
osrm::json::Value value = object; | ||
mapbox::util::apply_visitor(V8Renderer(out), value); | ||
} | ||
} | ||
|
||
#endif // JSON_V8_RENDERER_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#ifndef OSRM_BINDINGS_NODE_HPP | ||
#define OSRM_BINDINGS_NODE_HPP | ||
|
||
#include "osrm/osrm_fwd.hpp" | ||
|
||
#include <nan.h> | ||
|
||
#include <memory> | ||
|
||
namespace node_osrm | ||
{ | ||
|
||
struct Engine final : public Nan::ObjectWrap | ||
{ | ||
using Base = Nan::ObjectWrap; | ||
|
||
static NAN_MODULE_INIT(Init); | ||
|
||
static NAN_METHOD(New); | ||
|
||
static NAN_METHOD(route); | ||
static NAN_METHOD(nearest); | ||
static NAN_METHOD(table); | ||
static NAN_METHOD(tile); | ||
static NAN_METHOD(match); | ||
static NAN_METHOD(trip); | ||
|
||
Engine(osrm::EngineConfig &config); | ||
|
||
// Thread-safe singleton accessor | ||
static Nan::Persistent<v8::Function> &constructor(); | ||
|
||
// Ref-counted OSRM alive even after shutdown until last callback is done | ||
std::shared_ptr<osrm::OSRM> this_; | ||
}; | ||
|
||
} // ns node_osrm | ||
|
||
NODE_MODULE(osrm, node_osrm::Engine::Init) | ||
|
||
#endif |
Oops, something went wrong.