Link to home
Start Free TrialLog in
Avatar of baal32
baal32

asked on

Distance between 2 addresses calculator

I need to implement a 'miles from' calculator for distances between 2 addresses (not zipcodes as I'm dealing with very short distances - 1-10 miles mostly).  Do I need to buy a service from someone or....?  I'm working in PHP and MYSQL BTW.
SOLUTION
Avatar of rdivilbiss
rdivilbiss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of baal32
baal32

ASKER

Hi rdivibliss - I can't get that link to show...

My situation - I'm trying to put together a local (small town) website showing off most of the 500 businesses located here.  If MS pricing is transactional I think it may be a little out of my league as I would like to be able to display "5 closest businesses" each time a business is viewed (499 transactions/click may bankrupt me pretty quick)

If the process of converting addresses to lat/lons isn't too difficult and the process of finding the mileage distance between 2 lat/lons is also not too difficult I may go that route (the 500 bsinesses all have known addresses - I won't be doing a "closest to you" where users enter their own info).

Could you lead me a little further on this?
Somewhere I have the code to do milage by Latitude and Longitude.

I suppose you could rent a GPS and visit 500 businesses, <smile>.

http://tiger.census.gov/cgi-bin/mapsurfer
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
P.S. I looks like Manifold may provide routing and distance info with their add-on product "Manifold 6.00 Business Tools".

"Manifold 6.00 Business Tools Order this product to enable Business Tools functionality in Manifold 6.00 editions.  Provides advanced and easy-to-use districting, optimal routes with driving directions, drive-time zones and geospatially-enabled emailing for only $95. Includes new programmatic functionality as well. This product is a serial number that enables Business Tools functionality - no CD is sent. Requires purchase of Manifold System Release 6.00 to function.   "
from http://www.manifold.net/products/geocoder/geocoder_comp_home.html
Avatar of baal32

ASKER

I'm going to split the points because both of you gave me good leads - I've started by using MSs terra server to get the lat and lon of some of my addresses and I've found some straight-line calculations for the distance.  I'm dealing with fairly short distances for the most part so I'm not very concerned with driving distance instead although I may convert over in the future although I feel a little wary of scraping 499*499 distances....
>  I feel a little wary of scraping 499*499 distances....
Yes.  You are wise.
If it had to be done, I'd spread it out over time, and have delays between between hits, so the serverisn't hammered too hard.  And, there are certainly several services out there that will give you distances.  You could spread it out so you're getting some results from each service.
Just an idea --- When I took a SQL class years ago (which I've forgotten much of), my instructor used an example he created for a state department of transportation to find a repaired section of highway by doing a fairly simple but not obvious SQL query.  I believe you could do the same fairly quickly by choosing the right query and table structure.  One possibility is a 500 row table with a "between"-type query based upon longitude and latitude, presented in order (this requires some additional thought, and it seems less feasible than the next option).  The other is a 2500 row table (500 businesses x 5 closest) based upon pre-calculated distances, or for ultimate flexibility, a 250,000 row (roughly 500 x 499) table with distances pre-calculated.  This query should be a fairly light load on the server, right?
Brett