Re: Script for "Dealer Locator"
From: Nikolai Chuvakhin (nc_at_iname.com)
Date: 07/05/04
- Next message: Savut: "Re: show webpage result"
- Previous message: D: "Forwarding Email"
- In reply to: Galsaba: "Script for "Dealer Locator""
- Next in thread: Matthew Del Buono: "Re: Script for "Dealer Locator""
- Reply: Matthew Del Buono: "Re: Script for "Dealer Locator""
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 5 Jul 2004 10:59:20 -0700
galsaba@aol.com (Galsaba) wrote in message
news:<20040704063732.04299.00001036@mb-m15.aol.com>...
>
> I am trying to find a script to a "dealer locator" or "find a store
> near you".
>
> I will have two tables. One will include all US and Canada ZIPs
> including lat and longtitudes. The other one is a table of our
> dealers (or store) including thier ZIP codes.
>
> When the user enters his ZIP code, the application needs to check
> (based on the lat and long) if there is a dealer in a 30 miles
> radious. After the application finds the list of all the dealers
> withing this radius, it will send a list with their name, address,
> and the distance from the (ZIP of ) user.
The formula to find the distancebetween two points given their cordinates
is:
$distance = $r * acos(cos($lat1) * cos($lon1) * cos($lat2) * cos($lon2) +
cos($lat1) * sin($lon1) * cos($lat2) * sin($lon2) +
sin($lat1) * sin($lat2));
where:
$r -- radius of the Earth
$lat1 -- latitude of point 1 in radians
$lon1 -- longitude of point 1 in radians
$lat2 -- latitude of point 2 in radians
$lon2 -- longitude of point 2 in radians
You can produce an SQL version of this formula and use it for retrieval
of distances and in the WHERE clause.
Cheers,
NC
- Next message: Savut: "Re: show webpage result"
- Previous message: D: "Forwarding Email"
- In reply to: Galsaba: "Script for "Dealer Locator""
- Next in thread: Matthew Del Buono: "Re: Script for "Dealer Locator""
- Reply: Matthew Del Buono: "Re: Script for "Dealer Locator""
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|