Browse Source

优化历史轨迹,解决点跨度较大时候,偏离原来方向得bug

lixioayao 5 years ago
parent
commit
2adc3b678c
1 changed files with 7 additions and 7 deletions
  1. 7 7
      his_location.h

+ 7 - 7
his_location.h

@@ -231,7 +231,7 @@ struct location_card
 	{
 		//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;";
+		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;";
 		double dist = m_p.dist(p);
 		double t	= (timestamp - m_timestamp)/1000;
 		double avge_speed= dist/t;
@@ -240,11 +240,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=%.2f 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_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=%.2f,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());
         }
         else
-		    snprintf(nsql,512,sql,tool_time::to_str(timestamp/1000).c_str(),avge_speed,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,m_objid,tool_time::to_str(m_timestamp/1000).c_str());
         if(flag==1) last_timestamp=timestamp;
         else last_timestamp=0;
 
@@ -295,9 +295,9 @@ struct location_card
 
         for(const point & pp:rc)
         {
-            if(flag){
-			    m_arg=make_arg(pp,m_p);insert();
-            }
+            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);
             double dist=m_p.dist(pp);uint64_t tt=dist/avge_speed*1000;
             uint64_t etime=m_timestamp+tt;