提交 9ba27fa1 编写于 作者: A Aaron Xiao 提交者: Jiangtao Hu

Map: Refactor PncMap code style.

上级 f2dab52a
......@@ -245,7 +245,7 @@ bool MapService::GetPoseWithLane(const double x, const double y, double *theta,
point.set_y(y);
double l;
LaneInfoConstPtr nearest_lane;
if (BaseMap()->get_nearest_lane(point, &nearest_lane, s, &l) < 0) {
if (BaseMap().get_nearest_lane(point, &nearest_lane, s, &l) < 0) {
AERROR << "Failed to get neareset lane!";
return false;
}
......
......@@ -81,7 +81,7 @@ class MapService {
double *s) const;
private:
const ::apollo::hdmap::HDMap *BaseMap() const {
const ::apollo::hdmap::HDMap& BaseMap() const {
return pnc_map_.HDMap();
}
......
......@@ -49,7 +49,7 @@ const double kDuplicatedPointsEpsilon = 1e-7;
// Maximum lateral error used in trajectory approximation.
const double kTrajectoryApproximationMaxError = 2.0;
void remove_duplicates(std::vector<common::math::Vec2d> *points) {
void RemoveDuplicates(std::vector<common::math::Vec2d> *points) {
CHECK_NOTNULL(points);
int count = 0;
const double limit = kDuplicatedPointsEpsilon * kDuplicatedPointsEpsilon;
......@@ -62,7 +62,7 @@ void remove_duplicates(std::vector<common::math::Vec2d> *points) {
points->resize(count);
}
void remove_duplicates(std::vector<hdmap::MapPathPoint> *points) {
void RemoveDuplicates(std::vector<hdmap::MapPathPoint> *points) {
CHECK_NOTNULL(points);
int count = 0;
const double limit = kDuplicatedPointsEpsilon * kDuplicatedPointsEpsilon;
......@@ -85,7 +85,7 @@ PncMap::PncMap(const std::string &map_file) {
AINFO << "map loaded, Map file: " << map_file;
}
bool PncMap::validate_routing(const RoutingResponse &routing) const {
bool PncMap::ValidateRouting(const RoutingResponse &routing) const {
const int num_routes = routing.route_size();
if (num_routes == 0) {
AERROR << "Route is empty.";
......@@ -178,7 +178,7 @@ bool PncMap::GetLaneSegmentsFromRouting(
<< forward_length << "] are invalid";
return false;
}
if (!validate_routing(routing)) {
if (!ValidateRouting(routing)) {
AERROR << "The provided routing result is invalid";
return false;
}
......@@ -395,7 +395,7 @@ bool PncMap::TruncateLaneSegments(
return true;
}
void PncMap::append_lane_to_points(
void PncMap::AppendLaneToPoints(
hdmap::LaneInfoConstPtr lane, const double start_s, const double end_s,
std::vector<hdmap::MapPathPoint> *const points) {
if (points == nullptr || start_s >= end_s) {
......@@ -429,8 +429,8 @@ void PncMap::append_lane_to_points(
}
}
bool PncMap::CreatePathFromRouting(
const ::apollo::routing::RoutingResponse &routing, Path *const path) const {
bool PncMap::CreatePathFromRouting(const RoutingResponse &routing,
Path *const path) const {
LaneSegments segments;
for (const auto &way : routing.route()) {
if (way.has_road_info() && !way.road_info().passage_region().empty()) {
......@@ -462,14 +462,13 @@ void PncMap::CreatePathFromLaneSegments(const LaneSegments &segments,
Path *const path) {
std::vector<hdmap::MapPathPoint> points;
for (const auto &segment : segments) {
append_lane_to_points(segment.lane, segment.start_s, segment.end_s,
&points);
AppendLaneToPoints(segment.lane, segment.start_s, segment.end_s, &points);
}
remove_duplicates(&points);
RemoveDuplicates(&points);
*path = hdmap::Path(points, segments, kTrajectoryApproximationMaxError);
}
const hdmap::HDMap *PncMap::HDMap() const { return &hdmap_; }
const hdmap::HDMap& PncMap::HDMap() const { return hdmap_; }
} // namespace hdmap
} // namespace apollo
......@@ -42,7 +42,7 @@ class PncMap {
virtual ~PncMap() = default;
explicit PncMap(const std::string &map_file);
const hdmap::HDMap *HDMap() const;
const hdmap::HDMap& HDMap() const;
/**
* @brief Warning: this function only works if there is no change lane in
......@@ -65,9 +65,8 @@ class PncMap {
double end_s,
LaneSegments *const truncated_segments) const;
bool validate_routing(
const ::apollo::routing::RoutingResponse &routing) const;
static void append_lane_to_points(
bool ValidateRouting(const ::apollo::routing::RoutingResponse &routing) const;
static void AppendLaneToPoints(
hdmap::LaneInfoConstPtr lane, const double start_s, const double end_s,
std::vector<hdmap::MapPathPoint> *const points);
hdmap::HDMap hdmap_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册