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>
|
2010-02-18 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
* godmode/agentes/configurar_agente.php: fix the date to save into DB.
|
* 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 refreshAjaxIntervalSeconds = 6000;
|
||||||
var idIntervalAjax = null;
|
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) {
|
function refreshAjaxLayer(layer) {
|
||||||
var featureIdArray = Array();
|
var featureIdArray = Array();
|
||||||
|
|
||||||
|
@ -255,48 +238,19 @@ function activateAjaxRefresh($layers = null, $lastTimeOfData = null) {
|
||||||
if (data.correct) {
|
if (data.correct) {
|
||||||
content = $.evalJSON(data.content);
|
content = $.evalJSON(data.content);
|
||||||
|
|
||||||
if (content.coords != null) {
|
if (content != null) {
|
||||||
listAgentsPoints = content.coords;
|
for (var idAgent in content) {
|
||||||
|
|
||||||
for (var idAgent in listAgentsPoints) {
|
|
||||||
if (isInt(idAgent)) {
|
if (isInt(idAgent)) {
|
||||||
listPoints = listAgentsPoints[idAgent];
|
agentDataGIS = content[idAgent];
|
||||||
|
|
||||||
for (var pointIndex in listPoints) {
|
feature = searchPointAgentById(idAgent);
|
||||||
if (isInt(pointIndex)) {
|
layer.removeFeatures(feature);
|
||||||
feature = searchPointAgentById(idAgent);
|
console.log(feature);
|
||||||
|
delete feature;
|
||||||
|
|
||||||
var point = new OpenLayers.LonLat(listPoints[pointIndex].longitude, listPoints[pointIndex].latitude)
|
js_addPointExtent(layer.name, agentDataGIS['name'],
|
||||||
.transform(map.displayProjection, map.getProjectionObject());
|
agentDataGIS['stored_longitude'], agentDataGIS['stored_latitude'],
|
||||||
|
agentDataGIS['icon_path'], 20, 20, idAgent, 'point_agent_info');
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -338,7 +292,7 @@ function activateAjaxRefresh($layers = null, $lastTimeOfData = null) {
|
||||||
<?php
|
<?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">
|
<script type="text/javascript">
|
||||||
$(document).ready (
|
$(document).ready (
|
||||||
|
|
|
@ -358,3 +358,26 @@ function js_addLineString(layerName, points, color) {
|
||||||
|
|
||||||
layer.addFeatures(lineString);
|
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
|
WHERE tagente_id_agente = %d AND end_timestamp > %d
|
||||||
ORDER BY end_timestamp DESC
|
ORDER BY end_timestamp DESC
|
||||||
LIMIT %d OFFSET %d", $agentId, get_system_time () - $period, $config['block_size'], get_parameter ('offset'));
|
LIMIT %d OFFSET %d", $agentId, get_system_time () - $period, $config['block_size'], get_parameter ('offset'));
|
||||||
|
|
||||||
$result = get_db_all_rows_sql ($sql, true);
|
$result = get_db_all_rows_sql ($sql, true);
|
||||||
|
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
|
|
|
@ -42,78 +42,41 @@ switch ($opt) {
|
||||||
$returnJSON = array();
|
$returnJSON = array();
|
||||||
$returnJSON['correct'] = 1;
|
$returnJSON['correct'] = 1;
|
||||||
|
|
||||||
$rows = get_db_all_rows_sql('SELECT *
|
$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
|
||||||
FROM tgis_data
|
|
||||||
WHERE tagente_id_agente IN (' . $id_features . ') AND start_timestamp > from_unixtime(' . $last_time_of_data . ') ORDER BY start_timestamp DESC');
|
|
||||||
|
|
||||||
$listCoords = null;
|
if ($flagGroupAll === false) {
|
||||||
foreach ($rows as $row) {
|
$agentsGISStatus = get_db_all_rows_sql('SELECT tagente_id_agente, stored_longitude, stored_latitude
|
||||||
if (empty($listCoords[$row['tagente_id_agente']])) {
|
FROM tgis_data_status
|
||||||
$coords['latitude'] = $row['latitude'];
|
WHERE tagente_id_agente IN
|
||||||
$coords['longitude'] = $row['longitude'];
|
(SELECT id_agente FROM tagente WHERE id_grupo IN
|
||||||
$coords['start_timestamp'] = $row['start_timestamp'];
|
(SELECT tgrupo_id_grupo FROM tgis_map_layer WHERE id_tmap_layer = ' . $layerId . '))
|
||||||
$coords['id_tgis_data'] = $row['id_tgis_data'];
|
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 {
|
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
|
if ($agentsGISStatus === false) {
|
||||||
FROM tagente
|
$agentsGISStatus = array();
|
||||||
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'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows = get_db_all_rows_sql('SELECT * FROM tgis_data
|
$agents = null;
|
||||||
WHERE tagente_id_agente NOT IN (' . $id_features . ') AND tagente_id_agente IN (' . implode(',',$temp) . ')
|
foreach ($agentsGISStatus as $row) {
|
||||||
AND start_timestamp > from_unixtime(' . $last_time_of_data . ') ORDER BY start_timestamp DESC;');
|
$agents[$row['tagente_id_agente']] = array(
|
||||||
|
'icon_path' => get_agent_icon_map($row['tagente_id_agente'], true),
|
||||||
$agents = get_db_all_rows_sql('SELECT id_agente, nombre FROM tagente WHERE
|
'name' => get_agent_name($row['tagente_id_agente']),
|
||||||
id_agente NOT IN (' . $id_features . ') AND id_agente IN (' . implode(',',$temp) . ')');
|
'status' => get_agent_status($idAgent),
|
||||||
|
'stored_longitude' => $row['stored_longitude'],
|
||||||
$listNewCoords = null;
|
'stored_latitude' => $row['stored_latitude']
|
||||||
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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = array('coords' => $listCoords, 'new_coords' => $listNewCoords);
|
$returnJSON['content'] = json_encode($agents);
|
||||||
|
|
||||||
$returnJSON['content'] = json_encode($content); json_encode($listcoords);
|
|
||||||
|
|
||||||
echo json_encode($returnJSON);
|
echo json_encode($returnJSON);
|
||||||
break;
|
break;
|
||||||
case 'point_path_info':
|
case 'point_path_info':
|
||||||
|
|
|
@ -84,11 +84,12 @@ if ($layers != false) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$icon = get_agent_icon_map($idAgent, true);
|
$icon = get_agent_icon_map($idAgent, true);
|
||||||
|
$status = get_agent_status($idAgent);
|
||||||
|
|
||||||
if ($show_history == 'y') {
|
if ($show_history == 'y') {
|
||||||
addPath($layer['layer_name'], $idAgent);
|
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