How do I implement a simple geographic information database

Hi,

Sorry that this topic is not really rails-specific, but I happen to be
implementing it in rails. I’m trying to implement a common scenario,
where you get a comprehensive list of states/provinces, cities, and
zip/postal codes, and you find nearby cities based on a specified
location, like on some of the dating sites. I have no clue where to
start, I’m not even sure what keywords I should use to search. If
anyone can point out to me how this is usually done, I would really
appreciate it.

Thanks!

Bob

Sorry that this topic is not really rails-specific, but I happen to be
implementing it in rails. I’m trying to implement a common scenario,
where you get a comprehensive list of states/provinces, cities, and
zip/postal codes, and you find nearby cities based on a specified
location, like on some of the dating sites. I have no clue where to
start, I’m not even sure what keywords I should use to search. If
anyone can point out to me how this is usually done, I would really
appreciate it.

Start here:

Get one of the packages that includes lat/long coordinates. Then just
do
earth-distance calculations and you’re done.

We use that to drive this: http://www.cardplayer.com/poker_room

-philip

On May 10, 12:48 pm, Philip H. [email protected] wrote:

http://www.zipcodedownload.com/

Get one of the packages that includes lat/long coordinates. Then just do
earth-distance calculations and you’re done.

We use that to drive this:http://www.cardplayer.com/poker_room

-philip

Thanks for the recommendation. I was wondering if there are any free
ones available that don’t do as much. I just need to let the user
select a city or zip/postal, and return a list of cities within say
50/100/200 miles. There’s no need to be too specific. I am just a
student writing this app from my bedroom, so I try not to spend too
much. :slight_smile:

Thanks!

Bob

On 5/10/07, bob [email protected] wrote:

start, I’m not even sure what keywords I should use to search. If

Thanks!

Bob

Purely out of curiosity, I decided to investigate this myself, and I found
http://www.cfdynamics.com/cfdynamics/zipbase/index.cfm . It’s free, and
has
lat/long coordinates and cities. It appears to be from 2001, but it may
be
accurate enough for your needs.

doppler

I haven’t looked into this at all, but does the Google Maps API have any
calls that would return the exact same information? If so, then just
make a
call out to their service.

On 5/10/07, David R. [email protected] wrote:

scenario,

http://www.zipcodedownload.com/
ones available that don’t do as much. I just need to let the user
found http://www.cfdynamics.com/cfdynamics/zipbase/index.cfm . It’s free,
and has lat/long coordinates and cities. It appears to be from 2001, but it
may be accurate enough for your needs.

doppler


Terry (TAD) Donaghe
http://tadspot.tumblr.com

I haven’t looked into this at all, but does the Google Maps API have any
calls that would return the exact same information? If so, then just make a
call out to their service.

Yes and no. You can get the lat/long for a given address/city/zip, but
you can’t do things like figure out the state given the zip, etc which
is
what this guy wants to do…

Also, they have a limit on the number of queries/day, but if you can
cache
it on insert that might work too.

Hello,

Check out YM4R/GM . I am using it for a website I just started
coding(experimenting yet) www.catbrowse.com

Enter in the text field something like: Arendsweg, netherlands
I list possible results if google maps API returns multiple locations
(thanks to google and YM4R/GM)

If it returns only one address than I show it on google map. Something
like Arendsweg, Alkmaar, Netherlands (and then drag map to a little
South West)

All I use is (query is user’s input)

def find_locations(query)
Geocoding.get(query, { :host => “catbrowse.com” })
end

You should really check out the YM4R/GM, great plugin.

Gokhan A.
www.sylow.net

I just run a quick query below and it finds the state for given zipcode.

$ ./script/console
Loading development environment.

Geocoding.get(“30327”)
=> [#<struct Ym4r::GmPlugin::Geocoding::Placemark address=“GA 30327,
USA”, country_code=“US”, administrative_area=“GA”,
sub_administrative_area=“”, locality=“”, dependent_locality=“”,
thoroughfare=“”, postal_code=“30327”, longitude=-84.419966,
latitude=33.862723, accuracy=5>]

Gokhan A.
www.sylow.net

Philip H. wrote:

I haven’t looked into this at all, but does the Google Maps API have any
calls that would return the exact same information? If so, then just make a
call out to their service.

Yes and no. You can get the lat/long for a given address/city/zip, but
you can’t do things like figure out the state given the zip, etc which
is
what this guy wants to do…

Also, they have a limit on the number of queries/day, but if you can
cache
it on insert that might work too.

I just run a quick query below and it finds the state for given zipcode.

Sweet! Guess I need to relook at it :slight_smile:

Oh well, give it a few more years and cheaper connectivity and storage
and
Google will provide an API for retrieving any information at all.

I guess if you want, you can already do a generic google search for
“85260.” The first thing retrieved is the name of the city. So, you
could
probably screen scrape that. I wonder if google watches for bots doing
stuff like that, or if they cap searches.

Heh… Idle minds…

On 5/10/07, Philip H. [email protected] wrote:

start, I’m not even sure what keywords I should use to search. If
earth-distance calculations and you’re done.
much. :slight_smile:
may be accurate enough for your needs.


Terry (TAD) Donaghe
http://tadspot.tumblr.com

http://zipcodesearch.rubyforge.org/

Problem solved.

Just gave a talk on this at our local ruby users group last night.
(ncl.rb).

Useful plugin is GeoKit ( http://geokit.rubyforge.org/ ) which allows
you to geocode addresses using a variety of sources (Google, Yahoo
etc) works great if you are in the US or Canada. For UK Codes it
becomes a problem due to copyright of the postcode database. I have
hacked together an extra geocoder ( http://magpieuk.blogspot.com )
which plugs in to GeoKit which utilises a server I found which offers
this for free ( Geocoding Tool for Virtual Earth & Google Maps – Emad Fanous ).

GeoKit gives you the acts_as_mappable which once you add lat and lng
fields to it allows you to do nice things such as:

object1.distance_to(object2)

origin = MultiGeocoder.geocode(“NE1 4ST”)

nearlocs = Model.find(:all, :origin => origin, :order => “distance
ASC”

If you need to integrate with Google / Yahoo maps have a look at YM4R
( thepochisuperstarmegashow.com )

Hope this helps

Regards

Lee