Apply micro-optimisation for Table & Trip APIs (#6949)
This commit is contained in:
parent
a0eda3e7d7
commit
feb9389436
@ -24,6 +24,7 @@
|
|||||||
- NodeJS:
|
- NodeJS:
|
||||||
- CHANGED: Use node-api instead of NAN. [#6452](https://github.com/Project-OSRM/osrm-backend/pull/6452)
|
- CHANGED: Use node-api instead of NAN. [#6452](https://github.com/Project-OSRM/osrm-backend/pull/6452)
|
||||||
- Misc:
|
- Misc:
|
||||||
|
- CHANGED: Apply micro-optimisation for Table & Trip APIs. [#6949](https://github.com/Project-OSRM/osrm-backend/pull/6949)
|
||||||
- CHANGED: Apply micro-optimisation for Route API. [#6948](https://github.com/Project-OSRM/osrm-backend/pull/6948)
|
- CHANGED: Apply micro-optimisation for Route API. [#6948](https://github.com/Project-OSRM/osrm-backend/pull/6948)
|
||||||
- CHANGED: Apply micro-optimisation for Match API. [#6945](https://github.com/Project-OSRM/osrm-backend/pull/6945)
|
- CHANGED: Apply micro-optimisation for Match API. [#6945](https://github.com/Project-OSRM/osrm-backend/pull/6945)
|
||||||
- CHANGED: Apply micro-optimisation for Nearest API. [#6944](https://github.com/Project-OSRM/osrm-backend/pull/6944)
|
- CHANGED: Apply micro-optimisation for Nearest API. [#6944](https://github.com/Project-OSRM/osrm-backend/pull/6944)
|
||||||
|
@ -179,7 +179,7 @@ class TableAPI final : public BaseAPI
|
|||||||
{
|
{
|
||||||
if (!parameters.skip_waypoints)
|
if (!parameters.skip_waypoints)
|
||||||
{
|
{
|
||||||
response.values["sources"] = MakeWaypoints(candidates);
|
response.values.emplace("sources", MakeWaypoints(candidates));
|
||||||
}
|
}
|
||||||
number_of_sources = candidates.size();
|
number_of_sources = candidates.size();
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ class TableAPI final : public BaseAPI
|
|||||||
{
|
{
|
||||||
if (!parameters.skip_waypoints)
|
if (!parameters.skip_waypoints)
|
||||||
{
|
{
|
||||||
response.values["sources"] = MakeWaypoints(candidates, parameters.sources);
|
response.values.emplace("sources", MakeWaypoints(candidates, parameters.sources));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ class TableAPI final : public BaseAPI
|
|||||||
{
|
{
|
||||||
if (!parameters.skip_waypoints)
|
if (!parameters.skip_waypoints)
|
||||||
{
|
{
|
||||||
response.values["destinations"] = MakeWaypoints(candidates);
|
response.values.emplace("destinations", MakeWaypoints(candidates));
|
||||||
}
|
}
|
||||||
number_of_destinations = candidates.size();
|
number_of_destinations = candidates.size();
|
||||||
}
|
}
|
||||||
@ -203,34 +203,37 @@ class TableAPI final : public BaseAPI
|
|||||||
{
|
{
|
||||||
if (!parameters.skip_waypoints)
|
if (!parameters.skip_waypoints)
|
||||||
{
|
{
|
||||||
response.values["destinations"] =
|
response.values.emplace("destinations",
|
||||||
MakeWaypoints(candidates, parameters.destinations);
|
MakeWaypoints(candidates, parameters.destinations));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameters.annotations & TableParameters::AnnotationsType::Duration)
|
if (parameters.annotations & TableParameters::AnnotationsType::Duration)
|
||||||
{
|
{
|
||||||
response.values["durations"] =
|
response.values.emplace(
|
||||||
MakeDurationTable(tables.first, number_of_sources, number_of_destinations);
|
"durations",
|
||||||
|
MakeDurationTable(tables.first, number_of_sources, number_of_destinations));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameters.annotations & TableParameters::AnnotationsType::Distance)
|
if (parameters.annotations & TableParameters::AnnotationsType::Distance)
|
||||||
{
|
{
|
||||||
response.values["distances"] =
|
response.values.emplace(
|
||||||
MakeDistanceTable(tables.second, number_of_sources, number_of_destinations);
|
"distances",
|
||||||
|
MakeDistanceTable(tables.second, number_of_sources, number_of_destinations));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameters.fallback_speed != from_alias<double>(INVALID_FALLBACK_SPEED) &&
|
if (parameters.fallback_speed != from_alias<double>(INVALID_FALLBACK_SPEED) &&
|
||||||
parameters.fallback_speed > 0)
|
parameters.fallback_speed > 0)
|
||||||
{
|
{
|
||||||
response.values["fallback_speed_cells"] = MakeEstimatesTable(fallback_speed_cells);
|
response.values.emplace("fallback_speed_cells",
|
||||||
|
MakeEstimatesTable(fallback_speed_cells));
|
||||||
}
|
}
|
||||||
|
|
||||||
response.values["code"] = "Ok";
|
response.values.emplace("code", "Ok");
|
||||||
auto data_timestamp = facade.GetTimestamp();
|
auto data_timestamp = facade.GetTimestamp();
|
||||||
if (!data_timestamp.empty())
|
if (!data_timestamp.empty())
|
||||||
{
|
{
|
||||||
response.values["data_version"] = data_timestamp;
|
response.values.emplace("data_version", data_timestamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,14 +79,14 @@ class TripAPI final : public RouteAPI
|
|||||||
}
|
}
|
||||||
if (!parameters.skip_waypoints)
|
if (!parameters.skip_waypoints)
|
||||||
{
|
{
|
||||||
response.values["waypoints"] = MakeWaypoints(sub_trips, candidates);
|
response.values.emplace("waypoints", MakeWaypoints(sub_trips, candidates));
|
||||||
}
|
}
|
||||||
response.values["trips"] = std::move(routes);
|
response.values.emplace("trips", std::move(routes));
|
||||||
response.values["code"] = "Ok";
|
response.values.emplace("code", "Ok");
|
||||||
auto data_timestamp = facade.GetTimestamp();
|
auto data_timestamp = facade.GetTimestamp();
|
||||||
if (!data_timestamp.empty())
|
if (!data_timestamp.empty())
|
||||||
{
|
{
|
||||||
response.values["data_version"] = data_timestamp;
|
response.values.emplace("data_version", data_timestamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,8 +151,8 @@ class TripAPI final : public RouteAPI
|
|||||||
BOOST_ASSERT(!trip_index.NotUsed());
|
BOOST_ASSERT(!trip_index.NotUsed());
|
||||||
|
|
||||||
auto waypoint = BaseAPI::MakeWaypoint(candidates[input_index]);
|
auto waypoint = BaseAPI::MakeWaypoint(candidates[input_index]);
|
||||||
waypoint.values["trips_index"] = trip_index.sub_trip_index;
|
waypoint.values.emplace("trips_index", trip_index.sub_trip_index);
|
||||||
waypoint.values["waypoint_index"] = trip_index.point_index;
|
waypoint.values.emplace("waypoint_index", trip_index.point_index);
|
||||||
waypoints.values.push_back(std::move(waypoint));
|
waypoints.values.push_back(std::move(waypoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user