Forum: Ruby on Rails How do I implement a simple geographic information database

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
bob (Guest)
on 2007-05-10 21:01
(Received via mailing list)
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
Philip Hallstrom (Guest)
on 2007-05-10 21:37
(Received via mailing list)
> 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:

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
bob (Guest)
on 2007-05-10 22:47
(Received via mailing list)
On May 10, 12:48 pm, Philip Hallstrom <r...@philip.pjkh.com> 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. :)

Thanks!

Bob
David Rose (Guest)
on 2007-05-10 23:45
(Received via mailing list)
On 5/10/07, bob <papersmith@gmail.com> 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
Terry Donaghe (Guest)
on 2007-05-10 23:51
(Received via mailing list)
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 Rose <doppler@gmail.com> 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
22eaa9e4501ca2a43160d2c06bed8844?d=identicon&s=25 Gokhan A. (sylow)
on 2007-05-11 00:19
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 Arli
www.sylow.net
Philip Hallstrom (Guest)
on 2007-05-11 01:19
(Received via mailing list)
> 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.
22eaa9e4501ca2a43160d2c06bed8844?d=identicon&s=25 Gokhan A. (sylow)
on 2007-05-11 01:30
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 Arli
www.sylow.net


Philip Hallstrom 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.
Philip Hallstrom (Guest)
on 2007-05-11 04:13
(Received via mailing list)
> I just run a quick query below and it finds the state for given zipcode.

Sweet! Guess I need to relook at it :)
Terry Donaghe (Guest)
on 2007-05-11 06:54
(Received via mailing list)
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 Hallstrom <rails@philip.pjkh.com> wrote:
>
> >>>
> >>>>> start, I'm not even sure what keywords I should use to search.  If
> >>>> earth-distance calculations and you're done.
> >>> much. :)
> >> may be accurate enough for your needs.
> >
> > >
> >
>
> >
>


--
Terry (TAD) Donaghe
http://tadspot.tumblr.com
Nate Clark (Guest)
on 2007-05-11 07:37
(Received via mailing list)
43236a277cc222ddd5ed86b3d3d9ed89?d=identicon&s=25 Lee I. (magpie-uk)
on 2007-05-11 13:44
(Received via mailing list)
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 ( http://emad.fano.us/blog/?p=277 ).

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
( http://thepochisuperstarmegashow.com/projects/ )

Hope this helps

Regards

Lee
This topic is locked and can not be replied to.