Jump to content

I need to make a calculation using this


CarlosGarcia

Recommended Posts

Good Day.

I want to know how can I take some data from acarmaps.tpl to make a PHP Formula to make a calculation.

Something like I want to convert Plane Altitude to Meters.

The Formula is very simple AltitudeMts = AltitudeFeets / 3.28 (Aprox).

acarmaps.tpl Give me <%=flight.alt%> I think this is the plane Actual Altitude. And can be show in the Html Table using <td><%=flight.alt%></td>.

Now The question, How can i assign the <%=flight.alt%> Value ta a PHP variable so I can make the formula using PHP and siplay in a new Row in the html table. ?

Thanks and sorry for my poor english I speak Spanish.

Regards

Carlos Garcia

Link to comment
Share on other sites

Shouldn't you be able to get a better result if you were to change this (in app.config.php)

# Units settings
#	These are global, also used for FSPAX
Config::Set('WeightUnit', '1');		# 0=Kg 1=lbs
Config::Set('DistanceUnit', '2');   # 0=KM 1= Miles 2=NMiles  <-Change this to 0->
Config::Set('SpeedUnit', '1');		# 0=Km/H 1=Kts
Config::Set('AltUnit', '1');		# 0=Meter 1=Feet 
Config::Set('LiquidUnit', '3');		# 0=liter 1=gal 2=kg 3=lbs
Config::Set('WelcomeMessage', 'phpVMS/FSPAX ACARS'); # Welcome Message
Config::Set('LIQUID_UNIT_NAMES', array('liter','gal','kg', 'lbs'));

and place that in the local.config.php?

Link to comment
Share on other sites

Hello Thanks for answer and sorry for my late reply.

Jeff : Yes I know that I can change this values in the Config files. But the Idea is to make some Calculation in the Acars Map, so I can Give the users Altitude Both in meters and Feets.

Kyle . Thanks for you code. But I was trying to assign the value to a variable, I think the way to make it its something like <?php $altmts = round(<%=flight.alt%>/3.28);?> Then I can use the $altmts variable to make another calculations.

Kyle : Yes the code must be in the acarsmap.tpl

The altitude was just a example, im using Xacars so the plane Speed is in Knots, I will try to change this value to Ground Speed so I can Calculate the ETA. Well here I not shure if this works this way, But I will try.

I will give it a try and post my comments Thanks and Sorry again for the late reply.

Carlos Garcia Acevedo

SKBQ Barranquilla Colombia

Link to comment
Share on other sites

acarsmap.tpl

Trying to convert KIAS to KTAS :

( Ground Speed is what the aircraft travels over the ground. Basically, it is your TAS, plus the effect of the head/tail wind component.) I dont have into account the head/tail wind component... So I really calculating KTAS

Ok trying this but dont work :

I cant use another formula like : A good rule for true airspeed is to add 2% to your KIAS for every 1000ft of altitude. So 100KIAS at 5000ft MLS would be about 110 KTAS.

<?php $alt="<%=flight.alt%>" ;?>
<?php
if ($alt >=1 and $alt <=4999) { 
$F =1;
} elseif ($alt >=5000 and $alt <=9999) {
$F=1.08;
} elseif ($alt >=10000 and $alt <=14999) {
$F=1.17;
} elseif ($alt >=15000 and $alt <=19999) {
$F=1.26;
} elseif ($alt >=20000 and $alt <=24999) {
$F=1.37;
} elseif ($alt >=25000 and $alt <=29999) {
$F=1.50;
} elseif ($alt >=30000 and $alt <=34999) {
$F=1.64;
} elseif ($alt >=35000 and $alt <=34999) {
$F=1.79;
} else {
$F=2.02;
}
?>

<!-- Aprox Ground Speed - KTAS -->
<?php $speed ="<%=flight.gs* $F %>";?>
<td> <?php echo $speed ;?> </td>
</tr>
</script>

If I only use :

<?php $speed ="<%=flight.gs%>";?>
<td> <?php echo $speed ;?> </td>

I can see the Fly speed of the plane, But I cant make any calculation with $speed

$speed is a PHP String so I try to Convert to integer This way $speed=$speed + 0 This way $speed now is a Integer value but I cant make any Calculation... ?? Here Im a little Lost.

Any Ideas ?

Regards

Carlos

Link to comment
Share on other sites

  • 2 weeks 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...