Browse Source

增加区域逻辑,考勤和猴车使用区域定位,其他使用分站区域定位

lixioayao 5 years ago
parent
commit
a6fa880eec
3 changed files with 20 additions and 8 deletions
  1. 17 8
      area.cpp
  2. 2 0
      area.h
  3. 1 0
      common.h

+ 17 - 8
area.cpp

@@ -186,12 +186,9 @@ void area::on_leave(const std::shared_ptr<area_hover>&a,const std::shared_ptr<ca
 		i->on_leave(a,c,x);
 	}
 }
-bool area::in_area(const std::shared_ptr<site>&s,const std::shared_ptr<card_location_base>&c, const point & p,int & sarid)
+bool area::in_area(const point &p)
 {
-#ifdef SITE_AREA
-    return false;
-#endif
-	if(m_bound.empty())
+    if(m_bound.empty())
 	  return false;
 	int counter = 0;
 	double xinters;
@@ -216,6 +213,17 @@ bool area::in_area(const std::shared_ptr<site>&s,const std::shared_ptr<card_loca
 	}
 	return (counter % 2 == 0) ? false : true;
 }
+bool area::in_area(const std::shared_ptr<site>&s,const std::shared_ptr<card_location_base>&c, const point & p,int & sarid)
+{
+    switch(m_area_type){
+        case AREA_TYPE_MONKEY:
+        case AREA_TYPE_ATTENDANCE:
+        case AREA_TYPE_FORBIDDEN:
+            return in_area(p);
+        default:
+            return false;
+    }
+}
 
 area_list::area_list()
 {
@@ -298,6 +306,7 @@ void area_list::init_monkeycar_area(int id)
             da->m_point = init_path(monkeycar_coor,area_id);
             std::shared_ptr<area> ap = std::make_shared<monkey_area>(da,area_id,over_count_person, over_time_person,scale,map_id,b_type);
             ap->update(over_count_person, over_time_person,scale,map_id,over_count_vehicle,over_time_vehicle);
+            ap->m_area_type=area_type_id;
 
             ap->m_bound=init_path(path,area_id);
             for(const auto &p : ap->m_bound)
@@ -325,7 +334,7 @@ void area_list::init_monkeycar_area(int id)
 
 			tmp_ptr->m_bound=init_path(path,area_id);
             tmp_ptr->update(over_count_person, over_time_person,scale,map_id, over_count_vehicle,over_time_vehicle);
-
+            tmp_ptr->m_area_type=area_type_id;
 			if(newobj)
 			{
 				area_list::instance()->add(id, tmp_ptr);
@@ -449,6 +458,7 @@ void area_list::init_from_db(int id/*=-1*/)
 				ap->m_limit_vehicle_count = over_count_vehicle;
 				ap->m_speed=std::move(map_);
 				ap->m_is_work_area = is_work_area;
+                ap->m_area_type=area_type_id;
 
 				ap->m_bound=init_path(path,area_id);
 				for(const auto &p : ap->m_bound)
@@ -470,6 +480,7 @@ void area_list::init_from_db(int id/*=-1*/)
 				tmp_ptr->m_speed=std::move(map_);
 				tmp_ptr->m_bound=init_path(path,area_id);
 				tmp_ptr->m_is_work_area = is_work_area;
+                tmp_ptr->m_area_type=area_type_id;
 
 				for(const auto &p : tmp_ptr->m_bound)
 					log_info("point:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
@@ -540,11 +551,9 @@ std::vector<std::shared_ptr<area>> area_list::get_area(const std::shared_ptr<sit
 			ret.push_back(a.second);
     if(s){
         ret.push_back(s->get_area());
-#ifdef SITE_AREA
         int area_id=s->m_area_id;
         if(auto area_=area_list::instance()->get(area_id))
         ret.push_back(area_);
-#endif
     }
 	//区域覆盖不完全地图,很多车辆人行驶在地图外,如何确认.
 	return std::move(ret);

+ 2 - 0
area.h

@@ -32,6 +32,7 @@ struct area
     virtual	void on_load_his(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c);
 
     virtual bool in_area(const std::shared_ptr<site>&s,const std::shared_ptr<card_location_base>&c, const point & p,int &);
+    bool in_area(const point &p);
     int id()const
     {
         return m_id;
@@ -100,6 +101,7 @@ public:
 		8:猴车区域
 	*/
     int    m_biz_type=0;
+    int    m_area_type=0;
 
 	//人卡超时及超员数量(阀值)
     int m_limit_person_min;

+ 1 - 0
common.h

@@ -70,6 +70,7 @@ enum AREA_TYPE
 	AREA_TYPE_FORBIDDEN = 3,	// 限制区域
 	AREA_TYPE_DOWNMINE=4,
 	AREA_TYPE_MONKEY=5,
+    AREA_TYPE_ATTENDANCE=6,
 	AREA_TYPE_NO_COVER = 1000,	// 非覆盖区域,车辆信号消失后,定位到附近非覆盖区域内
 	AREA_TYPE_SPECIAL = 1001	// 特殊区域,只给你前端用来标识是否显示图标,胶轮车硐室
 };