|
@@ -27,6 +27,7 @@ void location_card::init()
|
|
{
|
|
{
|
|
m_areaid=-1;
|
|
m_areaid=-1;
|
|
m_mapid=-1;
|
|
m_mapid=-1;
|
|
|
|
+ m_siteid = -1;
|
|
m_timestamp=0;
|
|
m_timestamp=0;
|
|
m_p.set(0,0);
|
|
m_p.set(0,0);
|
|
std::queue<mini_data> tmp;
|
|
std::queue<mini_data> tmp;
|
|
@@ -124,6 +125,8 @@ bool location_card::time_out(const point &p,uint64_t time)
|
|
return true;
|
|
return true;
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+//区域是否发生变化
|
|
bool location_card::is_area_changed(int new_areaid)
|
|
bool location_card::is_area_changed(int new_areaid)
|
|
{
|
|
{
|
|
bool flag =false;
|
|
bool flag =false;
|
|
@@ -134,6 +137,8 @@ bool location_card::is_area_changed(int new_areaid)
|
|
}
|
|
}
|
|
return flag;
|
|
return flag;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+//地图是否发生变化
|
|
bool location_card::is_map_changed(int new_mapid)
|
|
bool location_card::is_map_changed(int new_mapid)
|
|
{
|
|
{
|
|
bool flag =false;
|
|
bool flag =false;
|
|
@@ -144,7 +149,8 @@ bool location_card::is_map_changed(int new_mapid)
|
|
}
|
|
}
|
|
return flag;
|
|
return flag;
|
|
}
|
|
}
|
|
-void location_card::push(uint64_t timestamp,const point & p,int32_t areaid,int32_t mapid,bool bclose/* = false*/)
|
|
|
|
|
|
+
|
|
|
|
+void location_card::push(uint64_t timestamp,const point & p,int32_t areaid,int32_t mapid,int32_t siteid,bool bclose/* = false*/)
|
|
{
|
|
{
|
|
if (bclose) //卡移除后直接更新his_location
|
|
if (bclose) //卡移除后直接更新his_location
|
|
{
|
|
{
|
|
@@ -152,10 +158,12 @@ void location_card::push(uint64_t timestamp,const point & p,int32_t areaid,int32
|
|
init();
|
|
init();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if(m_p.empty() || m_timestamp==0||m_areaid<0||m_mapid<0)
|
|
|
|
|
|
+ if(m_p.empty() || m_timestamp==0||m_areaid<0||m_mapid<0 || m_siteid < 0)
|
|
{
|
|
{
|
|
set(p,timestamp);
|
|
set(p,timestamp);
|
|
- m_areaid=areaid;m_mapid=mapid;
|
|
|
|
|
|
+ m_areaid = areaid;
|
|
|
|
+ m_mapid = mapid;
|
|
|
|
+ m_siteid = siteid;
|
|
m_d.emplace(p,timestamp);
|
|
m_d.emplace(p,timestamp);
|
|
return ;
|
|
return ;
|
|
}
|
|
}
|
|
@@ -197,7 +205,7 @@ void location_card::push(uint64_t timestamp,const point & p,int32_t areaid,int32
|
|
if(is_area_changed(areaid))
|
|
if(is_area_changed(areaid))
|
|
if(!flag)iflag=3;
|
|
if(!flag)iflag=3;
|
|
if(is_map_changed(mapid))
|
|
if(is_map_changed(mapid))
|
|
- if(!flag)iflag=4;
|
|
|
|
|
|
+ if(!flag)iflag=4;
|
|
log_info("his_location cardid:%d:%d",m_cardid,iflag);
|
|
log_info("his_location cardid:%d:%d",m_cardid,iflag);
|
|
if(iflag)
|
|
if(iflag)
|
|
{
|
|
{
|
|
@@ -213,9 +221,9 @@ void location_card::insert()
|
|
{
|
|
{
|
|
//std::string tabName=getTabName();
|
|
//std::string tabName=getTabName();
|
|
char nsql[512]={0};
|
|
char nsql[512]={0};
|
|
- const char * sql = "replace into his_location (obj_id,card_type_id,ident,begin_time,map_id,area_id,begin_pt,direction)"
|
|
|
|
- "values(%d,%d,%d,'%s',%d,%d,'%.2f,%.2f',%f);";
|
|
|
|
- snprintf(nsql,512,sql,m_objid,m_type,m_cardid,tool_time::to_str(m_timestamp/1000).c_str(),m_mapid,m_areaid,m_p.x,m_p.y,m_arg);
|
|
|
|
|
|
+ const char * sql = "replace into his_location (obj_id,card_type_id,ident,begin_time,map_id,area_id,begin_pt,direction,reader_id)"
|
|
|
|
+ "values(%d,%d,%d,'%s',%d,%d,'%.2f,%.2f',%f,%d);";
|
|
|
|
+ snprintf(nsql,512,sql,m_objid,m_type,m_cardid,tool_time::to_str(m_timestamp/1000).c_str(),m_mapid,m_areaid,m_p.x,m_p.y,m_arg,m_siteid);
|
|
log_info("his_location[%d,%lu]:%s",m_cardid,m_timestamp,nsql);
|
|
log_info("his_location[%d,%lu]:%s",m_cardid,m_timestamp,nsql);
|
|
sDBConnPool.PushAsync(nsql);
|
|
sDBConnPool.PushAsync(nsql);
|
|
}
|
|
}
|
|
@@ -226,7 +234,7 @@ void location_card::update(const point &p,uint64_t timestamp,int flag/*=0*/,int
|
|
const char * sql = "update his_location set last_time='%s',speed=%.3f,direction=%f,location_flag=%d where obj_id=%d and begin_time='%s' and last_time is null;";
|
|
const char * sql = "update his_location set last_time='%s',speed=%.3f,direction=%f,location_flag=%d where obj_id=%d and begin_time='%s' and last_time is null;";
|
|
double dist = m_p.dist(p);
|
|
double dist = m_p.dist(p);
|
|
double t = (timestamp - m_timestamp)/1000;
|
|
double t = (timestamp - m_timestamp)/1000;
|
|
- double avge_speed= dist/t;
|
|
|
|
|
|
+ double avge_speed = dist/t;
|
|
if(std::isnan(avge_speed)|| std::isinf(avge_speed))avge_speed=0;
|
|
if(std::isnan(avge_speed)|| std::isinf(avge_speed))avge_speed=0;
|
|
|
|
|
|
log_info("his_location_time[%d]:%d[%lu,%lu,%lu]",m_cardid,flag,last_timestamp,timestamp,m_timestamp);
|
|
log_info("his_location_time[%d]:%d[%lu,%lu,%lu]",m_cardid,flag,last_timestamp,timestamp,m_timestamp);
|