270 {
271 google::InitGoogleLogging(argv[0]);
272 google::ParseCommandLineFlags(&argc, &argv, true);
274 bool valid_arg = false;
275
277
278 if (FLAGS_xy_to_sl) {
279 double x = FLAGS_x;
280 double y = FLAGS_y;
282 point.set_x(x);
283 point.set_y(y);
284 point.set_z(0);
285 std::string lane_id;
286 double s = 0.0;
287 double l = 0.0;
288 double heading = 0.0;
289 map_util.
PointToSL(point, &lane_id, &s, &l, &heading);
290 printf("lane_id[%s], s[%f], l[%f], heading[%f]\n", lane_id.c_str(), s, l,
291 heading);
293 valid_arg = true;
294 }
295 if (FLAGS_sl_to_xy) {
297 double heading = 0.0;
298 map_util.
SLToPoint(map_util.GetLane(FLAGS_lane), FLAGS_s, FLAGS_l, &point,
299 &heading);
300 printf(
"x[%f] y[%f], heading[%f]\n", point.
x(), point.
y(), heading);
302 valid_arg = true;
303 }
304 if (FLAGS_xy_to_lane) {
305 double s = 0.0;
306 double l = 0.0;
307 double heading = 0.0;
308 int ret = map_util.
LaneProjection({FLAGS_x, FLAGS_y}, FLAGS_lane, &s, &l,
309 &heading);
310 if (ret != 0) {
311 printf("lane_projection for x[%f], y[%f], lane_id[%s] failed\n", FLAGS_x,
312 FLAGS_y, FLAGS_lane.c_str());
313 return -1;
314 }
315 printf("lane[%s] s[%f], l[%f], heading[%f]\n", FLAGS_lane.c_str(), s, l,
316 heading);
318 valid_arg = true;
319 }
320 if (FLAGS_lane_to_lane) {
322 double src_heading = 0.0;
323 map_util.
SLToPoint(map_util.GetLane(FLAGS_from_lane), FLAGS_s, 0.0, &point,
324 &src_heading);
325 double target_s = 0.0;
326 double target_l = 0.0;
327 double target_heading = 0.0;
329 &target_s, &target_l, &target_heading);
330 if (ret != 0) {
331 printf("lane_projection for lane[%s], s[%f] to lane_id[%s] failed\n",
332 FLAGS_from_lane.c_str(), FLAGS_s, FLAGS_to_lane.c_str());
333 return -1;
334 }
335 printf("lane[%s] s[%f], l[%f], heading[%f]\n", FLAGS_to_lane.c_str(),
336 target_s, target_l, target_heading);
339 valid_arg = true;
340 }
341 if (!FLAGS_lane.empty()) {
342 const auto lane_ptr = map_util.GetLane(FLAGS_lane);
343 if (!lane_ptr) {
344 std::cout << "Could not find lane " << FLAGS_lane << " on map "
345 << map_file;
346 return 0;
347 }
349 valid_arg = true;
350 }
351 if (!FLAGS_overlap.empty()) {
353 valid_arg = true;
354 }
355 if (!FLAGS_signal_info.empty()) {
356 std::cout << "Signal: " << FLAGS_signal_info << std::endl;
357 map_util.
Print(map_util.GetSignal(FLAGS_signal_info)->signal());
358 valid_arg = true;
359 }
360 if (!FLAGS_dump_txt_map.empty()) {
364 valid_arg = true;
365 }
366 if (!FLAGS_dump_bin_map.empty()) {
371 valid_arg = true;
372 }
373 if (!valid_arg) {
374 std::cout << "usage: --map_dir map/file/directory/" << std::endl;
375 std::cout << "usage: --base_map_filename map_file_name" << std::endl;
376 std::cout << "usage: --dump_txt_map text_map_file" << std::endl;
377 std::cout << "usage: --dump_bin_map bin_map_file" << std::endl;
378 std::cout << "usage: --xy_to_sl --x x --y y" << std::endl;
379 std::cout << "usage: --sl_to_xy --lane lane_id --s s --l l" << std::endl;
380 std::cout << "usage: --xy_to_lane --x --y --lane" << std::endl;
381 std::cout
382 << "usage: --lane_to_lane --from_lane lane_id --s s --to_lane lane_id"
383 << std::endl;
384 std::cout << "usage: --lane lane_id" << std::endl;
385 std::cout << "usage: --signal_info signal_id" << std::endl;
386 std::cout << "usage: --overlap overlap_id" << std::endl;
387 }
388 return 0;
389}
int SLToPoint(LaneInfoConstPtr lane_ptr, const double s, const double l, PointENU *point, double *heading) const
void PrintLane(const std::string &lane_id)
void PrintOverlap(const std::string &overlap_id)
int LaneProjection(const apollo::common::math::Vec2d &vec2d, const std::string &lane_id, double *s, double *l, double *heading) const
int PointToSL(const PointENU &point, std::string *lane_id, double *s, double *l, double *heading) const
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
bool SetProtoToBinaryFile(const google::protobuf::Message &message, const std::string &file_name)
Sets the content of the file specified by the file_name to be the binary representation of the input ...
bool SetProtoToASCIIFile(const google::protobuf::Message &message, int file_descriptor)
std::string BaseMapFile()
get base map file path from flags.