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_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_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) ); } $avaliableColors = array("#ff0000", "#00ff00", "#0000ff", "#000000"); $randomIndex = array_rand($avaliableColors); $color = $avaliableColors[$randomIndex]; ?> $idConectionMap)); //TODO DELETE IN OTHER TABLES } function saveMapConnection($mapConnection_name, $mapConnection_group, $mapConnection_numLevelsZoom, $mapConnection_defaultZoom, $mapConnection_defaultLatitude, $mapConnection_defaultLongitude, $mapConnection_defaultAltitude, $mapConnection_centerLatitude, $mapConnection_centerLongitude, $mapConnection_centerAltitude, $mapConnectionData, $idConnectionMap = null) { if ($idConnectionMap !== null) { $returnQuery = process_sql_update('tgis_map_connection', array( 'conection_name' => $mapConnection_name, 'connection_type' => $mapConnectionData['type'], 'conection_data' => json_encode($mapConnectionData), 'num_zoom_levels' => $mapConnection_numLevelsZoom, 'default_zoom_level' => $mapConnection_defaultZoom, 'default_longitude' => $mapConnection_defaultLongitude, 'default_latitude' => $mapConnection_defaultLatitude, 'default_altitude' => $mapConnection_defaultAltitude, 'initial_longitude' => $mapConnection_centerLongitude, 'initial_latitude' => $mapConnection_centerLatitude, 'initial_altitude' => $mapConnection_centerAltitude, 'group_id' => $mapConnection_group ), array('id_tmap_connection' => $idConnectionMap) ); } else { $returnQuery = process_sql_insert('tgis_map_connection', array( 'conection_name' => $mapConnection_name, 'connection_type' => $mapConnectionData['type'], 'conection_data' => json_encode($mapConnectionData), 'num_zoom_levels' => $mapConnection_numLevelsZoom, 'default_zoom_level' => $mapConnection_defaultZoom, 'default_longitude' => $mapConnection_defaultLongitude, 'default_latitude' => $mapConnection_defaultLatitude, 'default_altitude' => $mapConnection_defaultAltitude, 'initial_longitude' => $mapConnection_centerLongitude, 'initial_latitude' => $mapConnection_centerLatitude, 'initial_altitude' => $mapConnection_centerAltitude, 'group_id' => $mapConnection_group ) ); } return $returnQuery; } function saveMap($conf, $baselayers, $layers) { $return = false; //TODO validation data //BY DEFAULT TODO need code and change db $articaLongitude = -3.708187; $articaLatitude = 40.42056; $articaAltitude = 0; $defaultControl = array ('type' => 'controls', 'content' => array('Navigation', 'PanZoomBar', 'ScaleLine') ); //BY DEFAULT TODO need code and change db $idMap = process_sql_insert('tgis_map', array( 'map_name' => $conf['name'], 'initial_longitude' => $articaLongitude, 'initial_latitude' => $articaLatitude, 'initial_altitude' => $articaAltitude, 'zoom_level' => $conf['initial_zoom'], 'group_id' => $conf['group'] ) ); $zoom = array("type" => "numLevelsZoom","content" => $conf['numLevelsZoom']); process_sql_insert('tgis_map_connection', array( 'conection_data' => json_encode($defaultControl), 'tgis_map_id_tgis_map' => $idMap ) ); process_sql_insert('tgis_map_connection', array( 'conection_data' => json_encode($zoom), 'tgis_map_id_tgis_map' => $idMap ) ); foreach ($baselayers as $baselayer) { switch ($baselayer['type']) { case 'osm': $temp = array( 'type' => 'baselayer', 'content' => array( 'typeBaseLayer' => 'OSM', 'url' => $baselayer['url'], 'default' => $baselayer['default'] ) ); process_sql_insert('tgis_map_connection', array( 'conection_data' => json_encode($temp), 'tgis_map_id_tgis_map' => $idMap ) ); break; } } foreach($layers as $layer) { process_sql_insert('tgis_map_layer', array( 'layer_name' => $layer['name'], 'view_layer' => $layer['visible'], 'tgis_map_id_tgis_map' => $idMap, 'tgrupo_id_grupo' => $layer['group'] ) ); } return $return; } /** * Save the map into DB, tgis_map and with id_map save the connetions in * tgis_map_has_tgis_map_connection, and with id_map save the layers in * tgis_map_layer and witch each id_layer save the agent in this layer in * table tgis_map_layer_has_tagente. * * @param $map_name * @param $map_initial_longitude * @param $map_initial_latitude * @param $map_initial_altitude * @param $map_zoom_level * @param $map_background * @param $map_default_longitude * @param $map_default_latitude * @param $map_default_altitude * @param $map_group_id * @param $map_connection_list * @param $arrayLayers */ function saveMap2($map_name, $map_initial_longitude, $map_initial_latitude, $map_initial_altitude, $map_zoom_level, $map_background, $map_default_longitude, $map_default_latitude, $map_default_altitude, $map_group_id, $map_connection_list, $arrayLayers) { $idMap = process_sql_insert('tgis_map', array('map_name' => $map_name, 'initial_longitude' => $map_initial_longitude, 'initial_latitude' => $map_initial_latitude, 'initial_altitude' => $map_initial_altitude, 'zoom_level' => $map_zoom_level, 'map_background' => $map_background, 'default_longitude' => $map_default_longitude, 'default_latitude' => $map_default_latitude, 'default_altitude' => $map_default_altitude, 'group_id' => $map_group_id ) ); foreach ($map_connection_list as $map_connection) { process_sql_insert('tgis_map_has_tgis_map_connection', array( 'tgis_map_id_tgis_map' => $idMap, 'tgis_map_connection_id_tmap_connection' => $map_connection, 'default_map_connection' => false //TODO SET DEFAULT ) ); } foreach ($arrayLayers as $index => $layer) { $idLayer = process_sql_insert('tgis_map_layer', array( 'layer_name' => $layer['layer_name'], 'view_layer' => $layer['layer_visible'], 'layer_stack_order' => $index, 'tgis_map_id_tgis_map' => $idMap, 'tgrupo_id_grupo' => $layer['layer_group'] ) ); if (count($layer['layer_agent_list']) > 0) { foreach ($layer['layer_agent_list'] as $agent_name) { process_sql_insert('tgis_map_layer_has_tagente', array( 'tgis_map_layer_id_tmap_layer' => $idLayer, 'tagente_id_agente' => get_agent_id($agent_name) ) ); } } } } /** * 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); } ?>