Runs scripts/format.sh

This commit is contained in:
Daniel J. Hofmann
2016-03-03 14:26:13 +01:00
committed by Patrick Niklaus
parent bb06e044f5
commit 7c30ea32bf
70 changed files with 457 additions and 399 deletions
+9 -6
View File
@@ -15,13 +15,16 @@ namespace api
struct MatchParameters : public RouteParameters
{
MatchParameters()
: RouteParameters(false, false, RouteParameters::GeometriesType::Polyline, RouteParameters::OverviewType::Simplified, {})
: RouteParameters(false,
false,
RouteParameters::GeometriesType::Polyline,
RouteParameters::OverviewType::Simplified,
{})
{
}
template<typename... Args>
MatchParameters(std::vector<unsigned> timestamps_,
Args... args_)
template <typename... Args>
MatchParameters(std::vector<unsigned> timestamps_, Args... args_)
: RouteParameters{std::forward<Args>(args_)...}, timestamps{std::move(timestamps_)}
{
}
@@ -29,10 +32,10 @@ struct MatchParameters : public RouteParameters
std::vector<unsigned> timestamps;
bool IsValid() const
{
return RouteParameters::IsValid() && (timestamps.empty() || timestamps.size() == coordinates.size());
return RouteParameters::IsValid() &&
(timestamps.empty() || timestamps.size() == coordinates.size());
}
};
}
}
}
+11 -8
View File
@@ -26,20 +26,23 @@ class NearestAPI final : public BaseAPI
{
}
void MakeResponse(const std::vector<std::vector<PhantomNodeWithDistance>> &phantom_nodes, util::json::Object& response) const
void MakeResponse(const std::vector<std::vector<PhantomNodeWithDistance>> &phantom_nodes,
util::json::Object &response) const
{
BOOST_ASSERT(phantom_nodes.size() == 1);
BOOST_ASSERT(parameters.coordinates.size() == 1);
util::json::Array waypoints;
waypoints.values.resize(phantom_nodes.front().size());
std::transform(phantom_nodes.front().begin(),
phantom_nodes.front().end(), waypoints.values.begin(), [this](const PhantomNodeWithDistance& phantom_with_distance)
{
auto waypoint = MakeWaypoint(parameters.coordinates.front(), phantom_with_distance.phantom_node);
waypoint.values["distance"] = phantom_with_distance.distance;
return waypoint;
});
std::transform(phantom_nodes.front().begin(), phantom_nodes.front().end(),
waypoints.values.begin(),
[this](const PhantomNodeWithDistance &phantom_with_distance)
{
auto waypoint = MakeWaypoint(parameters.coordinates.front(),
phantom_with_distance.phantom_node);
waypoint.values["distance"] = phantom_with_distance.distance;
return waypoint;
});
response.values["code"] = "ok";
response.values["waypoints"] = std::move(waypoints);
+5 -4
View File
@@ -28,14 +28,15 @@ struct RouteParameters : public BaseParameters
RouteParameters() = default;
template<typename... Args>
template <typename... Args>
RouteParameters(const bool steps_,
const bool alternative_,
const GeometriesType geometries_,
const OverviewType overview_,
std::vector<boost::optional<bool>> uturns_, Args... args_)
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternative{alternative_}, geometries{geometries_},
overview{overview_}, uturns{std::move(uturns_)}
std::vector<boost::optional<bool>> uturns_,
Args... args_)
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternative{alternative_},
geometries{geometries_}, overview{overview_}, uturns{std::move(uturns_)}
{
}
+13 -10
View File
@@ -37,7 +37,8 @@ class TableAPI final : public BaseAPI
util::json::Object &response) const
{
auto number_of_sources = parameters.sources.size();
auto number_of_destinations = parameters.destinations.size();;
auto number_of_destinations = parameters.destinations.size();
;
// symmetric case
if (parameters.sources.empty())
@@ -60,7 +61,8 @@ class TableAPI final : public BaseAPI
response.values["destinations"] = MakeWaypoints(phantoms, parameters.destinations);
}
response.values["durations"] = MakeTable(durations, number_of_sources, number_of_destinations);
response.values["durations"] =
MakeTable(durations, number_of_sources, number_of_destinations);
response.values["code"] = "ok";
}
@@ -105,14 +107,15 @@ class TableAPI final : public BaseAPI
auto row_begin_iterator = values.begin() + (row * number_of_columns);
auto row_end_iterator = values.begin() + ((row + 1) * number_of_columns);
json_row.values.resize(number_of_columns);
std::transform(row_begin_iterator, row_end_iterator, json_row.values.begin(), [](const EdgeWeight duration)
{
if (duration == INVALID_EDGE_WEIGHT)
{
return util::json::Value(util::json::Null());
}
return util::json::Value(util::json::Number(duration / 10.));
});
std::transform(row_begin_iterator, row_end_iterator, json_row.values.begin(),
[](const EdgeWeight duration)
{
if (duration == INVALID_EDGE_WEIGHT)
{
return util::json::Value(util::json::Null());
}
return util::json::Value(util::json::Number(duration / 10.));
});
json_table.values.push_back(std::move(json_row));
}
return json_table;
+1 -5
View File
@@ -15,12 +15,8 @@ struct TileParameters final
unsigned z;
// FIXME check if x and y work with z
bool IsValid()
{
return z < 20;
};
bool IsValid() { return z < 20; };
};
}
}
}
+1 -2
View File
@@ -14,9 +14,8 @@ namespace api
struct TripParameters : public RouteParameters
{
//bool IsValid() const; Falls back to base class
// bool IsValid() const; Falls back to base class
};
}
}
}