|
@@ -144,7 +144,7 @@ bool location_card::is_map_changed(int new_mapid)
|
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
|
-void location_card::push(uint64_t timestamp,const point & p,int32_t areaid,int32_t mapid)
|
|
|
+void location_card::push(uint64_t timestamp,const point & p,int32_t areaid,int32_t mapid,bool bclose/* = false*/)
|
|
|
{
|
|
|
log_info("his_location:card[%d] area[%d] Point(%.2f,%.2f)--->(%.2f,%.2f)",m_cardid,areaid,m_p.x,m_p.y,p.x,p.y);
|
|
|
|
|
@@ -155,6 +155,11 @@ void location_card::push(uint64_t timestamp,const point & p,int32_t areaid,int32
|
|
|
m_d.emplace(p,timestamp);
|
|
|
return ;
|
|
|
}
|
|
|
+ if (bclose) //卡移除后直接更新his_location
|
|
|
+ {
|
|
|
+ update(p,timestamp,true);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
if(!is_valid())
|
|
|
{
|
|
@@ -239,50 +244,6 @@ void location_card::update(const point &p,uint64_t timestamp,int flag/*=0*/,int
|
|
|
sDBConnPool.PushAsync(nsql);
|
|
|
}
|
|
|
|
|
|
-//查询之前未处理数据last_time is null
|
|
|
-bool location_card::up_mine (const point & p1,int areaid,uint64_t timestamp)
|
|
|
-{
|
|
|
- if (timestamp < m_timestamp || m_timestamp == 0)
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- char nsql[512] = {0};
|
|
|
- double t = (m_timestamp - m_timestamp) / 1000;
|
|
|
- if (t < 0.001) t = 1.0;
|
|
|
- double speed = 0.0;
|
|
|
- int dist = p1.dist(m_p);
|
|
|
- if(dist > 10) //当前点距离原来的点有点远
|
|
|
- {
|
|
|
- speed = dist / t;
|
|
|
- if (std::isnan(speed) || std::isinf(speed)) {
|
|
|
- speed = 0.0;
|
|
|
- }
|
|
|
-
|
|
|
- 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;";
|
|
|
- snprintf(nsql, 512, sql, tool_time::to_str(timestamp / 1000).c_str(), speed, m_arg, 1, m_objid,tool_time::to_str(m_timestamp/1000).c_str());
|
|
|
- log_info("up_mine: his_location[%d]:%s[%lu,%lu]",m_cardid,nsql,timestamp,m_timestamp);
|
|
|
- sDBConnPool.PushAsync(nsql);
|
|
|
-
|
|
|
- memset(nsql,0, sizeof(nsql));
|
|
|
- const char * insert_sql = "replace into his_location (obj_id,card_type_id,ident,begin_time,last_time,map_id,area_id,begin_pt,direction)"
|
|
|
- "values(%d,%d,%d,'%s',%d,%d,'%.2f,%.2f',%f);";
|
|
|
- snprintf(nsql,512,insert_sql,m_objid,m_type,m_cardid,tool_time::to_str(timestamp/1000).c_str(),tool_time::to_str(timestamp/1000 + 1).c_str(),m_mapid
|
|
|
- ,m_areaid,p1.x,p1.y,m_arg);
|
|
|
- log_info("up_mine: his_location[%d,%lu]:%s",m_cardid,m_timestamp,nsql);
|
|
|
- sDBConnPool.PushAsync(nsql);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- 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;";
|
|
|
- snprintf(nsql, 512, sql, tool_time::to_str(timestamp / 1000).c_str(), 0.0, m_arg, 1, m_objid,tool_time::to_str(m_timestamp/1000).c_str());
|
|
|
-
|
|
|
- log_info("up_mine: his_location[%d]:%s[%lu,%lu]",m_cardid,nsql,timestamp,m_timestamp);
|
|
|
- sDBConnPool.PushAsync(nsql);
|
|
|
- }
|
|
|
-
|
|
|
- return true;
|
|
|
-}
|
|
|
-
|
|
|
std::vector<point> location_card::find_path(const point &p1,const point &p2)
|
|
|
{
|
|
|
std::vector<point> rc=card_path::inst().find_path(point(p1.x,-p1.y),point(p2.x,-p2.y));
|