1
0

area_business_geofault.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * @file
  3. * @brief
  4. * @version
  5. * @author
  6. * @date
  7. * @note
  8. * @warning
  9. * @bug
  10. * @copyright
  11. * */
  12. #ifndef AREA_BUSINESS_GEOFAULT
  13. #define AREA_BUSINESS_GEOFAULT
  14. #include"area_business.h"
  15. #include <unordered_map>
  16. #include<vector>
  17. struct config_file;
  18. struct point;
  19. struct area;
  20. /**
  21. * @brief 当采煤机和掘进机有数据点过来的时候,判断当前点与地址断层坐标点的距离d。如d<设置的阈值,则告警,d>阈值则取消。
  22. */
  23. class area_business_geofault:public area_business
  24. {
  25. public:
  26. void on_load_his(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data>&ptr);
  27. void on_enter(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data>&ptr);
  28. void on_hover(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data> ptr);
  29. void on_leave(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data> ptr);
  30. static void init(config_file& config);
  31. static void init_geofault_from_db();
  32. private:
  33. static bool _is_near(std::shared_ptr<area>& area_ptr, double x, double y, double& out_dist);
  34. static std::vector<std::string> split(const std::string& str, char tag)
  35. {
  36. std::vector<std::string> arr;
  37. std::string subStr;
  38. for(size_t i = 0; i < str.length(); i++)
  39. {
  40. if(tag == str[i])
  41. {
  42. if(!subStr.empty())
  43. {
  44. arr.push_back(subStr);
  45. subStr.clear();
  46. }
  47. }
  48. else
  49. {
  50. subStr.push_back(str[i]);
  51. }
  52. }
  53. if(!subStr.empty())
  54. {
  55. arr.push_back(subStr);
  56. }
  57. return arr;
  58. }
  59. static std::string _points2str(std::vector<point>& points);
  60. private:
  61. //area_id: points
  62. static std::unordered_map<int, std::vector<point>> _area_geofault_map;
  63. static int _geofault_count_limit;
  64. };
  65. #endif // AREA_BUSINESS_GEOFAULT