From c58e3c3a5d9184c687d29bf6e87e356819ad60a4 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Thu, 25 Feb 2010 15:51:37 +0000 Subject: [PATCH] 2010-02-25 Miguel de Dios * include/functions_gis.php: in function "addPath" add the parameter $history_time for to set limit in seconds to past where to start path. Use new parameter in function "getAgentMap". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2420 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 +++++ pandora_console/include/functions_gis.php | 27 ++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index b4aad4058f..71175838db 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2010-02-25 Miguel de Dios + + * include/functions_gis.php: in function "addPath" add the parameter + $history_time for to set limit in seconds to past where to start path. + Use new parameter in function "getAgentMap". + 2010-02-25 Miguel de Dios * operation/agentes/gis_view.php: change the empty message to standar. diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index 3ccb5bf170..f5ecd254f1 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -461,9 +461,30 @@ function get_agent_icon_map($idAgent, $state = false) { } } -function addPath($layerName, $idAgent) { +/** + * Print the path of agent. + * + * @param string $layerName String of layer. + * @param integer $idAgent The id of agent + * @param $history_time: Number of seconds in the past to show from where to start the history path. + * + * @return None + */ +function addPath($layerName, $idAgent, $history_time = null) { - $listPoints = get_db_all_rows_sql('SELECT * FROM tgis_data_history WHERE tagente_id_agente = ' . $idAgent . ' ORDER BY end_timestamp ASC'); + if ($history_time === null) { + $where = '1 = 1'; + } + else { + $where = 'start_timestamp = FROM_UNIXTIME(UNIX_TIMESTAMP() - ' . $history_time . ')'; + } + + $listPoints = get_db_all_rows_sql('SELECT * + FROM tgis_data_history + WHERE + tagente_id_agente = ' . $idAgent . ' AND + ' . $where . ' + ORDER BY end_timestamp ASC'); //If the agent is empty the history if ($listPoints === false) { @@ -794,7 +815,7 @@ function getAgentMap($agent_id, $heigth, $width, $show_history = false, $centerI /* If show_history is true, show the path of the agent */ if ($show_history) { /* TODO: only show the last history_time part of the path */ - addPath("layer_for_agent_".$agent_name,$agent_id); + addPath("layer_for_agent_".$agent_name,$agent_id, $history_time); } addPoint("layer_for_agent_".$agent_name, $agent_name, $agentPositionLatitude, $agentPositionLongitude, $agent_icon, 20, 20, $agent_id, $status, 'point_agent_info');