I have a table of about 400 different Lat/Long. coordinates. I could probably build my own script but I was hoping maybe someone had something like that built already that they would be willing to share.
The purpose of this script will be to direct a user to a regional page based on their IP location.
Thanks!
Determining Nearest Coordinates
Moderator: General Moderators
Re: Determining Nearest Coordinates
Why are you doing this with co-ordinates & not other Geo-ip information? For example, you can use Geo-IP to give one page to everyone in Canada. Another page to everyone in Estonia, etc.
Are these 400 co-ordinates spaced out everywhere on the planet & you just serve up the closest one?
Are these 400 co-ordinates spaced out everywhere on the planet & you just serve up the closest one?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: Determining Nearest Coordinates
They're spaced out all over the united states. So perhaps a person from Rogers, MN would be directed to the Minneapolis page, etc.
Re: Determining Nearest Coordinates
So you want to direct them to the closest page geographically, without regard to political boundaries?
Once you have the location of the IP (say, "Rogers, MN"), you can send that to a location API (Yahoo! has one) to get the latitude & longitude. Once you have that, you can use a horribly complex query to find the closest page.
Once you have the location of the IP (say, "Rogers, MN"), you can send that to a location API (Yahoo! has one) to get the latitude & longitude. Once you have that, you can use a horribly complex query to find the closest page.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
- flying_circus
- Forum Regular
- Posts: 732
- Joined: Wed Mar 05, 2008 10:23 pm
- Location: Sunriver, OR
Re: Determining Nearest Coordinates
Hey Jake,
I see that Pickle has already answered your question, but I was downloading mysql today and saw a blurb that reminded me of this post: "We have looked up your IP address using MaxMind GeoIP, and believe that these mirrors may be closest to you."
Not sure if you're working on a personal project or paid project, but it might be worth looking into. I just skimmed it real quick, but $20 for 50,000 queries might not be the end of the world depending on your traffic.
MaxMind GeoIP
I see that Pickle has already answered your question, but I was downloading mysql today and saw a blurb that reminded me of this post: "We have looked up your IP address using MaxMind GeoIP, and believe that these mirrors may be closest to you."
Not sure if you're working on a personal project or paid project, but it might be worth looking into. I just skimmed it real quick, but $20 for 50,000 queries might not be the end of the world depending on your traffic.
MaxMind GeoIP