Browse Source

进入盲区一定时长,更改路径后,距离超过一定距离得历史轨迹进行特殊标识

lixioayao 5 years ago
parent
commit
8a219264d3
3 changed files with 40 additions and 16 deletions
  1. 1 1
      Makefile.am
  2. 21 0
      his_location.cpp
  3. 18 15
      his_location.h

+ 1 - 1
Makefile.am

@@ -17,7 +17,7 @@ SRC_MODULE_SERVICE= module_service/area_business_car_attendance.cpp module_servi
 					module_service/module_other_alarm.cpp 
 
 
-SRC_MAIN= ant.cpp area.cpp base64.cpp bindmorecard.cpp mine_business.cpp card_area.cpp card_base.cpp card_car.cpp \
+SRC_MAIN= ant.cpp area.cpp base64.cpp bindmorecard.cpp mine_business.cpp card_area.cpp card_base.cpp card_car.cpp his_location.cpp\
     	  card.cpp card_message_handle.cpp cardMgr.cpp card_path.cpp card_person.cpp crc.cpp geo_hash.cpp \
 		  landmark.cpp line_fit.cpp loc_point.cpp loc_tool.cpp message.cpp message_file.cpp mine.cpp \
 		  net-service.cpp point.cpp select_tool.cpp  special_area.cpp tdoa_sync.cpp visit.cpp \

+ 21 - 0
his_location.cpp

@@ -0,0 +1,21 @@
+#include "his_location.h"
+
+#include <config_file.h>
+extern config_file config;
+uint32_t  location_card::m_difftime=0;
+int  location_card::m_distance=-1;
+
+location_card::location_card(uint32_t id,uint64_t type,uint32_t objid)
+:m_cardid(id)
+,m_type(type)
+    ,m_objid(objid)
+{
+    init();
+    if(location_card::m_distance==-1)
+    {
+        location_card::m_difftime=config.get("service.difftime",300);
+        location_card::m_distance=config.get("service.distance",30);
+        log_info("his_location_init:%u,%d",m_difftime,m_distance);
+    }
+}
+

+ 18 - 15
his_location.h

@@ -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;