2010-02-17 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_gis.php: add the parameter id layer in the function "makeLayer" for add the id layer (id of db) in the layer. Fill in the sourcecode in the function "activateAjaxRefresh" that now show new agents in the map in real time and add make changes in this function. * operation/gis_maps/render_view.php: use the new parameter in the call of function "makeLayer". * operation/gis_maps/ajax.php: add code to return new positions (and name and icon) when the ask the positions in "activateAjaxRefresh". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2373 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
f848cb4711
commit
2e1410f8dd
|
@ -1,3 +1,16 @@
|
|||
2010-02-17 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_gis.php: add the parameter id layer in the function
|
||||
"makeLayer" for add the id layer (id of db) in the layer. Fill in the
|
||||
sourcecode in the function "activateAjaxRefresh" that now show new
|
||||
agents in the map in real time and add make changes in this function.
|
||||
|
||||
* operation/gis_maps/render_view.php: use the new parameter in the call
|
||||
of function "makeLayer".
|
||||
|
||||
* operation/gis_maps/ajax.php: add code to return new positions (and name
|
||||
and icon) when the ask the positions in "activateAjaxRefresh".
|
||||
|
||||
2010-02-16 Raúl Mateos <raulofpandora@gmail.com>
|
||||
|
||||
* extensions/module_groups.php: Better description text. Changed font
|
||||
|
|
|
@ -90,7 +90,7 @@ function printMap($idDiv, $iniZoom, $numLevelZooms, $latCenter, $lonCenter, $bas
|
|||
<?php
|
||||
}
|
||||
|
||||
function makeLayer($name, $visible = true, $dot = null) {
|
||||
function makeLayer($name, $visible = true, $dot = null, $idLayer = null) {
|
||||
if ($dot == null) {
|
||||
$dot['url'] = 'images/dot_green.png';
|
||||
$dot['width'] = 20; //11;
|
||||
|
@ -116,6 +116,9 @@ function makeLayer($name, $visible = true, $dot = null) {
|
|||
'<?php echo $name; ?>', {styleMap: style}
|
||||
);
|
||||
|
||||
layer.data = {};
|
||||
layer.data.id = '<?php echo $idLayer; ?>';
|
||||
|
||||
layer.setVisibility(<?php echo $visible; ?>);
|
||||
map.addLayer(layer);
|
||||
|
||||
|
@ -192,7 +195,7 @@ function activateAjaxRefresh($layers = null, $lastTimeOfData = null) {
|
|||
?>
|
||||
<script type="text/javascript">
|
||||
var last_time_of_data = <?php echo $lastTimeOfData; ?>; //This time use in the ajax query to next recent points.
|
||||
var refreshAjaxIntervalSeconds = 1000;
|
||||
var refreshAjaxIntervalSeconds = 6000;
|
||||
var idIntervalAjax = null;
|
||||
|
||||
function searchPointAgentById(id) {
|
||||
|
@ -226,15 +229,17 @@ function activateAjaxRefresh($layers = null, $lastTimeOfData = null) {
|
|||
if (featureIdArray.length > 0) {
|
||||
jQuery.ajax ({
|
||||
data: "page=operation/gis_maps/ajax&opt=get_new_positions&id_features=" + featureIdArray.toString()
|
||||
+ "&last_time_of_data=" + last_time_of_data,
|
||||
+ "&last_time_of_data=" + last_time_of_data + "&layer_id=" + layer.data.id,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
url: "ajax.php",
|
||||
timeout: 10000,
|
||||
success: function (data) {
|
||||
if (data.correct) {
|
||||
if (data.content != "null") {
|
||||
listAgentsPoints = $.evalJSON(data.content);
|
||||
content = $.evalJSON(data.content);
|
||||
|
||||
if (content.coords != null) {
|
||||
listAgentsPoints = content.coords;
|
||||
|
||||
for (var idAgent in listAgentsPoints) {
|
||||
if (isInt(idAgent)) {
|
||||
|
@ -254,6 +259,30 @@ function activateAjaxRefresh($layers = null, $lastTimeOfData = null) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -278,7 +307,7 @@ function activateAjaxRefresh($layers = null, $lastTimeOfData = null) {
|
|||
}
|
||||
?>
|
||||
}
|
||||
//last_time_of_data = Math.round(new Date().getTime() / 1000); //Unixtimestamp
|
||||
last_time_of_data = Math.round(new Date().getTime() / 1000); //Unixtimestamp
|
||||
|
||||
//clearInterval(idIntervalAjax);
|
||||
}
|
||||
|
|
|
@ -37,25 +37,82 @@ switch ($opt) {
|
|||
case 'get_new_positions':
|
||||
$id_features = get_parameter('id_features', '');
|
||||
$last_time_of_data = get_parameter('last_time_of_data');
|
||||
$layerId = get_parameter('layer_id');
|
||||
|
||||
$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 . ')');
|
||||
WHERE tagente_id_agente IN (' . $id_features . ') AND start_timestamp > from_unixtime(' . $last_time_of_data . ') ORDER BY start_timestamp DESC');
|
||||
|
||||
$listCoords = array();
|
||||
$listCoords = null;
|
||||
foreach ($rows as $row) {
|
||||
$coords['latitude'] = $row['latitude'];
|
||||
$coords['longitude'] = $row['longitude'];
|
||||
$coords['start_timestamp'] = $row['start_timestamp'];
|
||||
$coords['id_tgis_data'] = $row['id_tgis_data'];
|
||||
|
||||
$listcoords[$row['tagente_id_agente']][] = $coords;
|
||||
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'];
|
||||
|
||||
$listCoords[$row['tagente_id_agente']][] = $coords;
|
||||
}
|
||||
}
|
||||
|
||||
$returnJSON['content'] = json_encode($listcoords);
|
||||
//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';
|
||||
}
|
||||
|
||||
$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'];
|
||||
}
|
||||
|
||||
$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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$content = array('coords' => $listCoords, 'new_coords' => $listNewCoords);
|
||||
|
||||
$returnJSON['content'] = json_encode($content); json_encode($listcoords);
|
||||
|
||||
echo json_encode($returnJSON);
|
||||
break;
|
||||
|
|
|
@ -72,7 +72,7 @@ printMap('map', $map['zoom_level'], $numZoomLevels, $map['initial_latitude'],
|
|||
|
||||
if ($layers != false) {
|
||||
foreach ($layers as $layer) {
|
||||
makeLayer($layer['layer_name'], $layer['view_layer']);
|
||||
makeLayer($layer['layer_name'], $layer['view_layer'], null, $layer['id_tmap_layer']);
|
||||
|
||||
// calling get_group_agents with none to obtain the names in the same case as they are in the DB.
|
||||
$agentNames = get_group_agents($layer['tgrupo_id_grupo'],false,'none');
|
||||
|
|
|
@ -993,11 +993,6 @@ CREATE TABLE IF NOT EXISTS `tgis_map_layer` (
|
|||
FOREIGN KEY (`tgis_map_id_tgis_map` )
|
||||
REFERENCES `tgis_map` (`id_tgis_map` )
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION,
|
||||
CONSTRAINT `fk_tmap_layer_tgrupo1`
|
||||
FOREIGN KEY (`tgrupo_id_grupo` )
|
||||
REFERENCES `tgrupo` (`id_grupo` )
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB
|
||||
COMMENT = 'Table containing information about the map layers';
|
||||
|
|
Loading…
Reference in New Issue