I wrote two models and a helper class.
- HistoricPlace objects store all the CSV parsed places
- DistanceHelper class in lib/distance_helper.rb helps to generate SQL to search for placed near a give location.
- Google API Key is defined separately in production.rb and development.rb so that I can develop with a localhost dev license and use a production license too.
- I overwrite the HistoricPlace.calc method to display distances with 2 decimal places
- Store all locations queried from and update their query_count (and time stamp) if multiple queries from one location.
- Uses JQTouch for mobile version.
- Use index to test browser type and render m.html if mobile otherwise I run another method.
- I have a library file to be used to load the csv file. It need the Rails environment so call it with script/runner.
To parse the data file run
ruby ./script/runner ./lib/ne_parser.rb csv-file.csv
Benchmarks
bash-3.2$ ./script/performance/benchmarker 'HistoricPlace.all'
user system total real
#1 0.510000 0.080000 0.590000 ( 0.701018)
./script/performance/benchmarker 'HistoricPlace.find_places_within(42.4083349,-71.1159683,3)'
user system total real
#1 0.010000 0.000000 0.010000 ( 0.081882)
bash-3.2$ ./script/performance/benchmarker 'HistoricPlace.find_places_within(42.4083349,-71.1159683,10)'
user system total real
#1 0.020000 0.000000 0.020000 ( 0.111107)