area.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. #include <memory>
  2. #include <write-copy.h>
  3. #include "db_api/CDBSingletonDefine.h"
  4. #include "log.h"
  5. #include <area.h>
  6. #include "point.h"
  7. #include "monkey_car/monkeycar_area.h"
  8. #include "landmark.h"
  9. #include "area_business.h"
  10. #include <boost/algorithm/string/split.hpp>
  11. #include <boost/algorithm/string/classification.hpp>
  12. #include"module_service/module_area.h"
  13. template<> std::shared_ptr<area_list>
  14. single_base<area_list, int, std::shared_ptr<area>>::m_instance=std::make_shared<area_list>();
  15. struct underground_area:area
  16. {
  17. underground_area(int limit_count_person, int limit_time_person,double scale,int32_t mapid)
  18. :area(-1,limit_count_person,limit_time_person,scale,mapid,(1<<1)|(1<<2)|(1<<3)|(1<<4))
  19. {
  20. m_area_business_list=area_business::get_instance_list(m_area_type);
  21. }
  22. void db_load_card_count()
  23. {
  24. }
  25. };
  26. struct ground_area:area
  27. {
  28. };
  29. void area::on_hover(std::shared_ptr<area_hover>&a,std::shared_ptr<card_location_base>&c)
  30. {
  31. for(auto i:m_area_business_list)
  32. {
  33. i->on_hover(a,c,a->get_business_data(i->business_type()));
  34. }
  35. }
  36. void area::on_enter(std::shared_ptr<area_hover>&a,std::shared_ptr<card_location_base>&c)
  37. {
  38. log_info("on_enter..%d areaId:%d",c->m_id,m_id);
  39. for(auto i:m_area_business_list)
  40. {
  41. i->on_enter(a,c,a->get_business_data(i->business_type()));
  42. }
  43. }
  44. void area::on_leave(std::shared_ptr<area_hover>&a,std::shared_ptr<card_location_base>&c)
  45. {
  46. log_info("on_leave..%d areaId:%d",c->m_id,m_id);
  47. for(auto i:m_area_business_list)
  48. {
  49. i->on_leave(a,c,a->get_business_data(i->business_type()));
  50. }
  51. }
  52. bool area::in_area(const point & p)
  53. {
  54. if(m_bound.empty())
  55. return false;
  56. int counter = 0;
  57. double xinters;
  58. point p1,p2;
  59. p1 = m_bound[0];
  60. int size = m_bound.size();
  61. for (int i=1;i<= size;i++) {
  62. p2 = m_bound[i%size];
  63. if (p.y > std::min(p1.y,p2.y)) {
  64. if (p.y <= std::max(p1.y,p2.y)) {
  65. if (p.x <= std::max(p1.x,p2.x)) {
  66. if (p1.y != p2.y) {
  67. xinters = (p.y-p1.y)*(p2.x-p1.x)/(p2.y-p1.y)+p1.x;
  68. if (p1.x == p2.x || p.x <= xinters)
  69. counter++;
  70. }
  71. }
  72. }
  73. }
  74. p1 = p2;
  75. }
  76. return (counter % 2 == 0) ? false : true;
  77. }
  78. area_list::area_list()
  79. {
  80. }
  81. #if 0
  82. void area_list::init_monkeycar_area()
  83. {
  84. std::unordered_map<int,std::shared_ptr<area>> map;
  85. const char *sql = "SELECT a.area_id, a.name, a.map_id, a.area_type_id, a.path, c.scale,\
  86. over_count_person, over_count_vehicle, over_time_person, over_time_vehicle, over_speed_vehicle, is_attendance ,b.monkeycar_coordinate,b.monkeycar_speed \
  87. FROM dat_area a ,dat_monkeycar_base_info b ,dat_map c\
  88. where a.area_id = b.monkeycar_base_info_id and a.map_id = c.map_id;";
  89. std::string Error;
  90. YADB::CDBResultSet DBRes;
  91. sDBConnPool.Query(sql,DBRes,Error);
  92. if(!Error.empty())
  93. log_error("monkeycar area init Error,%s",Error.c_str());
  94. int nCount = DBRes.GetRecordCount( Error );
  95. if (nCount > 0)
  96. {
  97. log_info( "init_monkey area. The record count=%d", nCount );
  98. while ( DBRes.GetNextRecod(Error) )
  99. {
  100. int area_id = 0;
  101. DBRes.GetField( "area_id",area_id, Error );
  102. int map_id = 0;
  103. DBRes.GetField( "map_id",map_id, Error );
  104. unsigned int area_type_id = 0;
  105. DBRes.GetField( "area_type_id",area_type_id, Error );
  106. int over_count_person = 0;
  107. DBRes.GetField( "over_count_person",over_count_person, Error );
  108. int over_count_vehicle = 0;
  109. DBRes.GetField( "over_count_vehicle",over_count_vehicle, Error );
  110. int over_time_person = 0;
  111. DBRes.GetField( "over_time_person",over_time_person, Error );
  112. int over_time_vehicle = 0;
  113. DBRes.GetField( "over_time_vehicle",over_time_vehicle, Error );
  114. std::string path;
  115. DBRes.GetField( "path",path, Error );
  116. float monkeycar_speed = 0;
  117. DBRes.GetField( "monkeycar_speed",monkeycar_speed, Error );
  118. std::string monkeycar_coor;
  119. DBRes.GetField( "monkeycar_coordinate",monkeycar_coor, Error );
  120. float scale=0;
  121. DBRes.GetField( "scale",scale, Error );
  122. log_info("init_area : id:%d,path:%s",area_id, path.c_str());
  123. std::shared_ptr<db_area> da = std::make_shared<db_area>();
  124. da->m_default_speed = monkeycar_speed;
  125. da->m_point = init_path(monkeycar_coor);
  126. std::shared_ptr<area> ap = std::make_shared<monkey_area>(da,area_id,over_count_person,over_time_person,scale,map_id,area_type_id);
  127. ap->m_bound=init_path(path);
  128. for(const auto &p : ap->m_bound)
  129. log_info("point:monkey:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
  130. for(const auto &p : da->m_point)
  131. log_info("point:monkey_coor:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
  132. map.insert({area_id,ap});
  133. }
  134. }
  135. area_list::instance()->add(map);
  136. }
  137. #endif
  138. void area_list::init_monkeycar_area(int id)
  139. {
  140. std::string sql = "SELECT a.area_id, a.name, a.map_id, a.area_type_id, a.path, c.scale,\
  141. over_count_person, over_count_vehicle, over_time_person, over_time_vehicle,\
  142. over_speed_vehicle, is_attendance ,b.monkeycar_coordinate,b.monkeycar_speed \
  143. FROM dat_area a ,dat_monkeycar_base_info b ,dat_map c\
  144. where a.area_id = b.monkeycar_base_info_id and a.map_id = c.map_id";
  145. if(-1 == id)
  146. {
  147. sql.append(";");
  148. }
  149. else
  150. {
  151. sql.append(" AND a.area_id=");
  152. sql.append(std::to_string(id));
  153. sql.append(";");
  154. std_debug("基础数据 monkeycar area 增加或修改区域 sql=%s", sql.c_str());
  155. log_info("基础数据 monkeycar area 增加或修改区域 sql=%s", sql.c_str());
  156. }
  157. std::string Error;
  158. YADB::CDBResultSet DBRes;
  159. sDBConnPool.Query(sql.c_str(),DBRes,Error);
  160. int nCount = DBRes.GetRecordCount( Error );
  161. if (nCount < 1)
  162. {
  163. log_error("基础数据 monkeycar area 增加或修改失败,数据库中找不到: area_id=%d", id);
  164. return ;
  165. }
  166. std::unordered_map<int,std::shared_ptr<area>> map;
  167. while ( DBRes.GetNextRecod(Error) )
  168. {
  169. int area_id = 0;
  170. DBRes.GetField( "area_id",area_id, Error );
  171. int map_id = 0;
  172. DBRes.GetField( "map_id",map_id, Error );
  173. unsigned int area_type_id = 0;
  174. DBRes.GetField( "area_type_id",area_type_id, Error );
  175. int over_count_person = 0;
  176. DBRes.GetField( "over_count_person",over_count_person, Error );
  177. int over_count_vehicle = 0;
  178. DBRes.GetField( "over_count_vehicle",over_count_vehicle, Error );
  179. int over_time_person = 0;
  180. DBRes.GetField( "over_time_person",over_time_person, Error );
  181. int over_time_vehicle = 0;
  182. DBRes.GetField( "over_time_vehicle",over_time_vehicle, Error );
  183. std::string path;
  184. DBRes.GetField( "path",path, Error );
  185. double monkeycar_speed = 0;
  186. DBRes.GetField( "monkeycar_speed",monkeycar_speed, Error );
  187. std::string monkeycar_coor;
  188. DBRes.GetField( "monkeycar_coordinate",monkeycar_coor, Error );
  189. double scale=0;
  190. DBRes.GetField( "scale",scale, Error );
  191. log_info("monkeycar area init_area : id:%d,path:%s",area_id, path.c_str());
  192. if(-1 == id)
  193. {
  194. std::shared_ptr<db_area> da = std::make_shared<db_area>();
  195. da->m_default_speed = monkeycar_speed;
  196. da->m_point = init_path(monkeycar_coor);
  197. std::shared_ptr<area> ap = std::make_shared<monkey_area>(da,area_id,over_count_person,
  198. over_time_person,scale,map_id,area_type_id);
  199. ap->m_bound=init_path(path);
  200. for(const auto &p : ap->m_bound)
  201. log_info("point:monkey:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
  202. for(const auto &p : da->m_point)
  203. log_info("point:monkey_coor:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
  204. map.insert({area_id,ap});
  205. }
  206. else
  207. {
  208. std::shared_ptr<db_area> da = std::make_shared<db_area>();
  209. da->m_default_speed = monkeycar_speed;
  210. da->m_point = init_path(monkeycar_coor);
  211. std::shared_ptr<area> ap = std::make_shared<monkey_area>(da,area_id,over_count_person,
  212. over_time_person,scale,map_id,area_type_id);
  213. ap->m_bound=init_path(path);
  214. for(const auto &p : ap->m_bound)
  215. log_info("point:monkey:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
  216. for(const auto &p : da->m_point)
  217. log_info("point:monkey_coor:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
  218. auto tmp_ptr = area_list::instance()->get(id);
  219. if(tmp_ptr)
  220. {
  221. area_list::instance()->remove(id);
  222. }
  223. area_list::instance()->add(id, ap);
  224. log_info("基础数据 monkeycar area增加或修改区域成功:区域id:%d,over_count_person:%d over_time_person:%d,\
  225. scale:%.2f,map_id:%d,area_type_id:%d,over_count_vehicle:%d,over_time_vehicle:%d",
  226. id,over_count_person, over_time_person,scale,map_id,area_type_id,
  227. over_count_vehicle,over_time_vehicle);
  228. std_debug("基础数据 monkeycar area增加或修改区域成功:区域id:%d,over_count_person:%d over_time_person:%d,\
  229. scale:%.2f,map_id:%d,area_type_id:%d,over_count_vehicle:%d,over_time_vehicle:%d",
  230. id,over_count_person, over_time_person,scale,map_id,area_type_id,
  231. over_count_vehicle,over_time_vehicle);
  232. }
  233. }
  234. if(-1 == id)
  235. {
  236. log_info( "monkeycar area init_area. The record count=%d\n", nCount );
  237. area_list::instance()->add(map);
  238. }
  239. }
  240. void area_list::init_from_db(int id/*=-1*/)
  241. {
  242. std::string sql = "SELECT a.area_id, a.name, a.map_id, a.area_type_id, a.path,b.scale, \
  243. over_count_person, over_count_vehicle, over_time_person, over_time_vehicle, \
  244. over_speed_vehicle, is_attendance \
  245. FROM dat_area a,dat_map b\
  246. where a.map_id = b.map_id and area_id not in \
  247. (select monkeycar_base_info_id from dat_monkeycar_base_info)";
  248. if(-1 == id)
  249. {
  250. sql.append(";");
  251. }
  252. else
  253. {
  254. sql.append(" AND s.area_id=");
  255. sql.append(std::to_string(id));
  256. sql.append(";");
  257. log_info("基础数据 增加或修改区域 sql=%s", sql.c_str());
  258. }
  259. std::string Error;
  260. YADB::CDBResultSet DBRes;
  261. sDBConnPool.Query(sql.c_str(),DBRes,Error);
  262. int nCount = DBRes.GetRecordCount( Error );
  263. if (nCount < 1)
  264. {
  265. log_error("基础数据 增加或修改失败,数据库中找不到: area_id=%d:%s", id,sql.c_str());
  266. return ;
  267. }
  268. std::unordered_map<int,std::shared_ptr<area>> map;
  269. while ( DBRes.GetNextRecod(Error) )
  270. {
  271. int area_id = 0;
  272. DBRes.GetField( "area_id",area_id, Error );
  273. int map_id = 0;
  274. DBRes.GetField( "map_id",map_id, Error );
  275. unsigned int area_type_id = 0;
  276. DBRes.GetField( "area_type_id",area_type_id, Error );
  277. int over_count_person = 0;
  278. DBRes.GetField( "over_count_person",over_count_person, Error );
  279. int over_count_vehicle = 0;
  280. DBRes.GetField( "over_count_vehicle",over_count_vehicle, Error );
  281. int over_time_person = 0;
  282. DBRes.GetField( "over_time_person",over_time_person, Error );
  283. int over_time_vehicle = 0;
  284. DBRes.GetField( "over_time_vehicle",over_time_vehicle, Error );
  285. std::string path;
  286. DBRes.GetField( "path",path, Error );
  287. double scale = 0;
  288. DBRes.GetField( "scale",scale, Error );
  289. log_info("init_area : id:%d,path:%s",area_id, path.c_str());
  290. if(-1 == id)
  291. {
  292. std::shared_ptr<area> ap = std::make_shared<area>(area_id,over_count_person,over_time_person,
  293. scale,map_id,area_type_id);
  294. ap->m_limit_vehicle_second = over_time_vehicle;
  295. ap->m_limit_vehicle_count = over_count_vehicle;
  296. ap->m_bound=init_path(path);
  297. for(const auto &p : ap->m_bound)
  298. log_info("point:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
  299. map.insert({area_id,ap});
  300. CheckAreaType(ap,area_type_id,0);
  301. }
  302. else
  303. {
  304. auto tmp_ptr = area_list::instance()->get(id);
  305. if(tmp_ptr)
  306. {
  307. CheckAreaType(tmp_ptr,area_type_id,tmp_ptr->m_area_type);
  308. tmp_ptr->update(over_count_person, over_time_person,scale,map_id,area_type_id,
  309. over_count_vehicle,over_time_vehicle);
  310. tmp_ptr->m_bound=init_path(path);
  311. }
  312. else
  313. {
  314. std::shared_ptr<area> ap = std::make_shared<area>(area_id,over_count_person,over_time_person,
  315. scale,map_id,area_type_id);
  316. ap->m_limit_vehicle_second = over_time_vehicle;
  317. ap->m_limit_vehicle_count = over_count_vehicle;
  318. ap->m_bound=init_path(path);
  319. for(const auto &p : ap->m_bound)
  320. log_info("point:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
  321. area_list::instance()->add(id, ap);
  322. CheckAreaType(ap,area_type_id,0);
  323. }
  324. log_info("基础数据 增加或修改区域成功:区域id:%d,over_count_person:%d over_time_person:%d,scale:%.2f,map_id:%d\
  325. ,area_type_id:%d,over_count_vehicle:%d,over_time_vehicle:%d",
  326. id,over_count_person, over_time_person,scale,map_id,area_type_id,
  327. over_count_vehicle,over_time_vehicle);
  328. }
  329. }
  330. if(-1 == id)
  331. {
  332. log_info( "init_area. The record count=%d\n", nCount );
  333. area_list::instance()->add(map);
  334. init_monkeycar_area();
  335. }
  336. }
  337. //新画禁区功能-给禁区中的卡发送警告及呼叫
  338. void area_list::CheckAreaType(int area_id,int new_area_type,int old_area_type)
  339. {
  340. auto area_ptr = area_list::instance()->get(area_id);
  341. if (!area_ptr) {
  342. log_info("区域已经删除:areaid=%d", area_id);
  343. return;
  344. }
  345. CheckAreaType(area_ptr,new_area_type,old_area_type);
  346. }
  347. void area_list::CheckAreaType( std::shared_ptr<area> pArea,int new_area_type,int old_area_type)
  348. {
  349. if (nullptr == pArea)
  350. {
  351. return ;
  352. }
  353. if (new_area_type != AREA_TYPE::AREA_TYPE_FORBIDDEN && old_area_type != AREA_TYPE::AREA_TYPE_FORBIDDEN)
  354. {
  355. return;
  356. }
  357. struct local_visit:visitor<std::shared_ptr<card_location_base>>
  358. {
  359. std::shared_ptr<area> m_area;
  360. int m_old_area_type;
  361. bool visit(std::shared_ptr<card_location_base> c)
  362. {
  363. //处理
  364. point pt(c->x,c->y,c->z);
  365. std::shared_ptr<area> point_area = area_list::instance()->get_area(pt);
  366. if (point_area == nullptr)
  367. {
  368. return true;
  369. }
  370. //不在区域里
  371. if (m_area->m_id != point_area->m_id)
  372. {
  373. return true;
  374. }
  375. if (m_area->m_area_type == AREA_TYPE::AREA_TYPE_FORBIDDEN)
  376. {
  377. //发送进入禁区的警告
  378. //呼叫
  379. std::shared_ptr<area_hover> _area_hover = c->get_area_hover();
  380. if (nullptr != _area_hover)
  381. {
  382. _area_hover->m_area = m_area;
  383. _area_hover->m_area->on_enter(_area_hover,c);
  384. }
  385. }
  386. else
  387. {
  388. if (m_old_area_type == AREA_TYPE::AREA_TYPE_FORBIDDEN)
  389. {
  390. //之前是禁区,改成非禁区
  391. //发送一个离开禁区的警告
  392. //停止呼叫
  393. std::shared_ptr<area_hover> _area_hover = c->get_area_hover();
  394. if (nullptr != _area_hover)
  395. {
  396. _area_hover->m_area->on_leave(_area_hover,c);
  397. }
  398. }
  399. else
  400. {
  401. return false;
  402. }
  403. }
  404. return true;
  405. }
  406. };
  407. local_visit lv;
  408. lv.m_area = pArea;
  409. lv.m_old_area_type = old_area_type;
  410. card_list::instance()->accept(lv);
  411. }
  412. #if 0
  413. void area_list::init_from_db()
  414. {
  415. std::unordered_map<int,std::shared_ptr<area>> map;
  416. const char *sql = "SELECT a.area_id, a.name, a.map_id, a.area_type_id, a.path,b.scale, \
  417. over_count_person, over_count_vehicle, over_time_person, over_time_vehicle, over_speed_vehicle, is_attendance \
  418. FROM dat_area a,dat_map b\
  419. where a.map_id = b.map_id and area_id not in (select monkeycar_base_info_id from dat_monkeycar_base_info);";
  420. std::string Error;
  421. YADB::CDBResultSet DBRes;
  422. sDBConnPool.Query(sql,DBRes,Error);
  423. if(!Error.empty())
  424. log_error("monkeycar area init Error,%s",Error.c_str());
  425. int nCount = DBRes.GetRecordCount( Error );
  426. if (nCount > 0)
  427. {
  428. log_info( "init_area. The record count=%d\n", nCount );
  429. while ( DBRes.GetNextRecod(Error) )
  430. {
  431. int area_id = 0;
  432. DBRes.GetField( "area_id",area_id, Error );
  433. int map_id = 0;
  434. DBRes.GetField( "map_id",map_id, Error );
  435. unsigned int area_type_id = 0;
  436. DBRes.GetField( "area_type_id",area_type_id, Error );
  437. int over_count_person = 0;
  438. DBRes.GetField( "over_count_person",over_count_person, Error );
  439. int over_count_vehicle = 0;
  440. DBRes.GetField( "over_count_vehicle",over_count_vehicle, Error );
  441. int over_time_person = 0;
  442. DBRes.GetField( "over_time_person",over_time_person, Error );
  443. int over_time_vehicle = 0;
  444. DBRes.GetField( "over_time_vehicle",over_time_vehicle, Error );
  445. std::string path;
  446. DBRes.GetField( "path",path, Error );
  447. double scale = 0;
  448. DBRes.GetField( "scale",scale, Error );
  449. log_info("init_area : id:%d,path:%s",area_id, path.c_str());
  450. std::shared_ptr<area> ap = std::make_shared<area>(area_id,over_count_person,over_time_person,scale,map_id,area_type_id);
  451. ap->m_limit_vehicle_second = over_time_vehicle;
  452. ap->m_limit_vehicle_count = over_count_vehicle;
  453. ap->m_bound=init_path(path);
  454. for(const auto &p : ap->m_bound)
  455. log_info("point:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
  456. map.insert({area_id,ap});
  457. }
  458. }
  459. area_list::instance()->add(map);
  460. init_monkeycar_area();
  461. }
  462. #endif
  463. std::vector<point> area_list::init_path(std::string &str)
  464. {
  465. if(str.empty())
  466. log_error("area path empty()...");
  467. std::vector<point> vp;
  468. std::vector<std::string> vs;
  469. std::vector<std::string> vs1;
  470. boost::split(vs,str,boost::is_any_of("ML ;"));
  471. for(auto & s:vs)
  472. {
  473. if(s.empty())
  474. continue;
  475. boost::split(vs1,s,boost::is_any_of(","));
  476. if(vs1.size()!=2)
  477. log_error("area path data Error.pls check data table.");
  478. vp.emplace_back(atof(vs1[0].c_str()),atof(vs1[1].c_str()));
  479. }
  480. return std::move(vp);
  481. }
  482. std::shared_ptr<area> area_list::get_area(const point&pt)
  483. {
  484. std::shared_ptr<area> ret=nullptr;
  485. auto map = area_list::instance()->m_map;
  486. for(const auto &a:map)
  487. {
  488. if(a.second->in_area(pt))
  489. ret = a.second;
  490. }
  491. //区域覆盖不完全地图,很多车辆人行驶在地图外,如何确认.
  492. return ret;
  493. }
  494. void area_tool::on_point(const std::shared_ptr<site>&s,std::shared_ptr<card_location_base> c,const point&pt)
  495. {
  496. log_info("on_point...cardid:%d,type:%d",c->m_id,c->m_type);
  497. //获取地标信息
  498. setLandmark(pt);
  499. if(m_area_hover != nullptr && m_area_hover->m_area->in_area(pt))
  500. {
  501. // do_hover_biz(card_id,speed,type);
  502. }
  503. else
  504. {
  505. auto area = area_list::instance()->get_area(pt);
  506. if(area == nullptr)
  507. {
  508. //这里使用分站区域比较合理
  509. // log_error("Cardid:%d can not find area..[x:%.2f,y:%.2f]",card_id,pt.x,pt.y);
  510. return;
  511. }
  512. if(m_area_hover==nullptr)
  513. {
  514. // m_area_hover = std::make_shared<area_hover>(area,pt,speed);
  515. // do_enter_biz(card_id,speed,type);
  516. }
  517. else
  518. {
  519. // do_leave_biz(card_id,speed,type);
  520. // m_area_hover.reset(new area_hover(area,pt,speed));
  521. // do_enter_biz(card_id,speed,type);
  522. }
  523. }
  524. }
  525. void area_hover::setLandmark(const point &pt)
  526. {
  527. set(pt);
  528. auto lm = Landmark_list::instance()->get(mapid(),id(),pt);
  529. landmark_id = std::get<0>(lm);
  530. landmark_dir = std::get<1>(lm);
  531. landmark_dis = std::get<2>(lm)*scale();
  532. log_info("landmark:%d %d %.2f,(%.2f,%.2f),%f",landmark_id,landmark_dir,landmark_dis,pt.x,pt.y,scale());
  533. }