Re: Radius-Based Zip Locator
This WebDNA talk-list message is from 2005
It keeps the original formatting.
numero = 61850
interpreted = N
texte = Actually, WebDNA has a [math] fuction to convert to radians: rad(number)On 4/22/05 10:12 AM, "kalin mintchev"
wrote:> here is a php function that works just fine for locators. you just filter> the distances you want - 10m, 20m, etc...> > the only thing is you have to find a formula to convert degrees to radius> in wc - the deg2rad() function in php is doing that here. there must be a> formula somewhere on wikipedia how to do that.> > here is the code:> > function decimal_distance($lat1,$lon1,$lat2,$lon2)> {> //$radius is determined using the following formula> //(360 degrees)*(60 minutes per degree)*(1.852) km per minute> //give a circumference of 40003.2 km> //radius is circumference/(2*pi) which gives us 6637km or 3956miles> $radius=3956;> //$radius=3958.75;> $lat1 = deg2rad ($lat1);> $lat2 = deg2rad ($lat2);> $lon1 = deg2rad ($lon1);> $lon2 = deg2rad ($lon2);> > //Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine",> //Sky and Telescope, vol. 68, no. 2, 1984, p. 159):> > $dlon=$lon2-$lon1;> $dlat=$lat2-$lat1;> $sinlat=sin($dlat/2);> $sinlon=sin($dlon/2);> $a=($sinlat*$sinlat)+cos($lat1)*cos($lat2)*($sinlon*$sinlon);> > $c=2*asin(min(1,sqrt($a)));> > $d=$radius*$c;> > > //> return round($d,2);> }-------------------------------------------------------------This message is sent to you because you are subscribed to the mailing list .To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/
Associated Messages, from the most recent to the oldest:
Actually, WebDNA has a [math] fuction to convert to radians: rad(number)On 4/22/05 10:12 AM, "kalin mintchev" wrote:> here is a php function that works just fine for locators. you just filter> the distances you want - 10m, 20m, etc...> > the only thing is you have to find a formula to convert degrees to radius> in wc - the deg2rad() function in php is doing that here. there must be a> formula somewhere on wikipedia how to do that.> > here is the code:> > function decimal_distance($lat1,$lon1,$lat2,$lon2)> {> //$radius is determined using the following formula> //(360 degrees)*(60 minutes per degree)*(1.852) km per minute> //give a circumference of 40003.2 km> //radius is circumference/(2*pi) which gives us 6637km or 3956miles> $radius=3956;> //$radius=3958.75;> $lat1 = deg2rad ($lat1);> $lat2 = deg2rad ($lat2);> $lon1 = deg2rad ($lon1);> $lon2 = deg2rad ($lon2);> > //Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine",> //Sky and Telescope, vol. 68, no. 2, 1984, p. 159):> > $dlon=$lon2-$lon1;> $dlat=$lat2-$lat1;> $sinlat=sin($dlat/2);> $sinlon=sin($dlon/2);> $a=($sinlat*$sinlat)+cos($lat1)*cos($lat2)*($sinlon*$sinlon);> > $c=2*asin(min(1,sqrt($a)));> > $d=$radius*$c;> > > //> return round($d,2);> }-------------------------------------------------------------This message is sent to you because you are subscribed to the mailing list .To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/
Clint Davis
DOWNLOAD WEBDNA NOW!
Top Articles:
Talk List
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...
Related Readings:
(2003)
Getting URL's entered manually (1997)
Max Record length restated as maybe bug (1997)
[sql] problems in WebCat 4.0 (2000)
Bug? (1997)
Performance Issue (2000)
Advice (2003)
Separate SSL Server (1997)
RAM to disk - well correction. (2002)
What happened to the archives? (1999)
[WebDNA] help with [ReturnRaw] - why is it killing the parse of the [include] file? (2009)
HELP WITH DATES (1997)
Attention SMSI - DOCS Error (2004)
This message couldn't reach the list! (multi-column (1998)
Can't use old cart file (was One more try) (1997)
searchable list archive (1997)
Is there a max number of fields? (1998)
2.0Beta Command Ref (can't find this instruction) (1997)
Multiple Merchant Accounts? (1997)
Prevent multiple appends with Reload Button (1997)