2010-02-25 Miguel de Dios <miguel.dedios@artica.es>
* ChangeLog: I did'nt upload in previous commit the changelog. * include/functions_gis.php: refactor the name of function "addPoint" to "addAgentPoint". In function "get_agent_icon_map" add new parameter $status for pass the status. * include/javascript/openlayers.pandora.js: add function "js_addAgentPoint" is same more or less "js_addPoint" and too for "js_addAgentPointExtent" and "js_addPointExtent". * operation/gis_maps/render_view.php: add the id_parent in the call of "addAgentPoint". * operation/gis_maps/ajax.php: clean source code and add the id_parent to return json for each agent. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2423 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
ba7ed06c8a
commit
4a57b9c9e4
|
@ -1,3 +1,29 @@
|
||||||
|
2010-02-25 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* ChangeLog: I did'nt upload in previous commit the changelog.
|
||||||
|
|
||||||
|
* include/functions_gis.php: refactor the name of function "addPoint"
|
||||||
|
to "addAgentPoint". In function "get_agent_icon_map" add new parameter
|
||||||
|
$status for pass the status.
|
||||||
|
|
||||||
|
* include/javascript/openlayers.pandora.js: add function "js_addAgentPoint"
|
||||||
|
is same more or less "js_addPoint" and too for "js_addAgentPointExtent" and
|
||||||
|
"js_addPointExtent".
|
||||||
|
|
||||||
|
* operation/gis_maps/render_view.php: add the id_parent in the call of
|
||||||
|
"addAgentPoint".
|
||||||
|
|
||||||
|
* operation/gis_maps/ajax.php: clean source code and add the id_parent to
|
||||||
|
return json for each agent.
|
||||||
|
|
||||||
|
2010-02-25 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* include/functions_gis.php: in function "addPath" fix the query to extract
|
||||||
|
the path from a time.
|
||||||
|
|
||||||
|
* operation/agentes/gis_view.php: add no-ajax control for filter the time
|
||||||
|
to show path.
|
||||||
|
|
||||||
2010-02-25 Miguel de Dios <miguel.dedios@artica.es>
|
2010-02-25 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
* include/functions_gis.php: in function "addPath" add the parameter
|
* include/functions_gis.php: in function "addPath" add the parameter
|
||||||
|
|
|
@ -278,9 +278,9 @@ function activateAjaxRefresh($layers = null, $lastTimeOfData = null) {
|
||||||
feature = null
|
feature = null
|
||||||
status = parseInt(agentDataGIS['status']);
|
status = parseInt(agentDataGIS['status']);
|
||||||
|
|
||||||
js_addPointExtent(layer.name, agentDataGIS['name'],
|
js_addAgentPointExtent(layer.name, agentDataGIS['name'],
|
||||||
agentDataGIS['stored_longitude'], agentDataGIS['stored_latitude'],
|
agentDataGIS['stored_longitude'], agentDataGIS['stored_latitude'],
|
||||||
agentDataGIS['icon_path'], 20, 20, idAgent, 'point_agent_info', status);
|
agentDataGIS['icon_path'], 20, 20, idAgent, 'point_agent_info', status, agentDataGIS['id_parent']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,18 +332,20 @@ function activateAjaxRefresh($layers = null, $lastTimeOfData = null) {
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
function addPoint($layerName, $pointName, $lat, $lon, $icon = null, $width = 20,
|
function addAgentPoint($layerName, $pointName, $lat, $lon, $icon = null, $width = 20,
|
||||||
$height = 20, $point_id = '', $status = -1, $type_string = '') {
|
$height = 20, $point_id = '', $status = -1, $type_string = '', $idParent = 0) {
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready (
|
$(document).ready (
|
||||||
function () {
|
function () {
|
||||||
<?php
|
<?php
|
||||||
if ($icon != null) {
|
if ($icon != null) {
|
||||||
echo "js_addPointExtent('$layerName', '$pointName', $lon, $lat, '$icon', $width, $height, $point_id, '$type_string', $status);";
|
//echo "js_addPointExtent('$layerName', '$pointName', $lon, $lat, '$icon', $width, $height, $point_id, '$type_string', $status);";
|
||||||
|
echo "js_addAgentPointExtent('$layerName', '$pointName', $lon, $lat, '$icon', $width, $height, $point_id, '$type_string', $status, $idParent);";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo "js_addPoint('$layerName', '$pointName', $lon, $lat, $point_id, '$type_string', $status);";
|
//echo "js_addPoint('$layerName', '$pointName', $lon, $lat, $point_id, '$type_string', $status);";
|
||||||
|
echo "js_addAgentPoint('$layerName', '$pointName', $lon, $lat, $point_id, '$type_string', $status, $idParent);";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
}
|
}
|
||||||
|
@ -424,7 +426,7 @@ function get_agent_last_coords($idAgent) {
|
||||||
return $coords;
|
return $coords;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_agent_icon_map($idAgent, $state = false) {
|
function get_agent_icon_map($idAgent, $state = false, $status = null) {
|
||||||
$row = get_db_row_sql('SELECT id_grupo, icon_path FROM tagente WHERE id_agente = ' . $idAgent);
|
$row = get_db_row_sql('SELECT id_grupo, icon_path FROM tagente WHERE id_agente = ' . $idAgent);
|
||||||
|
|
||||||
if (($row['icon_path'] === null) || (strlen($row['icon_path']) == 0)) {
|
if (($row['icon_path'] === null) || (strlen($row['icon_path']) == 0)) {
|
||||||
|
@ -434,11 +436,14 @@ function get_agent_icon_map($idAgent, $state = false) {
|
||||||
$icon = "images/gis_map/icons/" . $row['icon_path'];
|
$icon = "images/gis_map/icons/" . $row['icon_path'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$state) {
|
if ($state === false) {
|
||||||
return $icon . ".png";
|
return $icon . ".png";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
switch (get_agent_status($idAgent)) {
|
if ($status === null) {
|
||||||
|
$status = get_agent_status($idAgent);
|
||||||
|
}
|
||||||
|
switch ($status) {
|
||||||
case 1:
|
case 1:
|
||||||
case 4:
|
case 4:
|
||||||
//Critical (BAD or ALERT)
|
//Critical (BAD or ALERT)
|
||||||
|
@ -818,7 +823,7 @@ function getAgentMap($agent_id, $heigth, $width, $show_history = false, $centerI
|
||||||
addPath("layer_for_agent_".$agent_name,$agent_id, $history_time);
|
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');
|
addAgentPoint("layer_for_agent_".$agent_name, $agent_name, $agentPositionLatitude, $agentPositionLongitude, $agent_icon, 20, 20, $agent_id, $status, 'point_agent_info');
|
||||||
|
|
||||||
if ($centerInAgent) {
|
if ($centerInAgent) {
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -373,6 +373,38 @@ function showHideLayer(name, action) {
|
||||||
layer[0].setVisibility(action);
|
layer[0].setVisibility(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a point with the default icon in the map.
|
||||||
|
*
|
||||||
|
* @param string layerName The name of layer to put the point.
|
||||||
|
* @param string pointName The name to show in the point.
|
||||||
|
* @param float lon The coord of latitude for point.
|
||||||
|
* @param float lat The coord of longitude for point.
|
||||||
|
* @param string id The id of point.
|
||||||
|
* @param string type_string The type of point, it's use for ajax request.
|
||||||
|
* @param integer statusAgent The status of point.
|
||||||
|
* @param integer idParent Id Parent of agent.
|
||||||
|
*
|
||||||
|
* @return Object The point.
|
||||||
|
*/
|
||||||
|
function js_addAgentPoint(layerName, pointName, lon, lat, id, type_string, statusAgent, idParent) {
|
||||||
|
var point = new OpenLayers.Geometry.Point(lon, lat)
|
||||||
|
.transform(map.displayProjection, map.getProjectionObject());
|
||||||
|
|
||||||
|
var layer = map.getLayersByName(layerName);
|
||||||
|
layer = layer[0];
|
||||||
|
|
||||||
|
feature = new OpenLayers.Feature.Vector(point,{id_parent: idParent, status: statusAgent, nombre: pointName, id: id, type: type_string, long_lat: new OpenLayers.LonLat(lon, lat).transform(map.displayProjection, map.getProjectionObject()) });
|
||||||
|
|
||||||
|
if (isHideFeatureByStatus(statusAgent)) {
|
||||||
|
feature.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
layer.addFeatures(feature);
|
||||||
|
|
||||||
|
return feature;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a point with the default icon in the map.
|
* Add a point with the default icon in the map.
|
||||||
*
|
*
|
||||||
|
@ -404,6 +436,46 @@ function js_addPoint(layerName, pointName, lon, lat, id, type_string, statusAgen
|
||||||
return feature;
|
return feature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a agent point and set the icon in the map.
|
||||||
|
*
|
||||||
|
* @param string layerName The name of layer to put the point.
|
||||||
|
* @param string pointName The name to show in the point.
|
||||||
|
* @param float lon The coord of latitude for point.
|
||||||
|
* @param float lat The coord of longitude for point.
|
||||||
|
* @param string icon Url of icon image.
|
||||||
|
* @param integer width The width of icon.
|
||||||
|
* @param integer height The height of icon.
|
||||||
|
* @param string id The id of point.
|
||||||
|
* @param string type_string The type of point, it's use for ajax request.
|
||||||
|
* @param integer statusAgent The status of point.
|
||||||
|
* @param integer idParent Id Parent of agent.
|
||||||
|
*
|
||||||
|
* @return Object The point.
|
||||||
|
*/
|
||||||
|
function js_addAgentPointExtent(layerName, pointName, lon, lat, icon, width, height, id, type_string, statusAgent, idParent) {
|
||||||
|
var point = new OpenLayers.Geometry.Point(lon, lat)
|
||||||
|
.transform(map.displayProjection, map.getProjectionObject());
|
||||||
|
|
||||||
|
var layer = map.getLayersByName(layerName);
|
||||||
|
layer = layer[0];
|
||||||
|
|
||||||
|
if (typeof(statusAgent) == 'string')
|
||||||
|
statusA = parseInt(statusAgent);
|
||||||
|
else
|
||||||
|
statusA = statusAgent;
|
||||||
|
|
||||||
|
feature = new OpenLayers.Feature.Vector(point,{id_parent: idParent, status: statusA, id: id, type: type_string, long_lat: new OpenLayers.LonLat(lon, lat).transform(map.displayProjection, map.getProjectionObject()) }, {fontWeight: "bolder", fontColor: "#00014F", labelYOffset: -height, graphicHeight: width, graphicWidth: height, externalGraphic: icon, label: pointName});
|
||||||
|
|
||||||
|
if (isHideFeatureByStatus(statusAgent)) {
|
||||||
|
feature.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
layer.addFeatures(feature);
|
||||||
|
|
||||||
|
return feature;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a point and set the icon in the map.
|
* Add a point and set the icon in the map.
|
||||||
*
|
*
|
||||||
|
|
|
@ -66,33 +66,34 @@ switch ($opt) {
|
||||||
foreach ($idAgentsWithGISTemp as $idAgent) {
|
foreach ($idAgentsWithGISTemp as $idAgent) {
|
||||||
$idAgentsWithGIS[] = $idAgent['id_agente'];
|
$idAgentsWithGIS[] = $idAgent['id_agente'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$agentsGISStatus = get_db_all_rows_sql('SELECT t1.id_agente AS tagente_id_agente,
|
|
||||||
IFNULL(t2.stored_longitude, ' . $defaultCoords['default_longitude'] . ') AS stored_longitude,
|
|
||||||
IFNULL(t2.stored_latitude, ' . $defaultCoords['default_latitude'] . ') AS stored_latitude
|
|
||||||
FROM tagente AS t1
|
|
||||||
LEFT JOIN tgis_data_status AS t2 ON t1.id_agente = t2.tagente_id_agente
|
|
||||||
WHERE id_agente IN (' . implode(',', $idAgentsWithGIS) . ')');
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//Extract the agent GIS status for one agent.
|
//Extract the agent GIS status for one agent.
|
||||||
$agentsGISStatus = get_db_all_rows_sql('SELECT tagente_id_agente, stored_longitude, stored_latitude
|
$idAgentsWithGIS[] = $id_features;
|
||||||
FROM tgis_data_status
|
|
||||||
WHERE tagente_id_agente = ' . $id_features);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$agentsGISStatus = get_db_all_rows_sql('SELECT t1.nombre, id_parent, t1.id_parent1.id_agente AS tagente_id_agente,
|
||||||
|
IFNULL(t2.stored_longitude, ' . $defaultCoords['default_longitude'] . ') AS stored_longitude,
|
||||||
|
IFNULL(t2.stored_latitude, ' . $defaultCoords['default_latitude'] . ') AS stored_latitude
|
||||||
|
FROM tagente AS t1
|
||||||
|
LEFT JOIN tgis_data_status AS t2 ON t1.id_agente = t2.tagente_id_agente
|
||||||
|
WHERE id_agente IN (' . implode(',', $idAgentsWithGIS) . ')');
|
||||||
|
|
||||||
if ($agentsGISStatus === false) {
|
if ($agentsGISStatus === false) {
|
||||||
$agentsGISStatus = array();
|
$agentsGISStatus = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$agents = null;
|
$agents = null;
|
||||||
foreach ($agentsGISStatus as $row) {
|
foreach ($agentsGISStatus as $row) {
|
||||||
|
$status = get_agent_status($row['tagente_id_agente']);
|
||||||
|
|
||||||
$agents[$row['tagente_id_agente']] = array(
|
$agents[$row['tagente_id_agente']] = array(
|
||||||
'icon_path' => get_agent_icon_map($row['tagente_id_agente'], true),
|
'icon_path' => get_agent_icon_map($row['tagente_id_agente'], true, $status),
|
||||||
'name' => get_agent_name($row['tagente_id_agente']),
|
'name' => $row['nombre'],
|
||||||
'status' => get_agent_status($row['tagente_id_agente']),
|
'status' => $status,
|
||||||
'stored_longitude' => $row['stored_longitude'],
|
'stored_longitude' => $row['stored_longitude'],
|
||||||
'stored_latitude' => $row['stored_latitude']
|
'stored_latitude' => $row['stored_latitude'],
|
||||||
|
'id_parent' => $row['id_parent']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,9 +132,10 @@ if ($layers != false) {
|
||||||
}
|
}
|
||||||
$icon = get_agent_icon_map($idAgent, true);
|
$icon = get_agent_icon_map($idAgent, true);
|
||||||
$status = get_agent_status($idAgent);
|
$status = get_agent_status($idAgent);
|
||||||
|
$parent = get_db_value('id_parent', 'tagente', 'id_agente', $idAgent);
|
||||||
|
|
||||||
addPoint($layer['layer_name'], $agentName, $coords['stored_latitude'],
|
addAgentPoint($layer['layer_name'], $agentName, $coords['stored_latitude'],
|
||||||
$coords['stored_longitude'], $icon, 20, 20, $idAgent, $status, 'point_agent_info');
|
$coords['stored_longitude'], $icon, 20, 20, $idAgent, $status, 'point_agent_info', $parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue