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:

    
  1. Re: Radius-Based Zip Locator ( Clint Davis 2005)
  2. Re: Radius-Based Zip Locator ( "kalin mintchev" 2005)
  3. Re: Radius-Based Zip Locator ( David M. Dantowitz 2005)
  4. Re: Radius-Based Zip Locator ( Clint Davis 2005)
  5. Re: Radius-Based Zip Locator ( "Christian F. Gurney" 2005)
  6. Re: Radius-Based Zip Locator ( "Brian Boegershausen" 2005)
  7. Radius-Based Zip Locator ( Clint Davis 2005)
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:

japanese characters (1997) Nested tags count question (1997) Modifying databases manually (was Banner DNA) (1997) Accepting credit cards (1997) Exclamation point (1997) Using Plug-In while running 1.6.1 (1997) WebMerchant Question (1998) Need help with emailer- 2 issues (1997) Documentation Feedback (1997) Type 11 errors setting up WebCAt 2 (1997) WebCat2final1 crashes (1997) WebCat2b14MacPlugIn - [include] doesn't hide the search string (1997) WebCat2b13MacPlugIn - [showif][search][/showif] (1997) Trouble with PIXO and Welcome Plugin (1999) Deleting Orders (1997) So when do we get something similar? (1998) Multiple security dbs (1997) How do you hide [math]stuff[/math] (1997) Numbers and Numbers and Me (1999) Web Catalog Instability (2000)