2010-01-27 Pablo de la Concepción <pablo.concepcion@artica.es>
* include/functions_gis.php: Added more Openlayers Controls to the case on the printMap function, fixed typo manual_placemen -> manual_placement, added gectConectionConf and getAgentMap functions (last one still with some hardcoded values). Function get_agent_last_coords now also returns the agent name. * operation/agentes/estado_generalagente.php: Added last position information, and timezone offset if is not 0 * operation/agentes/gis_view.php: Added map with the last position of the agent and table with the previous positions of the agent. * operation/agentes/ver_agente.php: Used agent icon to show status if icon_path is defined. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2310 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
383b3ed4c3
commit
99c4675455
|
@ -1,3 +1,20 @@
|
|||
2010-01-27 Pablo de la Concepción <pablo.concepcion@artica.es>
|
||||
|
||||
* include/functions_gis.php: Added more Openlayers Controls to the case
|
||||
on the printMap function, fixed typo manual_placemen -> manual_placement,
|
||||
added gectConectionConf and getAgentMap functions (last one still with
|
||||
some hardcoded values). Function get_agent_last_coords now also returns the
|
||||
agent name.
|
||||
|
||||
* operation/agentes/estado_generalagente.php: Added last position
|
||||
information, and timezone offset if is not 0
|
||||
|
||||
* operation/agentes/gis_view.php: Added map with the last position of the
|
||||
agent and table with the previous positions of the agent.
|
||||
|
||||
* operation/agentes/ver_agente.php: Used agent icon to show status
|
||||
if icon_path is defined.
|
||||
|
||||
2010-01-26 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_gis.php: add functions "saveMapConnection" and
|
||||
|
|
|
@ -35,12 +35,24 @@ function printMap($idDiv, $iniZoom, $numLevelZooms, $latCenter, $lonCenter, $bas
|
|||
case 'Navigation':
|
||||
echo "new OpenLayers.Control.Navigation()";
|
||||
break;
|
||||
case 'MousePosition':
|
||||
echo "new OpenLayers.Control.MousePosition()";
|
||||
break;
|
||||
case 'OverviewMap':
|
||||
echo "new OpenLayers.Control.OverviewMap()";
|
||||
break;
|
||||
case 'PanZoom':
|
||||
echo "new OpenLayers.Control.PanZoom()";
|
||||
break;
|
||||
case 'PanZoomBar':
|
||||
echo "new OpenLayers.Control.PanZoomBar()";
|
||||
break;
|
||||
case 'ScaleLine':
|
||||
echo "new OpenLayers.Control.ScaleLine()";
|
||||
break;
|
||||
case 'Scale':
|
||||
echo "new OpenLayers.Control.Scale()";
|
||||
break;
|
||||
}
|
||||
}
|
||||
echo ", new OpenLayers.Control.LayerSwitcher()";
|
||||
|
@ -304,9 +316,9 @@ function getLayers($idMap) {
|
|||
}
|
||||
|
||||
function get_agent_last_coords($idAgent) {
|
||||
$coords = get_db_row_sql("SELECT last_latitude, last_longitude, last_altitude FROM tagente WHERE id_agente = " . $idAgent);
|
||||
|
||||
return $coords;
|
||||
$coords = get_db_row_sql("SELECT last_latitude, last_longitude, last_altitude, nombre FROM tagente WHERE id_agente = " . $idAgent);
|
||||
|
||||
return $coords;
|
||||
}
|
||||
|
||||
function get_agent_icon_map($idAgent, $state = false) {
|
||||
|
@ -331,28 +343,28 @@ function addPath($layerName, $idAgent) {
|
|||
|
||||
if ($idAgent == 1) {
|
||||
$listPoints = array(
|
||||
array('id_tgis_data' => 0, 'longitude' => -3.709, 'latitude' => 40.422, 'altitude' => 0, 'manual_placemen' => 1),
|
||||
array('id_tgis_data' => 1, 'longitude' => -3.710, 'latitude' => 40.420, 'altitude' => 0, 'manual_placemen' => 0),
|
||||
array('id_tgis_data' => 2, 'longitude' => -3.711, 'latitude' => 40.420, 'altitude' => 0, 'manual_placemen' => 1),
|
||||
array('id_tgis_data' => 3, 'longitude' => -3.712, 'latitude' => 40.422, 'altitude' => 0, 'manual_placemen' => 0),
|
||||
array('id_tgis_data' => 4, 'longitude' => -3.708187, 'latitude' => 40.42056, 'altitude' => 0, 'manual_placemen' => 0)
|
||||
array('id_tgis_data' => 0, 'longitude' => -3.709, 'latitude' => 40.422, 'altitude' => 0, 'manual_placement' => 1),
|
||||
array('id_tgis_data' => 1, 'longitude' => -3.710, 'latitude' => 40.420, 'altitude' => 0, 'manual_placement' => 0),
|
||||
array('id_tgis_data' => 2, 'longitude' => -3.711, 'latitude' => 40.420, 'altitude' => 0, 'manual_placement' => 1),
|
||||
array('id_tgis_data' => 3, 'longitude' => -3.712, 'latitude' => 40.422, 'altitude' => 0, 'manual_placement' => 0),
|
||||
array('id_tgis_data' => 4, 'longitude' => -3.708187, 'latitude' => 40.42056, 'altitude' => 0, 'manual_placement' => 0)
|
||||
);
|
||||
}
|
||||
|
||||
if ($idAgent == 2) {
|
||||
$listPoints = array(
|
||||
array('id_tgis_data' => 0, 'longitude' => -3.703, 'latitude' => 40.420, 'altitude' => 0, 'manual_placemen' => 0),
|
||||
array('id_tgis_data' => 0, 'longitude' => -3.704, 'latitude' => 40.422, 'altitude' => 0, 'manual_placemen' => 0),
|
||||
array('id_tgis_data' => 0, 'longitude' => -3.706, 'latitude' => 40.422, 'altitude' => 0, 'manual_placemen' => 0)
|
||||
array('id_tgis_data' => 0, 'longitude' => -3.703, 'latitude' => 40.420, 'altitude' => 0, 'manual_placement' => 0),
|
||||
array('id_tgis_data' => 0, 'longitude' => -3.704, 'latitude' => 40.422, 'altitude' => 0, 'manual_placement' => 0),
|
||||
array('id_tgis_data' => 0, 'longitude' => -3.706, 'latitude' => 40.422, 'altitude' => 0, 'manual_placement' => 0)
|
||||
);
|
||||
}
|
||||
|
||||
if ($idAgent == 3) {
|
||||
$listPoints = array(
|
||||
array('id_tgis_data' => 0, 'longitude' => -3.701, 'latitude' => 40.425, 'altitude' => 0, 'manual_placemen' => 0),
|
||||
array('id_tgis_data' => 0, 'longitude' => -3.703, 'latitude' => 40.422, 'altitude' => 0, 'manual_placemen' => 0),
|
||||
array('id_tgis_data' => 0, 'longitude' => -3.708, 'latitude' => 40.424, 'altitude' => 0, 'manual_placemen' => 0),
|
||||
array('id_tgis_data' => 0, 'longitude' => -3.705, 'latitude' => 40.421, 'altitude' => 0, 'manual_placemen' => 0)
|
||||
array('id_tgis_data' => 0, 'longitude' => -3.701, 'latitude' => 40.425, 'altitude' => 0, 'manual_placement' => 0),
|
||||
array('id_tgis_data' => 0, 'longitude' => -3.703, 'latitude' => 40.422, 'altitude' => 0, 'manual_placement' => 0),
|
||||
array('id_tgis_data' => 0, 'longitude' => -3.708, 'latitude' => 40.424, 'altitude' => 0, 'manual_placement' => 0),
|
||||
array('id_tgis_data' => 0, 'longitude' => -3.705, 'latitude' => 40.421, 'altitude' => 0, 'manual_placement' => 0)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -387,7 +399,7 @@ function addPath($layerName, $idAgent) {
|
|||
if ($listPoints != false) {
|
||||
foreach($listPoints as $point) {
|
||||
if (end($listPoints) != $point)
|
||||
addPointPath($layerName, $point['latitude'], $point['longitude'], $color, (int)$point['manual_placemen'], $point['id_tgis_data']);
|
||||
addPointPath($layerName, $point['latitude'], $point['longitude'], $color, (int)$point['manual_placement'], $point['id_tgis_data']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -523,4 +535,51 @@ function saveMap($conf, $baselayers, $layers) {
|
|||
|
||||
return $return;
|
||||
}
|
||||
?>
|
||||
|
||||
/**
|
||||
* Get the configuration parameters of a map connection
|
||||
*
|
||||
* @param idConnection: connection identifier for the map
|
||||
*
|
||||
* @result: An array with all the configuration parameters
|
||||
*/
|
||||
function getConectionConf($idConnection) {
|
||||
$confParameters = get_db_row_sql('SELECT * FROM tgis_map_connection WHERE id_tmap_connection = ' . $idConnection);
|
||||
return $confParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the map of an agent in a div with the width and heigth given and the history if asked
|
||||
*
|
||||
* @param $agent_id: id of the agent as in the table tagente;
|
||||
* @param $height: heigth in a string in css format
|
||||
* @param $width: width in a string in css format
|
||||
* @param $show_history: by default or when this parameter is false in the map the path with the
|
||||
* @param $history_time: Number of seconds in the past to show from where to start the history path.
|
||||
*
|
||||
* @return A div tag with the map and the agent and the history path if asked.
|
||||
*/
|
||||
function getAgentMap($agent_id, $heigth, $width, $show_history = false, $history_time = 86400) {
|
||||
|
||||
//$default_map_conf = getConectionConf($config['default_map']);
|
||||
$default_map_conf = getConectionConf(1);
|
||||
$baselayers[0]['url']= 'http://tile.openstreetmap.org/${z}/${x}/${y}.png';
|
||||
$baselayers[0]['name'] = "OSM";
|
||||
$baselayers[0]['typeBaseLayer'] = "OSM";
|
||||
$agent_position = get_agent_last_coords($agent_id);
|
||||
$agent_name = $agent_position['nombre'];
|
||||
printMap($agent_name."_agent_map", $default_map_conf['default_zoom_level'] , $default_map_conf['num_zoom_levels'],$agent_position['last_latitude'], $agent_position['last_longitude'], $baselayers, $controls = array('PanZoom', 'ScaleLine', 'Navigation', 'MousePosition', 'OverviewMap') );
|
||||
//printMap($agent_id."_agent_map", 16 , 19, 40.42056, -3.70818 -3.708187, $baselayers, $controls = null) {
|
||||
|
||||
makeLayer("layer_for_agent_".$agent_name);
|
||||
|
||||
$agent_icon = get_agent_icon_map($agent_id);
|
||||
/* 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);
|
||||
}
|
||||
addPoint("layer_for_agent_".$agent_name, $agent_name, $agent_position['last_latitude'], $agent_position['last_longitude'], $agent_icon);
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
|
@ -117,6 +117,11 @@ echo '</b>)</td></tr>';
|
|||
echo '<tr><td class="datos2"><b>'.__('Agent Version'). '</b></td>';
|
||||
echo '<td class="datos2" colspan="2">'.$agent["agent_version"].'</td></tr>';
|
||||
|
||||
// Position Information
|
||||
if ($config['activate_gis']) {
|
||||
echo '<tr><td class="datos2"><b>'.__('Position (Long, Lat)'). '</b></td>';
|
||||
echo '<td class="datos2" colspan="2"> <a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=gis&id_agente='.$id_agente.'">'.$agent["last_longitude"].', '.$agent["last_latitude"].'</a></td></tr>';
|
||||
}
|
||||
// Last contact
|
||||
echo '<tr><td class="datos2"><b>'.__('Last contact')." / ".__('Remote').'</b></td><td class="datos2 f9" colspan="2">';
|
||||
print_timestamp ($agent["ultimo_contacto"]);
|
||||
|
@ -130,6 +135,11 @@ if ($agent["ultimo_contacto_remoto"] == "0000-00-00 00:00:00") {
|
|||
}
|
||||
echo '</td></tr>';
|
||||
|
||||
// Timezone Offset
|
||||
if ($agent['timezone_offset'] != 0) {
|
||||
echo '<tr><td class="datos2"><b>'.__('Timezone Offset'). '</b></td>';
|
||||
echo '<td class="datos2" colspan="2">'.$agent["timezone_offset"].'</td></tr>';
|
||||
}
|
||||
// Next contact (agent)
|
||||
$progress = getNextAgentContact($id_agente);
|
||||
|
||||
|
|
|
@ -25,5 +25,52 @@ if (! give_acl ($config['id_user'], 0, "PM") && ! is_user_admin ($config['id_use
|
|||
}
|
||||
|
||||
require_once ('include/functions_gis.php');
|
||||
require_once ('include/functions_html.php');
|
||||
|
||||
?>
|
||||
/* Get the parameters */
|
||||
$period = get_parameter ("period", 86400);
|
||||
$agentId = get_parameter('id_agente');
|
||||
$agent_name = get_agent_name($agentId);
|
||||
|
||||
echo "<h2>".__('Received data from')." ". $agent_name . " </h2>";
|
||||
echo "<h3>" . __("Map with the last position/s") . " " . human_time_description ($period) ."</h3>";
|
||||
|
||||
/* Map with the current position */
|
||||
echo "<div id=\"".$agent_name."_agent_map\" style=\"border:1px solid black; width: 250px; height: 250px;\"></div>";
|
||||
echo getAgentMap($agentId, "500px", "98%", true);
|
||||
|
||||
echo "<h3>" . __("Positional data from the last") . " " . human_time_description ($period) ."</h3>";
|
||||
/* Get the total number of Elements for the pagination */
|
||||
$sqlCount = sprintf ("SELECT COUNT(*) FROM tgis_data WHERE tagente_id_agente = %d AND end_timestamp > %d ORDER BY end_timestamp DESC", $agentId, get_system_time () - $period);
|
||||
$countData = get_db_value_sql($sqlCount);
|
||||
/* Get the elements to present in this page */
|
||||
$sql = sprintf ("SELECT longitude, latitude, altitude, start_timestamp, end_timestamp, description, number_of_packages, manual_placement
|
||||
FROM tgis_data
|
||||
WHERE tagente_id_agente = %d AND end_timestamp > %d
|
||||
ORDER BY end_timestamp DESC
|
||||
LIMIT %d OFFSET %d", $agentId, get_system_time () - $period, $config['block_size'], get_parameter ('offset'));
|
||||
$result = get_db_all_rows_sql ($sql, true);
|
||||
|
||||
if ($result === false) {
|
||||
|
||||
echo '<h3 class="error">'.__('There was a problem locating the positional data').'</h3>';
|
||||
}
|
||||
else {
|
||||
pagination ($countData, false) ;
|
||||
$table->data = array();
|
||||
foreach ($result as $row) {
|
||||
$rowdata = array($row['longitude'], $row['latitude'], $row['altitude'], $row['start_timestamp'], $row['end_timestamp'], $row['description'], $row['number_of_packages'], $row['manual_placement']);
|
||||
array_push($table->data, $rowdata);
|
||||
}
|
||||
$table->head = array(__("Longitude"), __("Latitude"), __("Altitude"), __("From"), __("To"), __("Description"), '# '.__("of Packages"), __("Manual placement"));
|
||||
$table->class = 'position_data_table';
|
||||
$table->id = $agent_name.'_position_data_table';
|
||||
$table->title = $agent_name." ". __("positional data");
|
||||
print_table(&$table); unset($table);
|
||||
|
||||
pagination ($countData, false) ;
|
||||
echo "<h3>" . __('Total') . ' ' . $countData . ' ' . __('Data') . "</h3>";
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
@ -167,8 +167,9 @@ if (empty ($id_agente)) {
|
|||
return;
|
||||
}
|
||||
|
||||
$agent = get_db_row ('tagente', 'id_agente', $id_agente);
|
||||
// get group for this id_agente
|
||||
$id_grupo = get_db_value ('id_grupo', 'tagente', 'id_agente', $id_agente);
|
||||
$id_grupo = $agent['id_grupo'];
|
||||
if (! give_acl ($config['id_user'], $id_grupo, "AR")) {
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||
"Trying to access (read) to agent ".get_agent_name($id_agente));
|
||||
|
@ -192,8 +193,23 @@ if (isset($_GET["flag_agent"])){
|
|||
}
|
||||
|
||||
echo "<div id='menu_tab_frame_view'>";
|
||||
if ($agent["icon_path"]) {
|
||||
$icon = "images/gis_map/icons/" . $agent['icon_path'];
|
||||
$state = get_agent_status($id_agente);
|
||||
if (!$state) {
|
||||
$icon .= ".png";
|
||||
}
|
||||
else {
|
||||
$icon .= "_" . $state . ".png";
|
||||
}
|
||||
|
||||
echo '<img src="'.$icon.'" alt="'.__('Agent Icon').'" style="float:right;"/>';
|
||||
}
|
||||
else {
|
||||
$icon = 'images/bricks.png';
|
||||
}
|
||||
echo "<div id='menu_tab_left'><ul class='mn'><li class='view'>
|
||||
<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agente'><img src='images/bricks.png' class='top' border=0> ".mb_substr(get_agent_name($id_agente),0,21)."</a>";
|
||||
<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agente'><img src='$icon' class='top' border=0> ".mb_substr(get_agent_name($id_agente),0,21)."</a>";
|
||||
echo "</li>";
|
||||
echo "</ul></div>";
|
||||
$tab = get_parameter ("tab", "main");
|
||||
|
|
Loading…
Reference in New Issue