Browse Source

新增禁区,判断禁区中是否有人,并做相应的处理,告警等

chensongchao 6 years ago
parent
commit
b873cbf931
1 changed files with 11 additions and 1 deletions
  1. 11 1
      area.cpp

+ 11 - 1
area.cpp

@@ -347,18 +347,26 @@ void area_list::init_from_db(int id/*=-1*/)
         }
         else
         {
+            int tmp_old_area_type = 0;
             auto tmp_ptr = area_list::instance()->get(id);
             if(!tmp_ptr)
             {
 				tmp_ptr = create(area_type_id,area_id,over_count_person,over_time_person, scale,map_id,b_type);
                 area_list::instance()->add(id, tmp_ptr);
             }
+            else
+            {
+                tmp_old_area_type = tmp_ptr->m_area_type;
+            }
             tmp_ptr->update(over_count_person, over_time_person,scale,map_id,area_type_id, over_count_vehicle,over_time_vehicle);
             tmp_ptr->m_bound=init_path(path);
             tmp_ptr->m_over_speed_vehicle = over_speed_vehicle;
             for(const auto &p : tmp_ptr->m_bound)
                 log_info("point:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
 
+            // 检查原来的区域是否禁区
+            CheckAreaType(tmp_ptr,area_type_id,tmp_old_area_type);
+
             log_info("基础数据 增加或修改区域成功:区域id:%d,over_count_person:%d over_time_person:%d,scale:%.2f,map_id:%d\
                      ,area_type_id:%d,over_count_vehicle:%d,over_time_vehicle:%d",
                      id,over_count_person, over_time_person,scale,map_id,area_type_id,
@@ -399,6 +407,7 @@ void area_list::CheckAreaType( std::shared_ptr<area> pArea,int new_area_type,int
     {
         std::shared_ptr<area> m_area;
         int m_old_area_type;
+        int m_new_area_type;
         bool visit(std::shared_ptr<card_location_base> c)
         {
             //处理
@@ -420,7 +429,7 @@ void area_list::CheckAreaType( std::shared_ptr<area> pArea,int new_area_type,int
             {
                 return true;
             }
-            if (m_area->m_area_type == AREA_TYPE::AREA_TYPE_FORBIDDEN)
+            if (m_new_area_type == AREA_TYPE::AREA_TYPE_FORBIDDEN)
             {
                 //发送进入禁区的警告
                 //呼叫
@@ -439,6 +448,7 @@ void area_list::CheckAreaType( std::shared_ptr<area> pArea,int new_area_type,int
     local_visit lv;
     lv.m_area = pArea;
     lv.m_old_area_type = old_area_type;
+    lv.m_new_area_type = new_area_type;
     card_list::instance()->accept(lv);
 }