area_business_geofault.h 2.1 KB

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