area_business_geofault.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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_enter(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data>&ptr);
  25. void on_hover(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data> ptr);
  26. void on_leave(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data> ptr);
  27. static void init(config_file& config);
  28. static void init_geofault_from_db();
  29. private:
  30. static bool _is_near(std::shared_ptr<area>& area_ptr, double x, double y, double& out_dist);
  31. static std::vector<std::string> split(const std::string& str, char tag)
  32. {
  33. std::vector<std::string> arr;
  34. std::string subStr;
  35. for(size_t i = 0; i < str.length(); i++)
  36. {
  37. if(tag == str[i])
  38. {
  39. if(!subStr.empty())
  40. {
  41. arr.push_back(subStr);
  42. subStr.clear();
  43. }
  44. }
  45. else
  46. {
  47. subStr.push_back(str[i]);
  48. }
  49. }
  50. if(!subStr.empty())
  51. {
  52. arr.push_back(subStr);
  53. }
  54. return arr;
  55. }
  56. static std::string _points2str(std::vector<point>& points);
  57. private:
  58. //area_id: points
  59. static std::unordered_map<int, std::vector<point>> _area_geofault_map;
  60. static int _geofault_count_limit;
  61. };
  62. #endif // AREA_BUSINESS_GEOFAULT