-
Notifications
You must be signed in to change notification settings - Fork 49
Conversation
02dec87
to
d5069de
Compare
@freenerd would you please review this? I especially want your opinion on the way I've handled the errors coming from osrm-backend. I ended up using a simple equals message, instead of an error assertion because I couldn't get any of the error assertions to work with this kind of osrm-backend error: https://github.com/Project-OSRM/node-osrm/pull/296/files#diff-f2f7b3e695a783f368903f577c8f8036R207 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good to me
docs/api.md
Outdated
|
||
**Parameters** | ||
|
||
- `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object literal containing parameters for the trip query. | ||
- `options.roundtrip` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Return route is a roundtrip. (optional, default `true`) | ||
- `options.source` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Return route starts at `any` or `first` coordinate. Can also be `first`. (optional, default `any`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first
is in here double
docs/api.md
Outdated
|
||
**Parameters** | ||
|
||
- `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object literal containing parameters for the trip query. | ||
- `options.roundtrip` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Return route is a roundtrip. (optional, default `true`) | ||
- `options.source` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Return route starts at `any` or `first` coordinate. Can also be `first`. (optional, default `any`) | ||
- `options.destination` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Return route ends at `any` or `last` coordinate. Can also be `last`. (optional, default `any`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last
is in here double
docs/api.md
Outdated
- `options.steps` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Return route steps for each route. (optional, default `false`) | ||
- `options.annotations` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Return annotations for each route leg. (optional, default `false`) | ||
- `options.geometries` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Returned route geometry format (influences overview | ||
and per step). Can also be `geojson`. (optional, default `polyline`) | ||
- `options.overview` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Add overview geometry either `full`, `simplified` (optional, default `simplified`) | ||
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** | ||
|
||
**Fixing Start and End Points** | ||
|
||
It is possible to explicitely set the start or end coordinate of the trip. When source is set to `first`, the first coordinate is used as start coordinate of the trip in the output. When destination is set to `last`, the last coordinate will be used as destination of the trip in the returned output. If you specify `any`, any of the coordinates can be used as the first or last coordinate in the output. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explicitly
| false | first | last | **yes** | | ||
| false | first | any | no | | ||
| false | any | last | no | | ||
| false | any | any | no | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are our plans wrt. supporting the currently unsupported combinations? Is this getting checked for in code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daniel-j-h it gets checked for in the code and a NotImplemented
error is returned if it is an unsupported combination.
docs/api.md
Outdated
[13.374481201171875, 52.506191342034576] | ||
], | ||
source: first, | ||
destination: last, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is first and last? Does this work or should it be "first"
and "last"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh you're right. Changed these to strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe run your example locally to check if it works? :)
@@ -733,6 +733,74 @@ argumentsToTripParameter(const Nan::FunctionCallbackInfo<v8::Value> &args, | |||
return trip_parameters_ptr(); | |||
} | |||
|
|||
if (obj->Has(Nan::New("roundtrip").ToLocalChecked())) | |||
{ | |||
auto roundtrip = obj->Get(Nan::New("roundtrip").ToLocalChecked()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and below: what you can do instead of Has()
+Get()
is the following:
auto maybeRoundtrip = Nan::Get(..);
if (maybeRoundtrip.empty() || !maybeRoundtrip.ToLocalChecked()->IsBoolean) error();
Nan::Get
returns you a Maybe type similar to boost::optional<T>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to change it to the Get pattern but can't figure it out right now. But I'm going to leave this pattern as is for now as it is the pattern is used by the rest of the file. In a different PR, I can go through and convert all of them in one go.
return trip_parameters_ptr(); | ||
} | ||
|
||
std::string source_str = *v8::String::Utf8Value(source); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check for the ptr not being a nullptr?
Also please use Nan's string functions which are portable:
https://github.com/nodejs/nan/blob/master/doc/v8_misc.md
const Nan::Utf8String utf8str(source);
std::string s{*utf8str, *utf8str + utfstr.length()};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again I tried to implement this but didn't manage to get it to work, but I'll leave this for now, as the pattern here is different from elsewhere in the rest of the file. This can be addressed in a refactor PR that changes the rest of the file as well.
7ce81c2
to
ed6c5c8
Compare
ed6c5c8
to
acd22ed
Compare
Looks like circle is failing with:
Per chat we are discussing disabling circle since we are still using travis OS X, but we should still address ^^. I think this is happening because we still use |
It did. Let's discuss next actions at Project-OSRM/osrm-backend#3719 |
Addresses #294