I am currently working on a small prototype application that requires my rails app to store and process geospatial information. Basically, I am storing and querying longitude/latitude coordinates.
I have been working on projects that had similar use-cases before, but when I joined everything was set up already. Also, usually it was PostgreSQL with PostGIS. This time though, I had to do it myself and with MySQL.
So, since other people might have the same idea, I figured I’d put a few code snippets here so you can get started quicker.
First, here’s my Gemfile:
This is how a migration might look like (I don’t think you still need the ENGINE=MyISAM line with a current MySQL version):
I also added indexes on both decimal-fields.
And here is a bit from my model including two simple queries.
Check out the geokit-rails3 README on Github for some examples.
I hope I just saved someone an hour or so of googling.
P.S.: You can follow me on Twitter.