Jump to content

My Dreaded ACARS Issue [SOLVED]


freshJet

Recommended Posts

(Version 2.1.934)

This problem has now been ongoing for almost 2 years. Yes, two years I've been without an ACARS Map. You can see it here:

http://www.freshjetv...index.php/acars

I have tried and tried and tried on SEVERAL difference occasions to solve the issue without avail. I recently went to back and tried to tackle the problem by updating every related file with the default files on gitHub. These are:

  • acarsmap.js (edited to get the weather map too using the code in this thread)
  • acarsmap.tpl
  • local.config.php (just the ACARS options)
  • ACARS.php module

I also deleted my GoogleMapAPI.class.php and GoogleMap.class.php, as these were not in the latest release because they use the old API.

After doing each of these, I emptied the ACARS table, cleared cache and optimised my tables through the Admin Panel.

Still nothing.

It's is beyond frustrating and I'm sick to death of it and desperately want it solved. Here are my files:

acarsmap.js

/**
* phpVMS - Virtual Airline Administration Software
* Copyright (c) 2008 Nabeel Shahzad
* For more information, visit www.phpvms.net
* Forums: http://www.phpvms.net/forum
* Documentation: http://www.phpvms.net/docs
*
* phpVMS is licenced under the following license:
* Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
* View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/
*
* @author Nabeel Shahzad
* @copyright Copyright (c) 2008, Nabeel Shahzad
* @link http://www.phpvms.net
* @license http://creativecommons.org/licenses/by-nc-sa/3.0/
*
* Rewritten for Google Maps v3
*/

var flightMarkers = [];
var routeMarkers = [];
var flightPath = null;
var depMarker = null, arrMarker = null;
var info_window= null;
var run_once = false;

var defaultOptions = {
autozoom: true,
zoom: 4,
center: new google.maps.LatLng(-25.363882,131.044922),
mapTypeId: google.maps.MapTypeId.TERRAIN,
refreshTime: 12000,
autorefresh: true
};

var options = $.extend({}, defaultOptions, acars_map_defaults);
var map = new google.maps.Map(document.getElementById("acarsmap"), options);

// They clicked the map
google.maps.event.addListener(map, 'click', function()
{
//clearPreviousMarkers();
});

liveRefresh();
if(options.autorefresh == true)
{
setInterval(function () { liveRefresh(); }, options.refreshTime);
}

function liveRefresh()
{
$.ajax({
type: "GET",
url: url + "/action.php/acars/data",
dataType: "json",
cache: false,
success: function(data)
{
populateMap(data);
 }
});
};

function populateMap(data)
{
clearMap();
$("#pilotlist").html("");

if (data.length == 0) {
return false;
}

var lat, lng;
var details, row, pilotlink;
var bounds = new google.maps.LatLngBounds();

for (var i = 0; i < data.length; i++)
{
if(data[i] == null || data[i].lat == null || data[i].lng == null
 || data[i].lat == "" || data[i].lng == "")
{
continue;
 }

lat = data[i].lat;
lng = data[i].lng;

if(i%2 == 0)
data[i].trclass = "even";
else
data[i].trclass = "odd";

// Pull ze templates!
var map_row = tmpl("acars_map_row", {flight: data[i]});
var detailed_bubble = tmpl("acars_map_bubble", {flight: data[i]});

$('#pilotlist').append(map_row);

var pos = new google.maps.LatLng(lat, lng);
flightMarkers[flightMarkers.length] = new google.maps.Marker({
position: pos,
map: map,
icon: url+"/lib/images/inair/"+data[i].heading+".png",
flightdetails: data[i],
infowindow_content: detailed_bubble
});

bounds.extend(pos);

google.maps.event.addListener(flightMarkers[flightMarkers.length - 1], 'click', function()
{
clearPreviousMarkers();

var focus_bounds = new google.maps.LatLngBounds();
// Flight details info window
info_window = new google.maps.InfoWindow({
content: this.infowindow_content,
position: this.position
});

info_window.open(map, this);

// Add polyline, and start/end points
var dep_location = new google.maps.LatLng(this.flightdetails.deplat, this.flightdetails.deplng);
var arr_location = new google.maps.LatLng(this.flightdetails.arrlat, this.flightdetails.arrlng);

depMarker = new google.maps.Marker({
position: dep_location,
map: map,
icon: depicon,
title: this.flightdetails.depname,
zIndex: 100
});

arrMarker = new google.maps.Marker({
position: arr_location,
map: map,
icon: arricon,
title: this.flightdetails.arrname,
zIndex: 100
});

// Now the flight path, if it exists
var path = new Array();
path[path.length] = dep_location;
focus_bounds.extend(dep_location);
if(this.flightdetails.route_details.length > 0)
{
	 $.each(this.flightdetails.route_details, function(i, nav)
	 {
		 var loc = new google.maps.LatLng(nav.lat, nav.lng);

		 if(nav.type == 3)
			 icon = "icon_vor.png";
		 else
			 icon = "icon_fix.png";

		 var navpoint_info = tmpl("navpoint_bubble", {nav: nav});
		 routeMarkers[routeMarkers.length] = new google.maps.Marker({
		 position: loc,
		 map: map,
		 icon: url + "/lib/images/"+icon,
		 title: nav.title,
		 zIndex: 100,
		 infowindow_content: navpoint_info
		 });

		 google.maps.event.addListener(routeMarkers[routeMarkers.length - 1], 'click', function()
 {
 info_window = new google.maps.InfoWindow({
 content: this.infowindow_content,
 position: this.position
 });

 info_window.open(map, this);
 });

		 path[path.length] = loc;
		 focus_bounds.extend(loc);
	 });
 }

path[path.length] = arr_location;
focus_bounds.extend(this.position);
focus_bounds.extend(arr_location);

flightPath = new google.maps.Polyline({
path: path,
strokeColor: "#FF0000", strokeOpacity: 1.0, strokeWeight: 2
});

map.fitBounds(focus_bounds);
flightPath.setMap(map);
});
}

// If they selected autozoom, only do the zoom first time
if(options.autozoom == true && run_once == false)
{
map.fitBounds(bounds);
run_once = true;
}
}

function clearPreviousMarkers()
{
if(info_window)
{
info_window.close();
info_window = null;
}

if(depMarker != null)
{
depMarker.setMap(null);
depMarker = null;
}

if(arrMarker != null)
{
arrMarker.setMap(null);
arrMarker = null;
}

if(routeMarkers.length > 0)
{
 for(var i = 0; i < routeMarkers.length; i++) {
routeMarkers[i].setMap(null);
}
}

routeMarkers.length = 0;

if(flightPath != null)
{
flightPath.setMap(null);
flightPath = null;
}
}

function clearMap()
{
if(flightMarkers.length > 0)
{
for(var i = 0; i < flightMarkers.length; i++) {
flightMarkers[i].setMap(null);
}
}

flightMarkers.length = 0;

if(routeMarkers.length > 0)
{
 for(var i = 0; i < routeMarkers.length; i++) {
routeMarkers[i].setMap(null);
}
}

routeMarkers.length = 0;
}

acarsmap.tpl

<h2>Live Flight Map</h2>
<div id="error">The flight map is currently out of order</div>
<br>
<?php
/**
* These are some options for the ACARS map, you can change here
*
* By default, the zoom level and center are ignored, and the map
* will try to fit the all the flights in. If you want to manually set
* the zoom level and center, set "autozoom" to false.
*
* You can use these MapTypeId/s:
* http://code.google.com/apis/maps/documentation/v3/reference.html#MapTypeId
*
* Change the "TERRAIN" to the "Constant" listed there - they are case-sensitive
*
* Also, how to style the acars pilot list table. You can use these style selectors:
*
* table.acarsmap { }
* table.acarsmap thead { }
* table.acarsmap tbody { }
* table.acarsmap tbody tr.even { }
* table.acarsmap tbody tr.odd { }
*/
?>
<script type="text/javascript">
<?php
/* These are the settings for the Google map. You can see the
Google API reference if you want to add more options.

There is two options I have added:

autozoom: This will automatically center in on/zoom
so all your current flights are visible. If false,
then the zoom and center you specify will be used instead

refreshTime: Time, in seconds * 1000 to refresh the map.
The default is 10000 (10 seconds)
*/
?>
var acars_map_defaults = {
autozoom: true,
zoom: 4,
center: new google.maps.LatLng("<?php echo Config::Get('MAP_CENTER_LAT'); ?>", "<?php echo Config::Get('MAP_CENTER_LNG'); ?>"),
mapTypeId: google.maps.MapTypeId.TERRAIN,
refreshTime: 10000
};
</script>
<div class="mapcenter" align="center">
<div id="acarsmap" style="width:<?php echo Config::Get('MAP_WIDTH');?>; height: <?php echo Config::Get('MAP_HEIGHT')?>"></div>
</div>
<?php
/* See below for details and columns you can use in this table */
?>
<br>
<table border = "0" width="100%" class="acarsmap" cellpadding="5" style="border-collapse:collapse;">
<thead>
<tr>
<td style="background-color:#05a2ea; color:#fff; text-shadow:1px 1px 5px #555;"><b>Pilot</b></td>
<td style="background-color:#05a2ea; color:#fff; text-shadow:1px 1px 5px #555;"><b>Flight Number</b></td>
<td style="background-color:#05a2ea; color:#fff; text-shadow:1px 1px 5px #555;"><b>Departure</b></td>
<td style="background-color:#05a2ea; color:#fff; text-shadow:1px 1px 5px #555;"><b>Arrival</b></td>
<td style="background-color:#05a2ea; color:#fff; text-shadow:1px 1px 5px #555;"><b>Status</b></td>
<td style="background-color:#05a2ea; color:#fff; text-shadow:1px 1px 5px #555;"><b>Altitude</b></td>
<td style="background-color:#05a2ea; color:#fff; text-shadow:1px 1px 5px #555;"><b>Speed</b></td>
<td style="background-color:#05a2ea; color:#fff; text-shadow:1px 1px 5px #555;"><b>Distance/Time Remain</b></td>
<td style="background-color:#05a2ea; color:#fff; text-shadow:1px 1px 5px #555;"><b>Progress</b></td>
</tr>
</thead>
<tbody id="pilotlist"></tbody>
</table>
<script type="text/javascript" src="http://www.freshjetvirtual.com/lib/js/acarsmap.js"></script>
<?php
/* This is the template which is used in the table above, for each row.
Be careful modifying it. You can simply add/remove columns, combine
columns too. Keep each "section" (<%=...%>) intact

Variables you can use (what they are is pretty obvious)

Variable: Notes:
<%=flight.pilotid%>
<%=flight.firstname%>
<%=flight.lastname%>
<%=flight.pilotname%> First and last combined
<%=flight.flightnum%>
<%=flight.depapt%> Gives the airport name
<%=flight.depicao%>
<%=flight.arrapt%> Gives the airport name
<%=flight.arricao%>
<%=flight.phasedetail%>
<%=flight.heading%>
<%=flight.alt%>
<%=flight.gs%>
<%=flight.disremaining%>
<%=flight.timeremaning%>
<%=flight.aircraft%> Gives the registration
<%=flight.aircraftname%> Gives the full name
<%=flight.client%> FSACARS/Xacars/FSFK, etc
<%=flight.trclass%> "even" or "odd"

You can also use logic in the templating, if you so choose:
http://ejohn.org/blog/javascript-micro-templating/
*/
?>
<script type="text/html" id="acars_map_row">
<tr class="<%=flight.trclass%>">
<td><a href="<?php echo url('/profile/view');?>/<%=flight.pilotid%>"><%=flight.pilotid%> - <%=flight.pilotname%></a></td>
<td><%=flight.flightnum%></td>
<td><%=flight.depicao%></td>
<td><%=flight.arricao%></td>
<td><%=flight.phasedetail%></td>
<td><%=flight.alt%> ft</td>
<td><%=flight.gs%> kts</td>
<td><%=flight.distremaining%> <?php echo Config::Get('UNITS');?> / <%=flight.timeremaining%></td>
<td><div style="width:100%; height:20px; border:1px solid #999; padding:1px;"><div style="position:relative; height:20px; width:<%=flight.percomplete%>%; background-color:#05a2ea;"><span style="position:absolute; margin:3px; font-weight:bold;"><%=flight.percomplete%>%</span></div></div></td>
</tr>
</script>

<?php
/* This is the template for the little map bubble which pops up when you click on a flight
Same principle as above, keep the <%=...%> tags intact. The same variables are available
to use here as are available above.
*/
?>
<script type="text/html" id="acars_map_bubble">
<span style="font-size: 10px; text-align:left; width: 100%" align="left">
<a href="<?php echo url('/profile/view');?>/<%=flight.pilotid%>"><%=flight.pilotid%> - <%=flight.pilotname%></a><br />
<strong>Flight <%=flight.flightnum%></strong> (<%=flight.depicao%> to <%=flight.arricao%>)<br />
<strong>Status: </strong><%=flight.phasedetail%><br />
<strong>Dist/Time Remain: </strong><%=flight.distremaining%> <?php echo Config::Get('UNITS');?> / <%=flight.timeremaining%><br />
</span>
</script>

<?php
/* This is a small template for information about a navpoint popup

Variables available:

<%=nav.title%>
<%=nav.name%>
<%=nav.freq%>
<%=nav.lat%>
<%=nav.lng%>
<%=nav.type%> 2=NDB 3=VOR 4=DME 5=FIX 6=TRACK
*/
?>
<script type="text/html" id="navpoint_bubble">
<span style="font-size: 10px; text-align:left; width: 100%" align="left">
<strong>Name: </strong><%=nav.title%> (<%=nav.name%>)<br />
<strong>Type: </strong>
<?php /* Show the type of point */ ?>
<% if(nav.type == 2) { %> NDB <% } %>
<% if(nav.type == 3) { %> VOR <% } %>
<% if(nav.type == 4) { %> DME <% } %>
<% if(nav.type == 5) { %> FIX <% } %>
<% if(nav.type == 6) { %> TRACK <% } %>
<br />
<?php /* Only show frequency if its not a 0*/ ?>
<% if(nav.freq != 0) { %>
<strong>Frequency: </strong><%=nav.freq%>
<% } %>
</span>
</script>

core/modules/ACARS/ACARS.php

<?php
/**
* phpVMS - Virtual Airline Administration Software
* Copyright (c) 2008 Nabeel Shahzad
* For more information, visit www.phpvms.net
* Forums: http://www.phpvms.net/forum
* Documentation: http://www.phpvms.net/docs
*
* phpVMS is licenced under the following license:
* Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
* View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/
*
* @author Nabeel Shahzad
* @copyright Copyright (c) 2008, Nabeel Shahzad
* @link http://www.phpvms.net
* @license http://creativecommons.org/licenses/by-nc-sa/3.0/
*/

class ACARS extends CodonModule
{
public $title = 'ACARS';
public $acarsflights;

public function index()
{
$this->viewmap();
}

public function viewmap()
{
$this->title = 'ACARS Map';
$this->set('acarsdata', ACARSData::GetACARSData());
$this->render('acarsmap.tpl');
}

/**
* We didn't list a function for each ACARS client,
* so call this, which will include the acars peice in
*/
public function __call($name, $args)
{
$acars_action = $args[0];

// clean the name...
$name = preg_replace("/[^a-z0-9-]/", "", strtolower($name));
if(dirname(__FILE__).DS.$name.'.php')
{
include_once dirname(__FILE__).DS.$name.'.php';
return;
}
}

public function data()
{
$flights = ACARSData::GetACARSData();

if(!$flights)
$flights = array();

$this->acarsflights = array();
foreach($flights as $flight)
{
if($flight->route == '')
{
$flight->route_details = array();
}
else
{
$flight->route_details = NavData::parseRoute($flight->route);
}

$c = (array) $flight; // Convert the object to an array

$c['pilotid'] = PilotData::GetPilotCode($c['code'], $c['pilotid']);

// Normalize the data
if($c['timeremaining'] == '')
{
$c['timeremaining'] == '-';
}

if(trim($c['phasedetail']) == '')
{
$c['phasedetail'] = 'Enroute';
}

/* If no heading was passed via ACARS app then calculate it
This should probably move to inside the ACARSData function, so then
the heading is always there for no matter what the calcuation is
*/
if($flight->heading == '')
{
/* Calculate an angle based on current coords and the
destination coordinates */

$flight->heading = intval(atan2(($flight->lat - $flight->arrlat), ($flight->lng - $flight->arrlng)) * 180 / 3.14);
//$flight->heading *= intval(180/3.14159);

if(($flight->lng - $flight->arrlng) < 0)
{
$flight->heading += 180;
}

if($flight->heading < 0)
{
$flight->heading += 360;
}
}

// Little one-off fixes to normalize data
$c['distremaining'] = $c['distremain'];
$c['pilotname'] = $c['firstname'] . ' ' . $c['lastname'];

unset($c['messagelog']);

$this->acarsflights[] = $c;

continue;
}

CodonEvent::Dispatch('refresh_acars', 'ACARS');

echo json_encode($this->acarsflights);
}

public function routeinfo()
{
if($this->get->depicao == '' || $this->get->arricao == '')
return;

$depinfo = OperationsData::GetAirportInfo($this->get->depicao);
if(!$depinfo)
{
$depinfo = OperationsData::RetrieveAirportInfo($this->get->depicao);
}

$arrinfo = OperationsData::GetAirportInfo($this->get->arricao);
if(!$arrinfo)
{
$arrinfo = OperationsData::RetrieveAirportInfo($this->get->arricao);
}

// Convert to json format
$c = array();
$c['depapt'] = (array) $depinfo;
$c['arrapt'] = (array) $arrinfo;

echo json_encode($c);
}

public function fsacarsconfig()
{
$this->write_config('fsacars_config.tpl', Auth::$userinfo->code.'.ini');
}

public function fspaxconfig()
{
$this->write_config('fspax_config.tpl', Auth::$userinfo->code.'_config.cfg');
}

public function xacarsconfig()
{
$this->write_config('xacars_config.tpl', 'xacars.ini');
}

/**
* Write out a config file to the user, give the template name and
* the filename to save the template as to the user
*
* @param mixed $template_name Template to use for config (fspax_config.tpl)
* @param mixed $save_as File to save as (xacars.ini)
* @return mixed Nothing, sends the file to the user
*
*/
public function write_config($template_name, $save_as)
{
if(!Auth::LoggedIn())
{
echo 'You are not logged in!';
break;
}

$this->set('pilotcode', PilotData::GetPilotCode(Auth::$userinfo->code, Auth::$userinfo->pilotid));
$this->set('userinfo', Auth::$userinfo);

$acars_config = Template::GetTemplate($template_name, true);
$acars_config = str_replace("\n", "\r\n", $acars_config);

Util::downloadFile($acars_config, $save_as);
}
}

Sorry for the long post but I hope it's worth it.

Link to comment
Share on other sites

<script type="[url=""]text/javascript[/url]" src="[url="view-source:http://maps.google.com/maps?file=api&v=2&key=ABQIAAAASk9UOLkN7J1sfTeYyS92ERTJHRHAGbfvAuNReGOVJPUWTmIr5RQglXm4oCvrYNQp0PbWb9ud2FqJRA"]http://maps.google.com/maps?file=api&v=2&key=ABQIAAAASk9UOLkN7J1sfTeYyS92ERTJHRHAGbfvAuNReGOVJPUWTmIr5RQglXm4oCvrYNQp0PbWb9ud2FqJRA[/url]"></script>

I had a look at the code for my va acars map, and I dont have that line, and it works fine. Maybe try commenting it out, or cutting and pasting it into a different file, and try your acars map without it, that way, you can always return it if something goes horribly wrong.

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...