From e19f1166370b30e89747950b32c4c0634d9c110f Mon Sep 17 00:00:00 2001 From: fermin831 Date: Fri, 22 Jun 2018 13:33:04 +0200 Subject: [PATCH] Fixed add particular agents to GIS layers --- pandora_console/include/functions_gis.php | 26 ++++++------------- .../operation/gis_maps/public_console.php | 12 +++------ .../operation/gis_maps/render_view.php | 9 +++---- 3 files changed, 15 insertions(+), 32 deletions(-) diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index 9d941b35a1..d37a4a433e 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -446,37 +446,27 @@ function gis_add_agent_point($layerName, $pointName, $lat, $lon, $icon = null, $ * Get the agents in layer but not by group in layer. * * @param integer $idLayer Layer ID. - * @param array $fields Fields of row tagente to return. * * @return array The array rows of tagente of agents in the layer. */ -function gis_get_agents_layer($idLayer, $fields = null) { - - if ($fields === null) { - $select = '*'; - } - else { - $select = implode(',',$fields); - } - - $sql = "SELECT $select +function gis_get_agents_layer($idLayer) { + + $sql = "SELECT id_agente, nombre FROM tagente WHERE id_agente IN ( SELECT tagente_id_agente FROM tgis_map_layer_has_tagente WHERE tgis_map_layer_id_tmap_layer = $idLayer)"; $agents = db_get_all_rows_sql($sql); - + + $returned_agents = array(); if ($agents !== false) { foreach ($agents as $index => $agent) { - $agents[$index] = $agent['nombre']; + $returned_agents[$agent['id_agente']] = $agent['nombre']; } } - else { - return array(); - } - - return $agents; + + return $returned_agents; } function gis_add_point_path($layerName, $lat, $lon, $color, $manual = 1, $id) { diff --git a/pandora_console/operation/gis_maps/public_console.php b/pandora_console/operation/gis_maps/public_console.php index 725ce6e601..2d9d0e32b5 100755 --- a/pandora_console/operation/gis_maps/public_console.php +++ b/pandora_console/operation/gis_maps/public_console.php @@ -146,13 +146,10 @@ if ($layers != false) { $agentNamesByGroup = agents_get_group_agents($layer['tgrupo_id_grupo'], false, 'none', true, true, false); } - $agentNamesByLayer = gis_get_agents_layer($layer['id_tmap_layer'], - array('nombre')); - - - + $agentNamesByLayer = gis_get_agents_layer($layer['id_tmap_layer']); + $agentNames = array_unique($agentNamesByGroup + $agentNamesByLayer); - + foreach ($agentNames as $agentName) { $idAgent = agents_get_agent_id($agentName); $coords = gis_get_data_last_position_agent($idAgent); @@ -167,8 +164,7 @@ if ($layers != false) { gis_add_path($layer['layer_name'], $idAgent, $lastPosition); } } - - + $icon = gis_get_agent_icon_map($idAgent, true); $icon_size = getimagesize($icon); $icon_width = $icon_size[0]; diff --git a/pandora_console/operation/gis_maps/render_view.php b/pandora_console/operation/gis_maps/render_view.php index 9b4b8f65c8..1bcab74905 100644 --- a/pandora_console/operation/gis_maps/render_view.php +++ b/pandora_console/operation/gis_maps/render_view.php @@ -182,13 +182,10 @@ if ($layers != false) { $agentNamesByGroup = agents_get_group_agents($layer['tgrupo_id_grupo'], false, 'none', true, true, false); } - $agentNamesByLayer = gis_get_agents_layer($layer['id_tmap_layer'], - array('nombre')); - - - + $agentNamesByLayer = gis_get_agents_layer($layer['id_tmap_layer']); + $agentNames = array_unique($agentNamesByGroup + $agentNamesByLayer); - + foreach ($agentNames as $key => $agentName) { $idAgent = $key; $coords = gis_get_data_last_position_agent($idAgent);