What would be the best technique to use to get all the addresses in my DB that are , say, within 10 miles of a given postcode? Each of my addresses has a postcode. Does anyone have any experience of doing this? any input would be greatly appreciated. Thanks Chris -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Chris, You need the expensive Postcode Address File: http://www.royalmail.com/portal/rm/jump2?mediaId=400085&catId=400084 There is a campaign to make this information freely available (as it is for ZIP codes in the USA): http://www.freethepostcode.org/ Cheers, Olly. -- www.lylo.co.uk On Aug 7, 5:33 pm, Chris Richards <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> What would be the best technique to use to get all the addresses in my > DB that are , say, within 10 miles of a given postcode? > > Each of my addresses has a postcode. > > Does anyone have any experience of doing this? any input would be > greatly appreciated. > > Thanks > > Chris--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Chris, You need the expensive Postzon Data: http://www.royalmail.com/portal/rm/content3?mediaId=55900704&catId=400088 There is a campaign to make this information freely available (as it is for ZIP codes in the USA): http://www.freethepostcode.org/ Cheers, Olly. -- www.lylo.co.uk On Aug 7, 5:33 pm, Chris Richards <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> What would be the best technique to use to get all the addresses in my > DB that are , say, within 10 miles of a given postcode? > > Each of my addresses has a postcode. > > Does anyone have any experience of doing this? any input would be > greatly appreciated. > > Thanks > > Chris > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Isn''t it possible to geocode a postcode into latitude/longitue using a webservice, and then calculate the distances from that? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Chris - On 7-Aug-07, at 5:09 PM, Chris Richards wrote:> > Isn''t it possible to geocode a postcode into latitude/longitue using a > webservice, and then calculate the distances from that?I''ve just started using this one: http://geokit.rubyforge.org/ check out Ben''s plugin directory for others: http://agilewebdevelopment.com/plugins cheers, Jodi --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> I''ve just started using this one: > http://geokit.rubyforge.org/ > check out Ben''s plugin directory for others: > http://agilewebdevelopment.com/plugins > cheers, > JodiThanks, i think ill use that for my geocoding. Is there a way to calculate the distance between two lat/longs without connecting to an external location? Im guessing there is a fairly simple way to do it? Thanks Chris -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Chris - On 8-Aug-07, at 11:59 AM, Chris Richards wrote:> >> I''ve just started using this one: >> http://geokit.rubyforge.org/ >> check out Ben''s plugin directory for others: >> http://agilewebdevelopment.com/plugins >> cheers, >> Jodi > > Thanks, i think ill use that for my geocoding. > > Is there a way to calculate the distance between two lat/longs without > connecting to an external location? > > Im guessing there is a fairly simple way to do it? > > Thanks > ChrisGenerally you should geocode all your current addresses - store the long and lat for each. Then geocode each address as it''s added. Then you can use geokit to calculate distances, etc. make sense? Jodi --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
If you are going to do stuff like select all database rows in a certain range of a point (within 10 miles of a point) and need any kind of performance at all, I would HIGHLY suggest that you use a database that has geometric types built in. As long as you can build an index on a geometric type and do searches using that index, then go for it. I glanced over geokit really quick and it uses the geometric formulas straight in the sql query, which means that the database is going to have to do a sequential scan performing the "expensive" mathmatical operations for every row in your table each time you do a query. Anyway, my point is, pick the right tool for the job. On 8/8/07, Jodi Showers <jodi-BOB1p6JRLoAV+D8aMU/kSg@public.gmane.org> wrote:> > Chris - > > On 8-Aug-07, at 11:59 AM, Chris Richards wrote: > > > > >> I''ve just started using this one: > >> http://geokit.rubyforge.org/ > >> check out Ben''s plugin directory for others: > >> http://agilewebdevelopment.com/plugins > >> cheers, > >> Jodi > > > > Thanks, i think ill use that for my geocoding. > > > > Is there a way to calculate the distance between two lat/longs without > > connecting to an external location? > > > > Im guessing there is a fairly simple way to do it? > > > > Thanks > > Chris > > Generally you should geocode all your current addresses - store the > long and lat for each. Then geocode each address as it''s added. > > Then you can use geokit to calculate distances, etc. > > make sense? > > Jodi > > > > > >-- EPA Rating: 3000 Lines of Code / Gallon (of coffee) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
A database with geometric types built in would be the best option, but assuming you don''t have that... (And I''m only brainstorming here, I haven''t tried any technique or looked at Geokit.) It might be less "expensive" to pull records from the database where the latitude or longitude was plus or minus 10 miles from a point and then calculate the geometry on those records to determine which are actually 10 miles from the point and sort them. Basically, retrieve a rough square and then narrow it down to a precise circle. It would save you from performing the geometry on every address in the database, including addresses on the other side of the planet. Kevin Skoglund --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jodi Showers wrote:> Chris - > > On 8-Aug-07, at 11:59 AM, Chris Richards wrote: > >> Is there a way to calculate the distance between two lat/longs without >> connecting to an external location? >> >> Im guessing there is a fairly simple way to do it? >> >> Thanks >> Chris > > Generally you should geocode all your current addresses - store the > long and lat for each. Then geocode each address as it''s added. > > Then you can use geokit to calculate distances, etc. > > make sense? > > Jodithanks Jodi, but thats what I said :-) "I glanced over geokit really quick and it uses the geometric formulas straight in the sql query," is what i really wanted to know -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Carl Lerche wrote:> If you are going to do stuff like select all database rows in a > certain range of a point (within 10 miles of a point) and need any > kind of performance at all, I would HIGHLY suggest that you use a > database that has geometric types built in. As long as you can build > an index on a geometric type and do searches using that index, then go > for it.Do you have any suggestions on dbs with built-in geometrics? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Postgresql (http://www.postgresql.org/) has geometric types and functions. On Aug 8, 2007, at 2:09 PM, Carl Johnson wrote:> > Carl Lerche wrote: >> If you are going to do stuff like select all database rows in a >> certain range of a point (within 10 miles of a point) and need any >> kind of performance at all, I would HIGHLY suggest that you use a >> database that has geometric types built in. As long as you can build >> an index on a geometric type and do searches using that index, >> then go >> for it. > > Do you have any suggestions on dbs with built-in geometrics? > > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
This tends to be my preference. On 8/8/07, s.ross <cwdinfo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Postgresql (http://www.postgresql.org/) has geometric types and > functions. >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 8/8/07, Carl Lerche <carl.lerche-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> This tends to be my preference. > > On 8/8/07, s.ross <cwdinfo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Postgresql (http://www.postgresql.org/) has geometric types and > > functions.Be prepared for a bit of work. For example with postgis you can do a proximity search but the sql can get rather complex, and you have to translate points into meters, miles, or whatever unit of measure you are after. A search of the postgis archives should turn up pretty much everything you need. What we did was use the perl code from geocoder.us to put the whole US TIGER dataset into a dbm file, and used that to get the lat/long for an address. It''s not complete so we would fall back to the google api if it wasn''t found. The google geocoding api and all other free api''s have a limit on how many queries you can do per second, so if you are geocoding a large number of addresses you are better off having a local database to geocode against. Chris --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---