Re: Radius-Based Zip Locator
This WebDNA talk-list message is from 2005
It keeps the original formatting.
numero = 61847
interpreted = N
texte = here is a php function that works just fine for locators. you just filterthe distances you want - 10m, 20m, etc...the only thing is you have to find a formula to convert degrees to radiusin wc - the deg2rad() function in php is doing that here. there must be aformula 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);}> I have a database from Census.gov containing 42,000+ zip codes - each with> longitude and latitude. I also have the zip, longitude, and latitude for> each record in my dealer database.>> Would anyone care to share the [math] that performs the distance> calculations after a visitor to enters a zip and radius in miles?>>>> On 2/7/05 9:04 AM, "Clint Davis"
wrote:>>> Anyone have a radius-based zip locator written in WebDNA that they might>> share or sell for cheap? I've been using a CGI that isn't providing>> enough>> flexibility and integration.>>>> -------------------------------------------------------------> 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/>-- -------------------------------------------------------------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:
here is a php function that works just fine for locators. you just filterthe distances you want - 10m, 20m, etc...the only thing is you have to find a formula to convert degrees to radiusin wc - the deg2rad() function in php is doing that here. there must be aformula 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);}> I have a database from Census.gov containing 42,000+ zip codes - each with> longitude and latitude. I also have the zip, longitude, and latitude for> each record in my dealer database.>> Would anyone care to share the [math] that performs the distance> calculations after a visitor to enters a zip and radius in miles?>>>> On 2/7/05 9:04 AM, "Clint Davis" wrote:>>> Anyone have a radius-based zip locator written in WebDNA that they might>> share or sell for cheap? I've been using a CGI that isn't providing>> enough>> flexibility and integration.>>>> -------------------------------------------------------------> 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/>-- -------------------------------------------------------------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/
"kalin mintchev"
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:
Payment Processors (2005)
Where is f2? (1997)
select multiple (1997)
this works sometimes and sometimes not (1997)
Fufillment e-mail? (1998)
emailer settings and control questions (1997)
RedHat Linux glibc version 2.1.2 or higher required (2000)
2 databases problem (1997)
SSL (1998)
A Global Variable (1997)
PIXO (1997)
# fields limited? (1997)
different show next (1997)
[OT] MacOs IE5 topmargin and leftmargin bug (2000)
WebCatalog can't find database (1997)
two unique banners on one page (1997)
Re:no [search] with NT (1997)
Multiple cart additions (1997)
using showpage and showcart commands (1996)
Version f1 status (1997)