Merge pull request #5513 from akashihi/flatbuffers
Flatbuffers support added
This commit is contained in:
commit
f1a4b70a56
2
.eslintignore
Normal file
2
.eslintignore
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
features/support/flatbuffers.js
|
||||||
|
features/support/fbresult_generated.js
|
@ -7,6 +7,7 @@
|
|||||||
- ADDED: data timestamp information in the response (saved in new file `.osrm.timestamp`). [#5115](https://github.com/Project-OSRM/osrm-backend/issues/5115)
|
- ADDED: data timestamp information in the response (saved in new file `.osrm.timestamp`). [#5115](https://github.com/Project-OSRM/osrm-backend/issues/5115)
|
||||||
- ADDED: new API parameter - `snapping=any|default` to allow snapping to previously unsnappable edges [#5361](https://github.com/Project-OSRM/osrm-backend/pull/5361)
|
- ADDED: new API parameter - `snapping=any|default` to allow snapping to previously unsnappable edges [#5361](https://github.com/Project-OSRM/osrm-backend/pull/5361)
|
||||||
- ADDED: keepalive support to the osrm-routed HTTP server [#5518](https://github.com/Project-OSRM/osrm-backend/pull/5518)
|
- ADDED: keepalive support to the osrm-routed HTTP server [#5518](https://github.com/Project-OSRM/osrm-backend/pull/5518)
|
||||||
|
- ADDED: flatbuffers output format support [#5513](https://github.com/Project-OSRM/osrm-backend/pull/5513)
|
||||||
- Routing:
|
- Routing:
|
||||||
- CHANGED: allow routing past `barrier=arch` [#5352](https://github.com/Project-OSRM/osrm-backend/pull/5352)
|
- CHANGED: allow routing past `barrier=arch` [#5352](https://github.com/Project-OSRM/osrm-backend/pull/5352)
|
||||||
- CHANGED: default car weight was reduced to 2000 kg. [#5371](https://github.com/Project-OSRM/osrm-backend/pull/5371)
|
- CHANGED: default car weight was reduced to 2000 kg. [#5371](https://github.com/Project-OSRM/osrm-backend/pull/5371)
|
||||||
|
@ -439,6 +439,12 @@ include_directories(SYSTEM ${PROTOZERO_INCLUDE_DIR})
|
|||||||
set(VTZERO_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/vtzero/include")
|
set(VTZERO_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/vtzero/include")
|
||||||
include_directories(SYSTEM ${VTZERO_INCLUDE_DIR})
|
include_directories(SYSTEM ${VTZERO_INCLUDE_DIR})
|
||||||
|
|
||||||
|
set(FLATBUFFERS_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/flatbuffers")
|
||||||
|
set(FLATBUFFERS_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/flatbuffers/include")
|
||||||
|
include_directories(${FLATBUFFERS_INCLUDE_DIR})
|
||||||
|
add_subdirectory(${FLATBUFFERS_SRC_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/flatbuffers-build
|
||||||
|
EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
# if mason is enabled no find_package calls are made
|
# if mason is enabled no find_package calls are made
|
||||||
# to ensure that we are only compiling and linking against
|
# to ensure that we are only compiling and linking against
|
||||||
@ -738,8 +744,10 @@ set_property(TARGET osrm-datastore PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|||||||
set_property(TARGET osrm-routed PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
set_property(TARGET osrm-routed PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||||
|
|
||||||
file(GLOB VariantGlob third_party/variant/include/mapbox/*.hpp)
|
file(GLOB VariantGlob third_party/variant/include/mapbox/*.hpp)
|
||||||
|
file(GLOB FlatbuffersGlob third_party/flatbuffers/include/flatbuffers/*.h)
|
||||||
file(GLOB LibraryGlob include/osrm/*.hpp)
|
file(GLOB LibraryGlob include/osrm/*.hpp)
|
||||||
file(GLOB ParametersGlob include/engine/api/*_parameters.hpp)
|
file(GLOB ParametersGlob include/engine/api/*_parameters.hpp)
|
||||||
|
set(ApiHeader include/engine/api/base_result.hpp)
|
||||||
set(EngineHeader include/engine/status.hpp include/engine/engine_config.hpp include/engine/hint.hpp include/engine/bearing.hpp include/engine/approach.hpp include/engine/phantom_node.hpp)
|
set(EngineHeader include/engine/status.hpp include/engine/engine_config.hpp include/engine/hint.hpp include/engine/bearing.hpp include/engine/approach.hpp include/engine/phantom_node.hpp)
|
||||||
set(UtilHeader include/util/coordinate.hpp include/util/json_container.hpp include/util/typedefs.hpp include/util/alias.hpp include/util/exception.hpp include/util/bearing.hpp)
|
set(UtilHeader include/util/coordinate.hpp include/util/json_container.hpp include/util/typedefs.hpp include/util/alias.hpp include/util/exception.hpp include/util/bearing.hpp)
|
||||||
set(ExtractorHeader include/extractor/extractor.hpp include/storage/io_config.hpp include/extractor/extractor_config.hpp include/extractor/travel_mode.hpp)
|
set(ExtractorHeader include/extractor/extractor.hpp include/storage/io_config.hpp include/extractor/extractor_config.hpp include/extractor/travel_mode.hpp)
|
||||||
@ -754,7 +762,9 @@ install(FILES ${PartitionerHeader} DESTINATION include/osrm/partitioner)
|
|||||||
install(FILES ${ContractorHeader} DESTINATION include/osrm/contractor)
|
install(FILES ${ContractorHeader} DESTINATION include/osrm/contractor)
|
||||||
install(FILES ${LibraryGlob} DESTINATION include/osrm)
|
install(FILES ${LibraryGlob} DESTINATION include/osrm)
|
||||||
install(FILES ${ParametersGlob} DESTINATION include/osrm/engine/api)
|
install(FILES ${ParametersGlob} DESTINATION include/osrm/engine/api)
|
||||||
|
install(FILES ${ApiHeader} DESTINATION include/osrm/engine/api)
|
||||||
install(FILES ${VariantGlob} DESTINATION include/mapbox)
|
install(FILES ${VariantGlob} DESTINATION include/mapbox)
|
||||||
|
install(FILES ${FlatbuffersGlob} DESTINATION include/flatbuffers)
|
||||||
install(TARGETS osrm-extract DESTINATION bin)
|
install(TARGETS osrm-extract DESTINATION bin)
|
||||||
install(TARGETS osrm-partition DESTINATION bin)
|
install(TARGETS osrm-partition DESTINATION bin)
|
||||||
install(TARGETS osrm-customize DESTINATION bin)
|
install(TARGETS osrm-customize DESTINATION bin)
|
||||||
|
173
docs/http.md
173
docs/http.md
@ -21,7 +21,7 @@ GET /{service}/{version}/{profile}/{coordinates}[.{format}]?option=value&option=
|
|||||||
| `version` | Version of the protocol implemented by the service. `v1` for all OSRM 5.x installations |
|
| `version` | Version of the protocol implemented by the service. `v1` for all OSRM 5.x installations |
|
||||||
| `profile` | Mode of transportation, is determined statically by the Lua profile that is used to prepare the data using `osrm-extract`. Typically `car`, `bike` or `foot` if using one of the supplied profiles. |
|
| `profile` | Mode of transportation, is determined statically by the Lua profile that is used to prepare the data using `osrm-extract`. Typically `car`, `bike` or `foot` if using one of the supplied profiles. |
|
||||||
| `coordinates`| String of format `{longitude},{latitude};{longitude},{latitude}[;{longitude},{latitude} ...]` or `polyline({polyline}) or polyline6({polyline6})`. |
|
| `coordinates`| String of format `{longitude},{latitude};{longitude},{latitude}[;{longitude},{latitude} ...]` or `polyline({polyline}) or polyline6({polyline6})`. |
|
||||||
| `format`| Only `json` is supported at the moment. This parameter is optional and defaults to `json`. |
|
| `format`| `json` or `flatbuffers`. This parameter is optional and defaults to `json`. |
|
||||||
|
|
||||||
Passing any `option=value` is optional. `polyline` follows Google's polyline format with precision 5 by default and can be generated using [this package](https://www.npmjs.com/package/polyline).
|
Passing any `option=value` is optional. `polyline` follows Google's polyline format with precision 5 by default and can be generated using [this package](https://www.npmjs.com/package/polyline).
|
||||||
|
|
||||||
@ -944,3 +944,174 @@ Object used to describe waypoint on a route.
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Flatbuffers format
|
||||||
|
|
||||||
|
Default response format is `json`, but OSRM supports binary [`flatbuffers`](https://google.github.io/flatbuffers/) format, which
|
||||||
|
is much faster in serialization/deserialization, comparing to `json`.
|
||||||
|
|
||||||
|
The format itself is described in message descriptors, located at `include/engine/api/flatbuffers directory`. Those descriptors could
|
||||||
|
be compiled to provide protocol parsers in Go/Javascript/Typescript/Java/Dart/C#/Python/Lobster/Lua/Rust/PHP/Kotlin. Precompiled
|
||||||
|
protocol parser for C++ is supplied with OSRM.
|
||||||
|
|
||||||
|
`Flatbuffers` format provides exactly same data, as `json` format with a slightly different layout, which was optimized to minimize
|
||||||
|
in-transfer size.
|
||||||
|
|
||||||
|
### Root object
|
||||||
|
|
||||||
|
Root object is the only object, available from a 'raw' `flatbuffers` buffer. It can be constructed with a following call:
|
||||||
|
|
||||||
|
auto osrm = osrm::engine::api::fbresult::GetFBResult(some_input_buffer);
|
||||||
|
|
||||||
|
**Properties**
|
||||||
|
|
||||||
|
- `error`: `bool` Marks response as erroneous. Erroneus response should include `code` field set, all the other field may not present.
|
||||||
|
- `code`: `Error` Error description object, only present, when `error` is `true`
|
||||||
|
- `waypoints`: `[Waypoint]` Array of `Waypoint` objects. Should present for every service call. Table service will put `sources` array here.
|
||||||
|
- `routes`: `[RouteObject]` Array of `RouteObject` objects. May be empty or absent. Should present for Route/Trip/Match services call.
|
||||||
|
- `table`: `Table` Table object, may absent. Should be present in case of Table service call.
|
||||||
|
|
||||||
|
### Error object
|
||||||
|
|
||||||
|
Contains error information.
|
||||||
|
|
||||||
|
**Properties**
|
||||||
|
|
||||||
|
- `code`: `string` Error code
|
||||||
|
- `message`: `string` Detailed error message
|
||||||
|
|
||||||
|
### Waypoint object
|
||||||
|
|
||||||
|
Almost same as `json` Waypoint object. The following properties differ:
|
||||||
|
|
||||||
|
- `location`: `Position` Same as `json` location field, but different format.
|
||||||
|
- `nodes`: `Uint64Pair` Same as `json` nodes field, but different format.
|
||||||
|
|
||||||
|
### RouteObject object
|
||||||
|
|
||||||
|
Almost same as `json` Route object. The following properties differ:
|
||||||
|
|
||||||
|
- `polyline`: `string` Same as `json` geometry.polyline or geometry.polyline6 fields. One field for both formats.
|
||||||
|
- `coordinates`: `[Position]` Same as `json` geometry.coordinates field, but different format.
|
||||||
|
- `legs`: `[Leg]` Array of `Leg` objects.
|
||||||
|
|
||||||
|
### Leg object
|
||||||
|
|
||||||
|
Almost same as `json` Leg object. The following properties differ:
|
||||||
|
|
||||||
|
- `annotations`: `Annotation` Same as `json` annotation field, but different format.
|
||||||
|
- `steps`: `[Step]` Same as `step` annotation field, but different format.
|
||||||
|
|
||||||
|
### Step object
|
||||||
|
|
||||||
|
Almost same as `json` Step object. The following properties differ:
|
||||||
|
|
||||||
|
- `polyline`: `string` Same as `json` geometry.polyline or geometry.polyline6 fields. One field for both formats.
|
||||||
|
- `coordinates`: `[Position]` Same as `json` geometry.coordinates field, but different format.
|
||||||
|
- `maneuver`: `StepManeuver` Same as `json` maneuver field, but different format.
|
||||||
|
|
||||||
|
| `type` | Description |
|
||||||
|
|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
|
| `Turn` | a basic turn into direction of the `modifier` |
|
||||||
|
| `NewName` | no turn is taken/possible, but the road name changes. The road can take a turn itself, following `modifier`. |
|
||||||
|
| `Depart` | indicates the departure of the leg |
|
||||||
|
| `Arrive` | indicates the destination of the leg |
|
||||||
|
| `Merge` | merge onto a street (e.g. getting on the highway from a ramp, the `modifier specifies the direction of the merge`) |
|
||||||
|
| `OnRamp` | take a ramp to enter a highway (direction given my `modifier`) |
|
||||||
|
| `OffRamp` | take a ramp to exit a highway (direction given my `modifier`) |
|
||||||
|
| `Fork` | take the left/right side at a fork depending on `modifier` |
|
||||||
|
| `EndOfRoad` | road ends in a T intersection turn in direction of `modifier` |
|
||||||
|
| `Continue` | Turn in direction of `modifier` to stay on the same road |
|
||||||
|
| `Roundabout` | traverse roundabout, if the route leaves the roundabout there will be an additional property `exit` for exit counting. The modifier specifies the direction of entering the roundabout. |
|
||||||
|
| `Rotary` | a traffic circle. While very similar to a larger version of a roundabout, it does not necessarily follow roundabout rules for right of way. It can offer `rotary_name` and/or `rotary_pronunciation` parameters (located in the RouteStep object) in addition to the `exit` parameter (located on the StepManeuver object). |
|
||||||
|
| `RoundaboutTurn` | Describes a turn at a small roundabout that should be treated as normal turn. The `modifier` indicates the turn direciton. Example instruction: `At the roundabout turn left`. |
|
||||||
|
| `Notification` | not an actual turn but a change in the driving conditions. For example the travel mode or classes. If the road takes a turn itself, the `modifier` describes the direction |
|
||||||
|
| `ExitRoundabout` | Describes a maneuver exiting a roundabout (usually preceeded by a `roundabout` instruction) |
|
||||||
|
| `ExitRotary` | Describes the maneuver exiting a rotary (large named roundabout) |
|
||||||
|
|
||||||
|
- `driving_side`: `bool` Ttrue stands for the left side driving.
|
||||||
|
- `intersections`: `[Intersection]` Same as `json` intersections field, but different format.
|
||||||
|
|
||||||
|
### Intersection object
|
||||||
|
|
||||||
|
Almost same as `json` Intersection object. The following properties differ:
|
||||||
|
|
||||||
|
- `location`: `Position` Same as `json` location property, but in different format.
|
||||||
|
- `lanes`: `[Lane]` Array of `Lane` objects.
|
||||||
|
|
||||||
|
### Lane object
|
||||||
|
|
||||||
|
Almost same as `json` Lane object. The following properties differ:
|
||||||
|
|
||||||
|
- `indications`: `Turn` Array of `Turn` enum values.
|
||||||
|
|
||||||
|
| `value` | Description |
|
||||||
|
|------------------------|---------------------------------------------------------------------------------------------------------------------------|
|
||||||
|
| `None` | No dedicated indication is shown. |
|
||||||
|
| `UTurn` | An indication signaling the possibility to reverse (i.e. fully bend arrow). |
|
||||||
|
| `SharpRight` | An indication indicating a sharp right turn (i.e. strongly bend arrow). |
|
||||||
|
| `Right` | An indication indicating a right turn (i.e. bend arrow). |
|
||||||
|
| `SlightRight` | An indication indicating a slight right turn (i.e. slightly bend arrow). |
|
||||||
|
| `Straight` | No dedicated indication is shown (i.e. straight arrow). |
|
||||||
|
| `SlightLeft` | An indication indicating a slight left turn (i.e. slightly bend arrow). |
|
||||||
|
| `Left` | An indication indicating a left turn (i.e. bend arrow). |
|
||||||
|
| `SharpLeft` | An indication indicating a sharp left turn (i.e. strongly bend arrow). |
|
||||||
|
|
||||||
|
### StepManeuver object
|
||||||
|
|
||||||
|
Almost same as `json` StepManeuver object. The following properties differ:
|
||||||
|
|
||||||
|
- `location`: `Position` Same as `json` location property, but in different format.
|
||||||
|
- `type`: `ManeuverType` Type of a maneuver (enum)
|
||||||
|
|
||||||
|
| `type` | Description |
|
||||||
|
|------------------|--------------------------------------------------------------|
|
||||||
|
| `Turn` | a basic turn into direction of the `modifier` |
|
||||||
|
| `NewName` | no turn is taken/possible, but the road name changes. The road can take a turn itself, following `modifier`. |
|
||||||
|
| `Depart` | indicates the departure of the leg |
|
||||||
|
| `Arrive` | indicates the destination of the leg |
|
||||||
|
| `Merge` | merge onto a street (e.g. getting on the highway from a ramp, the `modifier specifies the direction of the merge`) |
|
||||||
|
| `OnRamp` | take a ramp to enter a highway (direction given my `modifier`) |
|
||||||
|
| `OffRamp` | take a ramp to exit a highway (direction given my `modifier`) |
|
||||||
|
| `Fork` | take the left/right side at a fork depending on `modifier` |
|
||||||
|
| `EndOfRoad` | road ends in a T intersection turn in direction of `modifier`|
|
||||||
|
| `Continue` | Turn in direction of `modifier` to stay on the same road |
|
||||||
|
| `Roundabout` | traverse roundabout, if the route leaves the roundabout there will be an additional property `exit` for exit counting. The modifier specifies the direction of entering the roundabout. |
|
||||||
|
| `Rotary` | a traffic circle. While very similar to a larger version of a roundabout, it does not necessarily follow roundabout rules for right of way. It can offer `rotary_name` and/or `rotary_pronunciation` parameters (located in the RouteStep object) in addition to the `exit` parameter (located on the StepManeuver object). |
|
||||||
|
| `RoundaboutTurn` | Describes a turn at a small roundabout that should be treated as normal turn. The `modifier` indicates the turn direciton. Example instruction: `At the roundabout turn left`. |
|
||||||
|
| `Notification` | not an actual turn but a change in the driving conditions. For example the travel mode or classes. If the road takes a turn itself, the `modifier` describes the direction |
|
||||||
|
| `ExitRoundabout` | Describes a maneuver exiting a roundabout (usually preceeded by a `roundabout` instruction) |
|
||||||
|
| `ExitRotary` | Describes the maneuver exiting a rotary (large named roundabout) |
|
||||||
|
|
||||||
|
- `modifier`: `Turn` Maneuver turn (enum)
|
||||||
|
|
||||||
|
### Annotation object
|
||||||
|
|
||||||
|
Exactly same as `json` annotation object.
|
||||||
|
|
||||||
|
|
||||||
|
### Position object
|
||||||
|
|
||||||
|
A point on Earth.
|
||||||
|
|
||||||
|
***Properties***
|
||||||
|
- `longitute`: `float` Point's longitude
|
||||||
|
- `latitude`: `float` Point's latitude
|
||||||
|
|
||||||
|
### Uint64Pair
|
||||||
|
|
||||||
|
A pair of long long integers. Used only by `Waypoint` object.
|
||||||
|
|
||||||
|
***Properties***
|
||||||
|
- `first`: `uint64` First pair value.
|
||||||
|
- `second`: `uint64` Second pair value.
|
||||||
|
|
||||||
|
### Table object
|
||||||
|
|
||||||
|
Almost same as `json` Table object. The main difference is that 'sources' field is absent and root's object 'waypoints' field is
|
||||||
|
used instead. All the other differences follow:
|
||||||
|
|
||||||
|
- `durations`: `[float]` Flat representation of a durations matrix. Element at row;col can be adressed as [row * cols + col]
|
||||||
|
- `destinations`: `[float]` Flat representation of a destinations matrix. Element at row;col can be adressed as [row * cols + col]
|
||||||
|
- `rows`: `ushort` Number of rows in durations/destinations matrices.
|
||||||
|
- `cols`: `ushort` Number of cols in durations/destinations matrices.
|
||||||
|
@ -52,14 +52,15 @@ int main(int argc, const char *argv[])
|
|||||||
params.coordinates.push_back({util::FloatLongitude{7.419505}, util::FloatLatitude{43.736825}});
|
params.coordinates.push_back({util::FloatLongitude{7.419505}, util::FloatLatitude{43.736825}});
|
||||||
|
|
||||||
// Response is in JSON format
|
// Response is in JSON format
|
||||||
json::Object result;
|
engine::api::ResultT result = json::Object();
|
||||||
|
|
||||||
// Execute routing request, this does the heavy lifting
|
// Execute routing request, this does the heavy lifting
|
||||||
const auto status = osrm.Route(params, result);
|
const auto status = osrm.Route(params, result);
|
||||||
|
|
||||||
|
auto &json_result = result.get<json::Object>();
|
||||||
if (status == Status::Ok)
|
if (status == Status::Ok)
|
||||||
{
|
{
|
||||||
auto &routes = result.values["routes"].get<json::Array>();
|
auto &routes = json_result.values["routes"].get<json::Array>();
|
||||||
|
|
||||||
// Let's just use the first route
|
// Let's just use the first route
|
||||||
auto &route = routes.values.at(0).get<json::Object>();
|
auto &route = routes.values.at(0).get<json::Object>();
|
||||||
@ -79,8 +80,8 @@ int main(int argc, const char *argv[])
|
|||||||
}
|
}
|
||||||
else if (status == Status::Error)
|
else if (status == Status::Error)
|
||||||
{
|
{
|
||||||
const auto code = result.values["code"].get<json::String>().value;
|
const auto code = json_result.values["code"].get<json::String>().value;
|
||||||
const auto message = result.values["message"].get<json::String>().value;
|
const auto message = json_result.values["message"].get<json::String>().value;
|
||||||
|
|
||||||
std::cout << "Code: " << code << "\n";
|
std::cout << "Code: " << code << "\n";
|
||||||
std::cout << "Message: " << code << "\n";
|
std::cout << "Message: " << code << "\n";
|
||||||
|
@ -111,3 +111,28 @@ Feature: Locating Nearest node on a Way - basic projection onto way
|
|||||||
| 7 | b |
|
| 7 | b |
|
||||||
| 8 | a |
|
| 8 | a |
|
||||||
| 9 | b |
|
| 9 | b |
|
||||||
|
|
||||||
|
Scenario: Nearest - easy-west way with flatbuffers
|
||||||
|
Given the node map
|
||||||
|
"""
|
||||||
|
0 1 2 3 4
|
||||||
|
a x b
|
||||||
|
5 6 7 8 9
|
||||||
|
"""
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes |
|
||||||
|
| ab |
|
||||||
|
|
||||||
|
When I request nearest with flatbuffers I should get
|
||||||
|
| in | out |
|
||||||
|
| 0 | a |
|
||||||
|
| 1 | a |
|
||||||
|
| 2 | x |
|
||||||
|
| 3 | b |
|
||||||
|
| 4 | b |
|
||||||
|
| 5 | a |
|
||||||
|
| 6 | a |
|
||||||
|
| 7 | x |
|
||||||
|
| 8 | b |
|
||||||
|
| 9 | b |
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
var util = require('util');
|
var util = require('util');
|
||||||
|
|
||||||
|
var flatbuffers = require('../support/flatbuffers').flatbuffers;
|
||||||
|
var FBResult = require('../support/fbresult_generated').osrm.engine.api.fbresult.FBResult;
|
||||||
|
|
||||||
module.exports = function () {
|
module.exports = function () {
|
||||||
this.When(/^I request nearest I should get$/, (table, callback) => {
|
this.When(/^I request nearest I should get$/, (table, callback) => {
|
||||||
this.reprocessAndLoadData((e) => {
|
this.reprocessAndLoadData((e) => {
|
||||||
@ -43,4 +46,55 @@ module.exports = function () {
|
|||||||
this.processRowsAndDiff(table, testRow, callback);
|
this.processRowsAndDiff(table, testRow, callback);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.When(/^I request nearest with flatbuffers I should get$/, (table, callback) => {
|
||||||
|
this.reprocessAndLoadData((e) => {
|
||||||
|
if (e) return callback(e);
|
||||||
|
var testRow = (row, ri, cb) => {
|
||||||
|
var inNode = this.findNodeByName(row.in);
|
||||||
|
if (!inNode) throw new Error(util.format('*** unknown in-node "%s"', row.in));
|
||||||
|
|
||||||
|
var outNode = this.findNodeByName(row.out);
|
||||||
|
if (!outNode) throw new Error(util.format('*** unknown out-node "%s"', row.out));
|
||||||
|
|
||||||
|
this.queryParams.output = 'flatbuffers';
|
||||||
|
this.requestNearest(inNode, this.queryParams, (err, response) => {
|
||||||
|
if (err) return cb(err);
|
||||||
|
var coord;
|
||||||
|
|
||||||
|
if (response.statusCode === 200 && response.body.length) {
|
||||||
|
var body = response.body;
|
||||||
|
var bytes = new Uint8Array(body.length);
|
||||||
|
for (var indx = 0; indx < body.length; ++indx) {
|
||||||
|
bytes[indx] = body.charCodeAt(indx);
|
||||||
|
}
|
||||||
|
var buf = new flatbuffers.ByteBuffer(bytes);
|
||||||
|
var fb = FBResult.getRootAsFBResult(buf);
|
||||||
|
var location = fb.waypoints(0).location();
|
||||||
|
|
||||||
|
coord = [location.longitude(), location.latitude()];
|
||||||
|
|
||||||
|
var got = { in: row.in, out: row.out };
|
||||||
|
|
||||||
|
Object.keys(row).forEach((key) => {
|
||||||
|
if (key === 'out') {
|
||||||
|
if (this.FuzzyMatch.matchLocation(coord, outNode)) {
|
||||||
|
got[key] = row[key];
|
||||||
|
} else {
|
||||||
|
row[key] = util.format('%s [%d,%d]', row[key], outNode.lat, outNode.lon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cb(null, got);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
this.processRowsAndDiff(table, testRow, callback);
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
3217
features/support/fbresult_generated.js
Normal file
3217
features/support/fbresult_generated.js
Normal file
File diff suppressed because it is too large
Load Diff
1259
features/support/flatbuffers.js
Normal file
1259
features/support/flatbuffers.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -2,6 +2,7 @@
|
|||||||
#define ENGINE_API_BASE_API_HPP
|
#define ENGINE_API_BASE_API_HPP
|
||||||
|
|
||||||
#include "engine/api/base_parameters.hpp"
|
#include "engine/api/base_parameters.hpp"
|
||||||
|
#include "engine/api/flatbuffers/fbresult_generated.h"
|
||||||
#include "engine/datafacade/datafacade_base.hpp"
|
#include "engine/datafacade/datafacade_base.hpp"
|
||||||
|
|
||||||
#include "engine/api/json_factory.hpp"
|
#include "engine/api/json_factory.hpp"
|
||||||
@ -71,6 +72,57 @@ class BaseAPI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>>
|
||||||
|
MakeWaypoints(flatbuffers::FlatBufferBuilder &builder,
|
||||||
|
const std::vector<PhantomNodes> &segment_end_coordinates) const
|
||||||
|
{
|
||||||
|
BOOST_ASSERT(parameters.coordinates.size() > 0);
|
||||||
|
BOOST_ASSERT(parameters.coordinates.size() == segment_end_coordinates.size() + 1);
|
||||||
|
|
||||||
|
std::vector<flatbuffers::Offset<fbresult::Waypoint>> waypoints;
|
||||||
|
waypoints.resize(parameters.coordinates.size());
|
||||||
|
waypoints[0] =
|
||||||
|
MakeWaypoint(builder, segment_end_coordinates.front().source_phantom).Finish();
|
||||||
|
|
||||||
|
std::transform(segment_end_coordinates.begin(),
|
||||||
|
segment_end_coordinates.end(),
|
||||||
|
std::next(waypoints.begin()),
|
||||||
|
[this, &builder](const PhantomNodes &phantom_pair) {
|
||||||
|
return MakeWaypoint(builder, phantom_pair.target_phantom).Finish();
|
||||||
|
});
|
||||||
|
return builder.CreateVector(waypoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: gcc 4.9 does not like MakeWaypoints to be protected
|
||||||
|
// protected:
|
||||||
|
fbresult::WaypointBuilder MakeWaypoint(flatbuffers::FlatBufferBuilder &builder,
|
||||||
|
const PhantomNode &phantom) const
|
||||||
|
{
|
||||||
|
|
||||||
|
auto location =
|
||||||
|
fbresult::Position(static_cast<double>(util::toFloating(phantom.location.lon)),
|
||||||
|
static_cast<double>(util::toFloating(phantom.location.lat)));
|
||||||
|
auto name_string = builder.CreateString(
|
||||||
|
facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)).to_string());
|
||||||
|
|
||||||
|
boost::optional<flatbuffers::Offset<flatbuffers::String>> hint_string = boost::none;
|
||||||
|
if (parameters.generate_hints)
|
||||||
|
{
|
||||||
|
hint_string = builder.CreateString(Hint{phantom, facade.GetCheckSum()}.ToBase64());
|
||||||
|
}
|
||||||
|
|
||||||
|
fbresult::WaypointBuilder waypoint(builder);
|
||||||
|
waypoint.add_location(&location);
|
||||||
|
waypoint.add_distance(util::coordinate_calculation::fccApproximateDistance(
|
||||||
|
phantom.location, phantom.input_location));
|
||||||
|
waypoint.add_name(name_string);
|
||||||
|
if (hint_string)
|
||||||
|
{
|
||||||
|
waypoint.add_hint(*hint_string);
|
||||||
|
}
|
||||||
|
return waypoint;
|
||||||
|
}
|
||||||
|
|
||||||
const datafacade::BaseDataFacade &facade;
|
const datafacade::BaseDataFacade &facade;
|
||||||
const BaseParameters ¶meters;
|
const BaseParameters ¶meters;
|
||||||
};
|
};
|
||||||
|
@ -70,12 +70,19 @@ struct BaseParameters
|
|||||||
Any
|
Any
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class OutputFormatType
|
||||||
|
{
|
||||||
|
JSON,
|
||||||
|
FLATBUFFERS
|
||||||
|
};
|
||||||
|
|
||||||
std::vector<util::Coordinate> coordinates;
|
std::vector<util::Coordinate> coordinates;
|
||||||
std::vector<boost::optional<Hint>> hints;
|
std::vector<boost::optional<Hint>> hints;
|
||||||
std::vector<boost::optional<double>> radiuses;
|
std::vector<boost::optional<double>> radiuses;
|
||||||
std::vector<boost::optional<Bearing>> bearings;
|
std::vector<boost::optional<Bearing>> bearings;
|
||||||
std::vector<boost::optional<Approach>> approaches;
|
std::vector<boost::optional<Approach>> approaches;
|
||||||
std::vector<std::string> exclude;
|
std::vector<std::string> exclude;
|
||||||
|
boost::optional<OutputFormatType> format = OutputFormatType::JSON;
|
||||||
|
|
||||||
// Adds hints to response which can be included in subsequent requests, see `hints` above.
|
// Adds hints to response which can be included in subsequent requests, see `hints` above.
|
||||||
bool generate_hints = true;
|
bool generate_hints = true;
|
||||||
|
23
include/engine/api/base_result.hpp
Normal file
23
include/engine/api/base_result.hpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef ENGINE_API_BASE_RESULT_HPP
|
||||||
|
#define ENGINE_API_BASE_RESULT_HPP
|
||||||
|
|
||||||
|
#include <flatbuffers/flatbuffers.h>
|
||||||
|
#include <mapbox/variant.hpp>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "util/json_container.hpp"
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace api
|
||||||
|
{
|
||||||
|
using ResultT =
|
||||||
|
mapbox::util::variant<util::json::Object, std::string, flatbuffers::FlatBufferBuilder>;
|
||||||
|
} // ns api
|
||||||
|
} // ns engine
|
||||||
|
} // ns osrm
|
||||||
|
|
||||||
|
#endif
|
20
include/engine/api/flatbuffers/fbresult.fbs
Normal file
20
include/engine/api/flatbuffers/fbresult.fbs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
include "route.fbs";
|
||||||
|
include "table.fbs";
|
||||||
|
|
||||||
|
namespace osrm.engine.api.fbresult;
|
||||||
|
|
||||||
|
table Error {
|
||||||
|
code: string;
|
||||||
|
message: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
table FBResult {
|
||||||
|
error: bool = false;
|
||||||
|
code: Error;
|
||||||
|
data_version: string;
|
||||||
|
waypoints: [Waypoint]; //Used as 'sources' waypoints for a 'Table' service
|
||||||
|
routes: [RouteObject];
|
||||||
|
table: Table;
|
||||||
|
}
|
||||||
|
|
||||||
|
root_type FBResult;
|
2439
include/engine/api/flatbuffers/fbresult_generated.h
Normal file
2439
include/engine/api/flatbuffers/fbresult_generated.h
Normal file
File diff suppressed because it is too large
Load Diff
6
include/engine/api/flatbuffers/position.fbs
Normal file
6
include/engine/api/flatbuffers/position.fbs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
namespace osrm.engine.api.fbresult;
|
||||||
|
|
||||||
|
struct Position {
|
||||||
|
longitude: float;
|
||||||
|
latitude: float;
|
||||||
|
}
|
110
include/engine/api/flatbuffers/route.fbs
Normal file
110
include/engine/api/flatbuffers/route.fbs
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
include "waypoint.fbs";
|
||||||
|
namespace osrm.engine.api.fbresult;
|
||||||
|
|
||||||
|
table Metadata {
|
||||||
|
datasource_names: [string];
|
||||||
|
}
|
||||||
|
|
||||||
|
table Annotation {
|
||||||
|
distance: [uint];
|
||||||
|
duration: [uint];
|
||||||
|
datasources: [uint];
|
||||||
|
nodes: [uint];
|
||||||
|
weight: [uint];
|
||||||
|
speed: [float];
|
||||||
|
metadata: Metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ManeuverType: byte {
|
||||||
|
Turn,
|
||||||
|
NewName,
|
||||||
|
Depart,
|
||||||
|
Arrive,
|
||||||
|
Merge,
|
||||||
|
OnRamp,
|
||||||
|
OffRamp,
|
||||||
|
Fork,
|
||||||
|
EndOfRoad,
|
||||||
|
Continue,
|
||||||
|
Roundabout,
|
||||||
|
Rotary,
|
||||||
|
RoundaboutTurn,
|
||||||
|
Notification,
|
||||||
|
ExitRoundabout,
|
||||||
|
ExitRotary
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Turn: byte {
|
||||||
|
None,
|
||||||
|
UTurn,
|
||||||
|
SharpRight,
|
||||||
|
Right,
|
||||||
|
SlightRight,
|
||||||
|
Straight,
|
||||||
|
SlightLeft,
|
||||||
|
Left,
|
||||||
|
SharpLeft
|
||||||
|
}
|
||||||
|
|
||||||
|
table StepManeuver {
|
||||||
|
location: Position;
|
||||||
|
bearing_before: ushort;
|
||||||
|
bearing_after: ushort;
|
||||||
|
type: ManeuverType;
|
||||||
|
modifier: Turn;
|
||||||
|
exit: ubyte;
|
||||||
|
}
|
||||||
|
|
||||||
|
table Lane {
|
||||||
|
indications: [Turn];
|
||||||
|
valid: bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
table Intersection {
|
||||||
|
location: Position;
|
||||||
|
bearings: [short];
|
||||||
|
classes: [string];
|
||||||
|
entry: [bool];
|
||||||
|
in_bearing: uint;
|
||||||
|
out_bearing: uint;
|
||||||
|
lanes: [Lane];
|
||||||
|
}
|
||||||
|
|
||||||
|
table Step {
|
||||||
|
distance: float;
|
||||||
|
duration: float;
|
||||||
|
polyline: string;
|
||||||
|
coordinates: [Position];
|
||||||
|
weight: float;
|
||||||
|
name: string;
|
||||||
|
ref: string;
|
||||||
|
pronunciation: string;
|
||||||
|
destinations: string;
|
||||||
|
exits: string;
|
||||||
|
mode: string;
|
||||||
|
maneuver: StepManeuver;
|
||||||
|
intersections: [Intersection];
|
||||||
|
rotary_name: string;
|
||||||
|
rotary_pronunciation: string;
|
||||||
|
driving_side: bool; //Where true stands for the left side.
|
||||||
|
}
|
||||||
|
|
||||||
|
table Leg {
|
||||||
|
distance: double;
|
||||||
|
duration: double;
|
||||||
|
weight: double;
|
||||||
|
summary: string;
|
||||||
|
annotations: Annotation;
|
||||||
|
steps: [Step];
|
||||||
|
}
|
||||||
|
|
||||||
|
table RouteObject {
|
||||||
|
distance: float;
|
||||||
|
duration: float;
|
||||||
|
weight: float;
|
||||||
|
weight_name: string;
|
||||||
|
confidence: float; //Used only by 'Match' service
|
||||||
|
polyline: string;
|
||||||
|
coordinates: [Position];
|
||||||
|
legs: [Leg];
|
||||||
|
}
|
11
include/engine/api/flatbuffers/table.fbs
Normal file
11
include/engine/api/flatbuffers/table.fbs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
include "waypoint.fbs";
|
||||||
|
namespace osrm.engine.api.fbresult;
|
||||||
|
|
||||||
|
table Table {
|
||||||
|
durations: [float];
|
||||||
|
rows: ushort;
|
||||||
|
cols: ushort;
|
||||||
|
distances: [float];
|
||||||
|
destinations: [Waypoint];
|
||||||
|
fallback_speed_cells: [uint];
|
||||||
|
}
|
19
include/engine/api/flatbuffers/waypoint.fbs
Normal file
19
include/engine/api/flatbuffers/waypoint.fbs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
include "position.fbs";
|
||||||
|
namespace osrm.engine.api.fbresult;
|
||||||
|
|
||||||
|
struct Uint64Pair {
|
||||||
|
first: uint64;
|
||||||
|
second: uint64;
|
||||||
|
}
|
||||||
|
|
||||||
|
table Waypoint {
|
||||||
|
hint: string;
|
||||||
|
distance: float;
|
||||||
|
name: string;
|
||||||
|
location: Position;
|
||||||
|
nodes: Uint64Pair; //Used only by 'Nearest' service
|
||||||
|
matchings_index: uint; //Used only by 'Match' service
|
||||||
|
waypoint_index: uint; //Used by 'Match' and 'Trip' services
|
||||||
|
alternatives_count: uint; //Used only by 'Match' service
|
||||||
|
trips_index: uint; //Used only by 'Trip' service
|
||||||
|
}
|
@ -33,6 +33,18 @@ namespace json
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Check whether to include a modifier in the result of the API
|
||||||
|
inline bool isValidModifier(const guidance::StepManeuver maneuver)
|
||||||
|
{
|
||||||
|
return (maneuver.waypoint_type == guidance::WaypointType::None ||
|
||||||
|
maneuver.instruction.direction_modifier != osrm::guidance::DirectionModifier::UTurn);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool hasValidLanes(const guidance::IntermediateIntersection &intersection)
|
||||||
|
{
|
||||||
|
return intersection.lanes.lanes_in_turn > 0;
|
||||||
|
}
|
||||||
|
|
||||||
util::json::Array coordinateToLonLat(const util::Coordinate &coordinate);
|
util::json::Array coordinateToLonLat(const util::Coordinate &coordinate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,6 +29,44 @@ class MatchAPI final : public RouteAPI
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MakeResponse(const std::vector<map_matching::SubMatching> &sub_matchings,
|
||||||
|
const std::vector<InternalRouteResult> &sub_routes,
|
||||||
|
osrm::engine::api::ResultT &response) const
|
||||||
|
{
|
||||||
|
BOOST_ASSERT(sub_matchings.size() == sub_routes.size());
|
||||||
|
if (response.is<flatbuffers::FlatBufferBuilder>())
|
||||||
|
{
|
||||||
|
auto &fb_result = response.get<flatbuffers::FlatBufferBuilder>();
|
||||||
|
MakeResponse(sub_matchings, sub_routes, fb_result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto &json_result = response.get<util::json::Object>();
|
||||||
|
MakeResponse(sub_matchings, sub_routes, json_result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void MakeResponse(const std::vector<map_matching::SubMatching> &sub_matchings,
|
||||||
|
const std::vector<InternalRouteResult> &sub_routes,
|
||||||
|
flatbuffers::FlatBufferBuilder &fb_result) const
|
||||||
|
{
|
||||||
|
auto data_timestamp = facade.GetTimestamp();
|
||||||
|
boost::optional<flatbuffers::Offset<flatbuffers::String>> data_version_string = boost::none;
|
||||||
|
if (!data_timestamp.empty())
|
||||||
|
{
|
||||||
|
data_version_string = fb_result.CreateString(data_timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto response = MakeFBResponse(sub_routes, fb_result, [this, &fb_result, &sub_matchings]() {
|
||||||
|
return MakeTracepoints(fb_result, sub_matchings);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (data_version_string)
|
||||||
|
{
|
||||||
|
response.add_data_version(*data_version_string);
|
||||||
|
}
|
||||||
|
|
||||||
|
fb_result.Finish(response.Finish());
|
||||||
|
}
|
||||||
void MakeResponse(const std::vector<map_matching::SubMatching> &sub_matchings,
|
void MakeResponse(const std::vector<map_matching::SubMatching> &sub_matchings,
|
||||||
const std::vector<InternalRouteResult> &sub_routes,
|
const std::vector<InternalRouteResult> &sub_routes,
|
||||||
util::json::Object &response) const
|
util::json::Object &response) const
|
||||||
@ -36,7 +74,6 @@ class MatchAPI final : public RouteAPI
|
|||||||
auto number_of_routes = sub_matchings.size();
|
auto number_of_routes = sub_matchings.size();
|
||||||
util::json::Array routes;
|
util::json::Array routes;
|
||||||
routes.values.reserve(number_of_routes);
|
routes.values.reserve(number_of_routes);
|
||||||
BOOST_ASSERT(sub_matchings.size() == sub_routes.size());
|
|
||||||
for (auto index : util::irange<std::size_t>(0UL, sub_matchings.size()))
|
for (auto index : util::irange<std::size_t>(0UL, sub_matchings.size()))
|
||||||
{
|
{
|
||||||
auto route = MakeRoute(sub_routes[index].segment_end_coordinates,
|
auto route = MakeRoute(sub_routes[index].segment_end_coordinates,
|
||||||
@ -55,12 +92,6 @@ class MatchAPI final : public RouteAPI
|
|||||||
// FIXME this logic is a little backwards. We should change the output format of the
|
// FIXME this logic is a little backwards. We should change the output format of the
|
||||||
// map_matching
|
// map_matching
|
||||||
// routing algorithm to be easier to consume here.
|
// routing algorithm to be easier to consume here.
|
||||||
util::json::Array
|
|
||||||
MakeTracepoints(const std::vector<map_matching::SubMatching> &sub_matchings) const
|
|
||||||
{
|
|
||||||
util::json::Array waypoints;
|
|
||||||
waypoints.values.reserve(parameters.coordinates.size());
|
|
||||||
|
|
||||||
struct MatchingIndex
|
struct MatchingIndex
|
||||||
{
|
{
|
||||||
MatchingIndex() = default;
|
MatchingIndex() = default;
|
||||||
@ -79,23 +110,69 @@ class MatchAPI final : public RouteAPI
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<MatchingIndex> trace_idx_to_matching_idx(parameters.coordinates.size());
|
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>>
|
||||||
for (auto sub_matching_index :
|
MakeTracepoints(flatbuffers::FlatBufferBuilder &fb_result,
|
||||||
util::irange(0u, static_cast<unsigned>(sub_matchings.size())))
|
const std::vector<map_matching::SubMatching> &sub_matchings) const
|
||||||
{
|
{
|
||||||
for (auto point_index : util::irange(
|
std::vector<flatbuffers::Offset<fbresult::Waypoint>> waypoints;
|
||||||
0u, static_cast<unsigned>(sub_matchings[sub_matching_index].indices.size())))
|
waypoints.reserve(parameters.coordinates.size());
|
||||||
|
|
||||||
|
auto trace_idx_to_matching_idx = MakeMatchingIndices(sub_matchings);
|
||||||
|
|
||||||
|
BOOST_ASSERT(parameters.waypoints.empty() || sub_matchings.size() == 1);
|
||||||
|
|
||||||
|
std::size_t was_waypoint_idx = 0;
|
||||||
|
for (auto trace_index : util::irange<std::size_t>(0UL, parameters.coordinates.size()))
|
||||||
{
|
{
|
||||||
// tidied_to_original: index of the input coordinate that a tidied coordinate
|
|
||||||
// corresponds to.
|
if (tidy_result.can_be_removed[trace_index])
|
||||||
// sub_matching indices: index of the coordinate passed to map matching plugin that
|
{
|
||||||
// a matched node corresponds to.
|
waypoints.push_back(fbresult::WaypointBuilder(fb_result).Finish());
|
||||||
trace_idx_to_matching_idx[tidy_result
|
continue;
|
||||||
.tidied_to_original[sub_matchings[sub_matching_index]
|
}
|
||||||
.indices[point_index]]] =
|
auto matching_index = trace_idx_to_matching_idx[trace_index];
|
||||||
MatchingIndex{sub_matching_index, point_index};
|
if (matching_index.NotMatched())
|
||||||
|
{
|
||||||
|
waypoints.push_back(fbresult::WaypointBuilder(fb_result).Finish());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const auto &phantom =
|
||||||
|
sub_matchings[matching_index.sub_matching_index].nodes[matching_index.point_index];
|
||||||
|
auto waypoint = BaseAPI::MakeWaypoint(fb_result, phantom);
|
||||||
|
waypoint.add_matchings_index(matching_index.sub_matching_index);
|
||||||
|
waypoint.add_alternatives_count(sub_matchings[matching_index.sub_matching_index]
|
||||||
|
.alternatives_count[matching_index.point_index]);
|
||||||
|
// waypoint indices need to be adjusted if route legs were collapsed
|
||||||
|
// waypoint parameter assumes there is only one match object
|
||||||
|
if (!parameters.waypoints.empty())
|
||||||
|
{
|
||||||
|
if (tidy_result.was_waypoint[trace_index])
|
||||||
|
{
|
||||||
|
waypoint.add_waypoint_index(was_waypoint_idx);
|
||||||
|
was_waypoint_idx++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
waypoint.add_waypoint_index(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
waypoint.add_waypoint_index(matching_index.point_index);
|
||||||
|
}
|
||||||
|
waypoints.push_back(waypoint.Finish());
|
||||||
|
}
|
||||||
|
|
||||||
|
return fb_result.CreateVector(waypoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
util::json::Array
|
||||||
|
MakeTracepoints(const std::vector<map_matching::SubMatching> &sub_matchings) const
|
||||||
|
{
|
||||||
|
util::json::Array waypoints;
|
||||||
|
waypoints.values.reserve(parameters.coordinates.size());
|
||||||
|
|
||||||
|
auto trace_idx_to_matching_idx = MakeMatchingIndices(sub_matchings);
|
||||||
|
|
||||||
BOOST_ASSERT(parameters.waypoints.empty() || sub_matchings.size() == 1);
|
BOOST_ASSERT(parameters.waypoints.empty() || sub_matchings.size() == 1);
|
||||||
|
|
||||||
@ -141,6 +218,29 @@ class MatchAPI final : public RouteAPI
|
|||||||
return waypoints;
|
return waypoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<MatchingIndex>
|
||||||
|
MakeMatchingIndices(const std::vector<map_matching::SubMatching> &sub_matchings) const
|
||||||
|
{
|
||||||
|
std::vector<MatchingIndex> trace_idx_to_matching_idx(parameters.coordinates.size());
|
||||||
|
for (auto sub_matching_index :
|
||||||
|
util::irange(0u, static_cast<unsigned>(sub_matchings.size())))
|
||||||
|
{
|
||||||
|
for (auto point_index : util::irange(
|
||||||
|
0u, static_cast<unsigned>(sub_matchings[sub_matching_index].indices.size())))
|
||||||
|
{
|
||||||
|
// tidied_to_original: index of the input coordinate that a tidied coordinate
|
||||||
|
// corresponds to.
|
||||||
|
// sub_matching indices: index of the coordinate passed to map matching plugin that
|
||||||
|
// a matched node corresponds to.
|
||||||
|
trace_idx_to_matching_idx[tidy_result
|
||||||
|
.tidied_to_original[sub_matchings[sub_matching_index]
|
||||||
|
.indices[point_index]]] =
|
||||||
|
MatchingIndex{sub_matching_index, point_index};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return trace_idx_to_matching_idx;
|
||||||
|
}
|
||||||
|
|
||||||
const MatchParameters ¶meters;
|
const MatchParameters ¶meters;
|
||||||
const tidy::Result &tidy_result;
|
const tidy::Result &tidy_result;
|
||||||
};
|
};
|
||||||
|
@ -27,15 +27,65 @@ class NearestAPI final : public BaseAPI
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MakeResponse(const std::vector<std::vector<PhantomNodeWithDistance>> &phantom_nodes,
|
void MakeResponse(const std::vector<std::vector<PhantomNodeWithDistance>> &phantom_nodes,
|
||||||
util::json::Object &response) const
|
osrm::engine::api::ResultT &response) const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(phantom_nodes.size() == 1);
|
BOOST_ASSERT(phantom_nodes.size() == 1);
|
||||||
BOOST_ASSERT(parameters.coordinates.size() == 1);
|
BOOST_ASSERT(parameters.coordinates.size() == 1);
|
||||||
|
|
||||||
|
if (response.is<flatbuffers::FlatBufferBuilder>())
|
||||||
|
{
|
||||||
|
auto &fb_result = response.get<flatbuffers::FlatBufferBuilder>();
|
||||||
|
MakeResponse(phantom_nodes, fb_result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto &json_result = response.get<util::json::Object>();
|
||||||
|
MakeResponse(phantom_nodes, json_result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MakeResponse(const std::vector<std::vector<PhantomNodeWithDistance>> &phantom_nodes,
|
||||||
|
flatbuffers::FlatBufferBuilder &fb_result) const
|
||||||
|
{
|
||||||
|
auto data_timestamp = facade.GetTimestamp();
|
||||||
|
boost::optional<flatbuffers::Offset<flatbuffers::String>> data_version_string = boost::none;
|
||||||
|
if (!data_timestamp.empty())
|
||||||
|
{
|
||||||
|
data_version_string = fb_result.CreateString(data_timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<flatbuffers::Offset<fbresult::Waypoint>> waypoints;
|
||||||
|
waypoints.resize(phantom_nodes.front().size());
|
||||||
|
std::transform(phantom_nodes.front().begin(),
|
||||||
|
phantom_nodes.front().end(),
|
||||||
|
waypoints.begin(),
|
||||||
|
[this, &fb_result](const PhantomNodeWithDistance &phantom_with_distance) {
|
||||||
|
auto &phantom_node = phantom_with_distance.phantom_node;
|
||||||
|
|
||||||
|
auto node_values = MakeNodes(phantom_node);
|
||||||
|
fbresult::Uint64Pair nodes{node_values.first, node_values.second};
|
||||||
|
|
||||||
|
auto waypoint = MakeWaypoint(fb_result, phantom_node);
|
||||||
|
waypoint.add_nodes(&nodes);
|
||||||
|
|
||||||
|
return waypoint.Finish();
|
||||||
|
});
|
||||||
|
|
||||||
|
auto waypoints_vector = fb_result.CreateVector(waypoints);
|
||||||
|
fbresult::FBResultBuilder response(fb_result);
|
||||||
|
response.add_waypoints(waypoints_vector);
|
||||||
|
if (data_version_string)
|
||||||
|
{
|
||||||
|
response.add_data_version(*data_version_string);
|
||||||
|
}
|
||||||
|
fb_result.Finish(response.Finish());
|
||||||
|
}
|
||||||
|
void MakeResponse(const std::vector<std::vector<PhantomNodeWithDistance>> &phantom_nodes,
|
||||||
|
util::json::Object &response) const
|
||||||
|
{
|
||||||
util::json::Array waypoints;
|
util::json::Array waypoints;
|
||||||
waypoints.values.resize(phantom_nodes.front().size());
|
waypoints.values.resize(phantom_nodes.front().size());
|
||||||
std::transform(
|
std::transform(phantom_nodes.front().begin(),
|
||||||
phantom_nodes.front().begin(),
|
|
||||||
phantom_nodes.front().end(),
|
phantom_nodes.front().end(),
|
||||||
waypoints.values.begin(),
|
waypoints.values.begin(),
|
||||||
[this](const PhantomNodeWithDistance &phantom_with_distance) {
|
[this](const PhantomNodeWithDistance &phantom_with_distance) {
|
||||||
@ -44,6 +94,24 @@ class NearestAPI final : public BaseAPI
|
|||||||
|
|
||||||
util::json::Array nodes;
|
util::json::Array nodes;
|
||||||
|
|
||||||
|
auto node_values = MakeNodes(phantom_node);
|
||||||
|
|
||||||
|
nodes.values.push_back(node_values.first);
|
||||||
|
nodes.values.push_back(node_values.second);
|
||||||
|
waypoint.values["nodes"] = std::move(nodes);
|
||||||
|
|
||||||
|
return waypoint;
|
||||||
|
});
|
||||||
|
|
||||||
|
response.values["code"] = "Ok";
|
||||||
|
response.values["waypoints"] = std::move(waypoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
const NearestParameters ¶meters;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::pair<uint64_t, uint64_t> MakeNodes(const PhantomNode &phantom_node) const
|
||||||
|
{
|
||||||
std::uint64_t from_node = 0;
|
std::uint64_t from_node = 0;
|
||||||
std::uint64_t to_node = 0;
|
std::uint64_t to_node = 0;
|
||||||
|
|
||||||
@ -54,8 +122,8 @@ class NearestAPI final : public BaseAPI
|
|||||||
const auto geometry_id = facade.GetGeometryIndex(segment_id).id;
|
const auto geometry_id = facade.GetGeometryIndex(segment_id).id;
|
||||||
forward_geometry = facade.GetUncompressedForwardGeometry(geometry_id);
|
forward_geometry = facade.GetUncompressedForwardGeometry(geometry_id);
|
||||||
|
|
||||||
auto osm_node_id = facade.GetOSMNodeIDOfNode(
|
auto osm_node_id =
|
||||||
forward_geometry(phantom_node.fwd_segment_position));
|
facade.GetOSMNodeIDOfNode(forward_geometry(phantom_node.fwd_segment_position));
|
||||||
to_node = static_cast<std::uint64_t>(osm_node_id);
|
to_node = static_cast<std::uint64_t>(osm_node_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,26 +136,16 @@ class NearestAPI final : public BaseAPI
|
|||||||
facade.GetOSMNodeIDOfNode(geometry(phantom_node.fwd_segment_position + 1));
|
facade.GetOSMNodeIDOfNode(geometry(phantom_node.fwd_segment_position + 1));
|
||||||
from_node = static_cast<std::uint64_t>(osm_node_id);
|
from_node = static_cast<std::uint64_t>(osm_node_id);
|
||||||
}
|
}
|
||||||
else if (phantom_node.forward_segment_id.enabled &&
|
else if (phantom_node.forward_segment_id.enabled && phantom_node.fwd_segment_position > 0)
|
||||||
phantom_node.fwd_segment_position > 0)
|
|
||||||
{
|
{
|
||||||
// In the case of one way, rely on forward segment only
|
// In the case of one way, rely on forward segment only
|
||||||
auto osm_node_id = facade.GetOSMNodeIDOfNode(
|
auto osm_node_id =
|
||||||
forward_geometry(phantom_node.fwd_segment_position - 1));
|
facade.GetOSMNodeIDOfNode(forward_geometry(phantom_node.fwd_segment_position - 1));
|
||||||
from_node = static_cast<std::uint64_t>(osm_node_id);
|
from_node = static_cast<std::uint64_t>(osm_node_id);
|
||||||
}
|
}
|
||||||
nodes.values.push_back(from_node);
|
|
||||||
nodes.values.push_back(to_node);
|
|
||||||
waypoint.values["nodes"] = std::move(nodes);
|
|
||||||
|
|
||||||
return waypoint;
|
return std::make_pair(from_node, to_node);
|
||||||
});
|
|
||||||
|
|
||||||
response.values["code"] = "Ok";
|
|
||||||
response.values["waypoints"] = std::move(waypoints);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const NearestParameters ¶meters;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // ns api
|
} // ns api
|
||||||
|
@ -48,10 +48,54 @@ class RouteAPI : public BaseAPI
|
|||||||
MakeResponse(const InternalManyRoutesResult &raw_routes,
|
MakeResponse(const InternalManyRoutesResult &raw_routes,
|
||||||
const std::vector<PhantomNodes>
|
const std::vector<PhantomNodes>
|
||||||
&all_start_end_points, // all used coordinates, ignoring waypoints= parameter
|
&all_start_end_points, // all used coordinates, ignoring waypoints= parameter
|
||||||
util::json::Object &response) const
|
osrm::engine::api::ResultT &response) const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(!raw_routes.routes.empty());
|
BOOST_ASSERT(!raw_routes.routes.empty());
|
||||||
|
|
||||||
|
if (response.is<flatbuffers::FlatBufferBuilder>())
|
||||||
|
{
|
||||||
|
auto &fb_result = response.get<flatbuffers::FlatBufferBuilder>();
|
||||||
|
MakeResponse(raw_routes, all_start_end_points, fb_result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto &json_result = response.get<util::json::Object>();
|
||||||
|
MakeResponse(raw_routes, all_start_end_points, json_result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MakeResponse(const InternalManyRoutesResult &raw_routes,
|
||||||
|
const std::vector<PhantomNodes>
|
||||||
|
&all_start_end_points, // all used coordinates, ignoring waypoints= parameter
|
||||||
|
flatbuffers::FlatBufferBuilder &fb_result) const
|
||||||
|
{
|
||||||
|
|
||||||
|
auto data_timestamp = facade.GetTimestamp();
|
||||||
|
boost::optional<flatbuffers::Offset<flatbuffers::String>> data_version_string = boost::none;
|
||||||
|
if (!data_timestamp.empty())
|
||||||
|
{
|
||||||
|
data_version_string = fb_result.CreateString(data_timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto response =
|
||||||
|
MakeFBResponse(raw_routes, fb_result, [this, &all_start_end_points, &fb_result]() {
|
||||||
|
return BaseAPI::MakeWaypoints(fb_result, all_start_end_points);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (data_version_string)
|
||||||
|
{
|
||||||
|
response.add_data_version(*data_version_string);
|
||||||
|
}
|
||||||
|
fb_result.Finish(response.Finish());
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MakeResponse(const InternalManyRoutesResult &raw_routes,
|
||||||
|
const std::vector<PhantomNodes>
|
||||||
|
&all_start_end_points, // all used coordinates, ignoring waypoints= parameter
|
||||||
|
util::json::Object &response) const
|
||||||
|
{
|
||||||
util::json::Array jsRoutes;
|
util::json::Array jsRoutes;
|
||||||
|
|
||||||
for (const auto &route : raw_routes.routes)
|
for (const auto &route : raw_routes.routes)
|
||||||
@ -76,21 +120,95 @@ class RouteAPI : public BaseAPI
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
template <typename GetWptsFn>
|
||||||
|
fbresult::FBResultBuilder MakeFBResponse(const InternalManyRoutesResult &raw_routes,
|
||||||
|
flatbuffers::FlatBufferBuilder &fb_result,
|
||||||
|
GetWptsFn getWaypoints) const
|
||||||
|
{
|
||||||
|
|
||||||
|
std::vector<flatbuffers::Offset<fbresult::RouteObject>> routes;
|
||||||
|
for (const auto &raw_route : raw_routes.routes)
|
||||||
|
{
|
||||||
|
if (!raw_route.is_valid())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
routes.push_back(MakeRoute(fb_result,
|
||||||
|
raw_route.segment_end_coordinates,
|
||||||
|
raw_route.unpacked_path_segments,
|
||||||
|
raw_route.source_traversed_in_reverse,
|
||||||
|
raw_route.target_traversed_in_reverse));
|
||||||
|
}
|
||||||
|
|
||||||
|
auto routes_vector = fb_result.CreateVector(routes);
|
||||||
|
auto waypoints_vector = getWaypoints();
|
||||||
|
|
||||||
|
fbresult::FBResultBuilder response(fb_result);
|
||||||
|
response.add_routes(routes_vector);
|
||||||
|
response.add_waypoints(waypoints_vector);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename ForwardIter>
|
template <typename ForwardIter>
|
||||||
util::json::Value MakeGeometry(ForwardIter begin, ForwardIter end) const
|
mapbox::util::variant<flatbuffers::Offset<flatbuffers::String>,
|
||||||
|
flatbuffers::Offset<flatbuffers::Vector<const fbresult::Position *>>>
|
||||||
|
MakeGeometry(flatbuffers::FlatBufferBuilder &builder, ForwardIter begin, ForwardIter end) const
|
||||||
{
|
{
|
||||||
if (parameters.geometries == RouteParameters::GeometriesType::Polyline)
|
if (parameters.geometries == RouteParameters::GeometriesType::Polyline)
|
||||||
{
|
{
|
||||||
return json::makePolyline<100000>(begin, end);
|
return builder.CreateString(encodePolyline<100000>(begin, end));
|
||||||
}
|
}
|
||||||
|
else if (parameters.geometries == RouteParameters::GeometriesType::Polyline6)
|
||||||
if (parameters.geometries == RouteParameters::GeometriesType::Polyline6)
|
|
||||||
{
|
{
|
||||||
return json::makePolyline<1000000>(begin, end);
|
return builder.CreateString(encodePolyline<1000000>(begin, end));
|
||||||
|
}
|
||||||
|
std::vector<fbresult::Position> coordinates;
|
||||||
|
coordinates.resize(std::distance(begin, end));
|
||||||
|
std::transform(begin, end, coordinates.begin(), [](const Coordinate &c) {
|
||||||
|
return fbresult::Position{static_cast<float>(util::toFloating(c.lon).__value),
|
||||||
|
static_cast<float>(util::toFloating(c.lat).__value)};
|
||||||
|
});
|
||||||
|
return builder.CreateVectorOfStructs(coordinates);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::optional<util::json::Value>
|
||||||
|
MakeGeometry(boost::optional<std::vector<Coordinate>> &&annotations) const
|
||||||
|
{
|
||||||
|
boost::optional<util::json::Value> json_geometry;
|
||||||
|
if (annotations)
|
||||||
|
{
|
||||||
|
auto begin = annotations->begin();
|
||||||
|
auto end = annotations->end();
|
||||||
|
if (parameters.geometries == RouteParameters::GeometriesType::Polyline)
|
||||||
|
{
|
||||||
|
json_geometry = json::makePolyline<100000>(begin, end);
|
||||||
|
}
|
||||||
|
else if (parameters.geometries == RouteParameters::GeometriesType::Polyline6)
|
||||||
|
{
|
||||||
|
json_geometry = json::makePolyline<1000000>(begin, end);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
BOOST_ASSERT(parameters.geometries == RouteParameters::GeometriesType::GeoJSON);
|
BOOST_ASSERT(parameters.geometries == RouteParameters::GeometriesType::GeoJSON);
|
||||||
return json::makeGeoJSONGeometry(begin, end);
|
json_geometry = json::makeGeoJSONGeometry(begin, end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return json_geometry;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename ValueType, typename GetFn>
|
||||||
|
flatbuffers::Offset<flatbuffers::Vector<ValueType>> GetAnnotations(
|
||||||
|
flatbuffers::FlatBufferBuilder &fb_result, guidance::LegGeometry &leg, GetFn Get) const
|
||||||
|
{
|
||||||
|
std::vector<ValueType> annotations_store;
|
||||||
|
annotations_store.reserve(leg.annotations.size());
|
||||||
|
|
||||||
|
for (const auto &step : leg.annotations)
|
||||||
|
{
|
||||||
|
annotations_store.push_back(Get(step));
|
||||||
|
}
|
||||||
|
|
||||||
|
return fb_result.CreateVector(annotations_store);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename GetFn>
|
template <typename GetFn>
|
||||||
@ -107,118 +225,492 @@ class RouteAPI : public BaseAPI
|
|||||||
return annotations_store;
|
return annotations_store;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fbresult::ManeuverType WaypointTypeToFB(guidance::WaypointType type) const
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case guidance::WaypointType::Arrive:
|
||||||
|
return fbresult::ManeuverType_Arrive;
|
||||||
|
case guidance::WaypointType::Depart:
|
||||||
|
return fbresult::ManeuverType_Depart;
|
||||||
|
default:
|
||||||
|
return fbresult::ManeuverType_Notification;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fbresult::ManeuverType TurnTypeToFB(osrm::guidance::TurnType::Enum turn) const
|
||||||
|
{
|
||||||
|
static std::map<osrm::guidance::TurnType::Enum, fbresult::ManeuverType> mappings = {
|
||||||
|
{osrm::guidance::TurnType::Invalid, fbresult::ManeuverType_Notification},
|
||||||
|
{osrm::guidance::TurnType::NewName, fbresult::ManeuverType_NewName},
|
||||||
|
{osrm::guidance::TurnType::Continue, fbresult::ManeuverType_Continue},
|
||||||
|
{osrm::guidance::TurnType::Turn, fbresult::ManeuverType_Turn},
|
||||||
|
{osrm::guidance::TurnType::Merge, fbresult::ManeuverType_Merge},
|
||||||
|
{osrm::guidance::TurnType::OnRamp, fbresult::ManeuverType_OnRamp},
|
||||||
|
{osrm::guidance::TurnType::OffRamp, fbresult::ManeuverType_OffRamp},
|
||||||
|
{osrm::guidance::TurnType::Fork, fbresult::ManeuverType_Fork},
|
||||||
|
{osrm::guidance::TurnType::EndOfRoad, fbresult::ManeuverType_EndOfRoad},
|
||||||
|
{osrm::guidance::TurnType::Notification, fbresult::ManeuverType_Notification},
|
||||||
|
{osrm::guidance::TurnType::EnterRoundabout, fbresult::ManeuverType_Roundabout},
|
||||||
|
{osrm::guidance::TurnType::EnterAndExitRoundabout,
|
||||||
|
fbresult::ManeuverType_ExitRoundabout},
|
||||||
|
{osrm::guidance::TurnType::EnterRotary, fbresult::ManeuverType_Rotary},
|
||||||
|
{osrm::guidance::TurnType::EnterAndExitRotary, fbresult::ManeuverType_ExitRotary},
|
||||||
|
{osrm::guidance::TurnType::EnterRoundaboutIntersection,
|
||||||
|
fbresult::ManeuverType_Roundabout},
|
||||||
|
{osrm::guidance::TurnType::EnterAndExitRoundaboutIntersection,
|
||||||
|
fbresult::ManeuverType_ExitRoundabout},
|
||||||
|
{osrm::guidance::TurnType::NoTurn, fbresult::ManeuverType_Notification},
|
||||||
|
{osrm::guidance::TurnType::Suppressed, fbresult::ManeuverType_Notification},
|
||||||
|
{osrm::guidance::TurnType::EnterRoundaboutAtExit, fbresult::ManeuverType_Roundabout},
|
||||||
|
{osrm::guidance::TurnType::ExitRoundabout, fbresult::ManeuverType_ExitRoundabout},
|
||||||
|
{osrm::guidance::TurnType::EnterRotaryAtExit, fbresult::ManeuverType_Rotary},
|
||||||
|
{osrm::guidance::TurnType::ExitRotary, fbresult::ManeuverType_ExitRotary},
|
||||||
|
{osrm::guidance::TurnType::EnterRoundaboutIntersectionAtExit,
|
||||||
|
fbresult::ManeuverType_Roundabout},
|
||||||
|
{osrm::guidance::TurnType::ExitRoundaboutIntersection,
|
||||||
|
fbresult::ManeuverType_ExitRoundabout},
|
||||||
|
{osrm::guidance::TurnType::StayOnRoundabout, fbresult::ManeuverType_RoundaboutTurn},
|
||||||
|
{osrm::guidance::TurnType::Sliproad, fbresult::ManeuverType_Notification},
|
||||||
|
{osrm::guidance::TurnType::MaxTurnType, fbresult::ManeuverType_Notification}};
|
||||||
|
return mappings[turn];
|
||||||
|
}
|
||||||
|
|
||||||
|
fbresult::Turn TurnModifierToFB(osrm::guidance::DirectionModifier::Enum modifier) const
|
||||||
|
{
|
||||||
|
static std::map<osrm::guidance::DirectionModifier::Enum, fbresult::Turn> mappings = {
|
||||||
|
{osrm::guidance::DirectionModifier::UTurn, fbresult::Turn_UTurn},
|
||||||
|
{osrm::guidance::DirectionModifier::SharpRight, fbresult::Turn_SharpRight},
|
||||||
|
{osrm::guidance::DirectionModifier::Right, fbresult::Turn_Right},
|
||||||
|
{osrm::guidance::DirectionModifier::SlightRight, fbresult::Turn_SlightRight},
|
||||||
|
{osrm::guidance::DirectionModifier::Straight, fbresult::Turn_Straight},
|
||||||
|
{osrm::guidance::DirectionModifier::SlightLeft, fbresult::Turn_SlightLeft},
|
||||||
|
{osrm::guidance::DirectionModifier::Left, fbresult::Turn_Left},
|
||||||
|
{osrm::guidance::DirectionModifier::SharpLeft, fbresult::Turn_SharpLeft},
|
||||||
|
};
|
||||||
|
return mappings[modifier];
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<int8_t> TurnLaneTypeToFB(const extractor::TurnLaneType::Mask lane_type) const
|
||||||
|
{
|
||||||
|
const static fbresult::Turn mapping[] = {fbresult::Turn_None,
|
||||||
|
fbresult::Turn_Straight,
|
||||||
|
fbresult::Turn_SharpLeft,
|
||||||
|
fbresult::Turn_Left,
|
||||||
|
fbresult::Turn_SlightLeft,
|
||||||
|
fbresult::Turn_SlightRight,
|
||||||
|
fbresult::Turn_Right,
|
||||||
|
fbresult::Turn_SharpRight,
|
||||||
|
fbresult::Turn_UTurn,
|
||||||
|
fbresult::Turn_SlightLeft,
|
||||||
|
fbresult::Turn_SlightRight};
|
||||||
|
std::vector<int8_t> result;
|
||||||
|
std::bitset<8 * sizeof(extractor::TurnLaneType::Mask)> mask(lane_type);
|
||||||
|
for (auto index : util::irange<std::size_t>(0, extractor::TurnLaneType::NUM_TYPES))
|
||||||
|
{
|
||||||
|
if (mask[index])
|
||||||
|
{
|
||||||
|
result.push_back(mapping[index]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
flatbuffers::Offset<fbresult::RouteObject>
|
||||||
|
MakeRoute(flatbuffers::FlatBufferBuilder &fb_result,
|
||||||
|
const std::vector<PhantomNodes> &segment_end_coordinates,
|
||||||
|
const std::vector<std::vector<PathData>> &unpacked_path_segments,
|
||||||
|
const std::vector<bool> &source_traversed_in_reverse,
|
||||||
|
const std::vector<bool> &target_traversed_in_reverse) const
|
||||||
|
{
|
||||||
|
auto legs_info = MakeLegs(segment_end_coordinates,
|
||||||
|
unpacked_path_segments,
|
||||||
|
source_traversed_in_reverse,
|
||||||
|
target_traversed_in_reverse);
|
||||||
|
std::vector<guidance::RouteLeg> legs = legs_info.first;
|
||||||
|
std::vector<guidance::LegGeometry> leg_geometries = legs_info.second;
|
||||||
|
auto route = guidance::assembleRoute(legs);
|
||||||
|
|
||||||
|
// Fill legs
|
||||||
|
std::vector<flatbuffers::Offset<fbresult::Leg>> routeLegs;
|
||||||
|
routeLegs.reserve(legs.size());
|
||||||
|
for (const auto idx : util::irange<std::size_t>(0UL, legs.size()))
|
||||||
|
{
|
||||||
|
auto leg = legs[idx];
|
||||||
|
auto &leg_geometry = leg_geometries[idx];
|
||||||
|
|
||||||
|
// Fill steps
|
||||||
|
std::vector<flatbuffers::Offset<fbresult::Step>> legSteps;
|
||||||
|
if (!leg.steps.empty())
|
||||||
|
{
|
||||||
|
legSteps.resize(leg.steps.size());
|
||||||
|
std::transform(leg.steps.begin(),
|
||||||
|
leg.steps.end(),
|
||||||
|
legSteps.begin(),
|
||||||
|
[this, &fb_result, &leg_geometry](auto &step) {
|
||||||
|
return this->MakeFBStep(fb_result, leg_geometry, step);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
auto steps_vector = fb_result.CreateVector(legSteps);
|
||||||
|
|
||||||
|
// Fill annotations
|
||||||
|
// To maintain support for uses of the old default constructors, we check
|
||||||
|
// if annotations property was set manually after default construction
|
||||||
|
auto requested_annotations = parameters.annotations_type;
|
||||||
|
if ((parameters.annotations == true) &&
|
||||||
|
(parameters.annotations_type == RouteParameters::AnnotationsType::None))
|
||||||
|
{
|
||||||
|
requested_annotations = RouteParameters::AnnotationsType::All;
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::optional<flatbuffers::Offset<fbresult::Annotation>> annotation_buffer =
|
||||||
|
boost::none;
|
||||||
|
if (requested_annotations != RouteParameters::AnnotationsType::None)
|
||||||
|
{
|
||||||
|
annotation_buffer =
|
||||||
|
MakeFBAnnotations(fb_result, leg_geometry, requested_annotations);
|
||||||
|
}
|
||||||
|
|
||||||
|
flatbuffers::Offset<flatbuffers::String> summary_string;
|
||||||
|
if (!leg.summary.empty())
|
||||||
|
{
|
||||||
|
summary_string = fb_result.CreateString(leg.summary);
|
||||||
|
}
|
||||||
|
|
||||||
|
fbresult::LegBuilder legBuilder(fb_result);
|
||||||
|
legBuilder.add_distance(leg.distance);
|
||||||
|
legBuilder.add_duration(leg.duration);
|
||||||
|
legBuilder.add_weight(leg.weight);
|
||||||
|
if (!leg.summary.empty())
|
||||||
|
{
|
||||||
|
legBuilder.add_summary(summary_string);
|
||||||
|
}
|
||||||
|
legBuilder.add_steps(steps_vector);
|
||||||
|
|
||||||
|
if (annotation_buffer)
|
||||||
|
{
|
||||||
|
legBuilder.add_annotations(*annotation_buffer);
|
||||||
|
}
|
||||||
|
routeLegs.emplace_back(legBuilder.Finish());
|
||||||
|
}
|
||||||
|
auto legs_vector = fb_result.CreateVector(routeLegs);
|
||||||
|
|
||||||
|
// Fill geometry
|
||||||
|
auto overview = MakeOverview(leg_geometries);
|
||||||
|
mapbox::util::variant<flatbuffers::Offset<flatbuffers::String>,
|
||||||
|
flatbuffers::Offset<flatbuffers::Vector<const fbresult::Position *>>>
|
||||||
|
geometry;
|
||||||
|
if (overview)
|
||||||
|
{
|
||||||
|
geometry = MakeGeometry(fb_result, overview->begin(), overview->end());
|
||||||
|
}
|
||||||
|
|
||||||
|
auto weight_name_string = fb_result.CreateString(facade.GetWeightName());
|
||||||
|
|
||||||
|
fbresult::RouteObjectBuilder routeObject(fb_result);
|
||||||
|
routeObject.add_distance(route.distance);
|
||||||
|
routeObject.add_duration(route.duration);
|
||||||
|
routeObject.add_weight(route.weight);
|
||||||
|
routeObject.add_weight_name(weight_name_string);
|
||||||
|
routeObject.add_legs(legs_vector);
|
||||||
|
if (overview)
|
||||||
|
{
|
||||||
|
mapbox::util::apply_visitor(GeometryVisitor<fbresult::RouteObjectBuilder>(routeObject),
|
||||||
|
geometry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return routeObject.Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
flatbuffers::Offset<fbresult::Annotation>
|
||||||
|
MakeFBAnnotations(flatbuffers::FlatBufferBuilder &fb_result,
|
||||||
|
guidance::LegGeometry &leg_geometry,
|
||||||
|
const RouteParameters::AnnotationsType &requested_annotations) const
|
||||||
|
{
|
||||||
|
// AnnotationsType uses bit flags, & operator checks if a property is set
|
||||||
|
flatbuffers::Offset<flatbuffers::Vector<float>> speed;
|
||||||
|
if (parameters.annotations_type & RouteParameters::AnnotationsType::Speed)
|
||||||
|
{
|
||||||
|
double prev_speed = 0;
|
||||||
|
speed =
|
||||||
|
GetAnnotations<float>(fb_result,
|
||||||
|
leg_geometry,
|
||||||
|
[&prev_speed](const guidance::LegGeometry::Annotation &anno) {
|
||||||
|
if (anno.duration < std::numeric_limits<float>::min())
|
||||||
|
{
|
||||||
|
return prev_speed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto speed =
|
||||||
|
round(anno.distance / anno.duration * 10.) / 10.;
|
||||||
|
prev_speed = speed;
|
||||||
|
return util::json::clamp_float(speed);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
flatbuffers::Offset<flatbuffers::Vector<uint32_t>> duration;
|
||||||
|
if (requested_annotations & RouteParameters::AnnotationsType::Duration)
|
||||||
|
{
|
||||||
|
duration = GetAnnotations<uint32_t>(
|
||||||
|
fb_result, leg_geometry, [](const guidance::LegGeometry::Annotation &anno) {
|
||||||
|
return anno.duration;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
flatbuffers::Offset<flatbuffers::Vector<uint32_t>> distance;
|
||||||
|
if (requested_annotations & RouteParameters::AnnotationsType::Distance)
|
||||||
|
{
|
||||||
|
distance = GetAnnotations<uint32_t>(
|
||||||
|
fb_result, leg_geometry, [](const guidance::LegGeometry::Annotation &anno) {
|
||||||
|
return anno.distance;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
flatbuffers::Offset<flatbuffers::Vector<uint32_t>> weight;
|
||||||
|
if (requested_annotations & RouteParameters::AnnotationsType::Weight)
|
||||||
|
{
|
||||||
|
weight = GetAnnotations<uint32_t>(
|
||||||
|
fb_result, leg_geometry, [](const guidance::LegGeometry::Annotation &anno) {
|
||||||
|
return anno.weight;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
flatbuffers::Offset<flatbuffers::Vector<uint32_t>> datasources;
|
||||||
|
if (requested_annotations & RouteParameters::AnnotationsType::Datasources)
|
||||||
|
{
|
||||||
|
datasources = GetAnnotations<uint32_t>(
|
||||||
|
fb_result, leg_geometry, [](const guidance::LegGeometry::Annotation &anno) {
|
||||||
|
return anno.datasource;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
std::vector<uint32_t> nodes;
|
||||||
|
if (requested_annotations & RouteParameters::AnnotationsType::Nodes)
|
||||||
|
{
|
||||||
|
nodes.reserve(leg_geometry.osm_node_ids.size());
|
||||||
|
for (const auto node_id : leg_geometry.osm_node_ids)
|
||||||
|
{
|
||||||
|
nodes.emplace_back(static_cast<uint64_t>(node_id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto nodes_vector = fb_result.CreateVector(nodes);
|
||||||
|
// Add any supporting metadata, if needed
|
||||||
|
boost::optional<flatbuffers::Offset<fbresult::Metadata>> metadata_buffer = boost::none;
|
||||||
|
if (requested_annotations & RouteParameters::AnnotationsType::Datasources)
|
||||||
|
{
|
||||||
|
const auto MAX_DATASOURCE_ID = 255u;
|
||||||
|
std::vector<flatbuffers::Offset<flatbuffers::String>> names;
|
||||||
|
for (auto i = 0u; i < MAX_DATASOURCE_ID; i++)
|
||||||
|
{
|
||||||
|
const auto name = facade.GetDatasourceName(i);
|
||||||
|
// Length of 0 indicates the first empty name, so we can stop here
|
||||||
|
if (name.size() == 0)
|
||||||
|
break;
|
||||||
|
names.emplace_back(
|
||||||
|
fb_result.CreateString(std::string(facade.GetDatasourceName(i))));
|
||||||
|
}
|
||||||
|
metadata_buffer = fbresult::CreateMetadataDirect(fb_result, &names);
|
||||||
|
}
|
||||||
|
fbresult::AnnotationBuilder annotation(fb_result);
|
||||||
|
annotation.add_speed(speed);
|
||||||
|
annotation.add_duration(duration);
|
||||||
|
annotation.add_distance(distance);
|
||||||
|
annotation.add_weight(weight);
|
||||||
|
annotation.add_datasources(datasources);
|
||||||
|
annotation.add_nodes(nodes_vector);
|
||||||
|
if (metadata_buffer)
|
||||||
|
{
|
||||||
|
annotation.add_metadata(*metadata_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return annotation.Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Builder> class GeometryVisitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GeometryVisitor(Builder &builder) : builder(builder) {}
|
||||||
|
|
||||||
|
void operator()(const flatbuffers::Offset<flatbuffers::String> &value)
|
||||||
|
{
|
||||||
|
builder.add_polyline(value);
|
||||||
|
}
|
||||||
|
void operator()(
|
||||||
|
const flatbuffers::Offset<flatbuffers::Vector<const fbresult::Position *>> &value)
|
||||||
|
{
|
||||||
|
builder.add_coordinates(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Builder &builder;
|
||||||
|
};
|
||||||
|
|
||||||
|
flatbuffers::Offset<fbresult::Step> MakeFBStep(flatbuffers::FlatBufferBuilder &builder,
|
||||||
|
const guidance::LegGeometry &leg_geometry,
|
||||||
|
const guidance::RouteStep &step) const
|
||||||
|
{
|
||||||
|
auto name_string = builder.CreateString(step.name);
|
||||||
|
|
||||||
|
flatbuffers::Offset<flatbuffers::String> ref_string;
|
||||||
|
if (!step.ref.empty())
|
||||||
|
{
|
||||||
|
ref_string = builder.CreateString(step.ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
flatbuffers::Offset<flatbuffers::String> pronunciation_string;
|
||||||
|
if (!step.pronunciation.empty())
|
||||||
|
{
|
||||||
|
pronunciation_string = builder.CreateString(step.pronunciation);
|
||||||
|
}
|
||||||
|
|
||||||
|
flatbuffers::Offset<flatbuffers::String> destinations_string;
|
||||||
|
if (!step.destinations.empty())
|
||||||
|
{
|
||||||
|
destinations_string = builder.CreateString(step.destinations);
|
||||||
|
}
|
||||||
|
|
||||||
|
flatbuffers::Offset<flatbuffers::String> exists_string;
|
||||||
|
if (!step.exits.empty())
|
||||||
|
{
|
||||||
|
exists_string = builder.CreateString(step.exits);
|
||||||
|
}
|
||||||
|
|
||||||
|
flatbuffers::Offset<flatbuffers::String> rotary_name_string;
|
||||||
|
flatbuffers::Offset<flatbuffers::String> rotary_pronunciation_string;
|
||||||
|
if (!step.rotary_name.empty())
|
||||||
|
{
|
||||||
|
rotary_name_string = builder.CreateString(step.rotary_name);
|
||||||
|
if (!step.rotary_pronunciation.empty())
|
||||||
|
{
|
||||||
|
rotary_pronunciation_string = builder.CreateString(step.rotary_pronunciation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto mode_string = builder.CreateString(extractor::travelModeToString(step.mode));
|
||||||
|
|
||||||
|
// Geometry
|
||||||
|
auto geometry = MakeGeometry(builder,
|
||||||
|
leg_geometry.locations.begin() + step.geometry_begin,
|
||||||
|
leg_geometry.locations.begin() + step.geometry_end);
|
||||||
|
// Maneuver
|
||||||
|
fbresult::StepManeuverBuilder maneuver(builder);
|
||||||
|
fbresult::Position maneuverPosition{
|
||||||
|
static_cast<float>(util::toFloating(step.maneuver.location.lon).__value),
|
||||||
|
static_cast<float>(util::toFloating(step.maneuver.location.lat).__value)};
|
||||||
|
maneuver.add_location(&maneuverPosition);
|
||||||
|
maneuver.add_bearing_before(step.maneuver.bearing_before);
|
||||||
|
maneuver.add_bearing_after(step.maneuver.bearing_after);
|
||||||
|
if (step.maneuver.waypoint_type == guidance::WaypointType::None)
|
||||||
|
maneuver.add_type(TurnTypeToFB(step.maneuver.instruction.type));
|
||||||
|
else
|
||||||
|
maneuver.add_type(WaypointTypeToFB(step.maneuver.waypoint_type));
|
||||||
|
if (osrm::engine::api::json::detail::isValidModifier(step.maneuver))
|
||||||
|
{
|
||||||
|
maneuver.add_modifier(TurnModifierToFB(step.maneuver.instruction.direction_modifier));
|
||||||
|
}
|
||||||
|
if (step.maneuver.exit != 0)
|
||||||
|
{
|
||||||
|
maneuver.add_exit(step.maneuver.exit);
|
||||||
|
}
|
||||||
|
auto maneuver_buffer = maneuver.Finish();
|
||||||
|
|
||||||
|
// intersections
|
||||||
|
auto intersections_vector = MakeFBIntersections(builder, step);
|
||||||
|
|
||||||
|
fbresult::StepBuilder stepBuilder(builder);
|
||||||
|
stepBuilder.add_duration(step.duration);
|
||||||
|
stepBuilder.add_distance(step.distance);
|
||||||
|
stepBuilder.add_weight(step.weight);
|
||||||
|
stepBuilder.add_name(name_string);
|
||||||
|
stepBuilder.add_mode(mode_string);
|
||||||
|
stepBuilder.add_driving_side(step.is_left_hand_driving);
|
||||||
|
stepBuilder.add_ref(ref_string);
|
||||||
|
stepBuilder.add_pronunciation(pronunciation_string);
|
||||||
|
stepBuilder.add_destinations(destinations_string);
|
||||||
|
stepBuilder.add_exits(exists_string);
|
||||||
|
stepBuilder.add_rotary_name(rotary_name_string);
|
||||||
|
stepBuilder.add_rotary_pronunciation(rotary_pronunciation_string);
|
||||||
|
stepBuilder.add_intersections(intersections_vector);
|
||||||
|
stepBuilder.add_maneuver(maneuver_buffer);
|
||||||
|
mapbox::util::apply_visitor(GeometryVisitor<fbresult::StepBuilder>(stepBuilder), geometry);
|
||||||
|
return stepBuilder.Finish();
|
||||||
|
};
|
||||||
|
|
||||||
|
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Intersection>>>
|
||||||
|
MakeFBIntersections(flatbuffers::FlatBufferBuilder &fb_result,
|
||||||
|
const guidance::RouteStep &step) const
|
||||||
|
{
|
||||||
|
std::vector<flatbuffers::Offset<fbresult::Intersection>> intersections;
|
||||||
|
intersections.resize(step.intersections.size());
|
||||||
|
std::transform(
|
||||||
|
step.intersections.begin(),
|
||||||
|
step.intersections.end(),
|
||||||
|
intersections.begin(),
|
||||||
|
[&fb_result, this](const guidance::IntermediateIntersection &intersection) {
|
||||||
|
|
||||||
|
std::vector<flatbuffers::Offset<fbresult::Lane>> lanes;
|
||||||
|
if (json::detail::hasValidLanes(intersection))
|
||||||
|
{
|
||||||
|
BOOST_ASSERT(intersection.lanes.lanes_in_turn >= 1);
|
||||||
|
lanes.reserve(intersection.lane_description.size());
|
||||||
|
LaneID lane_id = intersection.lane_description.size();
|
||||||
|
|
||||||
|
for (const auto &lane_desc : intersection.lane_description)
|
||||||
|
{
|
||||||
|
--lane_id;
|
||||||
|
auto indications = TurnLaneTypeToFB(lane_desc);
|
||||||
|
|
||||||
|
auto lane_valid = lane_id >= intersection.lanes.first_lane_from_the_right &&
|
||||||
|
lane_id < intersection.lanes.first_lane_from_the_right +
|
||||||
|
intersection.lanes.lanes_in_turn;
|
||||||
|
lanes.push_back(
|
||||||
|
fbresult::CreateLaneDirect(fb_result, &indications, lane_valid));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto lanes_vector = fb_result.CreateVector(lanes);
|
||||||
|
|
||||||
|
fbresult::Position maneuverPosition{
|
||||||
|
static_cast<float>(util::toFloating(intersection.location.lon).__value),
|
||||||
|
static_cast<float>(util::toFloating(intersection.location.lat).__value)};
|
||||||
|
auto bearings_vector = fb_result.CreateVector(intersection.bearings);
|
||||||
|
std::vector<flatbuffers::Offset<flatbuffers::String>> classes;
|
||||||
|
classes.resize(intersection.classes.size());
|
||||||
|
std::transform(
|
||||||
|
intersection.classes.begin(),
|
||||||
|
intersection.classes.end(),
|
||||||
|
classes.begin(),
|
||||||
|
[&fb_result](const std::string cls) { return fb_result.CreateString(cls); });
|
||||||
|
auto classes_vector = fb_result.CreateVector(classes);
|
||||||
|
auto entry_vector = fb_result.CreateVector(intersection.entry);
|
||||||
|
|
||||||
|
fbresult::IntersectionBuilder intersectionBuilder(fb_result);
|
||||||
|
intersectionBuilder.add_location(&maneuverPosition);
|
||||||
|
intersectionBuilder.add_bearings(bearings_vector);
|
||||||
|
intersectionBuilder.add_classes(classes_vector);
|
||||||
|
intersectionBuilder.add_entry(entry_vector);
|
||||||
|
intersectionBuilder.add_in_bearing(intersection.in);
|
||||||
|
intersectionBuilder.add_out_bearing(intersection.out);
|
||||||
|
intersectionBuilder.add_lanes(lanes_vector);
|
||||||
|
return intersectionBuilder.Finish();
|
||||||
|
});
|
||||||
|
return fb_result.CreateVector(intersections);
|
||||||
|
}
|
||||||
|
|
||||||
util::json::Object MakeRoute(const std::vector<PhantomNodes> &segment_end_coordinates,
|
util::json::Object MakeRoute(const std::vector<PhantomNodes> &segment_end_coordinates,
|
||||||
const std::vector<std::vector<PathData>> &unpacked_path_segments,
|
const std::vector<std::vector<PathData>> &unpacked_path_segments,
|
||||||
const std::vector<bool> &source_traversed_in_reverse,
|
const std::vector<bool> &source_traversed_in_reverse,
|
||||||
const std::vector<bool> &target_traversed_in_reverse) const
|
const std::vector<bool> &target_traversed_in_reverse) const
|
||||||
{
|
{
|
||||||
std::vector<guidance::RouteLeg> legs;
|
auto legs_info = MakeLegs(segment_end_coordinates,
|
||||||
std::vector<guidance::LegGeometry> leg_geometries;
|
unpacked_path_segments,
|
||||||
auto number_of_legs = segment_end_coordinates.size();
|
source_traversed_in_reverse,
|
||||||
legs.reserve(number_of_legs);
|
target_traversed_in_reverse);
|
||||||
leg_geometries.reserve(number_of_legs);
|
std::vector<guidance::RouteLeg> legs = legs_info.first;
|
||||||
|
std::vector<guidance::LegGeometry> leg_geometries = legs_info.second;
|
||||||
for (auto idx : util::irange<std::size_t>(0UL, number_of_legs))
|
|
||||||
{
|
|
||||||
const auto &phantoms = segment_end_coordinates[idx];
|
|
||||||
const auto &path_data = unpacked_path_segments[idx];
|
|
||||||
|
|
||||||
const bool reversed_source = source_traversed_in_reverse[idx];
|
|
||||||
const bool reversed_target = target_traversed_in_reverse[idx];
|
|
||||||
|
|
||||||
auto leg_geometry = guidance::assembleGeometry(BaseAPI::facade,
|
|
||||||
path_data,
|
|
||||||
phantoms.source_phantom,
|
|
||||||
phantoms.target_phantom,
|
|
||||||
reversed_source,
|
|
||||||
reversed_target);
|
|
||||||
auto leg = guidance::assembleLeg(facade,
|
|
||||||
path_data,
|
|
||||||
leg_geometry,
|
|
||||||
phantoms.source_phantom,
|
|
||||||
phantoms.target_phantom,
|
|
||||||
reversed_target,
|
|
||||||
parameters.steps);
|
|
||||||
|
|
||||||
util::Log(logDEBUG) << "Assembling steps " << std::endl;
|
|
||||||
if (parameters.steps)
|
|
||||||
{
|
|
||||||
auto steps = guidance::assembleSteps(BaseAPI::facade,
|
|
||||||
path_data,
|
|
||||||
leg_geometry,
|
|
||||||
phantoms.source_phantom,
|
|
||||||
phantoms.target_phantom,
|
|
||||||
reversed_source,
|
|
||||||
reversed_target);
|
|
||||||
|
|
||||||
// Apply maneuver overrides before any other post
|
|
||||||
// processing is performed
|
|
||||||
guidance::applyOverrides(BaseAPI::facade, steps, leg_geometry);
|
|
||||||
|
|
||||||
// Collapse segregated steps before others
|
|
||||||
steps = guidance::collapseSegregatedTurnInstructions(std::move(steps));
|
|
||||||
|
|
||||||
/* Perform step-based post-processing.
|
|
||||||
*
|
|
||||||
* Using post-processing on basis of route-steps for a single leg at a time
|
|
||||||
* comes at the cost that we cannot count the correct exit for roundabouts.
|
|
||||||
* We can only emit the exit nr/intersections up to/starting at a part of the leg.
|
|
||||||
* If a roundabout is not terminated in a leg, we will end up with a
|
|
||||||
*enter-roundabout
|
|
||||||
* and exit-roundabout-nr where the exit nr is out of sync with the previous enter.
|
|
||||||
*
|
|
||||||
* | S |
|
|
||||||
* * *
|
|
||||||
* ----* * ----
|
|
||||||
* T
|
|
||||||
* ----* * ----
|
|
||||||
* V * *
|
|
||||||
* | |
|
|
||||||
* | |
|
|
||||||
*
|
|
||||||
* Coming from S via V to T, we end up with the legs S->V and V->T. V-T will say to
|
|
||||||
*take
|
|
||||||
* the second exit, even though counting from S it would be the third.
|
|
||||||
* For S, we only emit `roundabout` without an exit number, showing that we enter a
|
|
||||||
*roundabout
|
|
||||||
* to find a via point.
|
|
||||||
* The same exit will be emitted, though, if we should start routing at S, making
|
|
||||||
* the overall response consistent.
|
|
||||||
*
|
|
||||||
* ⚠ CAUTION: order of post-processing steps is important
|
|
||||||
* - handleRoundabouts must be called before collapseTurnInstructions that
|
|
||||||
* expects post-processed roundabouts
|
|
||||||
*/
|
|
||||||
|
|
||||||
guidance::trimShortSegments(steps, leg_geometry);
|
|
||||||
leg.steps = guidance::handleRoundabouts(std::move(steps));
|
|
||||||
leg.steps = guidance::collapseTurnInstructions(std::move(leg.steps));
|
|
||||||
leg.steps = guidance::anticipateLaneChange(std::move(leg.steps));
|
|
||||||
leg.steps = guidance::buildIntersections(std::move(leg.steps));
|
|
||||||
leg.steps = guidance::suppressShortNameSegments(std::move(leg.steps));
|
|
||||||
leg.steps = guidance::assignRelativeLocations(std::move(leg.steps),
|
|
||||||
leg_geometry,
|
|
||||||
phantoms.source_phantom,
|
|
||||||
phantoms.target_phantom);
|
|
||||||
leg_geometry = guidance::resyncGeometry(std::move(leg_geometry), leg.steps);
|
|
||||||
}
|
|
||||||
|
|
||||||
leg_geometries.push_back(std::move(leg_geometry));
|
|
||||||
legs.push_back(std::move(leg));
|
|
||||||
}
|
|
||||||
|
|
||||||
auto route = guidance::assembleRoute(legs);
|
auto route = guidance::assembleRoute(legs);
|
||||||
boost::optional<util::json::Value> json_overview;
|
boost::optional<util::json::Value> json_overview =
|
||||||
if (parameters.overview != RouteParameters::OverviewType::False)
|
MakeGeometry(MakeOverview(leg_geometries));
|
||||||
{
|
|
||||||
const auto use_simplification =
|
|
||||||
parameters.overview == RouteParameters::OverviewType::Simplified;
|
|
||||||
BOOST_ASSERT(use_simplification ||
|
|
||||||
parameters.overview == RouteParameters::OverviewType::Full);
|
|
||||||
|
|
||||||
auto overview = guidance::assembleOverview(leg_geometries, use_simplification);
|
|
||||||
json_overview = MakeGeometry(overview.begin(), overview.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<util::json::Value> step_geometries;
|
std::vector<util::json::Value> step_geometries;
|
||||||
const auto total_step_count =
|
const auto total_step_count =
|
||||||
@ -364,6 +856,127 @@ class RouteAPI : public BaseAPI
|
|||||||
}
|
}
|
||||||
|
|
||||||
const RouteParameters ¶meters;
|
const RouteParameters ¶meters;
|
||||||
|
|
||||||
|
std::pair<std::vector<guidance::RouteLeg>, std::vector<guidance::LegGeometry>>
|
||||||
|
MakeLegs(const std::vector<PhantomNodes> &segment_end_coordinates,
|
||||||
|
const std::vector<std::vector<PathData>> &unpacked_path_segments,
|
||||||
|
const std::vector<bool> &source_traversed_in_reverse,
|
||||||
|
const std::vector<bool> &target_traversed_in_reverse) const
|
||||||
|
{
|
||||||
|
auto result =
|
||||||
|
std::make_pair(std::vector<guidance::RouteLeg>(), std::vector<guidance::LegGeometry>());
|
||||||
|
auto &legs = result.first;
|
||||||
|
auto &leg_geometries = result.second;
|
||||||
|
auto number_of_legs = segment_end_coordinates.size();
|
||||||
|
legs.reserve(number_of_legs);
|
||||||
|
leg_geometries.reserve(number_of_legs);
|
||||||
|
|
||||||
|
for (auto idx : util::irange<std::size_t>(0UL, number_of_legs))
|
||||||
|
{
|
||||||
|
const auto &phantoms = segment_end_coordinates[idx];
|
||||||
|
const auto &path_data = unpacked_path_segments[idx];
|
||||||
|
|
||||||
|
const bool reversed_source = source_traversed_in_reverse[idx];
|
||||||
|
const bool reversed_target = target_traversed_in_reverse[idx];
|
||||||
|
|
||||||
|
auto leg_geometry = guidance::assembleGeometry(BaseAPI::facade,
|
||||||
|
path_data,
|
||||||
|
phantoms.source_phantom,
|
||||||
|
phantoms.target_phantom,
|
||||||
|
reversed_source,
|
||||||
|
reversed_target);
|
||||||
|
auto leg = guidance::assembleLeg(facade,
|
||||||
|
path_data,
|
||||||
|
leg_geometry,
|
||||||
|
phantoms.source_phantom,
|
||||||
|
phantoms.target_phantom,
|
||||||
|
reversed_target,
|
||||||
|
parameters.steps);
|
||||||
|
|
||||||
|
util::Log(logDEBUG) << "Assembling steps " << std::endl;
|
||||||
|
if (parameters.steps)
|
||||||
|
{
|
||||||
|
auto steps = guidance::assembleSteps(BaseAPI::facade,
|
||||||
|
path_data,
|
||||||
|
leg_geometry,
|
||||||
|
phantoms.source_phantom,
|
||||||
|
phantoms.target_phantom,
|
||||||
|
reversed_source,
|
||||||
|
reversed_target);
|
||||||
|
|
||||||
|
// Apply maneuver overrides before any other post
|
||||||
|
// processing is performed
|
||||||
|
guidance::applyOverrides(BaseAPI::facade, steps, leg_geometry);
|
||||||
|
|
||||||
|
// Collapse segregated steps before others
|
||||||
|
steps = guidance::collapseSegregatedTurnInstructions(std::move(steps));
|
||||||
|
|
||||||
|
/* Perform step-based post-processing.
|
||||||
|
*
|
||||||
|
* Using post-processing on basis of route-steps for a single leg at a time
|
||||||
|
* comes at the cost that we cannot count the correct exit for roundabouts.
|
||||||
|
* We can only emit the exit nr/intersections up to/starting at a part of the leg.
|
||||||
|
* If a roundabout is not terminated in a leg, we will end up with a
|
||||||
|
*enter-roundabout
|
||||||
|
* and exit-roundabout-nr where the exit nr is out of sync with the previous enter.
|
||||||
|
*
|
||||||
|
* | S |
|
||||||
|
* * *
|
||||||
|
* ----* * ----
|
||||||
|
* T
|
||||||
|
* ----* * ----
|
||||||
|
* V * *
|
||||||
|
* | |
|
||||||
|
* | |
|
||||||
|
*
|
||||||
|
* Coming from S via V to T, we end up with the legs S->V and V->T. V-T will say to
|
||||||
|
*take
|
||||||
|
* the second exit, even though counting from S it would be the third.
|
||||||
|
* For S, we only emit `roundabout` without an exit number, showing that we enter a
|
||||||
|
*roundabout
|
||||||
|
* to find a via point.
|
||||||
|
* The same exit will be emitted, though, if we should start routing at S, making
|
||||||
|
* the overall response consistent.
|
||||||
|
*
|
||||||
|
* ⚠ CAUTION: order of post-processing steps is important
|
||||||
|
* - handleRoundabouts must be called before collapseTurnInstructions that
|
||||||
|
* expects post-processed roundabouts
|
||||||
|
*/
|
||||||
|
|
||||||
|
guidance::trimShortSegments(steps, leg_geometry);
|
||||||
|
leg.steps = guidance::handleRoundabouts(std::move(steps));
|
||||||
|
leg.steps = guidance::collapseTurnInstructions(std::move(leg.steps));
|
||||||
|
leg.steps = guidance::anticipateLaneChange(std::move(leg.steps));
|
||||||
|
leg.steps = guidance::buildIntersections(std::move(leg.steps));
|
||||||
|
leg.steps = guidance::suppressShortNameSegments(std::move(leg.steps));
|
||||||
|
leg.steps = guidance::assignRelativeLocations(std::move(leg.steps),
|
||||||
|
leg_geometry,
|
||||||
|
phantoms.source_phantom,
|
||||||
|
phantoms.target_phantom);
|
||||||
|
leg_geometry = guidance::resyncGeometry(std::move(leg_geometry), leg.steps);
|
||||||
|
}
|
||||||
|
|
||||||
|
leg_geometries.push_back(std::move(leg_geometry));
|
||||||
|
legs.push_back(std::move(leg));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::optional<std::vector<Coordinate>>
|
||||||
|
MakeOverview(const std::vector<guidance::LegGeometry> &leg_geometries) const
|
||||||
|
{
|
||||||
|
boost::optional<std::vector<Coordinate>> overview;
|
||||||
|
if (parameters.overview != RouteParameters::OverviewType::False)
|
||||||
|
{
|
||||||
|
const auto use_simplification =
|
||||||
|
parameters.overview == RouteParameters::OverviewType::Simplified;
|
||||||
|
BOOST_ASSERT(use_simplification ||
|
||||||
|
parameters.overview == RouteParameters::OverviewType::Full);
|
||||||
|
|
||||||
|
overview = guidance::assembleOverview(leg_geometries, use_simplification);
|
||||||
|
}
|
||||||
|
return overview;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // ns api
|
} // ns api
|
||||||
|
@ -45,6 +45,111 @@ class TableAPI final : public BaseAPI
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void
|
||||||
|
MakeResponse(const std::pair<std::vector<EdgeDuration>, std::vector<EdgeDistance>> &tables,
|
||||||
|
const std::vector<PhantomNode> &phantoms,
|
||||||
|
const std::vector<TableCellRef> &fallback_speed_cells,
|
||||||
|
osrm::engine::api::ResultT &response) const
|
||||||
|
{
|
||||||
|
if (response.is<flatbuffers::FlatBufferBuilder>())
|
||||||
|
{
|
||||||
|
auto &fb_result = response.get<flatbuffers::FlatBufferBuilder>();
|
||||||
|
MakeResponse(tables, phantoms, fallback_speed_cells, fb_result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto &json_result = response.get<util::json::Object>();
|
||||||
|
MakeResponse(tables, phantoms, fallback_speed_cells, json_result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void
|
||||||
|
MakeResponse(const std::pair<std::vector<EdgeDuration>, std::vector<EdgeDistance>> &tables,
|
||||||
|
const std::vector<PhantomNode> &phantoms,
|
||||||
|
const std::vector<TableCellRef> &fallback_speed_cells,
|
||||||
|
flatbuffers::FlatBufferBuilder &fb_result) const
|
||||||
|
{
|
||||||
|
auto number_of_sources = parameters.sources.size();
|
||||||
|
auto number_of_destinations = parameters.destinations.size();
|
||||||
|
|
||||||
|
auto data_timestamp = facade.GetTimestamp();
|
||||||
|
boost::optional<flatbuffers::Offset<flatbuffers::String>> data_version_string = boost::none;
|
||||||
|
if (!data_timestamp.empty())
|
||||||
|
{
|
||||||
|
data_version_string = fb_result.CreateString(data_timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// symmetric case
|
||||||
|
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>> sources;
|
||||||
|
if (parameters.sources.empty())
|
||||||
|
{
|
||||||
|
sources = MakeWaypoints(fb_result, phantoms);
|
||||||
|
number_of_sources = phantoms.size();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sources = MakeWaypoints(fb_result, phantoms, parameters.sources);
|
||||||
|
}
|
||||||
|
|
||||||
|
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>>
|
||||||
|
destinations;
|
||||||
|
if (parameters.destinations.empty())
|
||||||
|
{
|
||||||
|
destinations = MakeWaypoints(fb_result, phantoms);
|
||||||
|
number_of_destinations = phantoms.size();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
destinations = MakeWaypoints(fb_result, phantoms, parameters.destinations);
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::optional<flatbuffers::Offset<flatbuffers::Vector<float>>> durations = boost::none;
|
||||||
|
if (parameters.annotations & TableParameters::AnnotationsType::Duration)
|
||||||
|
{
|
||||||
|
durations = MakeDurationTable(fb_result, tables.first);
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::optional<flatbuffers::Offset<flatbuffers::Vector<float>>> distances = boost::none;
|
||||||
|
if (parameters.annotations & TableParameters::AnnotationsType::Distance)
|
||||||
|
{
|
||||||
|
distances = MakeDistanceTable(fb_result, tables.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::optional<flatbuffers::Offset<flatbuffers::Vector<uint32_t>>> speed_cells =
|
||||||
|
boost::none;
|
||||||
|
if (parameters.fallback_speed != INVALID_FALLBACK_SPEED && parameters.fallback_speed > 0)
|
||||||
|
{
|
||||||
|
speed_cells = MakeEstimatesTable(fb_result, fallback_speed_cells);
|
||||||
|
}
|
||||||
|
|
||||||
|
fbresult::TableBuilder table(fb_result);
|
||||||
|
table.add_destinations(destinations);
|
||||||
|
table.add_rows(number_of_sources);
|
||||||
|
table.add_cols(number_of_destinations);
|
||||||
|
if (durations)
|
||||||
|
{
|
||||||
|
table.add_durations(*durations);
|
||||||
|
}
|
||||||
|
if (distances)
|
||||||
|
{
|
||||||
|
table.add_distances(*distances);
|
||||||
|
}
|
||||||
|
if (speed_cells)
|
||||||
|
{
|
||||||
|
table.add_fallback_speed_cells(*speed_cells);
|
||||||
|
}
|
||||||
|
auto table_buffer = table.Finish();
|
||||||
|
|
||||||
|
fbresult::FBResultBuilder response(fb_result);
|
||||||
|
if (data_version_string)
|
||||||
|
{
|
||||||
|
response.add_data_version(*data_version_string);
|
||||||
|
}
|
||||||
|
response.add_table(table_buffer);
|
||||||
|
response.add_waypoints(sources);
|
||||||
|
fb_result.Finish(response.Finish());
|
||||||
|
}
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
MakeResponse(const std::pair<std::vector<EdgeDuration>, std::vector<EdgeDistance>> &tables,
|
MakeResponse(const std::pair<std::vector<EdgeDuration>, std::vector<EdgeDistance>> &tables,
|
||||||
const std::vector<PhantomNode> &phantoms,
|
const std::vector<PhantomNode> &phantoms,
|
||||||
@ -96,6 +201,85 @@ class TableAPI final : public BaseAPI
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>>
|
||||||
|
MakeWaypoints(flatbuffers::FlatBufferBuilder &builder,
|
||||||
|
const std::vector<PhantomNode> &phantoms) const
|
||||||
|
{
|
||||||
|
std::vector<flatbuffers::Offset<fbresult::Waypoint>> waypoints;
|
||||||
|
waypoints.reserve(phantoms.size());
|
||||||
|
BOOST_ASSERT(phantoms.size() == parameters.coordinates.size());
|
||||||
|
|
||||||
|
boost::range::transform(
|
||||||
|
phantoms, std::back_inserter(waypoints), [this, &builder](const PhantomNode &phantom) {
|
||||||
|
return BaseAPI::MakeWaypoint(builder, phantom).Finish();
|
||||||
|
});
|
||||||
|
return builder.CreateVector(waypoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>>
|
||||||
|
MakeWaypoints(flatbuffers::FlatBufferBuilder &builder,
|
||||||
|
const std::vector<PhantomNode> &phantoms,
|
||||||
|
const std::vector<std::size_t> &indices) const
|
||||||
|
{
|
||||||
|
std::vector<flatbuffers::Offset<fbresult::Waypoint>> waypoints;
|
||||||
|
waypoints.reserve(indices.size());
|
||||||
|
boost::range::transform(indices,
|
||||||
|
std::back_inserter(waypoints),
|
||||||
|
[this, &builder, phantoms](const std::size_t idx) {
|
||||||
|
BOOST_ASSERT(idx < phantoms.size());
|
||||||
|
return BaseAPI::MakeWaypoint(builder, phantoms[idx]).Finish();
|
||||||
|
});
|
||||||
|
return builder.CreateVector(waypoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual flatbuffers::Offset<flatbuffers::Vector<float>>
|
||||||
|
MakeDurationTable(flatbuffers::FlatBufferBuilder &builder,
|
||||||
|
const std::vector<EdgeWeight> &values) const
|
||||||
|
{
|
||||||
|
std::vector<float> distance_table;
|
||||||
|
distance_table.resize(values.size());
|
||||||
|
std::transform(
|
||||||
|
values.begin(), values.end(), distance_table.begin(), [](const EdgeWeight duration) {
|
||||||
|
if (duration == MAXIMAL_EDGE_DURATION)
|
||||||
|
{
|
||||||
|
return 0.;
|
||||||
|
}
|
||||||
|
return duration / 10.;
|
||||||
|
});
|
||||||
|
return builder.CreateVector(distance_table);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual flatbuffers::Offset<flatbuffers::Vector<float>>
|
||||||
|
MakeDistanceTable(flatbuffers::FlatBufferBuilder &builder,
|
||||||
|
const std::vector<EdgeDistance> &values) const
|
||||||
|
{
|
||||||
|
std::vector<float> duration_table;
|
||||||
|
duration_table.resize(values.size());
|
||||||
|
std::transform(
|
||||||
|
values.begin(), values.end(), duration_table.begin(), [](const EdgeDistance distance) {
|
||||||
|
if (distance == INVALID_EDGE_DISTANCE)
|
||||||
|
{
|
||||||
|
return 0.;
|
||||||
|
}
|
||||||
|
return std::round(distance * 10) / 10.;
|
||||||
|
});
|
||||||
|
return builder.CreateVector(duration_table);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual flatbuffers::Offset<flatbuffers::Vector<uint32_t>>
|
||||||
|
MakeEstimatesTable(flatbuffers::FlatBufferBuilder &builder,
|
||||||
|
const std::vector<TableCellRef> &fallback_speed_cells) const
|
||||||
|
{
|
||||||
|
std::vector<uint32_t> fb_table;
|
||||||
|
fb_table.reserve(fallback_speed_cells.size());
|
||||||
|
std::for_each(
|
||||||
|
fallback_speed_cells.begin(), fallback_speed_cells.end(), [&](const auto &cell) {
|
||||||
|
fb_table.push_back(cell.row);
|
||||||
|
fb_table.push_back(cell.column);
|
||||||
|
});
|
||||||
|
return builder.CreateVector(fb_table);
|
||||||
|
}
|
||||||
|
|
||||||
virtual util::json::Array MakeWaypoints(const std::vector<PhantomNode> &phantoms) const
|
virtual util::json::Array MakeWaypoints(const std::vector<PhantomNode> &phantoms) const
|
||||||
{
|
{
|
||||||
util::json::Array json_waypoints;
|
util::json::Array json_waypoints;
|
||||||
|
@ -24,7 +24,47 @@ class TripAPI final : public RouteAPI
|
|||||||
: RouteAPI(facade_, parameters_), parameters(parameters_)
|
: RouteAPI(facade_, parameters_), parameters(parameters_)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
void MakeResponse(const std::vector<std::vector<NodeID>> &sub_trips,
|
||||||
|
const std::vector<InternalRouteResult> &sub_routes,
|
||||||
|
const std::vector<PhantomNode> &phantoms,
|
||||||
|
osrm::engine::api::ResultT &response) const
|
||||||
|
{
|
||||||
|
BOOST_ASSERT(sub_trips.size() == sub_routes.size());
|
||||||
|
|
||||||
|
if (response.is<flatbuffers::FlatBufferBuilder>())
|
||||||
|
{
|
||||||
|
auto &fb_result = response.get<flatbuffers::FlatBufferBuilder>();
|
||||||
|
MakeResponse(sub_trips, sub_routes, phantoms, fb_result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto &json_result = response.get<util::json::Object>();
|
||||||
|
MakeResponse(sub_trips, sub_routes, phantoms, json_result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void MakeResponse(const std::vector<std::vector<NodeID>> &sub_trips,
|
||||||
|
const std::vector<InternalRouteResult> &sub_routes,
|
||||||
|
const std::vector<PhantomNode> &phantoms,
|
||||||
|
flatbuffers::FlatBufferBuilder &fb_result) const
|
||||||
|
{
|
||||||
|
auto data_timestamp = facade.GetTimestamp();
|
||||||
|
boost::optional<flatbuffers::Offset<flatbuffers::String>> data_version_string = boost::none;
|
||||||
|
if (!data_timestamp.empty())
|
||||||
|
{
|
||||||
|
data_version_string = fb_result.CreateString(data_timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto response =
|
||||||
|
MakeFBResponse(sub_routes, fb_result, [this, &fb_result, &sub_trips, &phantoms]() {
|
||||||
|
return MakeWaypoints(fb_result, sub_trips, phantoms);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (data_version_string)
|
||||||
|
{
|
||||||
|
response.add_data_version(*data_version_string);
|
||||||
|
}
|
||||||
|
fb_result.Finish(response.Finish());
|
||||||
|
}
|
||||||
void MakeResponse(const std::vector<std::vector<NodeID>> &sub_trips,
|
void MakeResponse(const std::vector<std::vector<NodeID>> &sub_trips,
|
||||||
const std::vector<InternalRouteResult> &sub_routes,
|
const std::vector<InternalRouteResult> &sub_routes,
|
||||||
const std::vector<PhantomNode> &phantoms,
|
const std::vector<PhantomNode> &phantoms,
|
||||||
@ -33,7 +73,6 @@ class TripAPI final : public RouteAPI
|
|||||||
auto number_of_routes = sub_trips.size();
|
auto number_of_routes = sub_trips.size();
|
||||||
util::json::Array routes;
|
util::json::Array routes;
|
||||||
routes.values.reserve(number_of_routes);
|
routes.values.reserve(number_of_routes);
|
||||||
BOOST_ASSERT(sub_trips.size() == sub_routes.size());
|
|
||||||
for (auto index : util::irange<std::size_t>(0UL, sub_trips.size()))
|
for (auto index : util::irange<std::size_t>(0UL, sub_trips.size()))
|
||||||
{
|
{
|
||||||
auto route = MakeRoute(sub_routes[index].segment_end_coordinates,
|
auto route = MakeRoute(sub_routes[index].segment_end_coordinates,
|
||||||
@ -50,15 +89,11 @@ class TripAPI final : public RouteAPI
|
|||||||
protected:
|
protected:
|
||||||
// FIXME this logic is a little backwards. We should change the output format of the
|
// FIXME this logic is a little backwards. We should change the output format of the
|
||||||
// trip plugin routing algorithm to be easier to consume here.
|
// trip plugin routing algorithm to be easier to consume here.
|
||||||
util::json::Array MakeWaypoints(const std::vector<std::vector<NodeID>> &sub_trips,
|
|
||||||
const std::vector<PhantomNode> &phantoms) const
|
|
||||||
{
|
|
||||||
util::json::Array waypoints;
|
|
||||||
waypoints.values.reserve(parameters.coordinates.size());
|
|
||||||
|
|
||||||
struct TripIndex
|
struct TripIndex
|
||||||
{
|
{
|
||||||
TripIndex() = default;
|
TripIndex() = default;
|
||||||
|
|
||||||
TripIndex(unsigned sub_trip_index_, unsigned point_index_)
|
TripIndex(unsigned sub_trip_index_, unsigned point_index_)
|
||||||
: sub_trip_index(sub_trip_index_), point_index(point_index_)
|
: sub_trip_index(sub_trip_index_), point_index(point_index_)
|
||||||
{
|
{
|
||||||
@ -74,16 +109,38 @@ class TripAPI final : public RouteAPI
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<TripIndex> input_idx_to_trip_idx(parameters.coordinates.size());
|
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>>
|
||||||
for (auto sub_trip_index : util::irange<unsigned>(0u, sub_trips.size()))
|
MakeWaypoints(flatbuffers::FlatBufferBuilder &fb_result,
|
||||||
|
const std::vector<std::vector<NodeID>> &sub_trips,
|
||||||
|
const std::vector<PhantomNode> &phantoms) const
|
||||||
{
|
{
|
||||||
for (auto point_index : util::irange<unsigned>(0u, sub_trips[sub_trip_index].size()))
|
std::vector<flatbuffers::Offset<fbresult::Waypoint>> waypoints;
|
||||||
|
waypoints.reserve(parameters.coordinates.size());
|
||||||
|
|
||||||
|
auto input_idx_to_trip_idx = MakeTripIndices(sub_trips);
|
||||||
|
|
||||||
|
for (auto input_index : util::irange<std::size_t>(0UL, parameters.coordinates.size()))
|
||||||
{
|
{
|
||||||
input_idx_to_trip_idx[sub_trips[sub_trip_index][point_index]] =
|
auto trip_index = input_idx_to_trip_idx[input_index];
|
||||||
TripIndex{sub_trip_index, point_index};
|
BOOST_ASSERT(!trip_index.NotUsed());
|
||||||
|
|
||||||
|
auto waypoint = BaseAPI::MakeWaypoint(fb_result, phantoms[input_index]);
|
||||||
|
waypoint.add_waypoint_index(trip_index.point_index);
|
||||||
|
waypoint.add_trips_index(trip_index.sub_trip_index);
|
||||||
|
waypoints.push_back(waypoint.Finish());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return fb_result.CreateVector(waypoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
util::json::Array MakeWaypoints(const std::vector<std::vector<NodeID>> &sub_trips,
|
||||||
|
const std::vector<PhantomNode> &phantoms) const
|
||||||
|
{
|
||||||
|
util::json::Array waypoints;
|
||||||
|
waypoints.values.reserve(parameters.coordinates.size());
|
||||||
|
|
||||||
|
auto input_idx_to_trip_idx = MakeTripIndices(sub_trips);
|
||||||
|
|
||||||
for (auto input_index : util::irange<std::size_t>(0UL, parameters.coordinates.size()))
|
for (auto input_index : util::irange<std::size_t>(0UL, parameters.coordinates.size()))
|
||||||
{
|
{
|
||||||
auto trip_index = input_idx_to_trip_idx[input_index];
|
auto trip_index = input_idx_to_trip_idx[input_index];
|
||||||
@ -98,6 +155,20 @@ class TripAPI final : public RouteAPI
|
|||||||
return waypoints;
|
return waypoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<TripIndex> MakeTripIndices(const std::vector<std::vector<NodeID>> &sub_trips) const
|
||||||
|
{
|
||||||
|
std::vector<TripIndex> input_idx_to_trip_idx(parameters.coordinates.size());
|
||||||
|
for (auto sub_trip_index : util::irange<unsigned>(0u, sub_trips.size()))
|
||||||
|
{
|
||||||
|
for (auto point_index : util::irange<unsigned>(0u, sub_trips[sub_trip_index].size()))
|
||||||
|
{
|
||||||
|
input_idx_to_trip_idx[sub_trips[sub_trip_index][point_index]] =
|
||||||
|
TripIndex{sub_trip_index, point_index};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return input_idx_to_trip_idx;
|
||||||
|
}
|
||||||
|
|
||||||
const TripParameters ¶meters;
|
const TripParameters ¶meters;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,17 +32,13 @@ class EngineInterface
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~EngineInterface() = default;
|
virtual ~EngineInterface() = default;
|
||||||
virtual Status Route(const api::RouteParameters ¶meters,
|
virtual Status Route(const api::RouteParameters ¶meters, api::ResultT &result) const = 0;
|
||||||
util::json::Object &result) const = 0;
|
virtual Status Table(const api::TableParameters ¶meters, api::ResultT &result) const = 0;
|
||||||
virtual Status Table(const api::TableParameters ¶meters,
|
|
||||||
util::json::Object &result) const = 0;
|
|
||||||
virtual Status Nearest(const api::NearestParameters ¶meters,
|
virtual Status Nearest(const api::NearestParameters ¶meters,
|
||||||
util::json::Object &result) const = 0;
|
api::ResultT &result) const = 0;
|
||||||
virtual Status Trip(const api::TripParameters ¶meters,
|
virtual Status Trip(const api::TripParameters ¶meters, api::ResultT &result) const = 0;
|
||||||
util::json::Object &result) const = 0;
|
virtual Status Match(const api::MatchParameters ¶meters, api::ResultT &result) const = 0;
|
||||||
virtual Status Match(const api::MatchParameters ¶meters,
|
virtual Status Tile(const api::TileParameters ¶meters, api::ResultT &result) const = 0;
|
||||||
util::json::Object &result) const = 0;
|
|
||||||
virtual Status Tile(const api::TileParameters ¶meters, std::string &result) const = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Algorithm> class Engine final : public EngineInterface
|
template <typename Algorithm> class Engine final : public EngineInterface
|
||||||
@ -89,36 +85,32 @@ template <typename Algorithm> class Engine final : public EngineInterface
|
|||||||
Engine &operator=(const Engine &) = delete;
|
Engine &operator=(const Engine &) = delete;
|
||||||
virtual ~Engine() = default;
|
virtual ~Engine() = default;
|
||||||
|
|
||||||
Status Route(const api::RouteParameters ¶ms,
|
Status Route(const api::RouteParameters ¶ms, api::ResultT &result) const override final
|
||||||
util::json::Object &result) const override final
|
|
||||||
{
|
{
|
||||||
return route_plugin.HandleRequest(GetAlgorithms(params), params, result);
|
return route_plugin.HandleRequest(GetAlgorithms(params), params, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status Table(const api::TableParameters ¶ms,
|
Status Table(const api::TableParameters ¶ms, api::ResultT &result) const override final
|
||||||
util::json::Object &result) const override final
|
|
||||||
{
|
{
|
||||||
return table_plugin.HandleRequest(GetAlgorithms(params), params, result);
|
return table_plugin.HandleRequest(GetAlgorithms(params), params, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status Nearest(const api::NearestParameters ¶ms,
|
Status Nearest(const api::NearestParameters ¶ms, api::ResultT &result) const override final
|
||||||
util::json::Object &result) const override final
|
|
||||||
{
|
{
|
||||||
return nearest_plugin.HandleRequest(GetAlgorithms(params), params, result);
|
return nearest_plugin.HandleRequest(GetAlgorithms(params), params, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status Trip(const api::TripParameters ¶ms, util::json::Object &result) const override final
|
Status Trip(const api::TripParameters ¶ms, api::ResultT &result) const override final
|
||||||
{
|
{
|
||||||
return trip_plugin.HandleRequest(GetAlgorithms(params), params, result);
|
return trip_plugin.HandleRequest(GetAlgorithms(params), params, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status Match(const api::MatchParameters ¶ms,
|
Status Match(const api::MatchParameters ¶ms, api::ResultT &result) const override final
|
||||||
util::json::Object &result) const override final
|
|
||||||
{
|
{
|
||||||
return match_plugin.HandleRequest(GetAlgorithms(params), params, result);
|
return match_plugin.HandleRequest(GetAlgorithms(params), params, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status Tile(const api::TileParameters ¶ms, std::string &result) const override final
|
Status Tile(const api::TileParameters ¶ms, api::ResultT &result) const override final
|
||||||
{
|
{
|
||||||
return tile_plugin.HandleRequest(GetAlgorithms(params), params, result);
|
return tile_plugin.HandleRequest(GetAlgorithms(params), params, result);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ class MatchPlugin : public BasePlugin
|
|||||||
|
|
||||||
Status HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
Status HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||||
const api::MatchParameters ¶meters,
|
const api::MatchParameters ¶meters,
|
||||||
util::json::Object &json_result) const;
|
osrm::engine::api::ResultT &json_result) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const int max_locations_map_matching;
|
const int max_locations_map_matching;
|
||||||
|
@ -21,7 +21,7 @@ class NearestPlugin final : public BasePlugin
|
|||||||
|
|
||||||
Status HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
Status HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||||
const api::NearestParameters ¶ms,
|
const api::NearestParameters ¶ms,
|
||||||
util::json::Object &result) const;
|
osrm::engine::api::ResultT &result) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const int max_results;
|
const int max_results;
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#define BASE_PLUGIN_HPP
|
#define BASE_PLUGIN_HPP
|
||||||
|
|
||||||
#include "engine/api/base_parameters.hpp"
|
#include "engine/api/base_parameters.hpp"
|
||||||
|
#include "engine/api/base_result.hpp"
|
||||||
|
#include "engine/api/flatbuffers/fbresult_generated.h"
|
||||||
#include "engine/datafacade/datafacade_base.hpp"
|
#include "engine/datafacade/datafacade_base.hpp"
|
||||||
#include "engine/phantom_node.hpp"
|
#include "engine/phantom_node.hpp"
|
||||||
#include "engine/routing_algorithms.hpp"
|
#include "engine/routing_algorithms.hpp"
|
||||||
@ -39,7 +41,7 @@ class BasePlugin
|
|||||||
|
|
||||||
bool CheckAlgorithms(const api::BaseParameters ¶ms,
|
bool CheckAlgorithms(const api::BaseParameters ¶ms,
|
||||||
const RoutingAlgorithmsInterface &algorithms,
|
const RoutingAlgorithmsInterface &algorithms,
|
||||||
util::json::Object &result) const
|
osrm::engine::api::ResultT &result) const
|
||||||
{
|
{
|
||||||
if (algorithms.IsValid())
|
if (algorithms.IsValid())
|
||||||
{
|
{
|
||||||
@ -62,12 +64,38 @@ class BasePlugin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status Error(const std::string &code,
|
struct ErrorRenderer
|
||||||
const std::string &message,
|
{
|
||||||
util::json::Object &json_result) const
|
std::string code;
|
||||||
|
std::string message;
|
||||||
|
|
||||||
|
ErrorRenderer(std::string code, std::string message)
|
||||||
|
: code(std::move(code)), message(std::move(message)){};
|
||||||
|
|
||||||
|
void operator()(util::json::Object &json_result)
|
||||||
{
|
{
|
||||||
json_result.values["code"] = code;
|
json_result.values["code"] = code;
|
||||||
json_result.values["message"] = message;
|
json_result.values["message"] = message;
|
||||||
|
};
|
||||||
|
void operator()(flatbuffers::FlatBufferBuilder &fb_result)
|
||||||
|
{
|
||||||
|
auto error = api::fbresult::CreateErrorDirect(fb_result, code.c_str(), message.c_str());
|
||||||
|
api::fbresult::FBResultBuilder response(fb_result);
|
||||||
|
response.add_error(true);
|
||||||
|
response.add_code(error);
|
||||||
|
fb_result.Finish(response.Finish());
|
||||||
|
};
|
||||||
|
void operator()(std::string &str_result)
|
||||||
|
{
|
||||||
|
str_result = str(boost::format("code=%1% message=%2%") % code % message);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
Status Error(const std::string &code,
|
||||||
|
const std::string &message,
|
||||||
|
osrm::engine::api::ResultT &result) const
|
||||||
|
{
|
||||||
|
mapbox::util::apply_visitor(ErrorRenderer(code, message), result);
|
||||||
return Status::Error;
|
return Status::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class TablePlugin final : public BasePlugin
|
|||||||
|
|
||||||
Status HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
Status HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||||
const api::TableParameters ¶ms,
|
const api::TableParameters ¶ms,
|
||||||
util::json::Object &result) const;
|
osrm::engine::api::ResultT &result) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const int max_locations_distance_table;
|
const int max_locations_distance_table;
|
||||||
|
@ -28,7 +28,7 @@ class TilePlugin final : public BasePlugin
|
|||||||
public:
|
public:
|
||||||
Status HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
Status HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||||
const api::TileParameters ¶meters,
|
const api::TileParameters ¶meters,
|
||||||
std::string &pbf_buffer) const;
|
osrm::engine::api::ResultT &pbf_buffer) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ class TripPlugin final : public BasePlugin
|
|||||||
|
|
||||||
Status HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
Status HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||||
const api::TripParameters ¶meters,
|
const api::TripParameters ¶meters,
|
||||||
util::json::Object &json_result) const;
|
osrm::engine::api::ResultT &json_result) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ class ViaRoutePlugin final : public BasePlugin
|
|||||||
|
|
||||||
Status HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
Status HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||||
const api::RouteParameters &route_parameters,
|
const api::RouteParameters &route_parameters,
|
||||||
util::json::Object &json_result) const;
|
osrm::engine::api::ResultT &json_result) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#ifndef OSRM_HPP
|
#ifndef OSRM_HPP
|
||||||
#define OSRM_HPP
|
#define OSRM_HPP
|
||||||
|
|
||||||
|
#include "engine/api/base_result.hpp"
|
||||||
#include "osrm/osrm_fwd.hpp"
|
#include "osrm/osrm_fwd.hpp"
|
||||||
#include "osrm/status.hpp"
|
#include "osrm/status.hpp"
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ class OSRM final
|
|||||||
* \return Status indicating success for the query or failure
|
* \return Status indicating success for the query or failure
|
||||||
* \see Status, RouteParameters and json::Object
|
* \see Status, RouteParameters and json::Object
|
||||||
*/
|
*/
|
||||||
Status Route(const RouteParameters ¶meters, json::Object &result) const;
|
Status Route(const RouteParameters ¶meters, osrm::engine::api::ResultT &result) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Distance tables for coordinates.
|
* Distance tables for coordinates.
|
||||||
@ -92,7 +93,7 @@ class OSRM final
|
|||||||
* \return Status indicating success for the query or failure
|
* \return Status indicating success for the query or failure
|
||||||
* \see Status, TableParameters and json::Object
|
* \see Status, TableParameters and json::Object
|
||||||
*/
|
*/
|
||||||
Status Table(const TableParameters ¶meters, json::Object &result) const;
|
Status Table(const TableParameters ¶meters, osrm::engine::api::ResultT &result) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nearest street segment for coordinate.
|
* Nearest street segment for coordinate.
|
||||||
@ -101,7 +102,7 @@ class OSRM final
|
|||||||
* \return Status indicating success for the query or failure
|
* \return Status indicating success for the query or failure
|
||||||
* \see Status, NearestParameters and json::Object
|
* \see Status, NearestParameters and json::Object
|
||||||
*/
|
*/
|
||||||
Status Nearest(const NearestParameters ¶meters, json::Object &result) const;
|
Status Nearest(const NearestParameters ¶meters, osrm::engine::api::ResultT &result) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trip: shortest round trip between coordinates.
|
* Trip: shortest round trip between coordinates.
|
||||||
@ -110,7 +111,7 @@ class OSRM final
|
|||||||
* \return Status indicating success for the query or failure
|
* \return Status indicating success for the query or failure
|
||||||
* \see Status, TripParameters and json::Object
|
* \see Status, TripParameters and json::Object
|
||||||
*/
|
*/
|
||||||
Status Trip(const TripParameters ¶meters, json::Object &result) const;
|
Status Trip(const TripParameters ¶meters, osrm::engine::api::ResultT &result) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match: snaps noisy coordinate traces to the road network
|
* Match: snaps noisy coordinate traces to the road network
|
||||||
@ -119,7 +120,7 @@ class OSRM final
|
|||||||
* \return Status indicating success for the query or failure
|
* \return Status indicating success for the query or failure
|
||||||
* \see Status, MatchParameters and json::Object
|
* \see Status, MatchParameters and json::Object
|
||||||
*/
|
*/
|
||||||
Status Match(const MatchParameters ¶meters, json::Object &result) const;
|
Status Match(const MatchParameters ¶meters, osrm::engine::api::ResultT &result) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tile: vector tiles with internal graph representation
|
* Tile: vector tiles with internal graph representation
|
||||||
@ -128,7 +129,7 @@ class OSRM final
|
|||||||
* \return Status indicating success for the query or failure
|
* \return Status indicating success for the query or failure
|
||||||
* \see Status, TileParameters and json::Object
|
* \see Status, TileParameters and json::Object
|
||||||
*/
|
*/
|
||||||
Status Tile(const TileParameters ¶meters, std::string &result) const;
|
Status Tile(const TileParameters ¶meters, osrm::engine::api::ResultT &result) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<engine::EngineInterface> engine_;
|
std::unique_ptr<engine::EngineInterface> engine_;
|
||||||
|
@ -169,6 +169,12 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
|
|||||||
qi::lit("snapping=") >
|
qi::lit("snapping=") >
|
||||||
snapping_type[ph::bind(&engine::api::BaseParameters::snapping, qi::_r1) = qi::_1];
|
snapping_type[ph::bind(&engine::api::BaseParameters::snapping, qi::_r1) = qi::_1];
|
||||||
|
|
||||||
|
format_type.add(".json", engine::api::BaseParameters::OutputFormatType::JSON)(
|
||||||
|
".flatbuffers", engine::api::BaseParameters::OutputFormatType::FLATBUFFERS);
|
||||||
|
|
||||||
|
format_rule =
|
||||||
|
-format_type[ph::bind(&engine::api::BaseParameters::format, qi::_r1) = qi::_1];
|
||||||
|
|
||||||
exclude_rule = qi::lit("exclude=") >
|
exclude_rule = qi::lit("exclude=") >
|
||||||
(qi::as_string[+qi::char_("a-zA-Z0-9")] %
|
(qi::as_string[+qi::char_("a-zA-Z0-9")] %
|
||||||
',')[ph::bind(&engine::api::BaseParameters::exclude, qi::_r1) = qi::_1];
|
',')[ph::bind(&engine::api::BaseParameters::exclude, qi::_r1) = qi::_1];
|
||||||
@ -185,6 +191,9 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
|
|||||||
protected:
|
protected:
|
||||||
qi::rule<Iterator, Signature> base_rule;
|
qi::rule<Iterator, Signature> base_rule;
|
||||||
qi::rule<Iterator, Signature> query_rule;
|
qi::rule<Iterator, Signature> query_rule;
|
||||||
|
qi::rule<Iterator, Signature> format_rule;
|
||||||
|
|
||||||
|
qi::symbols<char, engine::api::BaseParameters::OutputFormatType> format_type;
|
||||||
|
|
||||||
qi::real_parser<double, json_policy> double_;
|
qi::real_parser<double, json_policy> double_;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ struct MatchParametersGrammar final : public RouteParametersGrammar<Iterator, Si
|
|||||||
"ignore", engine::api::MatchParameters::GapsType::Ignore);
|
"ignore", engine::api::MatchParameters::GapsType::Ignore);
|
||||||
|
|
||||||
root_rule =
|
root_rule =
|
||||||
BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") >
|
BaseGrammar::query_rule(qi::_r1) > BaseGrammar::format_rule(qi::_r1) >
|
||||||
-('?' > (timestamps_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1) |
|
-('?' > (timestamps_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1) |
|
||||||
(qi::lit("gaps=") >
|
(qi::lit("gaps=") >
|
||||||
gaps_type[ph::bind(&engine::api::MatchParameters::gaps, qi::_r1) = qi::_1]) |
|
gaps_type[ph::bind(&engine::api::MatchParameters::gaps, qi::_r1) = qi::_1]) |
|
||||||
|
@ -32,7 +32,7 @@ struct NearestParametersGrammar final : public BaseParametersGrammar<Iterator, S
|
|||||||
qi::uint_)[ph::bind(&engine::api::NearestParameters::number_of_results,
|
qi::uint_)[ph::bind(&engine::api::NearestParameters::number_of_results,
|
||||||
qi::_r1) = qi::_1];
|
qi::_r1) = qi::_1];
|
||||||
|
|
||||||
root_rule = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") >
|
root_rule = BaseGrammar::query_rule(qi::_r1) > BaseGrammar::format_rule(qi::_r1) >
|
||||||
-('?' > (nearest_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1)) % '&');
|
-('?' > (nearest_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1)) % '&');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ struct RouteParametersGrammar : public BaseParametersGrammar<Iterator, Signature
|
|||||||
qi::bool_[ph::bind(&engine::api::RouteParameters::continue_straight, qi::_r1) =
|
qi::bool_[ph::bind(&engine::api::RouteParameters::continue_straight, qi::_r1) =
|
||||||
qi::_1]));
|
qi::_1]));
|
||||||
|
|
||||||
root_rule = query_rule(qi::_r1) > -qi::lit(".json") >
|
root_rule = query_rule(qi::_r1) > BaseGrammar::format_rule(qi::_r1) >
|
||||||
-('?' > (route_rule(qi::_r1) | base_rule(qi::_r1)) % '&');
|
-('?' > (route_rule(qi::_r1) | base_rule(qi::_r1)) % '&');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ struct TableParametersGrammar : public BaseParametersGrammar<Iterator, Signature
|
|||||||
|
|
||||||
table_rule = destinations_rule(qi::_r1) | sources_rule(qi::_r1);
|
table_rule = destinations_rule(qi::_r1) | sources_rule(qi::_r1);
|
||||||
|
|
||||||
root_rule = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") >
|
root_rule = BaseGrammar::query_rule(qi::_r1) > BaseGrammar::format_rule(qi::_r1) >
|
||||||
-('?' > (table_rule(qi::_r1) | base_rule(qi::_r1) | scale_factor_rule(qi::_r1) |
|
-('?' > (table_rule(qi::_r1) | base_rule(qi::_r1) | scale_factor_rule(qi::_r1) |
|
||||||
fallback_speed_rule(qi::_r1) |
|
fallback_speed_rule(qi::_r1) |
|
||||||
(qi::lit("fallback_coordinate=") >
|
(qi::lit("fallback_coordinate=") >
|
||||||
|
@ -45,7 +45,7 @@ struct TripParametersGrammar final : public RouteParametersGrammar<Iterator, Sig
|
|||||||
qi::lit("destination=") >
|
qi::lit("destination=") >
|
||||||
destination_type[ph::bind(&engine::api::TripParameters::destination, qi::_r1) = qi::_1];
|
destination_type[ph::bind(&engine::api::TripParameters::destination, qi::_r1) = qi::_1];
|
||||||
|
|
||||||
root_rule = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") >
|
root_rule = BaseGrammar::query_rule(qi::_r1) > BaseGrammar::format_rule(qi::_r1) >
|
||||||
-('?' > (roundtrip_rule(qi::_r1) | source_rule(qi::_r1) |
|
-('?' > (roundtrip_rule(qi::_r1) | source_rule(qi::_r1) |
|
||||||
destination_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1)) %
|
destination_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1)) %
|
||||||
'&');
|
'&');
|
||||||
|
@ -20,13 +20,11 @@ namespace service
|
|||||||
class BaseService
|
class BaseService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using ResultT = mapbox::util::variant<util::json::Object, std::string>;
|
|
||||||
|
|
||||||
BaseService(OSRM &routing_machine) : routing_machine(routing_machine) {}
|
BaseService(OSRM &routing_machine) : routing_machine(routing_machine) {}
|
||||||
virtual ~BaseService() = default;
|
virtual ~BaseService() = default;
|
||||||
|
|
||||||
virtual engine::Status
|
virtual engine::Status
|
||||||
RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) = 0;
|
RunQuery(std::size_t prefix_length, std::string &query, osrm::engine::api::ResultT &result) = 0;
|
||||||
|
|
||||||
virtual unsigned GetVersion() = 0;
|
virtual unsigned GetVersion() = 0;
|
||||||
|
|
||||||
|
@ -22,8 +22,9 @@ class MatchService final : public BaseService
|
|||||||
public:
|
public:
|
||||||
MatchService(OSRM &routing_machine) : BaseService(routing_machine) {}
|
MatchService(OSRM &routing_machine) : BaseService(routing_machine) {}
|
||||||
|
|
||||||
engine::Status
|
engine::Status RunQuery(std::size_t prefix_length,
|
||||||
RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override;
|
std::string &query,
|
||||||
|
osrm::engine::api::ResultT &result) final override;
|
||||||
|
|
||||||
unsigned GetVersion() final override { return 1; }
|
unsigned GetVersion() final override { return 1; }
|
||||||
};
|
};
|
||||||
|
@ -22,8 +22,9 @@ class NearestService final : public BaseService
|
|||||||
public:
|
public:
|
||||||
NearestService(OSRM &routing_machine) : BaseService(routing_machine) {}
|
NearestService(OSRM &routing_machine) : BaseService(routing_machine) {}
|
||||||
|
|
||||||
engine::Status
|
engine::Status RunQuery(std::size_t prefix_length,
|
||||||
RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override;
|
std::string &query,
|
||||||
|
osrm::engine::api::ResultT &result) final override;
|
||||||
|
|
||||||
unsigned GetVersion() final override { return 1; }
|
unsigned GetVersion() final override { return 1; }
|
||||||
};
|
};
|
||||||
|
@ -22,8 +22,9 @@ class RouteService final : public BaseService
|
|||||||
public:
|
public:
|
||||||
RouteService(OSRM &routing_machine) : BaseService(routing_machine) {}
|
RouteService(OSRM &routing_machine) : BaseService(routing_machine) {}
|
||||||
|
|
||||||
engine::Status
|
engine::Status RunQuery(std::size_t prefix_length,
|
||||||
RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override;
|
std::string &query,
|
||||||
|
osrm::engine::api::ResultT &result) final override;
|
||||||
|
|
||||||
unsigned GetVersion() final override { return 1; }
|
unsigned GetVersion() final override { return 1; }
|
||||||
};
|
};
|
||||||
|
@ -22,8 +22,9 @@ class TableService final : public BaseService
|
|||||||
public:
|
public:
|
||||||
TableService(OSRM &routing_machine) : BaseService(routing_machine) {}
|
TableService(OSRM &routing_machine) : BaseService(routing_machine) {}
|
||||||
|
|
||||||
engine::Status
|
engine::Status RunQuery(std::size_t prefix_length,
|
||||||
RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override;
|
std::string &query,
|
||||||
|
osrm::engine::api::ResultT &result) final override;
|
||||||
|
|
||||||
unsigned GetVersion() final override { return 1; }
|
unsigned GetVersion() final override { return 1; }
|
||||||
};
|
};
|
||||||
|
@ -22,8 +22,9 @@ class TileService final : public BaseService
|
|||||||
public:
|
public:
|
||||||
TileService(OSRM &routing_machine) : BaseService(routing_machine) {}
|
TileService(OSRM &routing_machine) : BaseService(routing_machine) {}
|
||||||
|
|
||||||
engine::Status
|
engine::Status RunQuery(std::size_t prefix_length,
|
||||||
RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override;
|
std::string &query,
|
||||||
|
osrm::engine::api::ResultT &result) final override;
|
||||||
|
|
||||||
unsigned GetVersion() final override { return 1; }
|
unsigned GetVersion() final override { return 1; }
|
||||||
};
|
};
|
||||||
|
@ -22,8 +22,9 @@ class TripService final : public BaseService
|
|||||||
public:
|
public:
|
||||||
TripService(OSRM &routing_machine) : BaseService(routing_machine) {}
|
TripService(OSRM &routing_machine) : BaseService(routing_machine) {}
|
||||||
|
|
||||||
engine::Status
|
engine::Status RunQuery(std::size_t prefix_length,
|
||||||
RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override;
|
std::string &query,
|
||||||
|
osrm::engine::api::ResultT &result) final override;
|
||||||
|
|
||||||
unsigned GetVersion() final override { return 1; }
|
unsigned GetVersion() final override { return 1; }
|
||||||
};
|
};
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "server/service/base_service.hpp"
|
#include "server/service/base_service.hpp"
|
||||||
|
|
||||||
|
#include "engine/api/base_api.hpp"
|
||||||
#include "osrm/osrm.hpp"
|
#include "osrm/osrm.hpp"
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@ -28,14 +29,14 @@ class ServiceHandlerInterface
|
|||||||
public:
|
public:
|
||||||
virtual ~ServiceHandlerInterface() {}
|
virtual ~ServiceHandlerInterface() {}
|
||||||
virtual engine::Status RunQuery(api::ParsedURL parsed_url,
|
virtual engine::Status RunQuery(api::ParsedURL parsed_url,
|
||||||
service::BaseService::ResultT &result) = 0;
|
osrm::engine::api::ResultT &result) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ServiceHandler final : public ServiceHandlerInterface
|
class ServiceHandler final : public ServiceHandlerInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ServiceHandler(osrm::EngineConfig &config);
|
ServiceHandler(osrm::EngineConfig &config);
|
||||||
using ResultT = service::BaseService::ResultT;
|
using ResultT = osrm::engine::api::ResultT;
|
||||||
|
|
||||||
virtual engine::Status RunQuery(api::ParsedURL parsed_url, ResultT &result) override;
|
virtual engine::Status RunQuery(api::ParsedURL parsed_url, ResultT &result) override;
|
||||||
|
|
||||||
|
@ -214,9 +214,11 @@ int main(int argc, const char *argv[]) try
|
|||||||
auto NUM = 100;
|
auto NUM = 100;
|
||||||
for (int i = 0; i < NUM; ++i)
|
for (int i = 0; i < NUM; ++i)
|
||||||
{
|
{
|
||||||
json::Object result;
|
engine::api::ResultT result = json::Object();
|
||||||
const auto rc = osrm.Match(params, result);
|
const auto rc = osrm.Match(params, result);
|
||||||
if (rc != Status::Ok || result.values.at("matchings").get<json::Array>().values.size() != 1)
|
auto &json_result = result.get<json::Object>();
|
||||||
|
if (rc != Status::Ok ||
|
||||||
|
json_result.values.at("matchings").get<json::Array>().values.size() != 1)
|
||||||
{
|
{
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace TurnType = osrm::guidance::TurnType;
|
namespace TurnType = osrm::guidance::TurnType;
|
||||||
namespace DirectionModifier = osrm::guidance::DirectionModifier;
|
|
||||||
using TurnInstruction = osrm::guidance::TurnInstruction;
|
using TurnInstruction = osrm::guidance::TurnInstruction;
|
||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
@ -34,18 +33,6 @@ namespace json
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
// Check whether to include a modifier in the result of the API
|
|
||||||
inline bool isValidModifier(const guidance::StepManeuver maneuver)
|
|
||||||
{
|
|
||||||
return (maneuver.waypoint_type == guidance::WaypointType::None ||
|
|
||||||
maneuver.instruction.direction_modifier != DirectionModifier::UTurn);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool hasValidLanes(const guidance::IntermediateIntersection &intersection)
|
|
||||||
{
|
|
||||||
return intersection.lanes.lanes_in_turn > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline util::json::Array toJSON(const extractor::TurnLaneType::Mask lane_type)
|
inline util::json::Array toJSON(const extractor::TurnLaneType::Mask lane_type)
|
||||||
{
|
{
|
||||||
util::json::Array result;
|
util::json::Array result;
|
||||||
|
@ -112,16 +112,16 @@ void filterCandidates(const std::vector<util::Coordinate> &coordinates,
|
|||||||
|
|
||||||
Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||||
const api::MatchParameters ¶meters,
|
const api::MatchParameters ¶meters,
|
||||||
util::json::Object &json_result) const
|
osrm::engine::api::ResultT &result) const
|
||||||
{
|
{
|
||||||
if (!algorithms.HasMapMatching())
|
if (!algorithms.HasMapMatching())
|
||||||
{
|
{
|
||||||
return Error("NotImplemented",
|
return Error("NotImplemented",
|
||||||
"Map matching is not implemented for the chosen search algorithm.",
|
"Map matching is not implemented for the chosen search algorithm.",
|
||||||
json_result);
|
result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CheckAlgorithms(parameters, algorithms, json_result))
|
if (!CheckAlgorithms(parameters, algorithms, result))
|
||||||
return Status::Error;
|
return Status::Error;
|
||||||
|
|
||||||
const auto &facade = algorithms.GetFacade();
|
const auto &facade = algorithms.GetFacade();
|
||||||
@ -132,12 +132,12 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
|||||||
if (max_locations_map_matching > 0 &&
|
if (max_locations_map_matching > 0 &&
|
||||||
static_cast<int>(parameters.coordinates.size()) > max_locations_map_matching)
|
static_cast<int>(parameters.coordinates.size()) > max_locations_map_matching)
|
||||||
{
|
{
|
||||||
return Error("TooBig", "Too many trace coordinates", json_result);
|
return Error("TooBig", "Too many trace coordinates", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CheckAllCoordinates(parameters.coordinates))
|
if (!CheckAllCoordinates(parameters.coordinates))
|
||||||
{
|
{
|
||||||
return Error("InvalidValue", "Invalid coordinate value.", json_result);
|
return Error("InvalidValue", "Invalid coordinate value.", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max_radius_map_matching > 0 && std::any_of(parameters.radiuses.begin(),
|
if (max_radius_map_matching > 0 && std::any_of(parameters.radiuses.begin(),
|
||||||
@ -148,7 +148,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
|||||||
return *radius > max_radius_map_matching;
|
return *radius > max_radius_map_matching;
|
||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
return Error("TooBig", "Radius search size is too large for map matching.", json_result);
|
return Error("TooBig", "Radius search size is too large for map matching.", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for same or increasing timestamps. Impl. note: Incontrast to `sort(first,
|
// Check for same or increasing timestamps. Impl. note: Incontrast to `sort(first,
|
||||||
@ -158,8 +158,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
|||||||
|
|
||||||
if (!time_increases_monotonically)
|
if (!time_increases_monotonically)
|
||||||
{
|
{
|
||||||
return Error(
|
return Error("InvalidValue", "Timestamps need to be monotonically increasing.", result);
|
||||||
"InvalidValue", "Timestamps need to be monotonically increasing.", json_result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SubMatchingList sub_matchings;
|
SubMatchingList sub_matchings;
|
||||||
@ -180,9 +179,8 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
|||||||
(tidied.parameters.waypoints[0] != 0 ||
|
(tidied.parameters.waypoints[0] != 0 ||
|
||||||
tidied.parameters.waypoints.back() != (tidied.parameters.coordinates.size() - 1)))
|
tidied.parameters.waypoints.back() != (tidied.parameters.coordinates.size() - 1)))
|
||||||
{
|
{
|
||||||
return Error("InvalidValue",
|
return Error(
|
||||||
"First and last coordinates must be specified as waypoints.",
|
"InvalidValue", "First and last coordinates must be specified as waypoints.", result);
|
||||||
json_result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// assuming radius is the standard deviation of a normal distribution
|
// assuming radius is the standard deviation of a normal distribution
|
||||||
@ -225,7 +223,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
|||||||
{
|
{
|
||||||
return Error("NoSegment",
|
return Error("NoSegment",
|
||||||
std::string("Could not find a matching segment for any coordinate."),
|
std::string("Could not find a matching segment for any coordinate."),
|
||||||
json_result);
|
result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// call the actual map matching
|
// call the actual map matching
|
||||||
@ -238,13 +236,13 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
|||||||
|
|
||||||
if (sub_matchings.size() == 0)
|
if (sub_matchings.size() == 0)
|
||||||
{
|
{
|
||||||
return Error("NoMatch", "Could not match the trace.", json_result);
|
return Error("NoMatch", "Could not match the trace.", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// trace was split, we don't support the waypoints parameter across multiple match objects
|
// trace was split, we don't support the waypoints parameter across multiple match objects
|
||||||
if (sub_matchings.size() > 1 && !parameters.waypoints.empty())
|
if (sub_matchings.size() > 1 && !parameters.waypoints.empty())
|
||||||
{
|
{
|
||||||
return Error("NoMatch", "Could not match the trace with the given waypoints.", json_result);
|
return Error("NoMatch", "Could not match the trace with the given waypoints.", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error: Check if user-supplied waypoints can be found in the resulting matches
|
// Error: Check if user-supplied waypoints can be found in the resulting matches
|
||||||
@ -260,8 +258,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
|||||||
}
|
}
|
||||||
if (!tidied_waypoints.empty())
|
if (!tidied_waypoints.empty())
|
||||||
{
|
{
|
||||||
return Error(
|
return Error("NoMatch", "Requested waypoint parameter could not be matched.", result);
|
||||||
"NoMatch", "Requested waypoint parameter could not be matched.", json_result);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// we haven't errored yet, only allow leg collapsing if it was originally requested
|
// we haven't errored yet, only allow leg collapsing if it was originally requested
|
||||||
@ -313,7 +310,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
|||||||
}
|
}
|
||||||
|
|
||||||
api::MatchAPI match_api{facade, parameters, tidied};
|
api::MatchAPI match_api{facade, parameters, tidied};
|
||||||
match_api.MakeResponse(sub_matchings, sub_routes, json_result);
|
match_api.MakeResponse(sub_matchings, sub_routes, result);
|
||||||
|
|
||||||
return Status::Ok;
|
return Status::Ok;
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,11 @@ NearestPlugin::NearestPlugin(const int max_results_) : max_results{max_results_}
|
|||||||
|
|
||||||
Status NearestPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
Status NearestPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||||
const api::NearestParameters ¶ms,
|
const api::NearestParameters ¶ms,
|
||||||
util::json::Object &json_result) const
|
osrm::engine::api::ResultT &result) const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(params.IsValid());
|
BOOST_ASSERT(params.IsValid());
|
||||||
|
|
||||||
if (!CheckAlgorithms(params, algorithms, json_result))
|
if (!CheckAlgorithms(params, algorithms, result))
|
||||||
return Status::Error;
|
return Status::Error;
|
||||||
|
|
||||||
const auto &facade = algorithms.GetFacade();
|
const auto &facade = algorithms.GetFacade();
|
||||||
@ -36,27 +36,27 @@ Status NearestPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms
|
|||||||
return Error("TooBig",
|
return Error("TooBig",
|
||||||
"Number of results " + std::to_string(params.number_of_results) +
|
"Number of results " + std::to_string(params.number_of_results) +
|
||||||
" is higher than current maximum (" + std::to_string(max_results) + ")",
|
" is higher than current maximum (" + std::to_string(max_results) + ")",
|
||||||
json_result);
|
result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CheckAllCoordinates(params.coordinates))
|
if (!CheckAllCoordinates(params.coordinates))
|
||||||
return Error("InvalidOptions", "Coordinates are invalid", json_result);
|
return Error("InvalidOptions", "Coordinates are invalid", result);
|
||||||
|
|
||||||
if (params.coordinates.size() != 1)
|
if (params.coordinates.size() != 1)
|
||||||
{
|
{
|
||||||
return Error("InvalidOptions", "Only one input coordinate is supported", json_result);
|
return Error("InvalidOptions", "Only one input coordinate is supported", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto phantom_nodes = GetPhantomNodes(facade, params, params.number_of_results);
|
auto phantom_nodes = GetPhantomNodes(facade, params, params.number_of_results);
|
||||||
|
|
||||||
if (phantom_nodes.front().size() == 0)
|
if (phantom_nodes.front().size() == 0)
|
||||||
{
|
{
|
||||||
return Error("NoSegment", "Could not find a matching segments for coordinate", json_result);
|
return Error("NoSegment", "Could not find a matching segments for coordinate", result);
|
||||||
}
|
}
|
||||||
BOOST_ASSERT(phantom_nodes.front().size() > 0);
|
BOOST_ASSERT(phantom_nodes.front().size() > 0);
|
||||||
|
|
||||||
api::NearestAPI nearest_api(facade, params);
|
api::NearestAPI nearest_api(facade, params);
|
||||||
nearest_api.MakeResponse(phantom_nodes, json_result);
|
nearest_api.MakeResponse(phantom_nodes, result);
|
||||||
|
|
||||||
return Status::Ok;
|
return Status::Ok;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ TablePlugin::TablePlugin(const int max_locations_distance_table)
|
|||||||
|
|
||||||
Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||||
const api::TableParameters ¶ms,
|
const api::TableParameters ¶ms,
|
||||||
util::json::Object &result) const
|
osrm::engine::api::ResultT &result) const
|
||||||
{
|
{
|
||||||
if (!algorithms.HasManyToManySearch())
|
if (!algorithms.HasManyToManySearch())
|
||||||
{
|
{
|
||||||
|
@ -665,10 +665,11 @@ void encodeVectorTile(const DataFacadeBase &facade,
|
|||||||
|
|
||||||
Status TilePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
Status TilePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||||
const api::TileParameters ¶meters,
|
const api::TileParameters ¶meters,
|
||||||
std::string &pbf_buffer) const
|
osrm::engine::api::ResultT &result) const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(parameters.IsValid());
|
BOOST_ASSERT(parameters.IsValid());
|
||||||
|
|
||||||
|
auto &pbf_buffer = result.get<std::string>();
|
||||||
const auto &facade = algorithms.GetFacade();
|
const auto &facade = algorithms.GetFacade();
|
||||||
auto edges = getEdges(facade, parameters.x, parameters.y, parameters.z);
|
auto edges = getEdges(facade, parameters.x, parameters.y, parameters.z);
|
||||||
auto segregated_nodes = getSegregatedNodes(facade, edges);
|
auto segregated_nodes = getSegregatedNodes(facade, edges);
|
||||||
|
@ -144,19 +144,19 @@ void ManipulateTableForFSE(const std::size_t source_id,
|
|||||||
|
|
||||||
Status TripPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
Status TripPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||||
const api::TripParameters ¶meters,
|
const api::TripParameters ¶meters,
|
||||||
util::json::Object &json_result) const
|
osrm::engine::api::ResultT &result) const
|
||||||
{
|
{
|
||||||
if (!algorithms.HasShortestPathSearch())
|
if (!algorithms.HasShortestPathSearch())
|
||||||
{
|
{
|
||||||
return Error("NotImplemented",
|
return Error("NotImplemented",
|
||||||
"Shortest path search is not implemented for the chosen search algorithm.",
|
"Shortest path search is not implemented for the chosen search algorithm.",
|
||||||
json_result);
|
result);
|
||||||
}
|
}
|
||||||
if (!algorithms.HasManyToManySearch())
|
if (!algorithms.HasManyToManySearch())
|
||||||
{
|
{
|
||||||
return Error("NotImplemented",
|
return Error("NotImplemented",
|
||||||
"Many to many search is not implemented for the chosen search algorithm.",
|
"Many to many search is not implemented for the chosen search algorithm.",
|
||||||
json_result);
|
result);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_ASSERT(parameters.IsValid());
|
BOOST_ASSERT(parameters.IsValid());
|
||||||
@ -177,21 +177,21 @@ Status TripPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
|||||||
bool fixed_end = (destination_id == number_of_locations - 1);
|
bool fixed_end = (destination_id == number_of_locations - 1);
|
||||||
if (!IsSupportedParameterCombination(fixed_start, fixed_end, parameters.roundtrip))
|
if (!IsSupportedParameterCombination(fixed_start, fixed_end, parameters.roundtrip))
|
||||||
{
|
{
|
||||||
return Error("NotImplemented", "This request is not supported", json_result);
|
return Error("NotImplemented", "This request is not supported", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// enforce maximum number of locations for performance reasons
|
// enforce maximum number of locations for performance reasons
|
||||||
if (max_locations_trip > 0 && static_cast<int>(number_of_locations) > max_locations_trip)
|
if (max_locations_trip > 0 && static_cast<int>(number_of_locations) > max_locations_trip)
|
||||||
{
|
{
|
||||||
return Error("TooBig", "Too many trip coordinates", json_result);
|
return Error("TooBig", "Too many trip coordinates", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CheckAllCoordinates(parameters.coordinates))
|
if (!CheckAllCoordinates(parameters.coordinates))
|
||||||
{
|
{
|
||||||
return Error("InvalidValue", "Invalid coordinate value.", json_result);
|
return Error("InvalidValue", "Invalid coordinate value.", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CheckAlgorithms(parameters, algorithms, json_result))
|
if (!CheckAlgorithms(parameters, algorithms, result))
|
||||||
return Status::Error;
|
return Status::Error;
|
||||||
|
|
||||||
const auto &facade = algorithms.GetFacade();
|
const auto &facade = algorithms.GetFacade();
|
||||||
@ -201,14 +201,14 @@ Status TripPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
|||||||
return Error("NoSegment",
|
return Error("NoSegment",
|
||||||
std::string("Could not find a matching segment for coordinate ") +
|
std::string("Could not find a matching segment for coordinate ") +
|
||||||
std::to_string(phantom_node_pairs.size()),
|
std::to_string(phantom_node_pairs.size()),
|
||||||
json_result);
|
result);
|
||||||
}
|
}
|
||||||
BOOST_ASSERT(phantom_node_pairs.size() == number_of_locations);
|
BOOST_ASSERT(phantom_node_pairs.size() == number_of_locations);
|
||||||
|
|
||||||
if (fixed_start && fixed_end && (source_id >= parameters.coordinates.size() ||
|
if (fixed_start && fixed_end && (source_id >= parameters.coordinates.size() ||
|
||||||
destination_id >= parameters.coordinates.size()))
|
destination_id >= parameters.coordinates.size()))
|
||||||
{
|
{
|
||||||
return Error("InvalidValue", "Invalid source or destination value.", json_result);
|
return Error("InvalidValue", "Invalid source or destination value.", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto snapped_phantoms = SnapPhantomNodes(phantom_node_pairs);
|
auto snapped_phantoms = SnapPhantomNodes(phantom_node_pairs);
|
||||||
@ -231,7 +231,7 @@ Status TripPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
|||||||
|
|
||||||
if (!IsStronglyConnectedComponent(result_duration_table))
|
if (!IsStronglyConnectedComponent(result_duration_table))
|
||||||
{
|
{
|
||||||
return Error("NoTrips", "No trip visiting all destinations possible.", json_result);
|
return Error("NoTrips", "No trip visiting all destinations possible.", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fixed_start && fixed_end)
|
if (fixed_start && fixed_end)
|
||||||
@ -275,7 +275,7 @@ Status TripPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
|||||||
const std::vector<std::vector<NodeID>> trips = {duration_trip};
|
const std::vector<std::vector<NodeID>> trips = {duration_trip};
|
||||||
const std::vector<InternalRouteResult> routes = {route};
|
const std::vector<InternalRouteResult> routes = {route};
|
||||||
api::TripAPI trip_api{facade, parameters};
|
api::TripAPI trip_api{facade, parameters};
|
||||||
trip_api.MakeResponse(trips, routes, snapped_phantoms, json_result);
|
trip_api.MakeResponse(trips, routes, snapped_phantoms, result);
|
||||||
|
|
||||||
return Status::Ok;
|
return Status::Ok;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ ViaRoutePlugin::ViaRoutePlugin(int max_locations_viaroute, int max_alternatives)
|
|||||||
|
|
||||||
Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||||
const api::RouteParameters &route_parameters,
|
const api::RouteParameters &route_parameters,
|
||||||
util::json::Object &json_result) const
|
osrm::engine::api::ResultT &result) const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(route_parameters.IsValid());
|
BOOST_ASSERT(route_parameters.IsValid());
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
|
|||||||
return Error("NotImplemented",
|
return Error("NotImplemented",
|
||||||
"Shortest path search is not implemented for the chosen search algorithm. "
|
"Shortest path search is not implemented for the chosen search algorithm. "
|
||||||
"Only two coordinates supported.",
|
"Only two coordinates supported.",
|
||||||
json_result);
|
result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!algorithms.HasDirectShortestPathSearch() && !algorithms.HasShortestPathSearch())
|
if (!algorithms.HasDirectShortestPathSearch() && !algorithms.HasShortestPathSearch())
|
||||||
@ -45,7 +45,7 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
|
|||||||
return Error(
|
return Error(
|
||||||
"NotImplemented",
|
"NotImplemented",
|
||||||
"Direct shortest path search is not implemented for the chosen search algorithm.",
|
"Direct shortest path search is not implemented for the chosen search algorithm.",
|
||||||
json_result);
|
result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max_locations_viaroute > 0 &&
|
if (max_locations_viaroute > 0 &&
|
||||||
@ -55,7 +55,7 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
|
|||||||
"Number of entries " + std::to_string(route_parameters.coordinates.size()) +
|
"Number of entries " + std::to_string(route_parameters.coordinates.size()) +
|
||||||
" is higher than current maximum (" +
|
" is higher than current maximum (" +
|
||||||
std::to_string(max_locations_viaroute) + ")",
|
std::to_string(max_locations_viaroute) + ")",
|
||||||
json_result);
|
result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Takes care of alternatives=n and alternatives=true
|
// Takes care of alternatives=n and alternatives=true
|
||||||
@ -65,12 +65,12 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
|
|||||||
return Error("TooBig",
|
return Error("TooBig",
|
||||||
"Requested number of alternatives is higher than current maximum (" +
|
"Requested number of alternatives is higher than current maximum (" +
|
||||||
std::to_string(max_alternatives) + ")",
|
std::to_string(max_alternatives) + ")",
|
||||||
json_result);
|
result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CheckAllCoordinates(route_parameters.coordinates))
|
if (!CheckAllCoordinates(route_parameters.coordinates))
|
||||||
{
|
{
|
||||||
return Error("InvalidValue", "Invalid coordinate value.", json_result);
|
return Error("InvalidValue", "Invalid coordinate value.", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error: first and last points should be waypoints
|
// Error: first and last points should be waypoints
|
||||||
@ -78,12 +78,11 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
|
|||||||
(route_parameters.waypoints[0] != 0 ||
|
(route_parameters.waypoints[0] != 0 ||
|
||||||
route_parameters.waypoints.back() != (route_parameters.coordinates.size() - 1)))
|
route_parameters.waypoints.back() != (route_parameters.coordinates.size() - 1)))
|
||||||
{
|
{
|
||||||
return Error("InvalidValue",
|
return Error(
|
||||||
"First and last coordinates must be specified as waypoints.",
|
"InvalidValue", "First and last coordinates must be specified as waypoints.", result);
|
||||||
json_result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CheckAlgorithms(route_parameters, algorithms, json_result))
|
if (!CheckAlgorithms(route_parameters, algorithms, result))
|
||||||
return Status::Error;
|
return Status::Error;
|
||||||
|
|
||||||
const auto &facade = algorithms.GetFacade();
|
const auto &facade = algorithms.GetFacade();
|
||||||
@ -93,7 +92,7 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
|
|||||||
return Error("NoSegment",
|
return Error("NoSegment",
|
||||||
std::string("Could not find a matching segment for coordinate ") +
|
std::string("Could not find a matching segment for coordinate ") +
|
||||||
std::to_string(phantom_node_pairs.size()),
|
std::to_string(phantom_node_pairs.size()),
|
||||||
json_result);
|
result);
|
||||||
}
|
}
|
||||||
BOOST_ASSERT(phantom_node_pairs.size() == route_parameters.coordinates.size());
|
BOOST_ASSERT(phantom_node_pairs.size() == route_parameters.coordinates.size());
|
||||||
|
|
||||||
@ -162,7 +161,7 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
route_api.MakeResponse(routes, start_end_nodes, json_result);
|
route_api.MakeResponse(routes, start_end_nodes, result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -175,11 +174,11 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
|
|||||||
|
|
||||||
if (not_in_same_component)
|
if (not_in_same_component)
|
||||||
{
|
{
|
||||||
return Error("NoRoute", "Impossible route between points", json_result);
|
return Error("NoRoute", "Impossible route between points", result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return Error("NoRoute", "No route found between points", json_result);
|
return Error("NoRoute", "No route found between points", result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,18 +151,20 @@ inline void async(const Nan::FunctionCallbackInfo<v8::Value> &info,
|
|||||||
|
|
||||||
void Execute() override try
|
void Execute() override try
|
||||||
{
|
{
|
||||||
osrm::json::Object r;
|
osrm::engine::api::ResultT r;
|
||||||
|
r = osrm::util::json::Object();
|
||||||
const auto status = ((*osrm).*(service))(*params, r);
|
const auto status = ((*osrm).*(service))(*params, r);
|
||||||
ParseResult(status, r);
|
auto json_result = r.get<osrm::json::Object>();
|
||||||
|
ParseResult(status, json_result);
|
||||||
if (pluginParams.renderJSONToBuffer)
|
if (pluginParams.renderJSONToBuffer)
|
||||||
{
|
{
|
||||||
std::ostringstream buf;
|
std::ostringstream buf;
|
||||||
osrm::util::json::render(buf, r);
|
osrm::util::json::render(buf, json_result);
|
||||||
result = buf.str();
|
result = buf.str();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = r;
|
result = json_result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
@ -230,8 +232,10 @@ inline void asyncForTiles(const Nan::FunctionCallbackInfo<v8::Value> &info,
|
|||||||
|
|
||||||
void Execute() override try
|
void Execute() override try
|
||||||
{
|
{
|
||||||
|
result = std::string();
|
||||||
const auto status = ((*osrm).*(service))(*params, result);
|
const auto status = ((*osrm).*(service))(*params, result);
|
||||||
ParseResult(status, result);
|
auto str_result = result.get<std::string>();
|
||||||
|
ParseResult(status, str_result);
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
@ -243,7 +247,8 @@ inline void asyncForTiles(const Nan::FunctionCallbackInfo<v8::Value> &info,
|
|||||||
Nan::HandleScope scope;
|
Nan::HandleScope scope;
|
||||||
|
|
||||||
const constexpr auto argc = 2u;
|
const constexpr auto argc = 2u;
|
||||||
v8::Local<v8::Value> argv[argc] = {Nan::Null(), render(result)};
|
auto str_result = result.get<std::string>();
|
||||||
|
v8::Local<v8::Value> argv[argc] = {Nan::Null(), render(str_result)};
|
||||||
|
|
||||||
callback->Call(argc, argv);
|
callback->Call(argc, argv);
|
||||||
}
|
}
|
||||||
@ -254,7 +259,7 @@ inline void asyncForTiles(const Nan::FunctionCallbackInfo<v8::Value> &info,
|
|||||||
const ParamPtr params;
|
const ParamPtr params;
|
||||||
const PluginParameters pluginParams;
|
const PluginParameters pluginParams;
|
||||||
|
|
||||||
std::string result;
|
osrm::engine::api::ResultT result;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto *callback = new Nan::Callback{info[info.Length() - 1].As<v8::Function>()};
|
auto *callback = new Nan::Callback{info[info.Length() - 1].As<v8::Function>()};
|
||||||
|
@ -57,33 +57,37 @@ OSRM &OSRM::operator=(OSRM &&) noexcept = default;
|
|||||||
// Forward to implementation
|
// Forward to implementation
|
||||||
|
|
||||||
engine::Status OSRM::Route(const engine::api::RouteParameters ¶ms,
|
engine::Status OSRM::Route(const engine::api::RouteParameters ¶ms,
|
||||||
util::json::Object &result) const
|
osrm::engine::api::ResultT &result) const
|
||||||
{
|
{
|
||||||
return engine_->Route(params, result);
|
return engine_->Route(params, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
engine::Status OSRM::Table(const engine::api::TableParameters ¶ms, json::Object &result) const
|
engine::Status OSRM::Table(const engine::api::TableParameters ¶ms,
|
||||||
|
osrm::engine::api::ResultT &result) const
|
||||||
{
|
{
|
||||||
return engine_->Table(params, result);
|
return engine_->Table(params, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
engine::Status OSRM::Nearest(const engine::api::NearestParameters ¶ms,
|
engine::Status OSRM::Nearest(const engine::api::NearestParameters ¶ms,
|
||||||
json::Object &result) const
|
osrm::engine::api::ResultT &result) const
|
||||||
{
|
{
|
||||||
return engine_->Nearest(params, result);
|
return engine_->Nearest(params, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
engine::Status OSRM::Trip(const engine::api::TripParameters ¶ms, json::Object &result) const
|
engine::Status OSRM::Trip(const engine::api::TripParameters ¶ms,
|
||||||
|
osrm::engine::api::ResultT &result) const
|
||||||
{
|
{
|
||||||
return engine_->Trip(params, result);
|
return engine_->Trip(params, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
engine::Status OSRM::Match(const engine::api::MatchParameters ¶ms, json::Object &result) const
|
engine::Status OSRM::Match(const engine::api::MatchParameters ¶ms,
|
||||||
|
osrm::engine::api::ResultT &result) const
|
||||||
{
|
{
|
||||||
return engine_->Match(params, result);
|
return engine_->Match(params, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
engine::Status OSRM::Tile(const engine::api::TileParameters ¶ms, std::string &result) const
|
engine::Status OSRM::Tile(const engine::api::TileParameters ¶ms,
|
||||||
|
osrm::engine::api::ResultT &result) const
|
||||||
{
|
{
|
||||||
return engine_->Tile(params, result);
|
return engine_->Tile(params, result);
|
||||||
}
|
}
|
||||||
|
@ -110,6 +110,17 @@ void RequestHandler::HandleRequest(const http::request ¤t_request, http::r
|
|||||||
|
|
||||||
util::json::render(current_reply.content, result.get<util::json::Object>());
|
util::json::render(current_reply.content, result.get<util::json::Object>());
|
||||||
}
|
}
|
||||||
|
else if (result.is<flatbuffers::FlatBufferBuilder>())
|
||||||
|
{
|
||||||
|
auto &buffer = result.get<flatbuffers::FlatBufferBuilder>();
|
||||||
|
current_reply.content.resize(buffer.GetSize());
|
||||||
|
std::copy(buffer.GetBufferPointer(),
|
||||||
|
buffer.GetBufferPointer() + buffer.GetSize(),
|
||||||
|
current_reply.content.begin());
|
||||||
|
|
||||||
|
current_reply.headers.emplace_back(
|
||||||
|
"Content-Type", "application/x-flatbuffers;schema=osrm.engine.api.fbresult");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(result.is<std::string>());
|
BOOST_ASSERT(result.is<std::string>());
|
||||||
|
@ -41,8 +41,9 @@ std::string getWrongOptionHelp(const engine::api::MatchParameters ¶meters)
|
|||||||
}
|
}
|
||||||
} // anon. ns
|
} // anon. ns
|
||||||
|
|
||||||
engine::Status
|
engine::Status MatchService::RunQuery(std::size_t prefix_length,
|
||||||
MatchService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
|
std::string &query,
|
||||||
|
osrm::engine::api::ResultT &result)
|
||||||
{
|
{
|
||||||
result = util::json::Object();
|
result = util::json::Object();
|
||||||
auto &json_result = result.get<util::json::Object>();
|
auto &json_result = result.get<util::json::Object>();
|
||||||
@ -68,7 +69,14 @@ MatchService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &r
|
|||||||
}
|
}
|
||||||
BOOST_ASSERT(parameters->IsValid());
|
BOOST_ASSERT(parameters->IsValid());
|
||||||
|
|
||||||
return BaseService::routing_machine.Match(*parameters, json_result);
|
if (parameters->format)
|
||||||
|
{
|
||||||
|
if (parameters->format == engine::api::BaseParameters::OutputFormatType::FLATBUFFERS)
|
||||||
|
{
|
||||||
|
result = flatbuffers::FlatBufferBuilder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BaseService::routing_machine.Match(*parameters, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,9 @@ std::string getWrongOptionHelp(const engine::api::NearestParameters ¶meters)
|
|||||||
}
|
}
|
||||||
} // anon. ns
|
} // anon. ns
|
||||||
|
|
||||||
engine::Status
|
engine::Status NearestService::RunQuery(std::size_t prefix_length,
|
||||||
NearestService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
|
std::string &query,
|
||||||
|
osrm::engine::api::ResultT &result)
|
||||||
{
|
{
|
||||||
result = util::json::Object();
|
result = util::json::Object();
|
||||||
auto &json_result = result.get<util::json::Object>();
|
auto &json_result = result.get<util::json::Object>();
|
||||||
@ -62,7 +63,14 @@ NearestService::RunQuery(std::size_t prefix_length, std::string &query, ResultT
|
|||||||
}
|
}
|
||||||
BOOST_ASSERT(parameters->IsValid());
|
BOOST_ASSERT(parameters->IsValid());
|
||||||
|
|
||||||
return BaseService::routing_machine.Nearest(*parameters, json_result);
|
if (parameters->format)
|
||||||
|
{
|
||||||
|
if (parameters->format == engine::api::BaseParameters::OutputFormatType::FLATBUFFERS)
|
||||||
|
{
|
||||||
|
result = flatbuffers::FlatBufferBuilder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BaseService::routing_machine.Nearest(*parameters, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,9 @@ std::string getWrongOptionHelp(const engine::api::RouteParameters ¶meters)
|
|||||||
}
|
}
|
||||||
} // anon. ns
|
} // anon. ns
|
||||||
|
|
||||||
engine::Status
|
engine::Status RouteService::RunQuery(std::size_t prefix_length,
|
||||||
RouteService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
|
std::string &query,
|
||||||
|
osrm::engine::api::ResultT &result)
|
||||||
{
|
{
|
||||||
result = util::json::Object();
|
result = util::json::Object();
|
||||||
auto &json_result = result.get<util::json::Object>();
|
auto &json_result = result.get<util::json::Object>();
|
||||||
@ -66,7 +67,14 @@ RouteService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &r
|
|||||||
}
|
}
|
||||||
BOOST_ASSERT(parameters->IsValid());
|
BOOST_ASSERT(parameters->IsValid());
|
||||||
|
|
||||||
return BaseService::routing_machine.Route(*parameters, json_result);
|
if (parameters->format)
|
||||||
|
{
|
||||||
|
if (parameters->format == engine::api::BaseParameters::OutputFormatType::FLATBUFFERS)
|
||||||
|
{
|
||||||
|
result = flatbuffers::FlatBufferBuilder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BaseService::routing_machine.Route(*parameters, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,8 +70,9 @@ std::string getWrongOptionHelp(const engine::api::TableParameters ¶meters)
|
|||||||
}
|
}
|
||||||
} // anon. ns
|
} // anon. ns
|
||||||
|
|
||||||
engine::Status
|
engine::Status TableService::RunQuery(std::size_t prefix_length,
|
||||||
TableService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
|
std::string &query,
|
||||||
|
osrm::engine::api::ResultT &result)
|
||||||
{
|
{
|
||||||
result = util::json::Object();
|
result = util::json::Object();
|
||||||
auto &json_result = result.get<util::json::Object>();
|
auto &json_result = result.get<util::json::Object>();
|
||||||
@ -97,7 +98,14 @@ TableService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &r
|
|||||||
}
|
}
|
||||||
BOOST_ASSERT(parameters->IsValid());
|
BOOST_ASSERT(parameters->IsValid());
|
||||||
|
|
||||||
return BaseService::routing_machine.Table(*parameters, json_result);
|
if (parameters->format)
|
||||||
|
{
|
||||||
|
if (parameters->format == engine::api::BaseParameters::OutputFormatType::FLATBUFFERS)
|
||||||
|
{
|
||||||
|
result = flatbuffers::FlatBufferBuilder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BaseService::routing_machine.Table(*parameters, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,9 @@ namespace server
|
|||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
engine::Status TileService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
|
engine::Status TileService::RunQuery(std::size_t prefix_length,
|
||||||
|
std::string &query,
|
||||||
|
osrm::engine::api::ResultT &result)
|
||||||
{
|
{
|
||||||
auto query_iterator = query.begin();
|
auto query_iterator = query.begin();
|
||||||
auto parameters =
|
auto parameters =
|
||||||
@ -43,8 +45,7 @@ engine::Status TileService::RunQuery(std::size_t prefix_length, std::string &que
|
|||||||
BOOST_ASSERT(parameters->IsValid());
|
BOOST_ASSERT(parameters->IsValid());
|
||||||
|
|
||||||
result = std::string();
|
result = std::string();
|
||||||
auto &string_result = result.get<std::string>();
|
return BaseService::routing_machine.Tile(*parameters, result);
|
||||||
return BaseService::routing_machine.Tile(*parameters, string_result);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,9 @@ std::string getWrongOptionHelp(const engine::api::TripParameters ¶meters)
|
|||||||
}
|
}
|
||||||
} // anon. ns
|
} // anon. ns
|
||||||
|
|
||||||
engine::Status TripService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
|
engine::Status TripService::RunQuery(std::size_t prefix_length,
|
||||||
|
std::string &query,
|
||||||
|
osrm::engine::api::ResultT &result)
|
||||||
{
|
{
|
||||||
result = util::json::Object();
|
result = util::json::Object();
|
||||||
auto &json_result = result.get<util::json::Object>();
|
auto &json_result = result.get<util::json::Object>();
|
||||||
@ -69,7 +71,14 @@ engine::Status TripService::RunQuery(std::size_t prefix_length, std::string &que
|
|||||||
}
|
}
|
||||||
BOOST_ASSERT(parameters->IsValid());
|
BOOST_ASSERT(parameters->IsValid());
|
||||||
|
|
||||||
return BaseService::routing_machine.Trip(*parameters, json_result);
|
if (parameters->format)
|
||||||
|
{
|
||||||
|
if (parameters->format == engine::api::BaseParameters::OutputFormatType::FLATBUFFERS)
|
||||||
|
{
|
||||||
|
result = flatbuffers::FlatBufferBuilder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BaseService::routing_machine.Trip(*parameters, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ ServiceHandler::ServiceHandler(osrm::EngineConfig &config) : routing_machine(con
|
|||||||
}
|
}
|
||||||
|
|
||||||
engine::Status ServiceHandler::RunQuery(api::ParsedURL parsed_url,
|
engine::Status ServiceHandler::RunQuery(api::ParsedURL parsed_url,
|
||||||
service::BaseService::ResultT &result)
|
osrm::engine::api::ResultT &result)
|
||||||
{
|
{
|
||||||
const auto &service_iter = service_map.find(parsed_url.service);
|
const auto &service_iter = service_map.find(parsed_url.service);
|
||||||
if (service_iter == service_map.end())
|
if (service_iter == service_map.end())
|
||||||
|
41
third_party/flatbuffers/.appveyor/check-generate-code.bat
vendored
Normal file
41
third_party/flatbuffers/.appveyor/check-generate-code.bat
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
:: Copyright 2018 Google Inc. All rights reserved.
|
||||||
|
::
|
||||||
|
:: Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
:: you may not use this file except in compliance with the License.
|
||||||
|
:: You may obtain a copy of the License at
|
||||||
|
::
|
||||||
|
:: http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
::
|
||||||
|
:: Unless required by applicable law or agreed to in writing, software
|
||||||
|
:: distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
:: See the License for the specific language governing permissions and
|
||||||
|
:: limitations under the License.
|
||||||
|
set buildtype=Release
|
||||||
|
if "%1"=="-b" set buildtype=%2
|
||||||
|
|
||||||
|
cd tests
|
||||||
|
call generate_code.bat -b %buildtype% || goto FAIL
|
||||||
|
|
||||||
|
:: TODO: Release and Debug builds produce differences here for some reason.
|
||||||
|
git checkout HEAD -- monster_test.bfbs
|
||||||
|
git checkout HEAD -- arrays_test.bfbs
|
||||||
|
|
||||||
|
git -c core.autocrlf=true diff --exit-code --quiet || goto :DIFFFOUND
|
||||||
|
goto SUCCESS
|
||||||
|
|
||||||
|
:DIFFFOUND
|
||||||
|
@echo "" >&2
|
||||||
|
@echo "ERROR: ********************************************************" >&2
|
||||||
|
@echo "ERROR: The following differences were found after running the" >&2
|
||||||
|
@echo "ERROR: tests/generate_code.sh script. Maybe you forgot to run" >&2
|
||||||
|
@echo "ERROR: it after making changes in a generator or schema?" >&2
|
||||||
|
@echo "ERROR: ********************************************************" >&2
|
||||||
|
@echo "" >&2
|
||||||
|
@git -c core.autocrlf=true --no-pager diff --binary
|
||||||
|
|
||||||
|
:FAIL
|
||||||
|
set EXITCODE=1
|
||||||
|
:SUCCESS
|
||||||
|
cd ..
|
||||||
|
EXIT /B %EXITCODE%
|
18
third_party/flatbuffers/.bazelci/presubmit.yml
vendored
Normal file
18
third_party/flatbuffers/.bazelci/presubmit.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
buildifier: latest
|
||||||
|
platforms:
|
||||||
|
ubuntu1604:
|
||||||
|
build_targets:
|
||||||
|
- "..."
|
||||||
|
test_targets:
|
||||||
|
- "..."
|
||||||
|
ubuntu1804:
|
||||||
|
build_targets:
|
||||||
|
- "..."
|
||||||
|
test_targets:
|
||||||
|
- "..."
|
||||||
|
macos:
|
||||||
|
build_targets:
|
||||||
|
- "..."
|
||||||
|
test_targets:
|
||||||
|
- "..."
|
13
third_party/flatbuffers/.clang-format
vendored
Normal file
13
third_party/flatbuffers/.clang-format
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
BasedOnStyle: Google
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
PointerAlignment: Right
|
||||||
|
IndentPPDirectives: AfterHash
|
||||||
|
Cpp11BracedListStyle: false
|
||||||
|
AlwaysBreakTemplateDeclarations: false
|
||||||
|
AllowShortCaseLabelsOnASingleLine: true
|
||||||
|
SpaceAfterTemplateKeyword: false
|
||||||
|
AllowShortBlocksOnASingleLine: true
|
||||||
|
...
|
||||||
|
|
7
third_party/flatbuffers/.editorconfig
vendored
Normal file
7
third_party/flatbuffers/.editorconfig
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
root = true
|
||||||
|
# Don't set line endings to avoid conflict with core.autocrlf flag.
|
||||||
|
# Line endings on checkout/checkin are controlled by .gitattributes file.
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
insert_final_newline = true
|
2
third_party/flatbuffers/.gitattributes
vendored
Normal file
2
third_party/flatbuffers/.gitattributes
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Set the default behavior, in case people don't have core.autocrlf set.
|
||||||
|
* text=auto
|
12
third_party/flatbuffers/.github/ISSUE_TEMPLATE.md
vendored
Normal file
12
third_party/flatbuffers/.github/ISSUE_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
Thank you for submitting an issue!
|
||||||
|
|
||||||
|
Please make sure you include the names of the affected language(s), compiler version(s), operating system version(s), and FlatBuffers version(s) in your issue title.
|
||||||
|
|
||||||
|
This helps us get the correct maintainers to look at your issue. Here are examples of good titles:
|
||||||
|
|
||||||
|
- Crash when accessing FlatBuffer [C++, gcc 4.8, OS X, master]
|
||||||
|
- Flatc converts a protobuf 'bytes' field to 'string' in fbs schema file [all languages, FlatBuffers 1.4]
|
||||||
|
|
||||||
|
Include other details as appropriate.
|
||||||
|
|
||||||
|
Thanks!
|
16
third_party/flatbuffers/.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
16
third_party/flatbuffers/.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
Thank you for submitting a PR!
|
||||||
|
|
||||||
|
Please make sure you include the names of the affected language(s) in your PR title.
|
||||||
|
This helps us get the correct maintainers to look at your issue.
|
||||||
|
|
||||||
|
If you make changes to any of the code generators, be sure to run
|
||||||
|
`cd tests && sh generate_code.sh` (or equivalent .bat) and include the generated
|
||||||
|
code changes in the PR. This allows us to better see the effect of the PR.
|
||||||
|
|
||||||
|
If your PR includes C++ code, please adhere to the Google C++ Style Guide,
|
||||||
|
and don't forget we try to support older compilers (e.g. VS2010, GCC 4.6.3),
|
||||||
|
so only some C++11 support is available.
|
||||||
|
|
||||||
|
Include other details as appropriate.
|
||||||
|
|
||||||
|
Thanks!
|
18
third_party/flatbuffers/.github/stale.yml
vendored
Normal file
18
third_party/flatbuffers/.github/stale.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Number of days of inactivity before an issue becomes stale
|
||||||
|
daysUntilStale: 365
|
||||||
|
# Number of days of inactivity before a stale issue is closed
|
||||||
|
daysUntilClose: 14
|
||||||
|
# Issues with these labels will never be considered stale
|
||||||
|
exemptLabels:
|
||||||
|
- pinned
|
||||||
|
- security
|
||||||
|
# Label to use when marking an issue as stale
|
||||||
|
staleLabel: stale
|
||||||
|
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||||
|
markComment: >
|
||||||
|
This issue has been automatically marked as stale because it has not had
|
||||||
|
activity for 1 year. It will be automatically closed if no further activity occurs.
|
||||||
|
To keep it open, simply post a new comment. Maintainers will re-open on
|
||||||
|
new activity. Thank you for your contributions.
|
||||||
|
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||||
|
closeComment: false
|
118
third_party/flatbuffers/.gitignore
vendored
Normal file
118
third_party/flatbuffers/.gitignore
vendored
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
*_wire.txt
|
||||||
|
*_wire.bin
|
||||||
|
.DS_Store
|
||||||
|
*.o
|
||||||
|
*.o.d
|
||||||
|
*.class
|
||||||
|
*.a
|
||||||
|
*.swp
|
||||||
|
*~
|
||||||
|
*.vcxproj
|
||||||
|
*.vcxproj.filters
|
||||||
|
*.vcxproj.user
|
||||||
|
*.sln
|
||||||
|
*.suo
|
||||||
|
*.opendb
|
||||||
|
*.keystore
|
||||||
|
**/.vs/**
|
||||||
|
**/bin/**
|
||||||
|
!tests/rust_usage_test/bin/**
|
||||||
|
**/gen/**
|
||||||
|
**/libs/**
|
||||||
|
**/obj/**
|
||||||
|
**/*.dir/**
|
||||||
|
**/CMakeFiles/**
|
||||||
|
**/cmake_install.cmake
|
||||||
|
**/install_manifest.txt
|
||||||
|
**/CMakeCache.txt
|
||||||
|
**/CMakeTestfile.cmake
|
||||||
|
**/CPackConfig.cmake
|
||||||
|
**/CPackSourceConfig.cmake
|
||||||
|
**/compile_commands.json
|
||||||
|
**/Debug/**
|
||||||
|
**/Release/**
|
||||||
|
**/RelWithDebInfo/**
|
||||||
|
**/x64/ #build artifacts from VS
|
||||||
|
build.xml
|
||||||
|
local.properties
|
||||||
|
project.properties
|
||||||
|
proguard-project.txt
|
||||||
|
linklint_results
|
||||||
|
Makefile
|
||||||
|
flatc
|
||||||
|
flatc.exe
|
||||||
|
flathash
|
||||||
|
flathash.exe
|
||||||
|
flattests
|
||||||
|
flattests.exe
|
||||||
|
flatsamplebinary
|
||||||
|
flatsamplebinary.exe
|
||||||
|
flatsampletext
|
||||||
|
flatsampletext.exe
|
||||||
|
flatsamplebfbs
|
||||||
|
flatsamplebfbs.exe
|
||||||
|
grpctest
|
||||||
|
grpctest.exe
|
||||||
|
snapshot.sh
|
||||||
|
tags
|
||||||
|
tests/dart_gen
|
||||||
|
tests/go_gen
|
||||||
|
tests/monsterdata_java_wire.mon
|
||||||
|
tests/monsterdata_java_wire_sp.mon
|
||||||
|
tests/monsterdata_go_wire.mon
|
||||||
|
tests/monsterdata_javascript_wire.mon
|
||||||
|
tests/monsterdata_lobster_wire.mon
|
||||||
|
tests/monsterdata_rust_wire.mon
|
||||||
|
tests/unicode_test.mon
|
||||||
|
tests/ts/
|
||||||
|
tests/php/
|
||||||
|
CMakeLists.txt.user
|
||||||
|
CMakeScripts/**
|
||||||
|
CTestTestfile.cmake
|
||||||
|
FlatbuffersConfigVersion.cmake
|
||||||
|
FlatBuffers.cbp
|
||||||
|
build/Xcode/FlatBuffers.xcodeproj/project.xcworkspace/**
|
||||||
|
build/Xcode/FlatBuffers.xcodeproj/xcuserdata/**
|
||||||
|
FlatBuffers.xcodeproj/
|
||||||
|
java/.idea
|
||||||
|
java/*.iml
|
||||||
|
.idea
|
||||||
|
*.iml
|
||||||
|
target
|
||||||
|
**/*.pyc
|
||||||
|
build/VS2010/FlatBuffers.sdf
|
||||||
|
build/VS2010/FlatBuffers.opensdf
|
||||||
|
build/VS2010/ipch/**/*.ipch
|
||||||
|
*.so
|
||||||
|
Testing/Temporary
|
||||||
|
.cproject
|
||||||
|
.settings/
|
||||||
|
.project
|
||||||
|
net/**/obj
|
||||||
|
node_modules/
|
||||||
|
android/.externalNativeBuild/
|
||||||
|
android/.gradle/
|
||||||
|
android/build/
|
||||||
|
samples/android/.externalNativeBuild/
|
||||||
|
samples/android/.gradle/
|
||||||
|
samples/android/build/
|
||||||
|
js/flatbuffers.mjs
|
||||||
|
/bazel-bin
|
||||||
|
/bazel-flatbuffers
|
||||||
|
/bazel-genfiles
|
||||||
|
/bazel-out
|
||||||
|
/bazel-testlogs
|
||||||
|
.ninja_deps
|
||||||
|
.ninja_log
|
||||||
|
build.ninja
|
||||||
|
rules.ninja
|
||||||
|
.vscode
|
||||||
|
dart/.pub/
|
||||||
|
dart/.packages
|
||||||
|
dart/pubspec.lock
|
||||||
|
dart/.dart_tool/
|
||||||
|
dart/build/
|
||||||
|
dart/doc/api/
|
||||||
|
Cargo.lock
|
||||||
|
.corpus**
|
||||||
|
.seed**
|
221
third_party/flatbuffers/.travis.yml
vendored
Normal file
221
third_party/flatbuffers/.travis.yml
vendored
Normal file
@ -0,0 +1,221 @@
|
|||||||
|
env:
|
||||||
|
global:
|
||||||
|
# Set at the root level as this is ignored when set under matrix.env.
|
||||||
|
- GCC_VERSION="4.9"
|
||||||
|
# Fail on first error if UBSAN or ASAN enabled for a target
|
||||||
|
- UBSAN_OPTIONS=halt_on_error=1
|
||||||
|
- ASAN_OPTIONS=halt_on_error=1
|
||||||
|
# Travis machines have 2 cores
|
||||||
|
- JOBS=2
|
||||||
|
- MAKEFLAGS="-j 2"
|
||||||
|
|
||||||
|
conan-linux: &conan-linux
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
language: python
|
||||||
|
python: "3.7"
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
install:
|
||||||
|
- ./conan/travis/install.sh
|
||||||
|
script:
|
||||||
|
- ./conan/travis/build.sh
|
||||||
|
if: tag IS present
|
||||||
|
|
||||||
|
conan-linux-master: &conan-linux-master
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
language: python
|
||||||
|
python: "3.7"
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
install:
|
||||||
|
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash ./conan/travis/install.sh; fi'
|
||||||
|
script:
|
||||||
|
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash ./conan/travis/build.sh; fi'
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
|
||||||
|
conan-osx: &conan-osx
|
||||||
|
os: osx
|
||||||
|
language: generic
|
||||||
|
install:
|
||||||
|
- ./conan/travis/install.sh
|
||||||
|
script:
|
||||||
|
- ./conan/travis/build.sh
|
||||||
|
if: tag IS present
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
#- language: python
|
||||||
|
# python: "2.7"
|
||||||
|
# install:
|
||||||
|
# - "pip install wheel twine"
|
||||||
|
# script:
|
||||||
|
# - "cd python/"
|
||||||
|
# - 'VERSION="$TRAVIS_TAG" python setup.py sdist bdist_wheel'
|
||||||
|
# - "cd ../"
|
||||||
|
# deploy:
|
||||||
|
# # Checkpointed release builds.
|
||||||
|
# - provider: script
|
||||||
|
# script: .travis/deploy-python.sh
|
||||||
|
# skip_cleanup: true
|
||||||
|
# on:
|
||||||
|
# tags: true
|
||||||
|
# # all_branches must be set with tags: true. See below post:
|
||||||
|
# # https://stackoverflow.com/a/27775257/1076585
|
||||||
|
# all_branches: true
|
||||||
|
# # Produce a new build for the cutting edge when master changes.
|
||||||
|
# - provider: script
|
||||||
|
# script: .travis/deploy-python.sh
|
||||||
|
# skip_cleanup: true
|
||||||
|
# on:
|
||||||
|
# branch: master
|
||||||
|
- language: cpp
|
||||||
|
os:
|
||||||
|
- linux
|
||||||
|
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- docker-ce
|
||||||
|
script:
|
||||||
|
- bash .travis/build-and-run-docker-test-containers.sh
|
||||||
|
|
||||||
|
- language: cpp
|
||||||
|
os:
|
||||||
|
- linux
|
||||||
|
|
||||||
|
compiler:
|
||||||
|
- gcc
|
||||||
|
|
||||||
|
env:
|
||||||
|
matrix:
|
||||||
|
- BUILD_TYPE=Debug
|
||||||
|
- BUILD_TYPE=Release
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test; fi
|
||||||
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update -qq; fi
|
||||||
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq g++-$GCC_VERSION; fi
|
||||||
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq gcc-$GCC_VERSION; fi
|
||||||
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which g++-$GCC_VERSION) /usr/bin/g++; fi
|
||||||
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which gcc-$GCC_VERSION) /usr/bin/gcc; fi
|
||||||
|
|
||||||
|
script:
|
||||||
|
- bash .travis/check-sources.sh
|
||||||
|
- bash grpc/build_grpc.sh
|
||||||
|
- cmake .
|
||||||
|
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||||
|
-DFLATBUFFERS_BUILD_GRPCTEST=ON
|
||||||
|
-DGRPC_INSTALL_PATH=$TRAVIS_BUILD_DIR/google/grpc/install
|
||||||
|
-DPROTOBUF_DOWNLOAD_PATH=$TRAVIS_BUILD_DIR/google/grpc/third_party/protobuf
|
||||||
|
-DFLATBUFFERS_CODE_SANITIZE=ON
|
||||||
|
- cmake --build . -- -j${JOBS}
|
||||||
|
- LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/google/grpc/install/lib ctest --extra-verbose --output-on-failure
|
||||||
|
- bash .travis/check-generate-code.sh
|
||||||
|
|
||||||
|
- language: cpp
|
||||||
|
os: osx
|
||||||
|
osx_image: xcode9.3
|
||||||
|
env:
|
||||||
|
matrix:
|
||||||
|
- BUILD_TYPE=Debug
|
||||||
|
- BUILD_TYPE=Release
|
||||||
|
|
||||||
|
script:
|
||||||
|
- bash grpc/build_grpc.sh
|
||||||
|
- cmake .
|
||||||
|
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||||
|
-DFLATBUFFERS_BUILD_GRPCTEST=ON
|
||||||
|
-DGRPC_INSTALL_PATH=$TRAVIS_BUILD_DIR/google/grpc/install
|
||||||
|
-DPROTOBUF_DOWNLOAD_PATH=$TRAVIS_BUILD_DIR/google/grpc/third_party/protobuf
|
||||||
|
-DFLATBUFFERS_CODE_SANITIZE=ON
|
||||||
|
- cmake --build . -- -j${JOBS}
|
||||||
|
- DYLD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/google/grpc/install/lib ctest --extra-verbose --output-on-failure
|
||||||
|
- bash .travis/check-generate-code.sh
|
||||||
|
|
||||||
|
- <<: *conan-linux-master
|
||||||
|
env: CONAN_GCC_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/gcc8
|
||||||
|
- <<: *conan-linux
|
||||||
|
env: CONAN_GCC_VERSIONS=4.9 CONAN_DOCKER_IMAGE=conanio/gcc49
|
||||||
|
- <<: *conan-linux
|
||||||
|
env: CONAN_GCC_VERSIONS=5 CONAN_DOCKER_IMAGE=conanio/gcc5
|
||||||
|
- <<: *conan-linux
|
||||||
|
env: CONAN_GCC_VERSIONS=6 CONAN_DOCKER_IMAGE=conanio/gcc6
|
||||||
|
- <<: *conan-linux
|
||||||
|
env: CONAN_GCC_VERSIONS=7 CONAN_DOCKER_IMAGE=conanio/gcc7
|
||||||
|
- <<: *conan-linux
|
||||||
|
env: CONAN_GCC_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/gcc8
|
||||||
|
- <<: *conan-linux
|
||||||
|
env: CONAN_GCC_VERSIONS=9 CONAN_DOCKER_IMAGE=conanio/gcc9
|
||||||
|
- <<: *conan-linux
|
||||||
|
env: CONAN_CLANG_VERSIONS=3.9 CONAN_DOCKER_IMAGE=conanio/clang39
|
||||||
|
- <<: *conan-linux
|
||||||
|
env: CONAN_CLANG_VERSIONS=4.0 CONAN_DOCKER_IMAGE=conanio/clang40
|
||||||
|
- <<: *conan-linux
|
||||||
|
env: CONAN_CLANG_VERSIONS=5.0 CONAN_DOCKER_IMAGE=conanio/clang50
|
||||||
|
- <<: *conan-linux
|
||||||
|
env: CONAN_CLANG_VERSIONS=6.0 CONAN_DOCKER_IMAGE=conanio/clang60
|
||||||
|
- <<: *conan-linux
|
||||||
|
env: CONAN_CLANG_VERSIONS=7.0 CONAN_DOCKER_IMAGE=conanio/clang7
|
||||||
|
- <<: *conan-linux
|
||||||
|
env: CONAN_CLANG_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/clang8
|
||||||
|
- <<: *conan-osx
|
||||||
|
osx_image: xcode7.3
|
||||||
|
env: CONAN_APPLE_CLANG_VERSIONS=7.3
|
||||||
|
- <<: *conan-osx
|
||||||
|
osx_image: xcode8.3
|
||||||
|
env: CONAN_APPLE_CLANG_VERSIONS=8.1
|
||||||
|
- <<: *conan-osx
|
||||||
|
osx_image: xcode9
|
||||||
|
env: CONAN_APPLE_CLANG_VERSIONS=9.0
|
||||||
|
- <<: *conan-osx
|
||||||
|
osx_image: xcode9.4
|
||||||
|
env: CONAN_APPLE_CLANG_VERSIONS=9.1
|
||||||
|
- <<: *conan-osx
|
||||||
|
osx_image: xcode10.2
|
||||||
|
env: CONAN_APPLE_CLANG_VERSIONS=10.0
|
||||||
|
|
||||||
|
- language: android
|
||||||
|
sudo: true
|
||||||
|
dist: trusty
|
||||||
|
android:
|
||||||
|
components:
|
||||||
|
- tools
|
||||||
|
- platform-tools
|
||||||
|
- build-tools-25.0.2
|
||||||
|
- android-25
|
||||||
|
- extra-android-m2repository
|
||||||
|
compiler:
|
||||||
|
- gcc
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
# Output something every 10 minutes or Travis kills the job
|
||||||
|
- while sleep 540; do echo "=====[ $SECONDS seconds still running ]====="; done &
|
||||||
|
# Install the r17c version of the NDK that still so that we can continue to test with gnustl
|
||||||
|
# and stlport.
|
||||||
|
- export ANDROID_NDK_HOME=$HOME/android-ndk
|
||||||
|
- NDK_ZIP=$ANDROID_NDK_HOME/ndk.zip
|
||||||
|
- mkdir -p $ANDROID_NDK_HOME
|
||||||
|
- curl -o $NDK_ZIP https://dl.google.com/android/repository/android-ndk-r17c-linux-x86_64.zip
|
||||||
|
- unzip -q -d $ANDROID_NDK_HOME $NDK_ZIP
|
||||||
|
- rm $NDK_ZIP
|
||||||
|
- mv $ANDROID_NDK_HOME/android-ndk-*/* $ANDROID_NDK_HOME
|
||||||
|
- rmdir $ANDROID_NDK_HOME/android-ndk-*
|
||||||
|
- export CMAKE=$(which cmake)
|
||||||
|
# libc required for prebuilt llvm toolchain the NDK r17c.
|
||||||
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update -qq; fi
|
||||||
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq libc6; fi
|
||||||
|
# Setup environment for Linux build which is required to build the sample.
|
||||||
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test; fi
|
||||||
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update -qq; fi
|
||||||
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq g++-$GCC_VERSION; fi
|
||||||
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq gcc-$GCC_VERSION; fi
|
||||||
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which g++-$GCC_VERSION) /usr/bin/g++; fi
|
||||||
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which gcc-$GCC_VERSION) /usr/bin/gcc; fi
|
||||||
|
script:
|
||||||
|
- failed=0; for build_gradle in $(git ls-files | grep build.gradle); do ( cd "$(dirname "${build_gradle}")" && ./gradlew build ) || failed=1; done; exit $((failed))
|
||||||
|
# Kill the sleep loop
|
||||||
|
- kill %1
|
40
third_party/flatbuffers/.travis/build-and-run-docker-test-containers.sh
vendored
Executable file
40
third_party/flatbuffers/.travis/build-and-run-docker-test-containers.sh
vendored
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright 2018 Google Inc. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# build flatc on debian once to speed up the test loop below
|
||||||
|
docker build -t build_flatc_debian_stretch -f tests/docker/Dockerfile.testing.build_flatc_debian_stretch .
|
||||||
|
BUILD_CONTAINER_ID=$(docker create --read-only build_flatc_debian_stretch)
|
||||||
|
docker cp ${BUILD_CONTAINER_ID}:/code/flatc flatc_debian_stretch
|
||||||
|
|
||||||
|
for f in $(ls tests/docker/languages | sort)
|
||||||
|
do
|
||||||
|
# docker pull sometimes fails for unknown reasons, probably travisci-related. this retries the pull we need a few times.
|
||||||
|
REQUIRED_BASE_IMAGE=$(cat tests/docker/languages/${f} | head -n 1 | awk ' { print $2 } ')
|
||||||
|
|
||||||
|
set +e
|
||||||
|
n=0
|
||||||
|
until [ $n -ge 5 ]
|
||||||
|
do
|
||||||
|
docker pull $REQUIRED_BASE_IMAGE && break
|
||||||
|
n=$[$n+1]
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
set -e
|
||||||
|
|
||||||
|
docker build -t $(echo ${f} | cut -f 3- -d .) -f tests/docker/languages/${f} .
|
||||||
|
echo "TEST OK: ${f}"
|
||||||
|
done
|
35
third_party/flatbuffers/.travis/check-generate-code.sh
vendored
Executable file
35
third_party/flatbuffers/.travis/check-generate-code.sh
vendored
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright 2018 Google Inc. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cd tests
|
||||||
|
./generate_code.sh
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# TODO: Linux and macos builds produce differences here for some reason.
|
||||||
|
git checkout HEAD -- tests/monster_test.bfbs
|
||||||
|
git checkout HEAD -- tests/arrays_test.bfbs
|
||||||
|
|
||||||
|
if ! git diff --quiet; then
|
||||||
|
echo >&2
|
||||||
|
echo "ERROR: ********************************************************" >&2
|
||||||
|
echo "ERROR: The following differences were found after running the" >&2
|
||||||
|
echo "ERROR: tests/generate_code.sh script. Maybe you forgot to run" >&2
|
||||||
|
echo "ERROR: it after making changes in a generator or schema?" >&2
|
||||||
|
echo "ERROR: ********************************************************" >&2
|
||||||
|
echo >&2
|
||||||
|
git diff --binary --exit-code
|
||||||
|
fi
|
33
third_party/flatbuffers/.travis/check-sources.sh
vendored
Normal file
33
third_party/flatbuffers/.travis/check-sources.sh
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright 2018 Google Inc. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ -n "$1" ]; then
|
||||||
|
scan_dir="$1"
|
||||||
|
else
|
||||||
|
scan_dir="$( pwd )"
|
||||||
|
fi
|
||||||
|
|
||||||
|
py_checker="$0.py"
|
||||||
|
|
||||||
|
echo "scan root directory = '$scan_dir'"
|
||||||
|
python3 --version
|
||||||
|
# Scan recursively and search all *.cpp and *.h files using regex patterns.
|
||||||
|
# Assume that script running from a root of Flatbuffers working dir.
|
||||||
|
python3 $py_checker "ascii" "$scan_dir/include" "\.h$"
|
||||||
|
python3 $py_checker "ascii" "$scan_dir/src" "\.cpp$"
|
||||||
|
python3 $py_checker "ascii" "$scan_dir/tests" "\.h$"
|
||||||
|
python3 $py_checker "utf-8" "$scan_dir/tests" "\.cpp$"
|
35
third_party/flatbuffers/.travis/check-sources.sh.py
vendored
Normal file
35
third_party/flatbuffers/.travis/check-sources.sh.py
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import os
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def check_encoding(encoding, scan_dir, regex_pattern):
|
||||||
|
fname = None
|
||||||
|
try:
|
||||||
|
assert encoding in ['ascii', 'utf-8'], "unexpected encoding"
|
||||||
|
cmp = re.compile(regex_pattern)
|
||||||
|
for root, dirs, files in os.walk(scan_dir):
|
||||||
|
fname = root
|
||||||
|
cmp_list = [f for f in files if cmp.search(f) is not None]
|
||||||
|
for f in cmp_list:
|
||||||
|
fname = os.path.join(root, f)
|
||||||
|
with open(fname, mode='rb') as test_file:
|
||||||
|
btext = test_file.read()
|
||||||
|
# check encoding
|
||||||
|
btext.decode(encoding=encoding, errors="strict")
|
||||||
|
if encoding == "utf-8" and btext.startswith(b'\xEF\xBB\xBF'):
|
||||||
|
raise ValueError("unexpected BOM in file")
|
||||||
|
# check LF line endings
|
||||||
|
LF = btext.count(b'\n')
|
||||||
|
CR = btext.count(b'\r')
|
||||||
|
if CR!=0:
|
||||||
|
raise ValueError("invalid line endings: LF({})/CR({})".format(LF, CR))
|
||||||
|
except Exception as err:
|
||||||
|
print("ERROR with [{}]: {}".format(fname, err))
|
||||||
|
return -1
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# python check-sources.sh.py 'ascii' '.' '.*\.(cpp|h)$'
|
||||||
|
res = check_encoding(sys.argv[1], sys.argv[2], sys.argv[3])
|
||||||
|
sys.exit(0 if res == 0 else -1)
|
12
third_party/flatbuffers/.travis/deploy-python.sh
vendored
Executable file
12
third_party/flatbuffers/.travis/deploy-python.sh
vendored
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
PROD_REPOSITORY="https://upload.pypi.org/legacy/"
|
||||||
|
TEST_REPOSITORY="https://test.pypi.org/legacy/"
|
||||||
|
|
||||||
|
twine upload \
|
||||||
|
--username "$PYPI_USERNAME" \
|
||||||
|
--password "$PYPI_PASSWORD" \
|
||||||
|
--repository-url "$PROD_REPOSITORY" \
|
||||||
|
"$DIR/../python/dist/"*
|
||||||
|
|
225
third_party/flatbuffers/BUILD
vendored
Normal file
225
third_party/flatbuffers/BUILD
vendored
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
licenses(["notice"])
|
||||||
|
|
||||||
|
package(
|
||||||
|
default_visibility = ["//visibility:public"],
|
||||||
|
features = [
|
||||||
|
"-layering_check",
|
||||||
|
"-parse_headers",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
exports_files([
|
||||||
|
"LICENSE",
|
||||||
|
])
|
||||||
|
|
||||||
|
load(":build_defs.bzl", "flatbuffer_cc_library")
|
||||||
|
|
||||||
|
# Public flatc library to compile flatbuffer files at runtime.
|
||||||
|
cc_library(
|
||||||
|
name = "flatbuffers",
|
||||||
|
srcs = [
|
||||||
|
"src/code_generators.cpp",
|
||||||
|
"src/idl_gen_fbs.cpp",
|
||||||
|
"src/idl_gen_general.cpp",
|
||||||
|
"src/idl_gen_text.cpp",
|
||||||
|
"src/idl_parser.cpp",
|
||||||
|
"src/reflection.cpp",
|
||||||
|
"src/util.cpp",
|
||||||
|
],
|
||||||
|
hdrs = [":public_headers"],
|
||||||
|
includes = ["include/"],
|
||||||
|
linkstatic = 1,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Public C++ headers for the Flatbuffers library.
|
||||||
|
filegroup(
|
||||||
|
name = "public_headers",
|
||||||
|
srcs = [
|
||||||
|
"include/flatbuffers/base.h",
|
||||||
|
"include/flatbuffers/code_generators.h",
|
||||||
|
"include/flatbuffers/flatbuffers.h",
|
||||||
|
"include/flatbuffers/flexbuffers.h",
|
||||||
|
"include/flatbuffers/hash.h",
|
||||||
|
"include/flatbuffers/idl.h",
|
||||||
|
"include/flatbuffers/minireflect.h",
|
||||||
|
"include/flatbuffers/reflection.h",
|
||||||
|
"include/flatbuffers/reflection_generated.h",
|
||||||
|
"include/flatbuffers/stl_emulation.h",
|
||||||
|
"include/flatbuffers/util.h",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Public flatc compiler library.
|
||||||
|
cc_library(
|
||||||
|
name = "flatc_library",
|
||||||
|
srcs = [
|
||||||
|
"src/code_generators.cpp",
|
||||||
|
"src/flatc.cpp",
|
||||||
|
"src/idl_gen_fbs.cpp",
|
||||||
|
"src/idl_parser.cpp",
|
||||||
|
"src/reflection.cpp",
|
||||||
|
"src/util.cpp",
|
||||||
|
],
|
||||||
|
hdrs = [
|
||||||
|
"include/flatbuffers/flatc.h",
|
||||||
|
":public_headers",
|
||||||
|
],
|
||||||
|
includes = [
|
||||||
|
"grpc/",
|
||||||
|
"include/",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Public flatc compiler.
|
||||||
|
cc_binary(
|
||||||
|
name = "flatc",
|
||||||
|
srcs = [
|
||||||
|
"grpc/src/compiler/config.h",
|
||||||
|
"grpc/src/compiler/cpp_generator.cc",
|
||||||
|
"grpc/src/compiler/cpp_generator.h",
|
||||||
|
"grpc/src/compiler/go_generator.cc",
|
||||||
|
"grpc/src/compiler/go_generator.h",
|
||||||
|
"grpc/src/compiler/java_generator.cc",
|
||||||
|
"grpc/src/compiler/java_generator.h",
|
||||||
|
"grpc/src/compiler/schema_interface.h",
|
||||||
|
"src/flatc_main.cpp",
|
||||||
|
"src/idl_gen_cpp.cpp",
|
||||||
|
"src/idl_gen_dart.cpp",
|
||||||
|
"src/idl_gen_general.cpp",
|
||||||
|
"src/idl_gen_kotlin.cpp",
|
||||||
|
"src/idl_gen_go.cpp",
|
||||||
|
"src/idl_gen_grpc.cpp",
|
||||||
|
"src/idl_gen_js_ts.cpp",
|
||||||
|
"src/idl_gen_json_schema.cpp",
|
||||||
|
"src/idl_gen_lobster.cpp",
|
||||||
|
"src/idl_gen_lua.cpp",
|
||||||
|
"src/idl_gen_php.cpp",
|
||||||
|
"src/idl_gen_python.cpp",
|
||||||
|
"src/idl_gen_rust.cpp",
|
||||||
|
"src/idl_gen_text.cpp",
|
||||||
|
"src/util.cpp",
|
||||||
|
],
|
||||||
|
includes = [
|
||||||
|
"grpc/",
|
||||||
|
"include/",
|
||||||
|
],
|
||||||
|
deps = [
|
||||||
|
":flatc_library",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "runtime_cc",
|
||||||
|
hdrs = [
|
||||||
|
"include/flatbuffers/base.h",
|
||||||
|
"include/flatbuffers/flatbuffers.h",
|
||||||
|
"include/flatbuffers/flexbuffers.h",
|
||||||
|
"include/flatbuffers/stl_emulation.h",
|
||||||
|
"include/flatbuffers/util.h",
|
||||||
|
],
|
||||||
|
includes = ["include/"],
|
||||||
|
linkstatic = 1,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test binary.
|
||||||
|
cc_test(
|
||||||
|
name = "flatbuffers_test",
|
||||||
|
testonly = 1,
|
||||||
|
srcs = [
|
||||||
|
"include/flatbuffers/minireflect.h",
|
||||||
|
"include/flatbuffers/registry.h",
|
||||||
|
"src/code_generators.cpp",
|
||||||
|
"src/idl_gen_fbs.cpp",
|
||||||
|
"src/idl_gen_general.cpp",
|
||||||
|
"src/idl_gen_text.cpp",
|
||||||
|
"src/idl_parser.cpp",
|
||||||
|
"src/reflection.cpp",
|
||||||
|
"src/util.cpp",
|
||||||
|
"tests/namespace_test/namespace_test1_generated.h",
|
||||||
|
"tests/namespace_test/namespace_test2_generated.h",
|
||||||
|
"tests/native_type_test_impl.h",
|
||||||
|
"tests/native_type_test_impl.cpp",
|
||||||
|
"tests/test.cpp",
|
||||||
|
"tests/test_assert.cpp",
|
||||||
|
"tests/test_assert.h",
|
||||||
|
"tests/test_builder.cpp",
|
||||||
|
"tests/test_builder.h",
|
||||||
|
"tests/union_vector/union_vector_generated.h",
|
||||||
|
":public_headers",
|
||||||
|
],
|
||||||
|
copts = [
|
||||||
|
"-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE",
|
||||||
|
"-DBAZEL_TEST_DATA_PATH",
|
||||||
|
],
|
||||||
|
data = [
|
||||||
|
":tests/include_test/include_test1.fbs",
|
||||||
|
":tests/include_test/sub/include_test2.fbs",
|
||||||
|
":tests/monster_test.bfbs",
|
||||||
|
":tests/monster_test.fbs",
|
||||||
|
":tests/monsterdata_test.golden",
|
||||||
|
":tests/monsterdata_test.json",
|
||||||
|
":tests/prototest/imported.proto",
|
||||||
|
":tests/prototest/test.golden",
|
||||||
|
":tests/prototest/test.proto",
|
||||||
|
":tests/prototest/test_union.golden",
|
||||||
|
":tests/unicode_test.json",
|
||||||
|
":tests/union_vector/union_vector.fbs",
|
||||||
|
":tests/union_vector/union_vector.json",
|
||||||
|
":tests/monster_extra.fbs",
|
||||||
|
":tests/monsterdata_extra.json",
|
||||||
|
":tests/arrays_test.bfbs",
|
||||||
|
":tests/arrays_test.fbs",
|
||||||
|
":tests/arrays_test.golden",
|
||||||
|
":tests/native_type_test.fbs",
|
||||||
|
],
|
||||||
|
includes = [
|
||||||
|
"include/",
|
||||||
|
"tests/",
|
||||||
|
],
|
||||||
|
deps = [
|
||||||
|
":monster_extra_cc_fbs",
|
||||||
|
":monster_test_cc_fbs",
|
||||||
|
":arrays_test_cc_fbs",
|
||||||
|
":native_type_test_cc_fbs",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test bzl rules
|
||||||
|
|
||||||
|
flatbuffer_cc_library(
|
||||||
|
name = "monster_test_cc_fbs",
|
||||||
|
srcs = ["tests/monster_test.fbs"],
|
||||||
|
include_paths = ["tests/include_test"],
|
||||||
|
includes = [
|
||||||
|
"tests/include_test/include_test1.fbs",
|
||||||
|
"tests/include_test/sub/include_test2.fbs",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
flatbuffer_cc_library(
|
||||||
|
name = "monster_extra_cc_fbs",
|
||||||
|
srcs = ["tests/monster_extra.fbs"],
|
||||||
|
)
|
||||||
|
|
||||||
|
flatbuffer_cc_library(
|
||||||
|
name = "arrays_test_cc_fbs",
|
||||||
|
srcs = ["tests/arrays_test.fbs"],
|
||||||
|
flatc_args = [
|
||||||
|
"--gen-object-api",
|
||||||
|
"--gen-compare",
|
||||||
|
"--no-includes",
|
||||||
|
"--gen-mutable",
|
||||||
|
"--reflect-names",
|
||||||
|
"--cpp-ptr-type flatbuffers::unique_ptr",
|
||||||
|
"--scoped-enums" ],
|
||||||
|
)
|
||||||
|
|
||||||
|
flatbuffer_cc_library(
|
||||||
|
name = "native_type_test_cc_fbs",
|
||||||
|
srcs = ["tests/native_type_test.fbs"],
|
||||||
|
flatc_args = [
|
||||||
|
"--gen-object-api",
|
||||||
|
"--gen-mutable",
|
||||||
|
"--cpp-ptr-type flatbuffers::unique_ptr" ],
|
||||||
|
)
|
||||||
|
|
152
third_party/flatbuffers/CMake/BuildFlatBuffers.cmake
vendored
Normal file
152
third_party/flatbuffers/CMake/BuildFlatBuffers.cmake
vendored
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
# Copyright 2015 Google Inc. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# General function to create FlatBuffer build rules for the given list of
|
||||||
|
# schemas.
|
||||||
|
#
|
||||||
|
# flatbuffers_schemas: A list of flatbuffer schema files to process.
|
||||||
|
#
|
||||||
|
# schema_include_dirs: A list of schema file include directories, which will be
|
||||||
|
# passed to flatc via the -I parameter.
|
||||||
|
#
|
||||||
|
# custom_target_name: The generated files will be added as dependencies for a
|
||||||
|
# new custom target with this name. You should add that target as a dependency
|
||||||
|
# for your main target to ensure these files are built. You can also retrieve
|
||||||
|
# various properties from this target, such as GENERATED_INCLUDES_DIR,
|
||||||
|
# BINARY_SCHEMAS_DIR, and COPY_TEXT_SCHEMAS_DIR.
|
||||||
|
#
|
||||||
|
# additional_dependencies: A list of additional dependencies that you'd like
|
||||||
|
# all generated files to depend on. Pass in a blank string if you have none.
|
||||||
|
#
|
||||||
|
# generated_includes_dir: Where to generate the C++ header files for these
|
||||||
|
# schemas. The generated includes directory will automatically be added to
|
||||||
|
# CMake's include directories, and will be where generated header files are
|
||||||
|
# placed. This parameter is optional; pass in empty string if you don't want to
|
||||||
|
# generate include files for these schemas.
|
||||||
|
#
|
||||||
|
# binary_schemas_dir: If you specify an optional binary schema directory, binary
|
||||||
|
# schemas will be generated for these schemas as well, and placed into the given
|
||||||
|
# directory.
|
||||||
|
#
|
||||||
|
# copy_text_schemas_dir: If you want all text schemas (including schemas from
|
||||||
|
# all schema include directories) copied into a directory (for example, if you
|
||||||
|
# need them within your project to build JSON files), you can specify that
|
||||||
|
# folder here. All text schemas will be copied to that folder.
|
||||||
|
#
|
||||||
|
# IMPORTANT: Make sure you quote all list arguments you pass to this function!
|
||||||
|
# Otherwise CMake will only pass in the first element.
|
||||||
|
# Example: build_flatbuffers("${fb_files}" "${include_dirs}" target_name ...)
|
||||||
|
function(build_flatbuffers flatbuffers_schemas
|
||||||
|
schema_include_dirs
|
||||||
|
custom_target_name
|
||||||
|
additional_dependencies
|
||||||
|
generated_includes_dir
|
||||||
|
binary_schemas_dir
|
||||||
|
copy_text_schemas_dir)
|
||||||
|
|
||||||
|
# Test if including from FindFlatBuffers
|
||||||
|
if(FLATBUFFERS_FLATC_EXECUTABLE)
|
||||||
|
set(FLATC_TARGET "")
|
||||||
|
set(FLATC ${FLATBUFFERS_FLATC_EXECUTABLE})
|
||||||
|
else()
|
||||||
|
set(FLATC_TARGET flatc)
|
||||||
|
set(FLATC flatc)
|
||||||
|
endif()
|
||||||
|
set(FLATC_SCHEMA_ARGS --gen-mutable)
|
||||||
|
if(FLATBUFFERS_FLATC_SCHEMA_EXTRA_ARGS)
|
||||||
|
set(FLATC_SCHEMA_ARGS
|
||||||
|
${FLATBUFFERS_FLATC_SCHEMA_EXTRA_ARGS}
|
||||||
|
${FLATC_SCHEMA_ARGS}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(working_dir "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
|
||||||
|
set(schema_glob "*.fbs")
|
||||||
|
# Generate the include files parameters.
|
||||||
|
set(include_params "")
|
||||||
|
set(all_generated_files "")
|
||||||
|
foreach (include_dir ${schema_include_dirs})
|
||||||
|
set(include_params -I ${include_dir} ${include_params})
|
||||||
|
if (NOT ${copy_text_schemas_dir} STREQUAL "")
|
||||||
|
# Copy text schemas from dependent folders.
|
||||||
|
file(GLOB_RECURSE dependent_schemas ${include_dir}/${schema_glob})
|
||||||
|
foreach (dependent_schema ${dependent_schemas})
|
||||||
|
file(COPY ${dependent_schema} DESTINATION ${copy_text_schemas_dir})
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
foreach(schema ${flatbuffers_schemas})
|
||||||
|
get_filename_component(filename ${schema} NAME_WE)
|
||||||
|
# For each schema, do the things we requested.
|
||||||
|
if (NOT ${generated_includes_dir} STREQUAL "")
|
||||||
|
set(generated_include ${generated_includes_dir}/${filename}_generated.h)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${generated_include}
|
||||||
|
COMMAND ${FLATC} ${FLATC_SCHEMA_ARGS}
|
||||||
|
-o ${generated_includes_dir}
|
||||||
|
${include_params}
|
||||||
|
-c ${schema}
|
||||||
|
DEPENDS ${FLATC_TARGET} ${schema} ${additional_dependencies}
|
||||||
|
WORKING_DIRECTORY "${working_dir}")
|
||||||
|
list(APPEND all_generated_files ${generated_include})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT ${binary_schemas_dir} STREQUAL "")
|
||||||
|
set(binary_schema ${binary_schemas_dir}/${filename}.bfbs)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${binary_schema}
|
||||||
|
COMMAND ${FLATC} -b --schema
|
||||||
|
-o ${binary_schemas_dir}
|
||||||
|
${include_params}
|
||||||
|
${schema}
|
||||||
|
DEPENDS ${FLATC_TARGET} ${schema} ${additional_dependencies}
|
||||||
|
WORKING_DIRECTORY "${working_dir}")
|
||||||
|
list(APPEND all_generated_files ${binary_schema})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT ${copy_text_schemas_dir} STREQUAL "")
|
||||||
|
file(COPY ${schema} DESTINATION ${copy_text_schemas_dir})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Create a custom target that depends on all the generated files.
|
||||||
|
# This is the target that you can depend on to trigger all these
|
||||||
|
# to be built.
|
||||||
|
add_custom_target(${custom_target_name}
|
||||||
|
DEPENDS ${all_generated_files} ${additional_dependencies})
|
||||||
|
|
||||||
|
# Register the include directory we are using.
|
||||||
|
if (NOT ${generated_includes_dir} STREQUAL "")
|
||||||
|
include_directories(${generated_includes_dir})
|
||||||
|
set_property(TARGET ${custom_target_name}
|
||||||
|
PROPERTY GENERATED_INCLUDES_DIR
|
||||||
|
${generated_includes_dir})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Register the binary schemas dir we are using.
|
||||||
|
if (NOT ${binary_schemas_dir} STREQUAL "")
|
||||||
|
set_property(TARGET ${custom_target_name}
|
||||||
|
PROPERTY BINARY_SCHEMAS_DIR
|
||||||
|
${binary_schemas_dir})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Register the text schema copy dir we are using.
|
||||||
|
if (NOT ${copy_text_schemas_dir} STREQUAL "")
|
||||||
|
set_property(TARGET ${custom_target_name}
|
||||||
|
PROPERTY COPY_TEXT_SCHEMAS_DIR
|
||||||
|
${copy_text_schemas_dir})
|
||||||
|
endif()
|
||||||
|
endfunction()
|
4
third_party/flatbuffers/CMake/DESCRIPTION.txt
vendored
Normal file
4
third_party/flatbuffers/CMake/DESCRIPTION.txt
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
FlatBuffers is a cross platform serialization library architected for
|
||||||
|
maximum memory efficiency. It allows you to directly access serialized
|
||||||
|
data without parsing/unpacking it first, while still having great
|
||||||
|
forwards/backwards compatibility.
|
61
third_party/flatbuffers/CMake/FindFlatBuffers.cmake
vendored
Normal file
61
third_party/flatbuffers/CMake/FindFlatBuffers.cmake
vendored
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
# Copyright 2014 Stefan.Eilemann@epfl.ch
|
||||||
|
# Copyright 2014 Google Inc. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# Find the flatbuffers schema compiler
|
||||||
|
#
|
||||||
|
# Output Variables:
|
||||||
|
# * FLATBUFFERS_FLATC_EXECUTABLE the flatc compiler executable
|
||||||
|
# * FLATBUFFERS_FOUND
|
||||||
|
#
|
||||||
|
# Provides:
|
||||||
|
# * FLATBUFFERS_GENERATE_C_HEADERS(Name <files>) creates the C++ headers
|
||||||
|
# for the given flatbuffer schema files.
|
||||||
|
# Returns the header files in ${Name}_OUTPUTS
|
||||||
|
|
||||||
|
set(FLATBUFFERS_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
|
||||||
|
find_program(FLATBUFFERS_FLATC_EXECUTABLE NAMES flatc)
|
||||||
|
find_path(FLATBUFFERS_INCLUDE_DIR NAMES flatbuffers/flatbuffers.h)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(flatbuffers
|
||||||
|
DEFAULT_MSG FLATBUFFERS_FLATC_EXECUTABLE FLATBUFFERS_INCLUDE_DIR)
|
||||||
|
|
||||||
|
if(FLATBUFFERS_FOUND)
|
||||||
|
function(FLATBUFFERS_GENERATE_C_HEADERS Name)
|
||||||
|
set(FLATC_OUTPUTS)
|
||||||
|
foreach(FILE ${ARGN})
|
||||||
|
get_filename_component(FLATC_OUTPUT ${FILE} NAME_WE)
|
||||||
|
set(FLATC_OUTPUT
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${FLATC_OUTPUT}_generated.h")
|
||||||
|
list(APPEND FLATC_OUTPUTS ${FLATC_OUTPUT})
|
||||||
|
|
||||||
|
add_custom_command(OUTPUT ${FLATC_OUTPUT}
|
||||||
|
COMMAND ${FLATBUFFERS_FLATC_EXECUTABLE}
|
||||||
|
ARGS -c -o "${CMAKE_CURRENT_BINARY_DIR}/" ${FILE}
|
||||||
|
DEPENDS ${FILE}
|
||||||
|
COMMENT "Building C++ header for ${FILE}"
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
endforeach()
|
||||||
|
set(${Name}_OUTPUTS ${FLATC_OUTPUTS} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
set(FLATBUFFERS_INCLUDE_DIRS ${FLATBUFFERS_INCLUDE_DIR})
|
||||||
|
include_directories(${CMAKE_BINARY_DIR})
|
||||||
|
else()
|
||||||
|
set(FLATBUFFERS_INCLUDE_DIR)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include("${FLATBUFFERS_CMAKE_DIR}/BuildFlatBuffers.cmake")
|
4
third_party/flatbuffers/CMake/FlatbuffersConfig.cmake
vendored
Normal file
4
third_party/flatbuffers/CMake/FlatbuffersConfig.cmake
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/FlatbuffersTargets.cmake" OPTIONAL)
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/FlatcTargets.cmake" OPTIONAL)
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/FlatbuffersSharedTargets.cmake" OPTIONAL)
|
||||||
|
|
11
third_party/flatbuffers/CMake/FlatbuffersConfigVersion.cmake.in
vendored
Normal file
11
third_party/flatbuffers/CMake/FlatbuffersConfigVersion.cmake.in
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
set(PACKAGE_VERSION "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@")
|
||||||
|
|
||||||
|
# Check whether the requested PACKAGE_FIND_VERSION is compatible
|
||||||
|
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
|
||||||
|
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||||
|
else()
|
||||||
|
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||||
|
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
|
||||||
|
set(PACKAGE_VERSION_EXACT TRUE)
|
||||||
|
endif()
|
||||||
|
endif()
|
39
third_party/flatbuffers/CMake/PackageDebian.cmake
vendored
Normal file
39
third_party/flatbuffers/CMake/PackageDebian.cmake
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# ------------------- Debianization ---------------------
|
||||||
|
if (UNIX)
|
||||||
|
|
||||||
|
# Set build environment
|
||||||
|
SET(CPACK_GENERATOR "TGZ;DEB")
|
||||||
|
SET(CPACK_SOURCE_TGZ "ON")
|
||||||
|
|
||||||
|
# Common package information
|
||||||
|
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
|
||||||
|
"FlatBuffers is an efficient cross platform serialization library for C++, with support for Java, C# and Go. It was created at Google specifically for game development and other performance-critical applications.")
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/google/flatbuffers")
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Vitaly Isaev <vitalyisaev2@gmail.com>")
|
||||||
|
|
||||||
|
SET(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
|
||||||
|
SET(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
|
||||||
|
SET(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
|
||||||
|
SET(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_COMMIT}")
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
|
||||||
|
|
||||||
|
# Derive architecture
|
||||||
|
IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
|
||||||
|
FIND_PROGRAM(DPKG_CMD dpkg)
|
||||||
|
IF(NOT DPKG_CMD)
|
||||||
|
MESSAGE(STATUS "Can not find dpkg in your path, default to i386.")
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
|
||||||
|
ENDIF(NOT DPKG_CMD)
|
||||||
|
EXECUTE_PROCESS(COMMAND "${DPKG_CMD}" --print-architecture
|
||||||
|
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
ENDIF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
|
||||||
|
|
||||||
|
# Package name
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_NAME "flatbuffers")
|
||||||
|
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt)
|
||||||
|
SET(CPACK_PACKAGE_FILE_NAME
|
||||||
|
"${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
|
||||||
|
|
||||||
|
endif(UNIX)
|
34
third_party/flatbuffers/CMake/PackageRedhat.cmake
vendored
Normal file
34
third_party/flatbuffers/CMake/PackageRedhat.cmake
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
if (UNIX)
|
||||||
|
set(CPACK_GENERATOR "RPM")
|
||||||
|
set(CPACK_SOURCE_TGZ "ON")
|
||||||
|
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "FlatBuffers serialization library and schema compiler.")
|
||||||
|
|
||||||
|
set(CPACK_RPM_PACKAGE_HOMEPAGE "https://github.com/google/flatbuffers")
|
||||||
|
set(CPACK_RPM_PACKAGE_MAINTAINER "Marc Butler <mockbutler@gmail.com>")
|
||||||
|
|
||||||
|
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
|
||||||
|
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
|
||||||
|
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
|
||||||
|
set(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_COMMIT}")
|
||||||
|
set(CPACK_RPM_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
|
||||||
|
|
||||||
|
set(CPACK_RPM_PACKAGE_NAME "flatbuffers")
|
||||||
|
|
||||||
|
# Assume this is not a cross complation build.
|
||||||
|
if(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
|
||||||
|
set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}")
|
||||||
|
endif(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
|
||||||
|
|
||||||
|
set(CPACK_RPM_PACKAGE_VENDOR "Google, Inc.")
|
||||||
|
set(CPACK_RPM_PACKAGE_LICENSE "Apache 2.0")
|
||||||
|
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt)
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/CMake/DESCRIPTION.txt)
|
||||||
|
|
||||||
|
# This may reduce rpm compatiblity with very old systems.
|
||||||
|
set(CPACK_RPM_COMPRESSION_TYPE lzma)
|
||||||
|
|
||||||
|
set(CPACK_RPM_PACKAGE_NAME "flatbuffers")
|
||||||
|
set(CPACK_PACKAGE_FILE_NAME
|
||||||
|
"${CPACK_RPM_PACKAGE_NAME}_${CPACK_RPM_PACKAGE_VERSION}_${CPACK_RPM_PACKAGE_ARCHITECTURE}")
|
||||||
|
endif(UNIX)
|
11
third_party/flatbuffers/CMake/Version.cmake
vendored
Normal file
11
third_party/flatbuffers/CMake/Version.cmake
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
find_program(GIT git)
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${GIT} describe
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_DESCRIBE_DIRTY
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_DESCRIBE_DIRTY}")
|
||||||
|
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GIT_DESCRIBE_DIRTY}")
|
||||||
|
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GIT_DESCRIBE_DIRTY}")
|
||||||
|
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${GIT_DESCRIBE_DIRTY}")
|
482
third_party/flatbuffers/CMakeLists.txt
vendored
Normal file
482
third_party/flatbuffers/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,482 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
# generate compile_commands.json
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
include(CheckCXXSymbolExists)
|
||||||
|
|
||||||
|
project(FlatBuffers)
|
||||||
|
|
||||||
|
# NOTE: Code coverage only works on Linux & OSX.
|
||||||
|
option(FLATBUFFERS_CODE_COVERAGE "Enable the code coverage build option." OFF)
|
||||||
|
option(FLATBUFFERS_BUILD_TESTS "Enable the build of tests and samples." ON)
|
||||||
|
option(FLATBUFFERS_INSTALL "Enable the installation of targets." ON)
|
||||||
|
option(FLATBUFFERS_BUILD_FLATLIB "Enable the build of the flatbuffers library"
|
||||||
|
ON)
|
||||||
|
option(FLATBUFFERS_BUILD_FLATC "Enable the build of the flatbuffers compiler"
|
||||||
|
ON)
|
||||||
|
option(FLATBUFFERS_BUILD_FLATHASH "Enable the build of flathash" ON)
|
||||||
|
option(FLATBUFFERS_BUILD_GRPCTEST "Enable the build of grpctest" OFF)
|
||||||
|
option(FLATBUFFERS_BUILD_SHAREDLIB
|
||||||
|
"Enable the build of the flatbuffers shared library"
|
||||||
|
OFF)
|
||||||
|
option(FLATBUFFERS_LIBCXX_WITH_CLANG "Force libc++ when using Clang" ON)
|
||||||
|
# NOTE: Sanitizer check only works on Linux & OSX (gcc & llvm).
|
||||||
|
option(FLATBUFFERS_CODE_SANITIZE
|
||||||
|
"Add '-fsanitize' flags to 'flattests' and 'flatc' targets."
|
||||||
|
OFF)
|
||||||
|
option(FLATBUFFERS_PACKAGE_REDHAT
|
||||||
|
"Build an rpm using the 'package' target."
|
||||||
|
OFF)
|
||||||
|
option(FLATBUFFERS_PACKAGE_DEBIAN
|
||||||
|
"Build an deb using the 'package' target."
|
||||||
|
OFF)
|
||||||
|
|
||||||
|
if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS)
|
||||||
|
message(WARNING
|
||||||
|
"Cannot build tests without building the compiler. Tests will be disabled.")
|
||||||
|
set(FLATBUFFERS_BUILD_TESTS OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DEFINED FLATBUFFERS_MAX_PARSING_DEPTH)
|
||||||
|
# Override the default recursion depth limit.
|
||||||
|
add_definitions(-DFLATBUFFERS_MAX_PARSING_DEPTH=${FLATBUFFERS_MAX_PARSING_DEPTH})
|
||||||
|
message(STATUS "FLATBUFFERS_MAX_PARSING_DEPTH: ${FLATBUFFERS_MAX_PARSING_DEPTH}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Auto-detect locale-narrow 'strtod_l' and 'strtoull_l' functions.
|
||||||
|
if(NOT DEFINED FLATBUFFERS_LOCALE_INDEPENDENT)
|
||||||
|
set(FLATBUFFERS_LOCALE_INDEPENDENT 0)
|
||||||
|
if(MSVC)
|
||||||
|
check_cxx_symbol_exists(_strtof_l stdlib.h FLATBUFFERS_HAS_STRTOF_L)
|
||||||
|
check_cxx_symbol_exists(_strtoui64_l stdlib.h FLATBUFFERS_HAS_STRTOULL_L)
|
||||||
|
else()
|
||||||
|
check_cxx_symbol_exists(strtof_l stdlib.h FLATBUFFERS_HAS_STRTOF_L)
|
||||||
|
check_cxx_symbol_exists(strtoull_l stdlib.h FLATBUFFERS_HAS_STRTOULL_L)
|
||||||
|
endif()
|
||||||
|
if(FLATBUFFERS_HAS_STRTOF_L AND FLATBUFFERS_HAS_STRTOULL_L)
|
||||||
|
set(FLATBUFFERS_LOCALE_INDEPENDENT 1)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
add_definitions(-DFLATBUFFERS_LOCALE_INDEPENDENT=$<BOOL:${FLATBUFFERS_LOCALE_INDEPENDENT}>)
|
||||||
|
|
||||||
|
set(FlatBuffers_Library_SRCS
|
||||||
|
include/flatbuffers/code_generators.h
|
||||||
|
include/flatbuffers/base.h
|
||||||
|
include/flatbuffers/flatbuffers.h
|
||||||
|
include/flatbuffers/hash.h
|
||||||
|
include/flatbuffers/idl.h
|
||||||
|
include/flatbuffers/util.h
|
||||||
|
include/flatbuffers/reflection.h
|
||||||
|
include/flatbuffers/reflection_generated.h
|
||||||
|
include/flatbuffers/stl_emulation.h
|
||||||
|
include/flatbuffers/flexbuffers.h
|
||||||
|
include/flatbuffers/registry.h
|
||||||
|
include/flatbuffers/minireflect.h
|
||||||
|
src/code_generators.cpp
|
||||||
|
src/idl_parser.cpp
|
||||||
|
src/idl_gen_text.cpp
|
||||||
|
src/reflection.cpp
|
||||||
|
src/util.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set(FlatBuffers_Compiler_SRCS
|
||||||
|
${FlatBuffers_Library_SRCS}
|
||||||
|
src/idl_gen_cpp.cpp
|
||||||
|
src/idl_gen_dart.cpp
|
||||||
|
src/idl_gen_general.cpp
|
||||||
|
src/idl_gen_kotlin.cpp
|
||||||
|
src/idl_gen_go.cpp
|
||||||
|
src/idl_gen_js_ts.cpp
|
||||||
|
src/idl_gen_php.cpp
|
||||||
|
src/idl_gen_python.cpp
|
||||||
|
src/idl_gen_lobster.cpp
|
||||||
|
src/idl_gen_lua.cpp
|
||||||
|
src/idl_gen_rust.cpp
|
||||||
|
src/idl_gen_fbs.cpp
|
||||||
|
src/idl_gen_grpc.cpp
|
||||||
|
src/idl_gen_json_schema.cpp
|
||||||
|
src/flatc.cpp
|
||||||
|
src/flatc_main.cpp
|
||||||
|
grpc/src/compiler/schema_interface.h
|
||||||
|
grpc/src/compiler/cpp_generator.h
|
||||||
|
grpc/src/compiler/cpp_generator.cc
|
||||||
|
grpc/src/compiler/go_generator.h
|
||||||
|
grpc/src/compiler/go_generator.cc
|
||||||
|
grpc/src/compiler/java_generator.h
|
||||||
|
grpc/src/compiler/java_generator.cc
|
||||||
|
)
|
||||||
|
|
||||||
|
set(FlatHash_SRCS
|
||||||
|
include/flatbuffers/hash.h
|
||||||
|
src/flathash.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set(FlatBuffers_Tests_SRCS
|
||||||
|
${FlatBuffers_Library_SRCS}
|
||||||
|
src/idl_gen_fbs.cpp
|
||||||
|
tests/test.cpp
|
||||||
|
tests/test_assert.h
|
||||||
|
tests/test_assert.cpp
|
||||||
|
tests/test_builder.h
|
||||||
|
tests/test_builder.cpp
|
||||||
|
tests/native_type_test_impl.h
|
||||||
|
tests/native_type_test_impl.cpp
|
||||||
|
# file generate by running compiler on tests/monster_test.fbs
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h
|
||||||
|
# file generate by running compiler on tests/arrays_test.fbs
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/tests/arrays_test_generated.h
|
||||||
|
# file generate by running compiler on tests/native_type_test.fbs
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/tests/native_type_test_generated.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set(FlatBuffers_Sample_Binary_SRCS
|
||||||
|
include/flatbuffers/flatbuffers.h
|
||||||
|
samples/sample_binary.cpp
|
||||||
|
# file generated by running compiler on samples/monster.fbs
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set(FlatBuffers_Sample_Text_SRCS
|
||||||
|
${FlatBuffers_Library_SRCS}
|
||||||
|
samples/sample_text.cpp
|
||||||
|
# file generated by running compiler on samples/monster.fbs
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set(FlatBuffers_Sample_BFBS_SRCS
|
||||||
|
${FlatBuffers_Library_SRCS}
|
||||||
|
src/idl_gen_general.cpp
|
||||||
|
samples/sample_bfbs.cpp
|
||||||
|
# file generated by running compiler on samples/monster.fbs
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set(FlatBuffers_GRPCTest_SRCS
|
||||||
|
include/flatbuffers/flatbuffers.h
|
||||||
|
include/flatbuffers/grpc.h
|
||||||
|
include/flatbuffers/util.h
|
||||||
|
src/util.cpp
|
||||||
|
tests/monster_test.grpc.fb.h
|
||||||
|
tests/test_assert.h
|
||||||
|
tests/test_builder.h
|
||||||
|
tests/monster_test.grpc.fb.cc
|
||||||
|
tests/test_assert.cpp
|
||||||
|
tests/test_builder.cpp
|
||||||
|
grpc/tests/grpctest.cpp
|
||||||
|
grpc/tests/message_builder_test.cpp
|
||||||
|
# file generated by running compiler on samples/monster.fbs
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
||||||
|
)
|
||||||
|
|
||||||
|
# source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS})
|
||||||
|
# source_group(Tests FILES ${FlatBuffers_Tests_SRCS})
|
||||||
|
|
||||||
|
if(EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
||||||
|
# do not apply any global settings if the toolchain
|
||||||
|
# is being configured externally
|
||||||
|
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
|
||||||
|
elseif(APPLE)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Wno-unused-parameter")
|
||||||
|
set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
|
||||||
|
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
if(CYGWIN)
|
||||||
|
set(CMAKE_CXX_FLAGS
|
||||||
|
"${CMAKE_CXX_FLAGS} -std=gnu++11")
|
||||||
|
else(CYGWIN)
|
||||||
|
set(CMAKE_CXX_FLAGS
|
||||||
|
"${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||||
|
endif(CYGWIN)
|
||||||
|
set(CMAKE_CXX_FLAGS
|
||||||
|
"${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Werror=shadow")
|
||||||
|
set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
|
||||||
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4)
|
||||||
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
|
||||||
|
set(CMAKE_CXX_FLAGS
|
||||||
|
"${CMAKE_CXX_FLAGS} -faligned-new -Werror=implicit-fallthrough=2")
|
||||||
|
endif()
|
||||||
|
set(CMAKE_CXX_FLAGS
|
||||||
|
"${CMAKE_CXX_FLAGS} -Wunused-result -Werror=unused-result -Wunused-parameter -Werror=unused-parameter")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Certain platforms such as ARM do not use signed chars by default
|
||||||
|
# which causes issues with certain bounds checks.
|
||||||
|
set(CMAKE_CXX_FLAGS
|
||||||
|
"${CMAKE_CXX_FLAGS} -fsigned-char")
|
||||||
|
|
||||||
|
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
|
||||||
|
set(CMAKE_CXX_FLAGS
|
||||||
|
"${CMAKE_CXX_FLAGS} -std=c++0x -Wall -pedantic -Werror -Wextra -Wno-unused-parameter")
|
||||||
|
set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
|
||||||
|
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.8)
|
||||||
|
list(APPEND FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wimplicit-fallthrough" "-Wextra-semi" "-Werror=unused-private-field") # enable warning
|
||||||
|
endif()
|
||||||
|
if(FLATBUFFERS_LIBCXX_WITH_CLANG)
|
||||||
|
if(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
||||||
|
set(CMAKE_CXX_FLAGS
|
||||||
|
"${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||||
|
endif()
|
||||||
|
if(NOT ("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD" OR
|
||||||
|
"${CMAKE_SYSTEM_NAME}" MATCHES "Linux"))
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS
|
||||||
|
"${CMAKE_EXE_LINKER_FLAGS} -lc++abi")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Certain platforms such as ARM do not use signed chars by default
|
||||||
|
# which causes issues with certain bounds checks.
|
||||||
|
set(CMAKE_CXX_FLAGS
|
||||||
|
"${CMAKE_CXX_FLAGS} -fsigned-char")
|
||||||
|
|
||||||
|
elseif(MSVC)
|
||||||
|
# Visual Studio pedantic build settings
|
||||||
|
# warning C4512: assignment operator could not be generated
|
||||||
|
# warning C4316: object allocated on the heap may not be aligned
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /wd4512 /wd4316")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FLATBUFFERS_CODE_COVERAGE)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS
|
||||||
|
"${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
function(add_fsanitize_to_target _target _sanitizer)
|
||||||
|
# FLATBUFFERS_CODE_SANITIZE: boolean {ON,OFF,YES,NO} or string with list of sanitizer.
|
||||||
|
# List of sanitizer is string starts with '=': "=address,undefined,thread,memory".
|
||||||
|
if((${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") OR
|
||||||
|
((${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9"))
|
||||||
|
)
|
||||||
|
set(_sanitizer_flags "=address,undefined")
|
||||||
|
if(_sanitizer MATCHES "=.*")
|
||||||
|
# override default by user-defined sanitizer list
|
||||||
|
set(_sanitizer_flags ${_sanitizer})
|
||||||
|
endif()
|
||||||
|
target_compile_options(${_target} PRIVATE
|
||||||
|
-g -fsigned-char -fno-omit-frame-pointer
|
||||||
|
"-fsanitize${_sanitizer_flags}")
|
||||||
|
target_link_libraries(${_target} PRIVATE
|
||||||
|
"-fsanitize${_sanitizer_flags}")
|
||||||
|
set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||||
|
message(STATUS "Sanitizer ${_sanitizer_flags} added to ${_target}")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
if(BIICODE)
|
||||||
|
include(biicode/cmake/biicode.cmake)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include_directories(include)
|
||||||
|
include_directories(grpc)
|
||||||
|
|
||||||
|
if(FLATBUFFERS_BUILD_FLATLIB)
|
||||||
|
add_library(flatbuffers STATIC ${FlatBuffers_Library_SRCS})
|
||||||
|
# CMake > 2.8.11: Attach header directory for when build via add_subdirectory().
|
||||||
|
target_include_directories(flatbuffers INTERFACE
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
|
||||||
|
target_compile_options(flatbuffers PRIVATE "${FLATBUFFERS_PRIVATE_CXX_FLAGS}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FLATBUFFERS_BUILD_FLATC)
|
||||||
|
add_executable(flatc ${FlatBuffers_Compiler_SRCS})
|
||||||
|
target_compile_options(flatc PRIVATE "${FLATBUFFERS_PRIVATE_CXX_FLAGS}")
|
||||||
|
if(FLATBUFFERS_CODE_SANITIZE AND NOT WIN32)
|
||||||
|
add_fsanitize_to_target(flatc ${FLATBUFFERS_CODE_SANITIZE})
|
||||||
|
endif()
|
||||||
|
if(NOT FLATBUFFERS_FLATC_EXECUTABLE)
|
||||||
|
set(FLATBUFFERS_FLATC_EXECUTABLE $<TARGET_FILE:flatc>)
|
||||||
|
endif()
|
||||||
|
if(MSVC)
|
||||||
|
# Make flatc.exe not depend on runtime dlls for easy distribution.
|
||||||
|
target_compile_options(flatc PUBLIC $<$<CONFIG:Release>:/MT>)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FLATBUFFERS_BUILD_FLATHASH)
|
||||||
|
add_executable(flathash ${FlatHash_SRCS})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FLATBUFFERS_BUILD_SHAREDLIB)
|
||||||
|
add_library(flatbuffers_shared SHARED ${FlatBuffers_Library_SRCS})
|
||||||
|
|
||||||
|
# Shared object version: "major.minor.micro"
|
||||||
|
# - micro updated every release when there is no API/ABI changes
|
||||||
|
# - minor updated when there are additions in API/ABI
|
||||||
|
# - major (ABI number) updated when there are changes in ABI (or removals)
|
||||||
|
set(FlatBuffers_Library_SONAME_MAJOR "1")
|
||||||
|
set(FlatBuffers_Library_SONAME_FULL "${FlatBuffers_Library_SONAME_MAJOR}.11.0")
|
||||||
|
set_target_properties(flatbuffers_shared PROPERTIES OUTPUT_NAME flatbuffers
|
||||||
|
SOVERSION "${FlatBuffers_Library_SONAME_MAJOR}"
|
||||||
|
VERSION "${FlatBuffers_Library_SONAME_FULL}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
function(compile_flatbuffers_schema_to_cpp_opt SRC_FBS OPT)
|
||||||
|
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
|
||||||
|
string(REGEX REPLACE "\\.fbs$" "_generated.h" GEN_HEADER ${SRC_FBS})
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${GEN_HEADER}
|
||||||
|
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -c --gen-mutable
|
||||||
|
--gen-object-api -o "${SRC_FBS_DIR}"
|
||||||
|
--cpp-ptr-type flatbuffers::unique_ptr # Used to test with C++98 STLs
|
||||||
|
--reflect-names ${OPT}
|
||||||
|
-I "${CMAKE_CURRENT_SOURCE_DIR}/tests/include_test"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||||
|
DEPENDS flatc)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(compile_flatbuffers_schema_to_cpp SRC_FBS)
|
||||||
|
compile_flatbuffers_schema_to_cpp_opt(${SRC_FBS} "--no-includes;--gen-compare")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(compile_flatbuffers_schema_to_binary SRC_FBS)
|
||||||
|
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
|
||||||
|
string(REGEX REPLACE "\\.fbs$" ".bfbs" GEN_BINARY_SCHEMA ${SRC_FBS})
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${GEN_BINARY_SCHEMA}
|
||||||
|
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -b --schema -o "${SRC_FBS_DIR}"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||||
|
DEPENDS flatc)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
if(FLATBUFFERS_BUILD_TESTS)
|
||||||
|
compile_flatbuffers_schema_to_cpp(tests/monster_test.fbs)
|
||||||
|
compile_flatbuffers_schema_to_cpp_opt(tests/native_type_test.fbs "")
|
||||||
|
compile_flatbuffers_schema_to_cpp_opt(tests/arrays_test.fbs --scoped-enums)
|
||||||
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests)
|
||||||
|
add_executable(flattests ${FlatBuffers_Tests_SRCS})
|
||||||
|
set_property(TARGET flattests
|
||||||
|
PROPERTY COMPILE_DEFINITIONS FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
|
||||||
|
FLATBUFFERS_DEBUG_VERIFICATION_FAILURE=1)
|
||||||
|
if(FLATBUFFERS_CODE_SANITIZE)
|
||||||
|
if(WIN32)
|
||||||
|
target_compile_definitions(flattests PRIVATE FLATBUFFERS_MEMORY_LEAK_TRACKING)
|
||||||
|
message(STATUS "Sanitizer MSVC::_CrtDumpMemoryLeaks added to flattests")
|
||||||
|
else()
|
||||||
|
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
compile_flatbuffers_schema_to_cpp(samples/monster.fbs)
|
||||||
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/samples)
|
||||||
|
add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS})
|
||||||
|
add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
|
||||||
|
add_executable(flatsamplebfbs ${FlatBuffers_Sample_BFBS_SRCS})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FLATBUFFERS_BUILD_GRPCTEST)
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-shadow")
|
||||||
|
endif()
|
||||||
|
if(NOT GRPC_INSTALL_PATH)
|
||||||
|
message(SEND_ERROR "GRPC_INSTALL_PATH variable is not defined. See grpc/README.md")
|
||||||
|
endif()
|
||||||
|
if(NOT PROTOBUF_DOWNLOAD_PATH)
|
||||||
|
message(SEND_ERROR "PROTOBUF_DOWNLOAD_PATH variable is not defined. See grpc/README.md")
|
||||||
|
endif()
|
||||||
|
INCLUDE_DIRECTORIES(${GRPC_INSTALL_PATH}/include)
|
||||||
|
INCLUDE_DIRECTORIES(${PROTOBUF_DOWNLOAD_PATH}/src)
|
||||||
|
LINK_DIRECTORIES(${GRPC_INSTALL_PATH}/lib)
|
||||||
|
add_executable(grpctest ${FlatBuffers_GRPCTest_SRCS})
|
||||||
|
target_link_libraries(grpctest grpc++_unsecure grpc_unsecure gpr pthread dl)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(CMake/Version.cmake)
|
||||||
|
|
||||||
|
if(FLATBUFFERS_INSTALL)
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
install(DIRECTORY include/flatbuffers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||||
|
|
||||||
|
set(FB_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/flatbuffers")
|
||||||
|
|
||||||
|
configure_file(CMake/FlatbuffersConfigVersion.cmake.in FlatbuffersConfigVersion.cmake @ONLY)
|
||||||
|
install(
|
||||||
|
FILES "CMake/FlatbuffersConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/FlatbuffersConfigVersion.cmake"
|
||||||
|
DESTINATION ${FB_CMAKE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(FLATBUFFERS_BUILD_FLATLIB)
|
||||||
|
if(CMAKE_VERSION VERSION_LESS 3.0)
|
||||||
|
install(
|
||||||
|
TARGETS flatbuffers EXPORT FlatbuffersTargets
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
install(
|
||||||
|
TARGETS flatbuffers EXPORT FlatbuffersTargets
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(EXPORT FlatbuffersTargets
|
||||||
|
FILE FlatbuffersTargets.cmake
|
||||||
|
NAMESPACE flatbuffers::
|
||||||
|
DESTINATION ${FB_CMAKE_DIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FLATBUFFERS_BUILD_FLATC)
|
||||||
|
install(
|
||||||
|
TARGETS flatc EXPORT FlatcTargets
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
EXPORT FlatcTargets
|
||||||
|
FILE FlatcTargets.cmake
|
||||||
|
NAMESPACE flatbuffers::
|
||||||
|
DESTINATION ${FB_CMAKE_DIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FLATBUFFERS_BUILD_SHAREDLIB)
|
||||||
|
if(CMAKE_VERSION VERSION_LESS 3.0)
|
||||||
|
install(
|
||||||
|
TARGETS flatbuffers_shared EXPORT FlatbuffersSharedTargets
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
install(
|
||||||
|
TARGETS flatbuffers_shared EXPORT FlatbuffersSharedTargets
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(
|
||||||
|
EXPORT FlatbuffersSharedTargets
|
||||||
|
FILE FlatbuffersSharedTargets.cmake
|
||||||
|
NAMESPACE flatbuffers::
|
||||||
|
DESTINATION ${FB_CMAKE_DIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FLATBUFFERS_BUILD_TESTS)
|
||||||
|
enable_testing()
|
||||||
|
|
||||||
|
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests" DESTINATION
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
|
add_test(NAME flattests COMMAND flattests)
|
||||||
|
if(FLATBUFFERS_BUILD_GRPCTEST)
|
||||||
|
add_test(NAME grpctest COMMAND grpctest)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(CMake/BuildFlatBuffers.cmake)
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
# Use of CPack only supported on Linux systems.
|
||||||
|
if(FLATBUFFERS_PACKAGE_DEBIAN)
|
||||||
|
include(CMake/PackageDebian.cmake)
|
||||||
|
endif()
|
||||||
|
if (FLATBUFFERS_PACKAGE_REDHAT)
|
||||||
|
include(CMake/PackageRedhat.cmake)
|
||||||
|
endif()
|
||||||
|
include(CPack)
|
||||||
|
endif()
|
42
third_party/flatbuffers/CONTRIBUTING.md
vendored
Normal file
42
third_party/flatbuffers/CONTRIBUTING.md
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
Contributing {#contributing}
|
||||||
|
============
|
||||||
|
|
||||||
|
Want to contribute? Great! First, read this page (including the small print at
|
||||||
|
the end).
|
||||||
|
|
||||||
|
# Before you contribute
|
||||||
|
Before we can use your code, you must sign the
|
||||||
|
[Google Individual Contributor License Agreement](https://developers.google.com/open-source/cla/individual?csw=1)
|
||||||
|
(CLA), which you can do online. The CLA is necessary mainly because you own the
|
||||||
|
copyright to your changes, even after your contribution becomes part of our
|
||||||
|
codebase, so we need your permission to use and distribute your code. We also
|
||||||
|
need to be sure of various other things—for instance that you'll tell us if you
|
||||||
|
know that your code infringes on other people's patents. You don't have to sign
|
||||||
|
the CLA until after you've submitted your code for review and a member has
|
||||||
|
approved it, but you must do it before we can put your code into our codebase.
|
||||||
|
Before you start working on a larger contribution, you should get in touch with
|
||||||
|
us first through the issue tracker with your idea so that we can help out and
|
||||||
|
possibly guide you. Coordinating up front makes it much easier to avoid
|
||||||
|
frustration later on.
|
||||||
|
|
||||||
|
# Code reviews
|
||||||
|
All submissions, including submissions by project members, require review. We
|
||||||
|
use Github pull requests for this purpose.
|
||||||
|
|
||||||
|
Some tips for good pull requests:
|
||||||
|
* Use our code
|
||||||
|
[style guide](https://google.github.io/styleguide/cppguide.html).
|
||||||
|
When in doubt, try to stay true to the existing code of the project.
|
||||||
|
* Write a descriptive commit message. What problem are you solving and what
|
||||||
|
are the consequences? Where and what did you test? Some good tips:
|
||||||
|
[here](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message)
|
||||||
|
and [here](https://www.kernel.org/doc/Documentation/SubmittingPatches).
|
||||||
|
* If your PR consists of multiple commits which are successive improvements /
|
||||||
|
fixes to your first commit, consider squashing them into a single commit
|
||||||
|
(`git rebase -i`) such that your PR is a single commit on top of the current
|
||||||
|
HEAD. This make reviewing the code so much easier, and our history more
|
||||||
|
readable.
|
||||||
|
|
||||||
|
# The small print
|
||||||
|
Contributions made by corporations are covered by a different agreement than
|
||||||
|
the one above, the Software Grant and Corporate Contributor License Agreement.
|
202
third_party/flatbuffers/LICENSE.txt
vendored
Normal file
202
third_party/flatbuffers/LICENSE.txt
vendored
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright 2014 Google Inc.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
18
third_party/flatbuffers/WORKSPACE
vendored
Normal file
18
third_party/flatbuffers/WORKSPACE
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
workspace(name = "com_github_google_flatbuffers")
|
||||||
|
|
||||||
|
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||||
|
|
||||||
|
http_archive(
|
||||||
|
name = "io_bazel_rules_go",
|
||||||
|
urls = [
|
||||||
|
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/0.18.6/rules_go-0.18.6.tar.gz",
|
||||||
|
"https://github.com/bazelbuild/rules_go/releases/download/0.18.6/rules_go-0.18.6.tar.gz",
|
||||||
|
],
|
||||||
|
sha256 = "f04d2373bcaf8aa09bccb08a98a57e721306c8f6043a2a0ee610fd6853dcde3d",
|
||||||
|
)
|
||||||
|
|
||||||
|
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
|
||||||
|
|
||||||
|
go_rules_dependencies()
|
||||||
|
|
||||||
|
go_register_toolchains()
|
45
third_party/flatbuffers/android/AndroidManifest.xml
vendored
Normal file
45
third_party/flatbuffers/android/AndroidManifest.xml
vendored
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (c) 2013 Google, Inc.
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
-->
|
||||||
|
<!-- BEGIN_INCLUDE(manifest) -->
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.example.FlatBufferTest">
|
||||||
|
|
||||||
|
<uses-feature android:glEsVersion="0x00020000"></uses-feature>
|
||||||
|
|
||||||
|
<!-- This .apk has no Java code itself, so set hasCode to false. -->
|
||||||
|
<application android:label="@string/app_name"
|
||||||
|
android:hasCode="false"
|
||||||
|
android:allowBackup="false">
|
||||||
|
<!-- Our activity is the built-in NativeActivity framework class.
|
||||||
|
This will take care of integrating with our NDK code. -->
|
||||||
|
<activity android:name="android.app.NativeActivity"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:configChanges="orientation|keyboardHidden"
|
||||||
|
android:screenOrientation="landscape">
|
||||||
|
<!-- Tell NativeActivity the name of or .so -->
|
||||||
|
<meta-data android:name="android.app.lib_name"
|
||||||
|
android:value="FlatBufferTest" />
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
||||||
|
<!-- END_INCLUDE(manifest) -->
|
108
third_party/flatbuffers/android/build.gradle
vendored
Normal file
108
third_party/flatbuffers/android/build.gradle
vendored
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
// Copyright (c) 2017 Google, Inc.
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied
|
||||||
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
|
// arising from the use of this software.
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it
|
||||||
|
// freely, subject to the following restrictions:
|
||||||
|
// 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
// claim that you wrote the original software. If you use this software
|
||||||
|
// in a product, an acknowledgment in the product documentation would be
|
||||||
|
// appreciated but is not required.
|
||||||
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
// misrepresented as being the original software.
|
||||||
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:2.3.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 25
|
||||||
|
buildToolsVersion '25.0.2'
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
manifest.srcFile 'AndroidManifest.xml'
|
||||||
|
res.srcDirs = ['res']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
externalNativeBuild {
|
||||||
|
ndkBuild {
|
||||||
|
path "jni/Android.mk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId 'com.example.FlatBufferTest'
|
||||||
|
// This is the platform API where NativeActivity was introduced.
|
||||||
|
minSdkVersion 9
|
||||||
|
targetSdkVersion 25
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
externalNativeBuild {
|
||||||
|
ndkBuild {
|
||||||
|
targets "FlatBufferTest"
|
||||||
|
arguments "-j" + Runtime.getRuntime().availableProcessors()
|
||||||
|
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lintOptions {
|
||||||
|
abortOnError false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build with each STL variant.
|
||||||
|
productFlavors {
|
||||||
|
stlport {
|
||||||
|
applicationIdSuffix ".stlport"
|
||||||
|
versionNameSuffix "-stlport"
|
||||||
|
externalNativeBuild {
|
||||||
|
ndkBuild {
|
||||||
|
arguments "APP_STL=stlport_static"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gnustl {
|
||||||
|
applicationIdSuffix ".gnustl"
|
||||||
|
versionNameSuffix "-gnustl"
|
||||||
|
externalNativeBuild {
|
||||||
|
ndkBuild {
|
||||||
|
arguments "APP_STL=gnustl_static"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
libcpp {
|
||||||
|
applicationIdSuffix ".libcpp"
|
||||||
|
versionNameSuffix "-libcpp"
|
||||||
|
externalNativeBuild {
|
||||||
|
ndkBuild {
|
||||||
|
arguments "APP_STL=c++_static"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
6
third_party/flatbuffers/android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
third_party/flatbuffers/android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#Mon Jun 19 11:54:59 PDT 2017
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip
|
172
third_party/flatbuffers/android/gradlew
vendored
Executable file
172
third_party/flatbuffers/android/gradlew
vendored
Executable file
@ -0,0 +1,172 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=$(save "$@")
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
84
third_party/flatbuffers/android/gradlew.bat
vendored
Normal file
84
third_party/flatbuffers/android/gradlew.bat
vendored
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
65
third_party/flatbuffers/android/jni/Android.mk
vendored
Normal file
65
third_party/flatbuffers/android/jni/Android.mk
vendored
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
# Copyright (c) 2013 Google, Inc.
|
||||||
|
#
|
||||||
|
# This software is provided 'as-is', without any express or implied
|
||||||
|
# warranty. In no event will the authors be held liable for any damages
|
||||||
|
# arising from the use of this software.
|
||||||
|
# Permission is granted to anyone to use this software for any purpose,
|
||||||
|
# including commercial applications, and to alter it and redistribute it
|
||||||
|
# freely, subject to the following restrictions:
|
||||||
|
# 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
# claim that you wrote the original software. If you use this software
|
||||||
|
# in a product, an acknowledgment in the product documentation would be
|
||||||
|
# appreciated but is not required.
|
||||||
|
# 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
# misrepresented as being the original software.
|
||||||
|
# 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
LOCAL_PATH := $(call my-dir)/../..
|
||||||
|
|
||||||
|
include $(LOCAL_PATH)/android/jni/include.mk
|
||||||
|
LOCAL_PATH := $(call realpath-portable,$(LOCAL_PATH))
|
||||||
|
|
||||||
|
# Empty static library so that other projects can include just the basic
|
||||||
|
# FlatBuffers headers as a module.
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
LOCAL_MODULE := flatbuffers
|
||||||
|
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
|
||||||
|
LOCAL_EXPORT_CPPFLAGS := -std=c++11 -fexceptions -Wall \
|
||||||
|
-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
|
||||||
|
|
||||||
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
|
||||||
|
# static library that additionally includes text parsing/generation/reflection
|
||||||
|
# for projects that want richer functionality.
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
LOCAL_MODULE := flatbuffers_extra
|
||||||
|
LOCAL_SRC_FILES := src/idl_parser.cpp \
|
||||||
|
src/idl_gen_text.cpp \
|
||||||
|
src/reflection.cpp \
|
||||||
|
src/util.cpp \
|
||||||
|
src/code_generators.cpp
|
||||||
|
LOCAL_STATIC_LIBRARIES := flatbuffers
|
||||||
|
LOCAL_ARM_MODE := arm
|
||||||
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
|
||||||
|
# FlatBuffers test
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
LOCAL_MODULE := FlatBufferTest
|
||||||
|
LOCAL_SRC_FILES := android/jni/main.cpp \
|
||||||
|
tests/test.cpp \
|
||||||
|
tests/test_assert.h \
|
||||||
|
tests/test_builder.h \
|
||||||
|
tests/test_assert.cpp \
|
||||||
|
tests/test_builder.cpp \
|
||||||
|
tests/native_type_test_impl.h \
|
||||||
|
tests/native_type_test_impl.cpp \
|
||||||
|
src/idl_gen_fbs.cpp \
|
||||||
|
src/idl_gen_general.cpp
|
||||||
|
LOCAL_LDLIBS := -llog -landroid -latomic
|
||||||
|
LOCAL_STATIC_LIBRARIES := android_native_app_glue flatbuffers_extra
|
||||||
|
LOCAL_ARM_MODE := arm
|
||||||
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
|
|
||||||
|
$(call import-module,android/native_app_glue)
|
||||||
|
|
||||||
|
$(call import-add-path,$(LOCAL_PATH)/../..)
|
20
third_party/flatbuffers/android/jni/Application.mk
vendored
Normal file
20
third_party/flatbuffers/android/jni/Application.mk
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Copyright (c) 2014 Google, Inc.
|
||||||
|
#
|
||||||
|
# This software is provided 'as-is', without any express or implied
|
||||||
|
# warranty. In no event will the authors be held liable for any damages
|
||||||
|
# arising from the use of this software.
|
||||||
|
# Permission is granted to anyone to use this software for any purpose,
|
||||||
|
# including commercial applications, and to alter it and redistribute it
|
||||||
|
# freely, subject to the following restrictions:
|
||||||
|
# 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
# claim that you wrote the original software. If you use this software
|
||||||
|
# in a product, an acknowledgment in the product documentation would be
|
||||||
|
# appreciated but is not required.
|
||||||
|
# 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
# misrepresented as being the original software.
|
||||||
|
# 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
APP_PLATFORM := android-9
|
||||||
|
APP_PROJECT_PATH := $(call my-dir)/..
|
||||||
|
APP_STL ?= stlport_static
|
||||||
|
APP_ABI := armeabi-v7a
|
||||||
|
APP_CPPFLAGS += -std=c++11
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user