fsx

% complete flight

75 posts in this topic

Its something I have being trying to work out for a while now. No one seems to be able to give me the code for the total flight distance of a route in the acars map. Then Lorathon decides to add it to his website while im still trying to work out how to show the total distance for a route..

Share this post


Link to post
Share on other sites

Its something I have being trying to work out for a while now.

I've been scratching my head on this one too :P I have tried and failed a few times on it. Would be very cool if the code could be shared.

1 person likes this

Share this post


Link to post
Share on other sites

I can not share my code since I use much more data then the standard phpVMS does. I have modified mine so much that my code no longer works with the standard. But I can point in the right direction,

It is actually quite simple when you think about it. You need two distances. TD = Total Distance (depicao to arricao). And AD = Actual distance (A/C to arricao) this is already in the ACARS table (distremain). The TD can be calculated using the SchedulesData::distanceBetweenPoints($lat1, $lng1, $lat2, $lng2) function. The departure lat/lng and arrival lat/lng are already pulled for the map. Now you have the two distances. The calculation for percentage is ((TD-AD)/TD)*100. Now you have the percent complete. Use the ACARS module to load the data into the json needed for the ACARS Map (Inside of the foreach loop).

The data can now be used inside of the template.

NOTE - You have to do some checks on the TD. If a zero ('0') is returned you have to skip the calc or you will get a divide by zero error!

1 person likes this

Share this post


Link to post
Share on other sites

Jeff, would the code to go in the ACARS module's for each loop go like this:

$td = SchedulesData::distanceBetweenPoints($depicao->lat, $depicao->lng, $arricao->lat, $arricao->lng);
$percentleft = (($TD-$c['distremaining'])/$TD)*100;

1 person likes this

Share this post


Link to post
Share on other sites

I did it like this

$totaldistance = round(SchedulesData::distanceBetweenPoints($flight->deplat, $flight->deplng, $flight->arrlat, $flight->arrlng));
$percomplete = ABS(number_format(((($totaldistance - $flight->distremain) / $totaldistance) * 100), 2));
$c['percomplete'] = $percomplete;

This will give you a nice number to work with.

7 people like this

Share this post


Link to post
Share on other sites

Thanks Jeff, much appreciated :)

+1 rep to you!

1 person likes this

Share this post


Link to post
Share on other sites

Well I did give you rep Jeff, but someone's playing silly peeps with the repping :rolleyes:

2 people like this

Share this post


Link to post
Share on other sites

No problem. Guess someone is out to get me :)

6 people like this

Share this post


Link to post
Share on other sites

No problem. Guess someone is out to get me :)

Sorry guys that was me, I tried to give you both +1 but for some reason I hit the -1 by mistake.

I gave you both +1 in your second posts though

Again sorry about that rolleyes.gif

2 people like this

Share this post


Link to post
Share on other sites
:P No worries, and thanks for the rep! Have some back.
2 people like this

Share this post


Link to post
Share on other sites

:P No worries, and thanks for the rep! Have some back.

Haha thanks :)

1 person likes this

Share this post


Link to post
Share on other sites

lets all have some reps :lol:

action failed: you have reached your quota of positive votes for the day

D: I'll do it tomorrow

Share this post


Link to post
Share on other sites

action failed: you have reached your quota of positive votes for the day

D: I'll do it tomorrow

haha i had the same :lol:

Share this post


Link to post
Share on other sites

can someone please post the code here so we can also take advantage as we are not much expert in modifying codes i will really appreciate it.

Thanx in advance

Share this post


Link to post
Share on other sites

Hi everybody,

@lorathon

If I click on the map plane, appears out a table shows (Time Altitude Heading LAT LNG Fuel Phase V SPD SPD G)it is from these data that run the mathematical operation ? or it is an additional table ?

Share this post


Link to post
Share on other sites

can someone please post the code here so we can also take advantage as we are not much expert in modifying codes i will really appreciate it.

Thanx in advance

Its there. Scroll up

Share this post


Link to post
Share on other sites

@James i know the code is there i mean the full code where exactly to put that code to work ........smile.gif

Thanks in Advance

Ahmad

3 people like this

Share this post


Link to post
Share on other sites

@James i know the code is there i mean the full code where exactly to put that code to work ........smile.gif

Thanks in Advance

Ahmad

Put the above code in your acars.php file (core/modules/acars) then put <%=flight.percomplete%> in your acarsmap.tpl file (core/templates)

Share this post


Link to post
Share on other sites

Put the above code in your acars.php file (core/modules/acars) then put <%=flight.percomplete%> in your acarsmap.tpl file (core/templates)

I can understand that, but at which place in the script, because I have put the code in and nothing happens. Maybe put the whole part

of the code here.

I have another question what to do with charterflights. How do you calculated that.

As always with regards,

Cor

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now