Jump to content

Recommended Posts

Posted

Hi, Is there any way to have the schedules in nautical miles. I know in the local.config I can have either miles or kilometres but all the flying I do is always in NM.

Posted

Thanks, but when we are in the admin panel and adding or editing a route we have the option of automatically calculating the distance. The figure that is calculated is in miles. I would like it to be calculated in nautical miles. Is this possible and if so how would I do it?

Posted

I have set the UNIT to nm in the local.config.php. I added a route from YPPH to YSSY and got phpvms to automatically calculate the distance. The figure it came up with is 2045.47471719. When I check this figure in google earth it is the distance in miles. The distance in nautical miles would be 1771.

I am using the current version 1.2.660

sorry to be a pain  :(

I love your work  ;D

Regards

Packo

  • 1 month later...
  • Administrators
Posted

No, sorry, just checked the code, here's the equation, it could be wrong:

<?php
$distance = (3958 * 3.1415926 * sqrt(($lat2-$lat1) * ($lat2-$lat1) 
               + cos($lat2/57.29578) * cos($lat1/57.29578) * ($lon2-$lon1) * ($lon2-$lon1))/180);
      
      # Distance is in miles
      #   Do proper conversions if needed
      #   Return in nm by default
      
      if(strtolower(Config::Get('UNITS')) == 'mi')
      {
         # Leave it in miles
         return $distance;
      }
      elseif(strtolower(Config::Get('UNITS')) == 'km')
      {
         # Convert to km
         return $distance * 1.609344;
      }
      else
      {
         # Convert to nm
         return $distance * .868976242; # Convert to nautical miles
      }

      return round($distance, 2);

  • 6 months later...
Posted

Hi Nabeel.  I'm having the same issue.  I have NM set up in the local config file but the distance in the schedule is incorrect. 

Does the code you provided above have to be input in any particular file? 

Sorry I don't know anything about PHP but I am learning  ;)

Dan

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...