123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- #ifndef algo_loc_common_h
- #define algo_loc_common_h
- #include <unordered_map>
- #include <deque>
- #include "point.h"
- /*
- * 基站id和基站坐标
- *
- * */
- struct site_point: point
- {
- unsigned int m_site_id; //分站号
- site_point():point(0.0,0.0), m_site_id(0)
- {}
- site_point(const point& p):point(p), m_site_id(0)
- {}
- site_point& operator=(const point& rhs)
- {
- this->x = rhs.x;
- this->y = rhs.y;
- this->z = rhs.z;
- return *this;
- }
- };
- /*
- * 基站构成的三角形
- * */
- struct triangle{
- std::vector<site_point> m_vertex; //三角形三个顶点
- triangle()
- {
- m_vertex.clear();
- std::vector<site_point>().swap(m_vertex);
- }
-
- /*
- * 求点P到三角形质心的距离
- *
- * */
- double get_distance(const point& p)
- {
- if(m_vertex.size() < 3 || m_vertex.size() > 3){
- return 0.0;
- }
- // 中心点坐标
- point _cp;
- for(auto it = m_vertex.cbegin(); it != m_vertex.cend(); ++it)
- {
- _cp.x += (*it).x;
- _cp.y += (*it).y;
- }
- _cp.x /= 3;
- _cp.y /= 3;
- return sqrt((p.x - _cp.x)*(p.x - _cp.x) + (p.y - _cp.y)*(p.y - _cp.y));
- }
- };
- struct algo_solution{
- std::shared_ptr<point> m_pos;
- std::shared_ptr<triangle> m_triangle;
- algo_solution(): m_pos(nullptr), m_triangle(nullptr)
- {}
- };
- struct pdoa_data{
- int site_id; // 分站号
- float distance; // 距离
- float pdoa; // pdoa值
- uint64_t loc_time; // 定位时间戳(毫秒级)
- pdoa_data(): site_id(0), distance(0.0), pdoa(0.0), loc_time(0)
- {}
- pdoa_data operator=(const pdoa_data& pd)
- {
- this->site_id = pd.site_id;
- this->distance = pd.distance;
- this->pdoa = pd.pdoa;
- this->loc_time = pd.loc_time;
- return *this;
- }
- };
- // 数据队列定义
- using msg_map = std::unordered_map<std::string, std::shared_ptr<loc_message>>;
- struct message_item{
- uint16_t m_card_stamp; // 卡的ct号
- msg_map m_msg_map;
- message_item(): m_card_stamp(0)
- {}
- };
- using msg_deque = std::deque<message_item>;
- const double EPS = 0.00001;
- const double SAFE = 3.0;
- #endif
|