Apollo 11.0
自动驾驶开放平台
apollo::hdmap::adapter::CoordinateConvertTool类 参考

#include <coordinate_convert_tool.h>

apollo::hdmap::adapter::CoordinateConvertTool 的协作图:

Public 成员函数

 CoordinateConvertTool ()
 
 ~CoordinateConvertTool ()
 
Status SetConvertParam (const std::string &source_param, const std::string &dst_param)
 
Status CoordiateConvert (const double longitude, const double latitude, const double height_ellipsoid, double *utm_x, double *utm_y, double *utm_z)
 

静态 Public 成员函数

static CoordinateConvertTool * GetInstance ()
 

详细描述

在文件 coordinate_convert_tool.h 第 28 行定义.

构造及析构函数说明

◆ CoordinateConvertTool()

apollo::hdmap::adapter::CoordinateConvertTool::CoordinateConvertTool ( )

在文件 coordinate_convert_tool.cc 第 23 行定义.

24 : pj_from_(nullptr), pj_to_(nullptr) {}

◆ ~CoordinateConvertTool()

apollo::hdmap::adapter::CoordinateConvertTool::~CoordinateConvertTool ( )

在文件 coordinate_convert_tool.cc 第 26 行定义.

26 {
27 if (pj_from_) {
28 pj_free(pj_from_);
29 pj_from_ = nullptr;
30 }
31
32 if (pj_to_) {
33 pj_free(pj_to_);
34 pj_to_ = nullptr;
35 }
36}

成员函数说明

◆ CoordiateConvert()

Status apollo::hdmap::adapter::CoordinateConvertTool::CoordiateConvert ( const double  longitude,
const double  latitude,
const double  height_ellipsoid,
double *  utm_x,
double *  utm_y,
double *  utm_z 
)

在文件 coordinate_convert_tool.cc 第 72 行定义.

76 {
77 CHECK_NOTNULL(utm_x);
78 CHECK_NOTNULL(utm_y);
79 CHECK_NOTNULL(utm_z);
80 if (!pj_from_ || !pj_to_) {
81 std::string err_msg = "no transform param";
83 }
84
85 double gps_longitude = longitude;
86 double gps_latitude = latitude;
87 double gps_alt = height_ellipsoid;
88
89 if (pj_is_latlong(pj_from_)) {
90 gps_longitude *= DEG_TO_RAD;
91 gps_latitude *= DEG_TO_RAD;
92 gps_alt = height_ellipsoid;
93 }
94
95 if (0 != pj_transform(pj_from_, pj_to_, 1, 1, &gps_longitude, &gps_latitude,
96 &gps_alt)) {
97 std::string err_msg = "fail to transform coordinate";
99 }
100
101 if (pj_is_latlong(pj_to_)) {
102 gps_longitude *= RAD_TO_DEG;
103 gps_latitude *= RAD_TO_DEG;
104 }
105
106 *utm_x = gps_longitude;
107 *utm_y = gps_latitude;
108 *utm_z = gps_alt;
109
110 return Status::OK();
111}
static Status OK()
generate a success status.
Definition status.h:60
#define DEG_TO_RAD
#define RAD_TO_DEG

◆ GetInstance()

CoordinateConvertTool * apollo::hdmap::adapter::CoordinateConvertTool::GetInstance ( )
static

在文件 coordinate_convert_tool.cc 第 38 行定义.

38 {
39 static CoordinateConvertTool instance;
40 return &instance;
41}

◆ SetConvertParam()

Status apollo::hdmap::adapter::CoordinateConvertTool::SetConvertParam ( const std::string &  source_param,
const std::string &  dst_param 
)

在文件 coordinate_convert_tool.cc 第 43 行定义.

44 {
45 source_convert_param_ = source_param;
46 dst_convert_param_ = dst_param;
47 if (pj_from_) {
48 pj_free(pj_from_);
49 pj_from_ = nullptr;
50 }
51
52 if (pj_to_) {
53 pj_free(pj_to_);
54 pj_to_ = nullptr;
55 }
56
57 if (!(pj_from_ = pj_init_plus(source_convert_param_.c_str()))) {
58 std::string err_msg = "Fail to pj_init_plus " + source_convert_param_;
60 }
61
62 if (!(pj_to_ = pj_init_plus(dst_convert_param_.c_str()))) {
63 std::string err_msg = "Fail to pj_init_plus " + dst_convert_param_;
64 pj_free(pj_from_);
65 pj_from_ = nullptr;
67 }
68
69 return Status::OK();
70}

该类的文档由以下文件生成: