Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Faker gem to generate VALID address for Google Maps using Ruby on Rails

I am generating seed data (or more accurately populating the database with test data) using the awesome FAKER gem for thousands (or hundreds of thousands) so something I don't want to do manually.

Because I am using google maps, it is automatically geocoding each address. It would be great if I could generate test data that was valid. Unfortunately, FAKER is well... fake. I could turn off the geocoding, but I would like valid test data.

Does anyone know a way to generate random, fake (well... not fake) addresses that will properly be geocoded.

Thanks in advance.

like image 771
Enric Ribas Avatar asked May 04 '11 17:05

Enric Ribas


1 Answers

I found all that and more here: http://www.fakenamegenerator.com/free-tools.php

I was looking for such a generator that could be restricted to a specific city. They can't do that (from what I can tell) but country wide data and multiple countries is available.

But because that link didn't work for me I ultimately used reverse logic. I generated random coordinates in the area I wanted to test and asked Google for the address. Many had no address but for those that did I had a bunch of valid addresses in precisely the locations I wanted. If you then geo-code the address you will not usually get the same coordinates back but they should be really close which makes for simple ball-park validation.

like image 53
bielawski Avatar answered Oct 19 '22 06:10

bielawski