Jump to content

Nautical Miles


packo88

Recommended Posts

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 1 month later...
  • Administrators

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);

Link to comment
Share on other sites

  • 6 months 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...