![]() |
php guru, convert function puzzle
I need this stored function converted into a regular php function, i get a bit confused on it
SET x = sin(lat1 * pi/180) * sin(lat2 * pi/180) + cos(lat1 *pi/180) * cos(lat2 * pi/180) * cos(abs((lon2 * pi/180) - (lon1 * pi/180))); SET x = atan((sqrt(1- power(x,2))) /x); RETURN (1.852 * 60.0 * ((x/pi)*180)) / 1.609344; so something like function _getDistance($lat1, $lon1, $lat2, $lon2) { ..fill in here with answer please Thanks in advance. |
Copypasta from http://www.codecodex.com/wiki/Calcul...nts_on_a_globe
Code:
function getDistance($latitude1, $longitude1, $latitude2, $longitude2) |
calculates distance as miles (M) or kilometers (K)
Code:
public function distance($lat1, $lon1, $lat2, $lon2, $unit='M') { |
just create this php page and view it.
Code:
<?php |
Quote:
not so funny actually pretty lame |
Quote:
|
thanks guys, giving it a whirl in a few here
|
Wewps, this is not what I wanted, i screwed up by putting 2 sets of longs and lats, basically I need to create the 2nd set of lat/long
using the range provided, only supplying the initial set of lat/longs $range = 30; // miles or kilometers; function _getDistance($lat1, $lon1, $range) { return $lat2, $lon2 the above "procedure" I provided does this, just needs to be converted.. im having problem getting it working creating the 2nd set of lat/longs based off the provided range.. I'll re paraphrase Providing a lat and long, and a range in miles, i need to create a second lat and long based off this.. Can anyone help? |
Hrmph, I think i just figured out what i need to do
$range = 30; (miles?) $rangeFactor = 0.014457; $lat2 = $lat1-($range*$rangeFactor)? $long2 = $long1-($range*$rangeFactor)? |
Quote:
It's like saying "stand in place X and walk 10 miles and tell me where you are". You could be anywhere depending on which heading you set off on.... here is a function that tells you the compass heading based on 2 pairs of lat/lon (lat1/lon1 are the starting point. The heading returned is heading toward lat2/lon2) Quote:
If you want me to figure it out, I'll have to charge you but you have the 2 most important functions there before you to figure it out... |
Quote:
|
All times are GMT -7. The time now is 05:44 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc