2010-02-19 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_gis.php: adapt to new tables. * include/javascript/openlayers.pandora.js * operation/gis_maps/render_view.php: adapt to new tables. * operation/gis_maps/ajax.php: adapt to new tables. * operation/agentes/gis_view.php: clean source code. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2386 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
b4515f6638
commit
72bc9ecb30
|
@ -1,3 +1,15 @@
|
|||
2010-02-19 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_gis.php: adapt to new tables.
|
||||
|
||||
* include/javascript/openlayers.pandora.js
|
||||
|
||||
* operation/gis_maps/render_view.php: adapt to new tables.
|
||||
|
||||
* operation/gis_maps/ajax.php: adapt to new tables.
|
||||
|
||||
* operation/agentes/gis_view.php: clean source code.
|
||||
|
||||
2010-02-18 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* godmode/agentes/configurar_agente.php: fix the date to save into DB.
|
||||
|
|
|
@ -215,23 +215,6 @@ function activateAjaxRefresh($layers = null, $lastTimeOfData = null) {
|
|||
var refreshAjaxIntervalSeconds = 6000;
|
||||
var idIntervalAjax = null;
|
||||
|
||||
function searchPointAgentById(id) {
|
||||
for (layerIndex = 0; layerIndex < map.getNumLayers(); layerIndex++) {
|
||||
layer = map.layers[layerIndex];
|
||||
|
||||
if (layer.features != undefined) {
|
||||
for (featureIndex = 0; featureIndex < layer.features.length; featureIndex++) {
|
||||
feature = layer.features[featureIndex];
|
||||
if (feature.data.id == id) {
|
||||
return feature;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function refreshAjaxLayer(layer) {
|
||||
var featureIdArray = Array();
|
||||
|
||||
|
@ -255,48 +238,19 @@ function activateAjaxRefresh($layers = null, $lastTimeOfData = null) {
|
|||
if (data.correct) {
|
||||
content = $.evalJSON(data.content);
|
||||
|
||||
if (content.coords != null) {
|
||||
listAgentsPoints = content.coords;
|
||||
|
||||
for (var idAgent in listAgentsPoints) {
|
||||
if (content != null) {
|
||||
for (var idAgent in content) {
|
||||
if (isInt(idAgent)) {
|
||||
listPoints = listAgentsPoints[idAgent];
|
||||
agentDataGIS = content[idAgent];
|
||||
|
||||
for (var pointIndex in listPoints) {
|
||||
if (isInt(pointIndex)) {
|
||||
feature = searchPointAgentById(idAgent);
|
||||
feature = searchPointAgentById(idAgent);
|
||||
layer.removeFeatures(feature);
|
||||
console.log(feature);
|
||||
delete feature;
|
||||
|
||||
var point = new OpenLayers.LonLat(listPoints[pointIndex].longitude, listPoints[pointIndex].latitude)
|
||||
.transform(map.displayProjection, map.getProjectionObject());
|
||||
|
||||
feature.data.long_lat = point;
|
||||
feature.move(point);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (content.new_coords != null) {
|
||||
listNewAgentsPoints = content.new_coords;
|
||||
|
||||
for (var idAgent in listNewAgentsPoints) {
|
||||
if (isInt(idAgent)) {
|
||||
point = listNewAgentsPoints[idAgent];
|
||||
|
||||
var geometryPoint = new OpenLayers.Geometry.Point(point.longitude, point.latitude)
|
||||
.transform(map.displayProjection, map.getProjectionObject());
|
||||
|
||||
feature = new OpenLayers.Feature.Vector(geometryPoint,
|
||||
{id: idAgent,
|
||||
type: 'point_agent_info',
|
||||
long_lat: new OpenLayers.LonLat(point.longitude, point.latitude).transform(map.displayProjection, map.getProjectionObject()) },
|
||||
{fontWeight: "bolder",
|
||||
fontColor: "#00014F",
|
||||
labelYOffset: -point.icon_height,
|
||||
graphicHeight: point.icon_width, graphicWidth: point.icon_height, externalGraphic: point.icon_path, label: point.name});
|
||||
|
||||
layer.addFeatures(feature);
|
||||
js_addPointExtent(layer.name, agentDataGIS['name'],
|
||||
agentDataGIS['stored_longitude'], agentDataGIS['stored_latitude'],
|
||||
agentDataGIS['icon_path'], 20, 20, idAgent, 'point_agent_info');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -338,7 +292,7 @@ function activateAjaxRefresh($layers = null, $lastTimeOfData = null) {
|
|||
<?php
|
||||
}
|
||||
|
||||
function addPoint($layerName, $pointName, $lat, $lon, $icon = null, $width = 20, $height = 20, $point_id = '', $type_string = '') {
|
||||
function addPoint($layerName, $pointName, $lat, $lon, $icon = null, $width = 20, $height = 20, $point_id = '', $status = -1, $type_string = '') {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$(document).ready (
|
||||
|
|
|
@ -358,3 +358,26 @@ function js_addLineString(layerName, points, color) {
|
|||
|
||||
layer.addFeatures(lineString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return feature object for a id agent passed.
|
||||
*
|
||||
* @param interger id The agent id.
|
||||
* @return mixed Return the feature object, if it didn't found then return null.
|
||||
*/
|
||||
function searchPointAgentById(id) {
|
||||
for (layerIndex = 0; layerIndex < map.getNumLayers(); layerIndex++) {
|
||||
layer = map.layers[layerIndex];
|
||||
|
||||
if (layer.features != undefined) {
|
||||
for (featureIndex = 0; featureIndex < layer.features.length; featureIndex++) {
|
||||
feature = layer.features[featureIndex];
|
||||
if (feature.data.id == id) {
|
||||
return feature;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
|
@ -56,6 +56,7 @@ $sql = sprintf ("SELECT longitude, latitude, altitude, start_timestamp, end_time
|
|||
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) {
|
||||
|
|
|
@ -42,78 +42,41 @@ switch ($opt) {
|
|||
$returnJSON = array();
|
||||
$returnJSON['correct'] = 1;
|
||||
|
||||
$rows = get_db_all_rows_sql('SELECT *
|
||||
FROM tgis_data
|
||||
WHERE tagente_id_agente IN (' . $id_features . ') AND start_timestamp > from_unixtime(' . $last_time_of_data . ') ORDER BY start_timestamp DESC');
|
||||
$flagGroupAll = get_db_all_rows_sql('SELECT tgrupo_id_grupo FROM tgis_map_layer WHERE id_tmap_layer = ' . $layerId . ' AND tgrupo_id_grupo = 1;'); //group 1 = all groups
|
||||
|
||||
$listCoords = null;
|
||||
foreach ($rows as $row) {
|
||||
if (empty($listCoords[$row['tagente_id_agente']])) {
|
||||
$coords['latitude'] = $row['latitude'];
|
||||
$coords['longitude'] = $row['longitude'];
|
||||
$coords['start_timestamp'] = $row['start_timestamp'];
|
||||
$coords['id_tgis_data'] = $row['id_tgis_data'];
|
||||
if ($flagGroupAll === false) {
|
||||
$agentsGISStatus = get_db_all_rows_sql('SELECT tagente_id_agente, stored_longitude, stored_latitude
|
||||
FROM tgis_data_status
|
||||
WHERE tagente_id_agente IN
|
||||
(SELECT id_agente FROM tagente WHERE id_grupo IN
|
||||
(SELECT tgrupo_id_grupo FROM tgis_map_layer WHERE id_tmap_layer = ' . $layerId . '))
|
||||
OR tagente_id_agente IN
|
||||
(SELECT tagente_id_agente FROM tgis_map_layer_has_tagente WHERE tgis_map_layer_id_tmap_layer = ' . $layerId . ');');
|
||||
|
||||
$listCoords[$row['tagente_id_agente']][] = $coords;
|
||||
}
|
||||
}
|
||||
|
||||
//Extract the data of tgis_data the new agents that it aren't in list
|
||||
//of features.
|
||||
$idGroup = get_db_value('tgrupo_id_grupo', 'tgis_map_layer', 'id_tmap_layer', $layerId);
|
||||
//If id group = 1 is the all groups.
|
||||
if ($idGroup != 1) {
|
||||
$whereGroup = 'id_grupo = ' . $idGroup;
|
||||
}
|
||||
else {
|
||||
$whereGroup = '1 = 1';
|
||||
//All groups, all agents
|
||||
$agentsGISStatus = get_db_all_rows_sql('SELECT tagente_id_agente, stored_longitude, stored_latitude
|
||||
FROM tgis_data_status
|
||||
WHERE tagente_id_agente');
|
||||
}
|
||||
|
||||
$idAgents = get_db_all_rows_sql('SELECT id_agente
|
||||
FROM tagente
|
||||
WHERE id_agente IN (SELECT tagente_id_agente
|
||||
FROM tgis_map_layer_has_tagente
|
||||
WHERE tgis_map_layer_id_tmap_layer = ' . $layerId .') OR ' . $whereGroup);
|
||||
|
||||
$temp = array();
|
||||
foreach($idAgents as $idAgent) {
|
||||
$temp[] = $idAgent['id_agente'];
|
||||
if ($agentsGISStatus === false) {
|
||||
$agentsGISStatus = array();
|
||||
}
|
||||
|
||||
$rows = get_db_all_rows_sql('SELECT * FROM tgis_data
|
||||
WHERE tagente_id_agente NOT IN (' . $id_features . ') AND tagente_id_agente IN (' . implode(',',$temp) . ')
|
||||
AND start_timestamp > from_unixtime(' . $last_time_of_data . ') ORDER BY start_timestamp DESC;');
|
||||
|
||||
$agents = get_db_all_rows_sql('SELECT id_agente, nombre FROM tagente WHERE
|
||||
id_agente NOT IN (' . $id_features . ') AND id_agente IN (' . implode(',',$temp) . ')');
|
||||
|
||||
$listNewCoords = null;
|
||||
foreach ($rows as $row) {
|
||||
if (empty($listNewCoords[$row['tagente_id_agente']])) {
|
||||
foreach ($agents as $agent) {
|
||||
if ($agent['id_agente'] == $row['tagente_id_agente']) {
|
||||
$name = $agent['nombre'];
|
||||
$icon_path = get_agent_icon_map($row['tagente_id_agente'], true);
|
||||
}
|
||||
}
|
||||
|
||||
$listNewCoords[$row['tagente_id_agente']] = array (
|
||||
'latitude' => $row['latitude'],
|
||||
'longitude' => $row['longitude'],
|
||||
'start_timestamp' => $row['start_timestamp'],
|
||||
'id_tgis_data' => $row['id_tgis_data'],
|
||||
'name' => $name,
|
||||
'icon_path' => $icon_path,
|
||||
'icon_width' => 20, //TODO SET CORRECT WIDTH
|
||||
'icon_height' => 20, //TODO SET CORRECT HEIGHT
|
||||
);
|
||||
}
|
||||
$agents = null;
|
||||
foreach ($agentsGISStatus as $row) {
|
||||
$agents[$row['tagente_id_agente']] = array(
|
||||
'icon_path' => get_agent_icon_map($row['tagente_id_agente'], true),
|
||||
'name' => get_agent_name($row['tagente_id_agente']),
|
||||
'status' => get_agent_status($idAgent),
|
||||
'stored_longitude' => $row['stored_longitude'],
|
||||
'stored_latitude' => $row['stored_latitude']
|
||||
);
|
||||
}
|
||||
|
||||
$content = array('coords' => $listCoords, 'new_coords' => $listNewCoords);
|
||||
|
||||
$returnJSON['content'] = json_encode($content); json_encode($listcoords);
|
||||
|
||||
$returnJSON['content'] = json_encode($agents);
|
||||
echo json_encode($returnJSON);
|
||||
break;
|
||||
case 'point_path_info':
|
||||
|
|
|
@ -84,11 +84,12 @@ if ($layers != false) {
|
|||
continue;
|
||||
|
||||
$icon = get_agent_icon_map($idAgent, true);
|
||||
$status = get_agent_status($idAgent);
|
||||
|
||||
if ($show_history == 'y') {
|
||||
addPath($layer['layer_name'], $idAgent);
|
||||
}
|
||||
addPoint($layer['layer_name'], $agentName, $coords['stored_latitude'], $coords['stored_longitude'], $icon, 20, 20, $idAgent, 'point_agent_info');
|
||||
addPoint($layer['layer_name'], $agentName, $coords['stored_latitude'], $coords['stored_longitude'], $icon, 20, 20, $idAgent, $status, 'point_agent_info');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue