area_business_geofault.h 2.0 KB

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