distance formula
Moderator: General Moderators
JshPro helped me figure out a better way to save database querying time. I'm going to store the lat/long of each user in the `users` table. This way when I show results I don't have to query the 800,000+ record table of zips and then query the users table for matches. I can just simply query the users table for lat/lon and matches.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Sorry for the insane delay in getting this posted. I found my ziplocator class and am posting it on my website for a few days. It is meant to be used in conjunction with a members table so that way you can find all members within a radius. If you have a lat and lon table (US zips or Canadian) I am sure this can be applied to what you want.
http://www.everah.com/freebies/ziplocator.php.txt
Please note that I am still adding items to this class. Also, this was written for PHP4. I just ran it in PHP5 and it seemed to work fine (although a little slow on my development system). When I ran it on my hosted server a few months ago it seemed to be pretty fast.
Anyhow, use it for what you will. All I ask is that if you market it, sell it or redistribute it that you give me credit it for it by including my web address http://www.everah.com. Thanks.
http://www.everah.com/freebies/ziplocator.php.txt
Please note that I am still adding items to this class. Also, this was written for PHP4. I just ran it in PHP5 and it seemed to work fine (although a little slow on my development system). When I ran it on my hosted server a few months ago it seemed to be pretty fast.
Anyhow, use it for what you will. All I ask is that if you market it, sell it or redistribute it that you give me credit it for it by including my web address http://www.everah.com. Thanks.
I have a script that it commented through out, that can do these calculations. I have both the U.S and Canada data sets. The U.S. data I just updated on February 5, 2006. The Canadian data I last updated on Jan 15, 2006. They both contain every postal code and city info, including populations that is valid from Dec 2005. The data sets use Geo Plate formula, which allows for very close to near driving distances and flying distances using the routing tables which commercial airlines must follow. All of this is done using just MySQL, without the need for a high end GIS data set.
It includes the data set (dump), scripts/classes ( distance, sql), templates (2 sets), (2) PSD pre-sliced so you can change the colors and text. The U.S. script contains 3 examples...
distance by zip code
radius by zip code
closest Post Office from a (physical address, 12 Beacon St, Boston MA) post office data has, phone, fax, hours of operation, dates closed
Canadian contains 3 examples
distance by zip code
radius by zip code
distance city, province
If you want the Canadian set PM and I will give you a link to it. You can also get the U.S. set, PM for that link.
I don't have the Canadian example up but I will put it tomorrow so you can try it! I 'll also put the post office one up tomorrow as I just looked and I don't have that data set at home with me!
U.S.
Zip Code Example
http://www.lovemedammit.com/distance/zip.php
Radius Example
http://www.lovemedammit.com/distance/radius.php
If anything, the examples will each you how to do better calculations than lame point to point measurements!
yj!
It includes the data set (dump), scripts/classes ( distance, sql), templates (2 sets), (2) PSD pre-sliced so you can change the colors and text. The U.S. script contains 3 examples...
distance by zip code
radius by zip code
closest Post Office from a (physical address, 12 Beacon St, Boston MA) post office data has, phone, fax, hours of operation, dates closed
Canadian contains 3 examples
distance by zip code
radius by zip code
distance city, province
If you want the Canadian set PM and I will give you a link to it. You can also get the U.S. set, PM for that link.
I don't have the Canadian example up but I will put it tomorrow so you can try it! I 'll also put the post office one up tomorrow as I just looked and I don't have that data set at home with me!
U.S.
Zip Code Example
http://www.lovemedammit.com/distance/zip.php
Radius Example
http://www.lovemedammit.com/distance/radius.php
If anything, the examples will each you how to do better calculations than lame point to point measurements!
yj!