|
@@ -7,6 +7,7 @@
|
|
|
#include "point.h"
|
|
|
#include "monkey_car/monkeycar_area.h"
|
|
|
#include "landmark.h"
|
|
|
+#include "area_business.h"
|
|
|
|
|
|
#include <boost/algorithm/string/split.hpp>
|
|
|
#include <boost/algorithm/string/classification.hpp>
|
|
@@ -16,30 +17,53 @@
|
|
|
template<> std::shared_ptr<area_list>
|
|
|
single_base<area_list, int, std::shared_ptr<area>>::m_instance=std::make_shared<area_list>();
|
|
|
|
|
|
-void area::on_hover(uint32_t card_id,std::shared_ptr<area_hover>&c,double speed,int32_t type)
|
|
|
- {
|
|
|
- //check超时
|
|
|
- log_info("on_hover..%d areaId:%d",card_id,m_id);
|
|
|
-// time_t now = time(NULL);
|
|
|
-// if(now-c->m_enter_time>m_limit_time_second && !c->m_is_over_time)
|
|
|
-// {
|
|
|
-// c->m_is_over_time=true;
|
|
|
-// //产生告警
|
|
|
-// }
|
|
|
- module_area::on_hover(card_id,c,type);
|
|
|
- }
|
|
|
-
|
|
|
-void area::on_enter(uint32_t card_id,std::shared_ptr<area_hover>&c,double speed,int32_t type)
|
|
|
+struct underground_area:area
|
|
|
{
|
|
|
- log_info("on_enter..%d areaId:%d",card_id,m_id);
|
|
|
- module_area::on_enter(card_id,c,type);
|
|
|
+ underground_area(int limit_count_person, int limit_time_person,double scale,int32_t mapid)
|
|
|
+ :area(-1,limit_count_person,limit_time_person,scale,mapid,(1<<1)|(1<<2)|(1<<3)|(1<<4))
|
|
|
+ {
|
|
|
+ m_area_business_list=area_business::get_instance_list(m_area_type);
|
|
|
+ }
|
|
|
+
|
|
|
+ void db_load_card_count()
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+struct ground_area:area
|
|
|
+{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+void area::on_hover(std::shared_ptr<area_hover>&a,std::shared_ptr<card_location_base>&c)
|
|
|
+{
|
|
|
+ for(auto i:m_area_business_list)
|
|
|
+ {
|
|
|
+ i->on_hover(a,c,a->get_business_data(i->business_type()));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-void area::on_leave(uint32_t card_id,std::shared_ptr<area_hover>&c,double speed,int32_t type)
|
|
|
+void area::on_enter(std::shared_ptr<area_hover>&a,std::shared_ptr<card_location_base>&c)
|
|
|
{
|
|
|
- log_info("on_leave..%d areaId:%d",card_id,m_id);
|
|
|
- module_area::on_leave(card_id,c,type);
|
|
|
+ log_info("on_enter..%d areaId:%d",c->m_id,m_id);
|
|
|
+ for(auto i:m_area_business_list)
|
|
|
+ {
|
|
|
+ i->on_enter(a,c,a->get_business_data(i->business_type()));
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void area::on_leave(std::shared_ptr<area_hover>&a,std::shared_ptr<card_location_base>&c)
|
|
|
+{
|
|
|
+ log_info("on_leave..%d areaId:%d",c->m_id,m_id);
|
|
|
+ for(auto i:m_area_business_list)
|
|
|
+ {
|
|
|
+ i->on_leave(a,c,a->get_business_data(i->business_type()));
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
bool area::in_area(const point & p)
|
|
|
{
|
|
|
if(m_bound.empty())
|
|
@@ -351,12 +375,16 @@ void area_list::init_from_db(int id/*=-1*/)
|
|
|
log_info("point:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
|
|
|
|
|
|
map.insert({area_id,ap});
|
|
|
+
|
|
|
+ CheckAreaType(ap,area_type_id,0);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
auto tmp_ptr = area_list::instance()->get(id);
|
|
|
if(tmp_ptr)
|
|
|
{
|
|
|
+ CheckAreaType(tmp_ptr,area_type_id,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);
|
|
@@ -374,6 +402,8 @@ void area_list::init_from_db(int id/*=-1*/)
|
|
|
log_info("point:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
|
|
|
|
|
|
area_list::instance()->add(id, ap);
|
|
|
+
|
|
|
+ CheckAreaType(ap,area_type_id,0);
|
|
|
}
|
|
|
|
|
|
log_info("基础数据 增加或修改区域成功:区域id:%d,over_count_person:%d over_time_person:%d,scale:%.2f,map_id:%d\
|
|
@@ -391,6 +421,87 @@ void area_list::init_from_db(int id/*=-1*/)
|
|
|
init_monkeycar_area();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+//新画禁区功能-给禁区中的卡发送警告及呼叫
|
|
|
+void area_list::CheckAreaType(int area_id,int new_area_type,int old_area_type)
|
|
|
+{
|
|
|
+ auto area_ptr = area_list::instance()->get(area_id);
|
|
|
+ if (!area_ptr) {
|
|
|
+ log_info("区域已经删除:areaid=%d", area_id);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ CheckAreaType(area_ptr,new_area_type,old_area_type);
|
|
|
+}
|
|
|
+void area_list::CheckAreaType( std::shared_ptr<area> pArea,int new_area_type,int old_area_type)
|
|
|
+{
|
|
|
+ if (nullptr == pArea)
|
|
|
+ {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ if (new_area_type != AREA_TYPE::AREA_TYPE_FORBIDDEN && old_area_type != AREA_TYPE::AREA_TYPE_FORBIDDEN)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ struct local_visit:visitor<std::shared_ptr<card_location_base>>
|
|
|
+ {
|
|
|
+ std::shared_ptr<area> m_area;
|
|
|
+ int m_old_area_type;
|
|
|
+ bool visit(std::shared_ptr<card_location_base> c)
|
|
|
+ {
|
|
|
+ //处理
|
|
|
+ point pt(c->x,c->y,c->z);
|
|
|
+ std::shared_ptr<area> point_area = area_list::instance()->get_area(pt);
|
|
|
+ if (point_area == nullptr)
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ //不在区域里
|
|
|
+ if (m_area->m_id != point_area->m_id)
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (m_area->m_area_type == AREA_TYPE::AREA_TYPE_FORBIDDEN)
|
|
|
+ {
|
|
|
+ //发送进入禁区的警告
|
|
|
+ //呼叫
|
|
|
+ std::shared_ptr<area_hover> _area_hover = c->get_area_hover();
|
|
|
+ if (nullptr != _area_hover)
|
|
|
+ {
|
|
|
+ _area_hover->m_area = m_area;
|
|
|
+ _area_hover->m_area->on_enter(_area_hover,c);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (m_old_area_type == AREA_TYPE::AREA_TYPE_FORBIDDEN)
|
|
|
+ {
|
|
|
+ //之前是禁区,改成非禁区
|
|
|
+ //发送一个离开禁区的警告
|
|
|
+ //停止呼叫
|
|
|
+ std::shared_ptr<area_hover> _area_hover = c->get_area_hover();
|
|
|
+ if (nullptr != _area_hover)
|
|
|
+ {
|
|
|
+ _area_hover->m_area->on_leave(_area_hover,c);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ local_visit lv;
|
|
|
+ lv.m_area = pArea;
|
|
|
+ lv.m_old_area_type = old_area_type;
|
|
|
+ card_list::instance()->accept(lv);
|
|
|
+}
|
|
|
+
|
|
|
#if 0
|
|
|
void area_list::init_from_db()
|
|
|
{
|
|
@@ -477,6 +588,7 @@ std::vector<point> area_list::init_path(std::string &str)
|
|
|
}
|
|
|
return std::move(vp);
|
|
|
}
|
|
|
+
|
|
|
std::shared_ptr<area> area_list::get_area(const point&pt)
|
|
|
{
|
|
|
std::shared_ptr<area> ret=nullptr;
|
|
@@ -492,15 +604,14 @@ std::shared_ptr<area> area_list::get_area(const point&pt)
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-void area_tool::on_point(uint32_t card_id,const point&pt,double speed,int16_t type)
|
|
|
+void area_tool::on_point(const std::shared_ptr<site>&s,std::shared_ptr<card_location_base> c,const point&pt)
|
|
|
{
|
|
|
- log_info("on_point...cardid:%d,type:%d",card_id,type);
|
|
|
+ log_info("on_point...cardid:%d,type:%d",c->m_id,c->m_type);
|
|
|
//获取地标信息
|
|
|
setLandmark(pt);
|
|
|
if(m_area_hover != nullptr && m_area_hover->m_area->in_area(pt))
|
|
|
{
|
|
|
- do_hover_biz(card_id,speed,type);
|
|
|
+// do_hover_biz(card_id,speed,type);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -508,23 +619,24 @@ void area_tool::on_point(uint32_t card_id,const point&pt,double speed,int16_t ty
|
|
|
if(area == nullptr)
|
|
|
{
|
|
|
//这里使用分站区域比较合理
|
|
|
- log_error("Cardid:%d can not find area..[x:%.2f,y:%.2f]",card_id,pt.x,pt.y);
|
|
|
+// log_error("Cardid:%d can not find area..[x:%.2f,y:%.2f]",card_id,pt.x,pt.y);
|
|
|
return;
|
|
|
}
|
|
|
if(m_area_hover==nullptr)
|
|
|
{
|
|
|
- m_area_hover = std::make_shared<area_hover>(area,pt,speed);
|
|
|
- do_enter_biz(card_id,speed,type);
|
|
|
+// m_area_hover = std::make_shared<area_hover>(area,pt,speed);
|
|
|
+// do_enter_biz(card_id,speed,type);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- do_leave_biz(card_id,speed,type);
|
|
|
+// do_leave_biz(card_id,speed,type);
|
|
|
|
|
|
- m_area_hover.reset(new area_hover(area,pt,speed));
|
|
|
- do_enter_biz(card_id,speed,type);
|
|
|
+// m_area_hover.reset(new area_hover(area,pt,speed));
|
|
|
+// do_enter_biz(card_id,speed,type);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
void area_hover::setLandmark(const point &pt)
|
|
|
{
|
|
|
set(pt);
|