From d69d0c2fe6ead467497e7fe91be42677dfbca519 Mon Sep 17 00:00:00 2001 From: Vsevolod Novikov Date: Mon, 15 Feb 2021 19:40:35 +0300 Subject: [PATCH] #5325 Documentation changes and some fix for flatbuffers --- docs/http.md | 8 ++++-- docs/nodejs/api.md | 6 ++-- .../api/flatbuffers/fbresult_generated.h | 28 +++++++++---------- include/engine/api/flatbuffers/route.fbs | 4 +-- include/engine/api/route_api.hpp | 4 +-- 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/docs/http.md b/docs/http.md index 398aba1aecf..58d0cd6ef61 100644 --- a/docs/http.md +++ b/docs/http.md @@ -208,7 +208,7 @@ In addition to the [general options](#general-options) the following options are |------------|---------------------------------------------|-------------------------------------------------------------------------------| |alternatives|`true`, `false` (default), or Number |Search for alternative routes. Passing a number `alternatives=n` searches for up to `n` alternative routes.\* | |steps |`true`, `false` (default) |Returned route steps for each route leg | -|annotations |`true`, `false` (default), `nodes`, `distance`, `duration`, `datasources`, `weight`, `speed` |Returns additional metadata for each coordinate along the route geometry. | +|annotations |`true`, `false` (default), `nodes`, `ways`, `distance`, `duration`, `datasources`, `weight`, `speed` |Returns additional metadata for each coordinate along the route geometry. | |geometries |`polyline` (default), `polyline6`, `geojson` |Returned route geometry format (influences overview and per step) | |overview |`simplified` (default), `full`, `false` |Add overview geometry either full, simplified according to highest zoom level it could be display on, or not at all.| |continue\_straight |`default` (default), `true`, `false` |Forces the route to keep going straight at waypoints constraining uturns there even if it would be faster. Default value depends on the profile. | @@ -430,7 +430,7 @@ In addition to the [general options](#general-options) the following options are |------------|------------------------------------------------|------------------------------------------------------------------------------------------| |steps |`true`, `false` (default) |Returned route steps for each route | |geometries |`polyline` (default), `polyline6`, `geojson` |Returned route geometry format (influences overview and per step) | -|annotations |`true`, `false` (default), `nodes`, `distance`, `duration`, `datasources`, `weight`, `speed` |Returns additional metadata for each coordinate along the route geometry. | +|annotations |`true`, `false` (default), `nodes`, `ways`, `distance`, `duration`, `datasources`, `weight`, `speed` |Returns additional metadata for each coordinate along the route geometry. | |overview |`simplified` (default), `full`, `false` |Add overview geometry either full, simplified according to highest zoom level it could be display on, or not at all.| |timestamps |`{timestamp};{timestamp}[;{timestamp} ...]` |Timestamps for the input locations in seconds since UNIX epoch. Timestamps need to be monotonically increasing. | |radiuses |`{radius};{radius}[;{radius} ...]` |Standard deviation of GPS precision used for map matching. If applicable use GPS accuracy.| @@ -486,7 +486,7 @@ In addition to the [general options](#general-options) the following options are |source |`any` (default), `first` |Returned route starts at `any` or `first` coordinate | |destination |`any` (default), `last` |Returned route ends at `any` or `last` coordinate | |steps |`true`, `false` (default) |Returned route instructions for each trip | -|annotations |`true`, `false` (default), `nodes`, `distance`, `duration`, `datasources`, `weight`, `speed` |Returns additional metadata for each coordinate along the route geometry. | +|annotations |`true`, `false` (default), `nodes`, `ways`, `distance`, `duration`, `datasources`, `weight`, `speed` |Returns additional metadata for each coordinate along the route geometry. | |geometries |`polyline` (default), `polyline6`, `geojson` |Returned route geometry format (influences overview and per step) | |overview |`simplified` (default), `full`, `false` |Add overview geometry either full, simplified according to highest zoom level it could be display on, or not at all.| @@ -700,6 +700,7 @@ Annotation of the whole route leg with fine-grained information about each segme - `duration`: The duration between each pair of coordinates, in seconds. Does not include the duration of any turns. - `datasources`: The index of the datasource for the speed between each pair of coordinates. `0` is the default profile, other values are supplied via `--segment-speed-file` to `osrm-contract` or `osrm-customize`. String-like names are in the `metadata.datasource_names` array. - `nodes`: The OSM node ID for each coordinate along the route, excluding the first/last user-supplied coordinates +- `ways`: The OSM way ID for each pair of neighbour nodes in the list of nodes - `weight`: The weights between each pair of coordinates. Does not include any turn costs. - `speed`: Convenience field, calculation of `distance / duration` rounded to one decimal place - `metadata`: Metadata related to other annotations @@ -714,6 +715,7 @@ Annotation of the whole route leg with fine-grained information about each segme "datasources": [1,0,0,0,1], "metadata": { "datasource_names": ["traffic","lua profile","lua profile","lua profile","traffic"] }, "nodes": [49772551,49772552,49786799,49786800,49786801,49786802], + "ways": [130764281,130764281,6056749,6056749,6056749], "weight": [15,15,40,15,15] } ``` diff --git a/docs/nodejs/api.md b/docs/nodejs/api.md index 9bff3ada8c6..a06ed047067 100644 --- a/docs/nodejs/api.md +++ b/docs/nodejs/api.md @@ -55,7 +55,7 @@ Returns the fastest route between two or more coordinates while visiting the way - `options.alternatives` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Search for up to this many alternative routes. _Please note that even if alternative routes are requested, a result cannot be guaranteed._ (optional, default `0`) - `options.steps` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Return route steps for each route leg. (optional, default `false`) - - `options.annotations` **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean))** An array with strings of `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed` or boolean for enabling/disabling all. (optional, default `false`) + - `options.annotations` **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean))** An array with strings of `duration`, `nodes`, `ways`, `distance`, `weight`, `datasources`, `speed` or boolean for enabling/disabling all. (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` according to highest zoom level it could be display on, or not at all (`false`). (optional, default `simplified`) - `options.continue_straight` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Forces the route to keep going straight at waypoints and don't do a uturn even if it would be faster. Default value depends on the profile. @@ -215,7 +215,7 @@ if they can not be matched successfully. - `options.hints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings. - `options.generate_hints` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Whether or not adds a Hint to the response which can be used in subsequent requests. (optional, default `true`) - `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` **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean))** An array with strings of `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed` or boolean for enabling/disabling all. (optional, default `false`) + - `options.annotations` **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean))** An array with strings of `duration`, `nodes`, `ways`, `distance`, `weight`, `datasources`, `speed` or boolean for enabling/disabling all. (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` according to highest zoom level it could be display on, or not at all (`false`). (optional, default `simplified`) - `options.timestamps` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>?** Timestamp of the input location (integers, UNIX-like timestamp). @@ -282,7 +282,7 @@ Right now, the following combinations are possible: - `options.hints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings. - `options.generate_hints` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Whether or not adds a Hint to the response which can be used in subsequent requests. (optional, default `true`) - `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` **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean))** An array with strings of `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed` or boolean for enabling/disabling all. (optional, default `false`) + - `options.annotations` **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean))** An array with strings of `duration`, `nodes`, `ways`, `distance`, `weight`, `datasources`, `speed` or boolean for enabling/disabling all. (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`) - `options.roundtrip` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Return route is a roundtrip. (optional, default `true`) diff --git a/include/engine/api/flatbuffers/fbresult_generated.h b/include/engine/api/flatbuffers/fbresult_generated.h index 28198e0fb65..ce09bf4d63e 100644 --- a/include/engine/api/flatbuffers/fbresult_generated.h +++ b/include/engine/api/flatbuffers/fbresult_generated.h @@ -461,8 +461,8 @@ struct AnnotationT : public flatbuffers::NativeTable { std::vector distance; std::vector duration; std::vector datasources; - std::vector nodes; - std::vector ways; + std::vector nodes; + std::vector ways; std::vector weight; std::vector speed; std::unique_ptr metadata; @@ -491,11 +491,11 @@ struct Annotation FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { const flatbuffers::Vector *datasources() const { return GetPointer *>(VT_DATASOURCES); } - const flatbuffers::Vector *nodes() const { - return GetPointer *>(VT_NODES); + const flatbuffers::Vector *nodes() const { + return GetPointer *>(VT_NODES); } - const flatbuffers::Vector *ways() const { - return GetPointer *>(VT_WAYS); + const flatbuffers::Vector *ways() const { + return GetPointer *>(VT_WAYS); } const flatbuffers::Vector *weight() const { return GetPointer *>(VT_WEIGHT); @@ -543,10 +543,10 @@ struct AnnotationBuilder { void add_datasources(flatbuffers::Offset> datasources) { fbb_.AddOffset(Annotation::VT_DATASOURCES, datasources); } - void add_nodes(flatbuffers::Offset> nodes) { + void add_nodes(flatbuffers::Offset> nodes) { fbb_.AddOffset(Annotation::VT_NODES, nodes); } - void add_ways(flatbuffers::Offset> ways) { + void add_ways(flatbuffers::Offset> ways) { fbb_.AddOffset(Annotation::VT_WAYS, ways); } void add_weight(flatbuffers::Offset> weight) { @@ -575,8 +575,8 @@ inline flatbuffers::Offset CreateAnnotation( flatbuffers::Offset> distance = 0, flatbuffers::Offset> duration = 0, flatbuffers::Offset> datasources = 0, - flatbuffers::Offset> nodes = 0, - flatbuffers::Offset> ways = 0, + flatbuffers::Offset> nodes = 0, + flatbuffers::Offset> ways = 0, flatbuffers::Offset> weight = 0, flatbuffers::Offset> speed = 0, flatbuffers::Offset metadata = 0) { @@ -597,16 +597,16 @@ inline flatbuffers::Offset CreateAnnotationDirect( const std::vector *distance = nullptr, const std::vector *duration = nullptr, const std::vector *datasources = nullptr, - const std::vector *nodes = nullptr, - const std::vector *ways = nullptr, + const std::vector *nodes = nullptr, + const std::vector *ways = nullptr, const std::vector *weight = nullptr, const std::vector *speed = nullptr, flatbuffers::Offset metadata = 0) { auto distance__ = distance ? _fbb.CreateVector(*distance) : 0; auto duration__ = duration ? _fbb.CreateVector(*duration) : 0; auto datasources__ = datasources ? _fbb.CreateVector(*datasources) : 0; - auto nodes__ = nodes ? _fbb.CreateVector(*nodes) : 0; - auto ways__ = ways ? _fbb.CreateVector(*ways) : 0; + auto nodes__ = nodes ? _fbb.CreateVector(*nodes) : 0; + auto ways__ = ways ? _fbb.CreateVector(*ways) : 0; auto weight__ = weight ? _fbb.CreateVector(*weight) : 0; auto speed__ = speed ? _fbb.CreateVector(*speed) : 0; return osrm::engine::api::fbresult::CreateAnnotation( diff --git a/include/engine/api/flatbuffers/route.fbs b/include/engine/api/flatbuffers/route.fbs index f826d5787f9..8b15429589c 100644 --- a/include/engine/api/flatbuffers/route.fbs +++ b/include/engine/api/flatbuffers/route.fbs @@ -9,8 +9,8 @@ table Annotation { distance: [uint]; duration: [uint]; datasources: [uint]; - nodes: [uint]; - ways: [uint]; + nodes: [ulong]; + ways: [ulong]; weight: [uint]; speed: [float]; metadata: Metadata; diff --git a/include/engine/api/route_api.hpp b/include/engine/api/route_api.hpp index e1d4ae59762..7376e6b0f7d 100644 --- a/include/engine/api/route_api.hpp +++ b/include/engine/api/route_api.hpp @@ -494,7 +494,7 @@ class RouteAPI : public BaseAPI return anno.datasource; }); } - std::vector nodes; + std::vector nodes; if (requested_annotations & RouteParameters::AnnotationsType::Nodes) { nodes.reserve(leg_geometry.osm_node_ids.size()); @@ -503,7 +503,7 @@ class RouteAPI : public BaseAPI nodes.emplace_back(static_cast(node_id)); } } - std::vector ways; + std::vector ways; if (requested_annotations & RouteParameters::AnnotationsType::Ways) { ways.reserve(leg_geometry.osm_way_ids.size());