|
@@ -29,13 +29,29 @@ struct underground_area:area
|
|
|
{
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ virtual bool in_area(const std::shared_ptr<site>&s, const point & p)
|
|
|
+ {
|
|
|
+ //根据s的地面、地下属性判断
|
|
|
+ return false;
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
struct ground_area:area
|
|
|
{
|
|
|
+ virtual bool in_area(const std::shared_ptr<site>&s, const point & p)
|
|
|
+ {
|
|
|
+ //根据s的地面、地下属性判断
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+struct special_area:area
|
|
|
+{
|
|
|
+ virtual bool in_area(const std::shared_ptr<site>&s, const point & p)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
void area::on_hover(std::shared_ptr<area_hover>&a,std::shared_ptr<card_location_base>&c)
|
|
@@ -64,7 +80,7 @@ void area::on_leave(std::shared_ptr<area_hover>&a,std::shared_ptr<card_location_
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-bool area::in_area(const point & p)
|
|
|
+bool area::in_area(const std::shared_ptr<site>&s, const point & p)
|
|
|
{
|
|
|
if(m_bound.empty())
|
|
|
return false;
|
|
@@ -376,14 +392,14 @@ void area_list::init_from_db(int id/*=-1*/)
|
|
|
|
|
|
map.insert({area_id,ap});
|
|
|
|
|
|
- CheckAreaType(ap,area_type_id,0);
|
|
|
+// 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);
|
|
|
+// 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);
|
|
@@ -403,7 +419,7 @@ void area_list::init_from_db(int id/*=-1*/)
|
|
|
|
|
|
area_list::instance()->add(id, ap);
|
|
|
|
|
|
- CheckAreaType(ap,area_type_id,0);
|
|
|
+// CheckAreaType(ap,area_type_id,0);
|
|
|
}
|
|
|
|
|
|
log_info("基础数据 增加或修改区域成功:区域id:%d,over_count_person:%d over_time_person:%d,scale:%.2f,map_id:%d\
|
|
@@ -423,6 +439,7 @@ void area_list::init_from_db(int id/*=-1*/)
|
|
|
}
|
|
|
|
|
|
|
|
|
+#if 0
|
|
|
//新画禁区功能-给禁区中的卡发送警告及呼叫
|
|
|
void area_list::CheckAreaType(int area_id,int new_area_type,int old_area_type)
|
|
|
{
|
|
@@ -502,6 +519,8 @@ void area_list::CheckAreaType( std::shared_ptr<area> pArea,int new_area_type,int
|
|
|
card_list::instance()->accept(lv);
|
|
|
}
|
|
|
|
|
|
+#endif
|
|
|
+
|
|
|
#if 0
|
|
|
void area_list::init_from_db()
|
|
|
{
|
|
@@ -589,52 +608,74 @@ 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::vector<std::shared_ptr<area>> area_list::get_area(const std::shared_ptr<site> s,const point&pt)
|
|
|
{
|
|
|
- std::shared_ptr<area> ret=nullptr;
|
|
|
+ std::vector<std::shared_ptr<area>> ret;
|
|
|
|
|
|
auto map = area_list::instance()->m_map;
|
|
|
|
|
|
for(const auto &a:map)
|
|
|
{
|
|
|
- if(a.second->in_area(pt))
|
|
|
- ret = a.second;
|
|
|
+ if(a.second->in_area(s, pt))
|
|
|
+ {
|
|
|
+ ret.push_back(a.second);
|
|
|
+ }
|
|
|
}
|
|
|
//区域覆盖不完全地图,很多车辆人行驶在地图外,如何确认.
|
|
|
- return ret;
|
|
|
+ return std::move(ret);
|
|
|
}
|
|
|
|
|
|
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",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);
|
|
|
- }
|
|
|
- else
|
|
|
+
|
|
|
+ std::vector<std::shared_ptr<area>> areas=area_list::instance()->get_area(s, pt);//找出所有的区域
|
|
|
+ std::sort(areas.begin(),areas.end(),[](std::shared_ptr<area>&l,std::shared_ptr<area>&r){
|
|
|
+ return l->id()<r->id();
|
|
|
+ });
|
|
|
+
|
|
|
+ auto c1=m_hover_list.begin(),ce=m_hover_list.end();
|
|
|
+ auto a1=areas.begin() ,ae=areas.end();
|
|
|
+
|
|
|
+ std::vector<std::shared_ptr<area_hover>> nlist;
|
|
|
+
|
|
|
+ while (c1!=ce && a1!=ae)
|
|
|
{
|
|
|
- auto area = area_list::instance()->get_area(pt);
|
|
|
- if(area == nullptr)
|
|
|
- {
|
|
|
- //这里使用分站区域比较合理
|
|
|
-// log_error("Cardid:%d can not find area..[x:%.2f,y:%.2f]",card_id,pt.x,pt.y);
|
|
|
- return;
|
|
|
+ if ((*c1)->id()<(*a1)->id())
|
|
|
+ {
|
|
|
+ (*c1)->m_area->on_leave(*c1, c);
|
|
|
+ ++c1;
|
|
|
}
|
|
|
- if(m_area_hover==nullptr)
|
|
|
+ else if ((*a1)->id()<(*c1)->id())
|
|
|
{
|
|
|
-// m_area_hover = std::make_shared<area_hover>(area,pt,speed);
|
|
|
-// do_enter_biz(card_id,speed,type);
|
|
|
+ nlist.push_back(std::make_shared<area_hover>(*a1,pt));
|
|
|
+ (*a1)->on_enter(nlist.back(),c);
|
|
|
+ ++a1;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
-// do_leave_biz(card_id,speed,type);
|
|
|
-
|
|
|
-// m_area_hover.reset(new area_hover(area,pt,speed));
|
|
|
-// do_enter_biz(card_id,speed,type);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ nlist.push_back(*c1);
|
|
|
+ (*c1)->m_area->on_hover(*c1,c);
|
|
|
+ ++c1,++a1;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ while(c1!=ce)
|
|
|
+ {
|
|
|
+ (*c1)->m_area->on_leave(*c1, c);
|
|
|
+ ++c1;
|
|
|
+ }
|
|
|
+
|
|
|
+ while(a1!=ae)
|
|
|
+ {
|
|
|
+ nlist.push_back(std::make_shared<area_hover>(*a1,pt));
|
|
|
+ (*a1)->on_enter(nlist.back(),c);
|
|
|
+ ++a1;
|
|
|
+ }
|
|
|
+
|
|
|
+ m_hover_list=std::move(nlist);
|
|
|
}
|
|
|
|
|
|
void area_hover::setLandmark(const point &pt)
|