I need to do a store/restaurant locator search from a persons postal code. Any suggestions on how to do this in Ruby/Rails? Commercial services would be a consideration if effective and not too costly. Thanks, Nick -- Nicholas Van Weerdenburg
You can the zip code data and a MySQL schema here: http://www.sanisoft.com/ziploc/ There is some PHP code there for searching that can easily be ported to Ruby: class ZipCode < ActiveRecord::Base def search(radius = 30) ZipCode.find_by_sql("SELECT * FROM zip_codes WHERE (POW((69.1*(lon-#{self.lon})*cos(#{self.lat}/57.3)),2)+ POW((69.1*(lat-#{self.lat})),2))<(#{radius}*#{radius})") end end
Nick, This can be done through the use of free Geocoding websites and a little math. One such site is GeoCoder.us (Web based, or API for a fee ..I beleive), where you can input the addresses (not just zip codes... which is what you asked for, but its close. "1 main street, ZIP CODE" is usually a fair assumption. http://geocoder.us/ Once you have both longitude/latitude coordinates for the addresses, you can then calculate the distance between the two. Here are two links which explain how: http://jan.ucc.nau.edu/~cvm/latlongdist.html http://www.mathforum.com/library/drmath/view/51711.html As for Rails/Ruby solutions.. I don''t know of any off hand, but there is a Perl interface to Geocoder.us <http://Geocoder.us> which may be easily ported or referenced to help you on your way: http://search.cpan.org/~sderle/Geo-Coder-US-1.00/US.pm\ Hope this helps, Adam On 11/4/05, Nicholas Van Weerdenburg <vanweerd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I need to do a store/restaurant locator search from a persons postal code. > > Any suggestions on how to do this in Ruby/Rails? Commercial services > would be a consideration if effective and not too costly. > > Thanks, > Nick > -- > Nicholas Van Weerdenburg > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Great info. Thanks. On 11/4/05, Adam Roth <adamjroth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Nick, > > This can be done through the use of free Geocoding websites and a little > math. > > One such site is GeoCoder.us (Web based, or API for a fee ..I beleive), > where you can input the addresses (not just zip codes... which is what you > asked for, but its close. "1 main street, ZIP CODE" is usually a fair > assumption. > > http://geocoder.us/ > > Once you have both longitude/latitude coordinates for the addresses, you can > then calculate the distance between the two. Here are two links which > explain how: > > http://jan.ucc.nau.edu/~cvm/latlongdist.html > http://www.mathforum.com/library/drmath/view/51711.html > > As for Rails/Ruby solutions.. I don''t know of any off hand, but there is a > Perl interface to Geocoder.us which may be easily ported or referenced to > help you on your way: > > http://search.cpan.org/~sderle/Geo-Coder-US-1.00/US.pm\ > > Hope this helps, > Adam > > > > On 11/4/05, Nicholas Van Weerdenburg <vanweerd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I need to do a store/restaurant locator search from a persons postal code. > > > > Any suggestions on how to do this in Ruby/Rails? Commercial services > > would be a consideration if effective and not too costly. > > > > Thanks, > > Nick > > -- > > Nicholas Van Weerdenburg > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- Nicholas Van Weerdenburg
Cool. Thanks. On 11/4/05, Scott Mace <rscottmace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You can the zip code data and a MySQL schema here: > > http://www.sanisoft.com/ziploc/ > > There is some PHP code there for searching that can easily be ported to Ruby: > > class ZipCode < ActiveRecord::Base > > def search(radius = 30) > ZipCode.find_by_sql("SELECT * FROM zip_codes WHERE > (POW((69.1*(lon-#{self.lon})*cos(#{self.lat}/57.3)),2)+ > POW((69.1*(lat-#{self.lat})),2))<(#{radius}*#{radius})") > end > end > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Nicholas Van Weerdenburg
On 11/4/05, Adam Roth <adamjroth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Nick, > > This can be done through the use of free Geocoding websites and a little > math. > > One such site is GeoCoder.us (Web based, or API for a fee ..I beleive), > where you can input the addresses (not just zip codes... which is what you > asked for, but its close. "1 main street, ZIP CODE" is usually a fair > assumption. > > http://geocoder.us/ > > Once you have both longitude/latitude coordinates for the addresses, you can > then calculate the distance between the two. Here are two links which > explain how: > > http://jan.ucc.nau.edu/~cvm/latlongdist.html > http://www.mathforum.com/library/drmath/view/51711.html > > As for Rails/Ruby solutions.. I don''t know of any off hand, but there is a > Perl interface to Geocoder.us which may be easily ported or referenced to > help you on your way: > > http://search.cpan.org/~sderle/Geo-Coder-US-1.00/US.pm\ > > Hope this helps, > Adam > > > > On 11/4/05, Nicholas Van Weerdenburg <vanweerd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I need to do a store/restaurant locator search from a persons postal code. > > > > Any suggestions on how to do this in Ruby/Rails? Commercial services > > would be a consideration if effective and not too costly. > > > > Thanks, > > Nick > > -- > > Nicholas Van Weerdenburg > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >Anyone know of similar for Canadian postal codes? I''ll need to do both US and Canada. Thanks, Nick -- Nicholas Van Weerdenburg
I''m writing my first web service with rails... The problem I''m having is when I''m using the invoke screen to debug the web service: http://localhost:3000/monitor_service/invoke If I don''t have any parameters on my methods, it works fine. However, if I do add params, I always get an error message: "can''t modify frozen object" I''m running ruby 1.8.2, rails 0.14.1, actionwebservice (0.9.2) Here''s the code: class MonitorServiceController < ApplicationController web_service_scaffold :invoke wsdl_service_name ''MonitorService'' def addEvent(event_type) return true end def test(msg) return msg end end class MonitorServiceApi < ActionWebService::API::Base api_method :addEvent, :expects=>[{:event_type=>:string}], :returns => [:bool] api_method :test, :expects=>[{:msg=>:string}], :returns => [:bool] end Any thoughts?
On 11/4/05, Nicholas Van Weerdenburg <vanweerd@gmail.com> wrote:> I need to do a store/restaurant locator search from a persons postal code. > > Any suggestions on how to do this in Ruby/Rails? Commercial services > would be a consideration if effective and not too costly. > > Thanks, > Nick > -- > Nicholas Van Weerdenburg >I''m now looking at http://www.zipcodedownload.com/ as they have US and Canadian data and seem reasonably priced. Anyone have any experience with them? Thanks, Nick -- Nicholas Van Weerdenburg
I''ve purchased from this company before: http://www.zipinfo.com Looks like the product and prices are similar at first glance. Nicholas Van Weerdenburg wrote:> On 11/4/05, Nicholas Van Weerdenburg <vanweerd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> I need to do a store/restaurant locator search from a persons postal code. >> >> Any suggestions on how to do this in Ruby/Rails? Commercial services >> would be a consideration if effective and not too costly. >> >> Thanks, >> Nick >> -- >> Nicholas Van Weerdenburg >> > > > I''m now looking at http://www.zipcodedownload.com/ as they have US and > Canadian data and seem reasonably priced. > > Anyone have any experience with them? > > Thanks, > Nick
Thanks for the info. How did you like the product/data? One single purchase of data is $99, but a monthly subscription for one year is $599. Do you find there is enough change to warrant that? Thanks, Nick On 11/4/05, Saltman <saltman-459giS/99bMmp8TqCH86vg@public.gmane.org> wrote:> I''ve purchased from this company before: http://www.zipinfo.com > > Looks like the product and prices are similar at first glance. > > Nicholas Van Weerdenburg wrote: > > On 11/4/05, Nicholas Van Weerdenburg <vanweerd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> I need to do a store/restaurant locator search from a persons postal code. > >> > >> Any suggestions on how to do this in Ruby/Rails? Commercial services > >> would be a consideration if effective and not too costly. > >> > >> Thanks, > >> Nick > >> -- > >> Nicholas Van Weerdenburg > >> > > > > > > I''m now looking at http://www.zipcodedownload.com/ as they have US and > > Canadian data and seem reasonably priced. > > > > Anyone have any experience with them? > > > > Thanks, > > Nick > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Nicholas Van Weerdenburg
Here is how one person did it. I have also used this method in a current project: http://www.hyperionreactor.net/node/87 As for data, I''m not sure how often there are ZIP code changes but I have always used one of the free databases. On Nov 4, 2005, at 9:37 AM, Nicholas Van Weerdenburg wrote:> I need to do a store/restaurant locator search from a persons > postal code. > > Any suggestions on how to do this in Ruby/Rails? Commercial services > would be a consideration if effective and not too costly. > > Thanks, > Nick > -- > Nicholas Van Weerdenburg > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
They do change a bit from month to month, but so far I''ve gotten away with just purchasing one-time data every so often (a couple times a year). I guess it depends on your application. The data is fine, they have small samples you can download I think. I purchased the set with the lat/long data so I could do distance calculations as well. I know this data is public domain, but all the free databases I''ve found were at least a couple years old. I don''t mind paying a few $$ for accuracy and convenience. -Ron Nicholas Van Weerdenburg wrote:> Thanks for the info. > > How did you like the product/data? > > One single purchase of data is $99, but a monthly subscription for one > year is $599. Do you find there is enough change to warrant that? > > Thanks, > Nick > > On 11/4/05, Saltman <saltman-459giS/99bMmp8TqCH86vg@public.gmane.org> wrote: >> I''ve purchased from this company before: http://www.zipinfo.com >> >> Looks like the product and prices are similar at first glance. >> >> Nicholas Van Weerdenburg wrote: >> > On 11/4/05, Nicholas Van Weerdenburg <vanweerd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> I need to do a store/restaurant locator search from a persons postal code. >> >> >> >> Any suggestions on how to do this in Ruby/Rails? Commercial services >> >> would be a consideration if effective and not too costly. >> >> >> >> Thanks, >> >> Nick >> >> -- >> >> Nicholas Van Weerdenburg >> >> >> > >> > >> > I''m now looking at http://www.zipcodedownload.com/ as they have US and >> > Canadian data and seem reasonably priced. >> > >> > Anyone have any experience with them? >> > >> > Thanks, >> > Nick >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > >