提交 3b14c9a3 编写于 作者: S sjiang2018 提交者: Qi Luo

routing: code clean.

上级 7b1b10d6
......@@ -147,17 +147,45 @@ double Routing::GetRoutingLength(const RoutingResponse& routing_response) {
}
bool Routing::GetParkingID(const PointENU& parking_point,
std::string& parking_space_id) {
std::string* parking_space_id) {
// search current parking space id associated with parking point.
constexpr double kDistance = 0.01; // meter
std::vector<ParkingSpaceInfoConstPtr> parking_spaces;
if (!hdmap_->GetParkingSpaces(parking_point, kDistance, &parking_spaces)) {
parking_space_id = parking_spaces.front()->id().id();
if (hdmap_->GetParkingSpaces(parking_point, kDistance, &parking_spaces) ==
0) {
*parking_space_id = parking_spaces.front()->id().id();
return true;
}
return false;
}
bool Routing::FillParkingID(RoutingResponse* routing_response) {
const auto& routing_request = routing_response->routing_request();
const bool has_parking_info = routing_request.has_parking_info();
const bool has_parking_id =
has_parking_info && routing_request.parking_info().has_parking_space_id();
// return early when has parking_id
if (has_parking_id) {
return true;
}
// set parking space ID when
// has parking info && has parking point && NOT has parking space id && get
// ID successfully
if (has_parking_info && routing_request.parking_info().has_parking_point()) {
const PointENU parking_point =
routing_request.parking_info().parking_point();
std::string parking_space_id;
if (GetParkingID(parking_point, &parking_space_id)) {
routing_response->mutable_routing_request()
->mutable_parking_info()
->set_parking_space_id(parking_space_id);
return true;
}
}
ADEBUG << "Failed to fill parking ID";
return false;
}
bool Routing::Process(const std::shared_ptr<RoutingRequest>& routing_request,
RoutingResponse* const routing_response) {
CHECK_NOTNULL(routing_response);
......@@ -174,44 +202,7 @@ bool Routing::Process(const std::shared_ptr<RoutingRequest>& routing_request,
min_routing_length = routing_length;
}
}
// set parking space ID when
// has parking info && has parking point && NOT has parking space id && get
// ID successfully
// if (routing_response->routing_request().has_parking_info() &&
// routing_response->routing_request()
// .parking_info()
// .has_parking_point() &&
// (!routing_response->routing_request()
// .parking_info()
// .has_parking_space_id())) {
// const PointENU parking_point =
// routing_response->routing_request().parking_info().parking_point();
// std::string parking_space_id;
// if (GetParkingID(parking_point, parking_space_id)) {
// routing_response->mutable_routing_request()
// ->mutable_parking_info()
// ->set_parking_space_id(parking_space_id);
// }
// }
const auto& routing_request = routing_response->routing_request();
const bool has_parking_info = routing_request.has_parking_info();
const bool has_parking_point =
has_parking_info && routing_request.parking_info().has_parking_point();
const bool has_parking_id =
has_parking_info &&
routing_request.parking_info().has_parking_space_id();
const PointENU parking_point =
has_parking_point ? routing_request.parking_info().parking_point()
: PointENU();
std::string parking_space_id;
const bool ret_get_parking_id =
GetParkingID(parking_point, parking_space_id);
if (has_parking_info && has_parking_point && !has_parking_id &&
ret_get_parking_id) {
routing_response->mutable_routing_request()
->mutable_parking_info()
->set_parking_space_id(parking_space_id);
}
FillParkingID(routing_response);
}
if (min_routing_length < std::numeric_limits<double>::max()) {
monitor_logger_buffer_.INFO("Routing success!");
......
......@@ -63,10 +63,12 @@ class Routing {
std::vector<RoutingRequest> FillLaneInfoIfMissing(
const RoutingRequest &routing_request);
double GetRoutingLength(const RoutingResponse &routing_response);
bool GetParkingID(const apollo::common::PointENU &parking_point,
std::string &parking_space_id);
std::string *parking_space_id);
double GetRoutingLength(const RoutingResponse &routing_response);
bool FillParkingID(RoutingResponse *routing_response);
private:
std::unique_ptr<Navigator> navigator_ptr_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册