Browse Source

修改历史轨迹 一定时间更新一次

lixioayao 5 years ago
parent
commit
753ca1d585
1 changed files with 6 additions and 2 deletions
  1. 6 2
      his_location.h

+ 6 - 2
his_location.h

@@ -29,6 +29,7 @@ struct location_card
 	uint64_t	m_timestamp;//入库后的时间
 	point		m_p;//入库后的点
     int         m_direct_index;
+    uint64_t    last_timestamp;
 	struct mini_data
 	{
 		mini_data(const point &p,uint64_t t)
@@ -48,6 +49,7 @@ struct location_card
 		std::queue<mini_data> tmp;
 		m_d.swap(tmp);
         m_direct_index=0;
+        last_timestamp=0;
 	}
 	void init_att(const point &pt,uint64_t time)
 	{
@@ -131,7 +133,8 @@ struct location_card
 	}
 	bool time_out(const point &p,uint64_t time)
 	{
-		if(time-m_timestamp>=30*1000 && m_p.dist(p)>0.1)
+        uint64_t t=last_timestamp==0?m_timestamp:last_timestamp;
+		if(time-t>=30*1000 && m_p.dist(p)>0.1)
 			return true;
 		return false;
 	}
@@ -224,7 +227,6 @@ struct location_card
 	}
 	void update(const point &p,uint64_t timestamp,int flag=0)
 	{
-        static uint64_t last_timestamp=0;
 		//std::string tabName=getTabName();
 		char nsql[512]={0};
 		const char * sql = "update his_location set last_time='%s',speed=%.2f where obj_id=%d and begin_time='%s' and last_time is null;";
@@ -232,6 +234,8 @@ struct location_card
 		double t	= (timestamp - m_timestamp)/1000;
 		double avge_speed= dist/t;
 		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);
         if(last_timestamp != 0) 
         {
 		    const char * ss = "update his_location set last_time='%s',speed=%.2f where obj_id=%d and begin_time='%s' and last_time = '%s';";