phpDivingLog 2.1 - Imperial Units fixes

3rd party extensions (phpDivingLog, dive computer downloader,...)
Post Reply
dave
Posts: 10
Joined: Fri Jul 18, 2008 16:47

phpDivingLog 2.1 - Imperial Units fixes

Post by dave »

I fixed a couple of bugs in phpDivingLog 2.1 for those using imperial units.

First, the SAC rate was calculated improperly. The scaling factor was wrong. In includes/misc.inc.php, edit the LitreToCuft function as follows:

Code: Select all

function LitreToCuft($value, $precision = 2)
{
#       return round(($value * 7), $precision);
        return round(($value * 0.0353146667), $precision);
}
Second, the Average Depth reported under the Breathing heading was wrong (not the one on the plot, just the text entry under Breathing). In includes/misc.inc.php, edit the MetreToFeet function as follows:

Code: Select all

function MetreToFeet($value, $precision = 2)
{
#       return round(($value * 3.2808399 ), $precision);
        return round(($value * sqrt( 3.2808399 ) ), $precision);
}
There's a loop somewhere and this scaling factor is applied twice. I'll let the original author sort out that loop.

Dave
dave
Posts: 10
Joined: Fri Jul 18, 2008 16:47

Re: phpDivingLog 2.1 - Imperial Units fixes

Post by dave »

One more addition. If you want two significant figures for the SAC rate, edit line 298 of includes/misc.inc.php as follows:

Code: Select all

#                       $sac = LitreToCuft($sac, 1) ." ". $_lang['unit_rate_imp'];
                        $sac = LitreToCuft($sac, 2) ." ". $_lang['unit_rate_imp'];
Dave
dave
Posts: 10
Joined: Fri Jul 18, 2008 16:47

Re: phpDivingLog 2.1 - Imperial Units fixes

Post by dave »

My average depth fix above broke the max depth - max depth doesn't get scaled twice. So, here is a new average depth fix that doesn't break the max depth.

In includes/misc.inc.php, edit line 294 as follows:

Code: Select all

# put in the / 3.2808399 thingy to fix a bug where the average depth gets scaled twice - k0rx 3/27/2009
                        $averagedepth = MetreToFeet($averagedepth / 3.2808399, 2) ." ";
Dave
Inferno
Posts: 264
Joined: Thu Apr 19, 2007 20:36
Location: The Netherlands
Contact:

Re: phpDivingLog 2.1 - Imperial Units fixes

Post by Inferno »

Will implement those in phpDivinglog

Did not look on the forum for a while, sorry for that!
Post Reply