|
@@ -13,13 +13,7 @@
|
|
|
//路径变换
|
|
|
struct location_card
|
|
|
{
|
|
|
- location_card(uint32_t id,uint64_t type,uint32_t objid)
|
|
|
- :m_cardid(id)
|
|
|
- ,m_type(type)
|
|
|
- ,m_objid(objid)
|
|
|
- {
|
|
|
- init();
|
|
|
- }
|
|
|
+ location_card(uint32_t id,uint64_t type,uint32_t objid);
|
|
|
uint32_t m_cardid;//卡id
|
|
|
uint16_t m_type;//卡类型
|
|
|
uint32_t m_objid;
|
|
@@ -30,6 +24,8 @@ struct location_card
|
|
|
point m_p;//入库后的点
|
|
|
int m_direct_index;
|
|
|
uint64_t last_timestamp;
|
|
|
+ static uint32_t m_difftime;//进入盲区得时长限制 时长
|
|
|
+ static int m_distance;//进入盲区后,第一个点与之前得距离 像素距离
|
|
|
struct mini_data
|
|
|
{
|
|
|
mini_data(const point &p,uint64_t t)
|
|
@@ -227,11 +223,11 @@ struct location_card
|
|
|
log_info("his_location[%d,%lu]:%s",m_cardid,m_timestamp,nsql);
|
|
|
sDBConnPool.PushAsync(nsql);
|
|
|
}
|
|
|
- void update(const point &p,uint64_t timestamp,int flag=0)
|
|
|
+ void update(const point &p,uint64_t timestamp,int flag=0,int dflag=0)
|
|
|
{
|
|
|
//std::string tabName=getTabName();
|
|
|
char nsql[512]={0};
|
|
|
- const char * sql = "update his_location set last_time='%s',speed=%.2f,direction=%f 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 t = (timestamp - m_timestamp)/1000;
|
|
|
double avge_speed= dist/t;
|
|
@@ -240,11 +236,11 @@ struct location_card
|
|
|
log_info("his_location_time[%d]:%d[%lu,%lu,%lu]",m_cardid,flag,last_timestamp,timestamp,m_timestamp);
|
|
|
if(last_timestamp != 0)
|
|
|
{
|
|
|
- const char * ss = "update his_location set last_time='%s',speed=%.3f,direction=%f where obj_id=%d and begin_time='%s' and last_time = '%s';";
|
|
|
- snprintf(nsql,512,ss,tool_time::to_str(timestamp/1000).c_str(),avge_speed,m_arg,m_objid,tool_time::to_str(m_timestamp/1000).c_str(),tool_time::to_str(last_timestamp/1000).c_str());
|
|
|
+ const char * ss = "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 = '%s';";
|
|
|
+ snprintf(nsql,512,ss,tool_time::to_str(timestamp/1000).c_str(),avge_speed,m_arg,dflag,m_objid,tool_time::to_str(m_timestamp/1000).c_str(),tool_time::to_str(last_timestamp/1000).c_str());
|
|
|
}
|
|
|
else
|
|
|
- snprintf(nsql,512,sql,tool_time::to_str(timestamp/1000).c_str(),avge_speed,m_arg,m_objid,tool_time::to_str(m_timestamp/1000).c_str());
|
|
|
+ snprintf(nsql,512,sql,tool_time::to_str(timestamp/1000).c_str(),avge_speed,m_arg,dflag,m_objid,tool_time::to_str(m_timestamp/1000).c_str());
|
|
|
if(flag==1) last_timestamp=timestamp;
|
|
|
else last_timestamp=0;
|
|
|
|
|
@@ -292,16 +288,23 @@ struct location_card
|
|
|
uint64_t t=timestamp/1000 - m_timestamp/1000;
|
|
|
if(t==0||dis<0.1)return true;
|
|
|
double avge_speed= dis/t;
|
|
|
-
|
|
|
+ //有拐点 盲区时间差 距离
|
|
|
+ uint64_t difftime=t;int dflag=0;
|
|
|
+ if(!m_d.empty()) difftime=timestamp/1000-(m_d.back().time)/1000;
|
|
|
+ if(difftime>=location_card::m_difftime && dis>location_card::m_distance)
|
|
|
+ {
|
|
|
+ log_info("his_location[%d]:abnormal_line difftime:%lu,ltime:%u,dis:%.2f,limit_dis:%d",m_cardid,difftime,location_card::m_difftime,dis,location_card::m_distance);
|
|
|
+ dflag=1;
|
|
|
+ }
|
|
|
for(const point & pp:rc)
|
|
|
{
|
|
|
m_arg=make_arg(pp,m_p);
|
|
|
if(flag)insert();
|
|
|
|
|
|
- log_info("his_location:line_changed_x %d point(%.2f,%.2f)--circle point(%.2f,%.2f),speed:%.2f",m_cardid,m_p.x,m_p.y,pp.x,pp.y,avge_speed);
|
|
|
+ log_info("his_location[%d]:line_changed_x point(%.2f,%.2f)--circle point(%.2f,%.2f),speed:%.2f",m_cardid,m_p.x,m_p.y,pp.x,pp.y,avge_speed);
|
|
|
double dist=m_p.dist(pp);uint64_t tt=dist/avge_speed*1000;
|
|
|
uint64_t etime=m_timestamp+tt;
|
|
|
- update(pp,etime);set(pp,etime);
|
|
|
+ update(pp,etime,0,dflag);set(pp,etime);
|
|
|
flag=true;
|
|
|
}
|
|
|
return false;
|