geokit / geokit-rails

Official Geokit plugin for Rails/ActiveRecord. Provides location-based goodness for your Rails app. Requires the Geokit gem.
MIT License
1.57k stars 245 forks source link

Add mysql2spatial adapter #38

Closed xnzac closed 11 years ago

xnzac commented 11 years ago

mysql2spatial adapter - https://github.com/dazuma/activerecord-mysql2spatial-adapter - is required by RGeo.

Copied geokit-rails' mysql2 adapter to mysql2adapter. No tests afraid, but working fine here.

As a side note, lots of duplication across the 3 mysql adapters. Might be worth extracting.

mnoack commented 11 years ago

I've added support via https://github.com/geokit/geokit-rails/commit/1d31634ef2aac2265e688e00dac098effef972e2 which also includes adding the test/gemspec lines to aid testers

Your 2nd commit reverting simplify sort_by_distance really is a separate issue that should be a separate pull request and we're really looking at removing that method anyway. Can you see any need for that method given the suggested alternative as specified in the file?

xnzac commented 11 years ago

Regarding the 2nd commit, I had intended this to be a separate PR. Not sure what happened.

As I mentioned in the commit, I needed the 'distance' field for each result returned. This was the behaviour stretching back a few years, and also documented in README as of now:

The plug-in creates a calculated distance field on AR instances that have been retrieved through a Geokit location query. By default, these fields are known as "distance" but this can be changed through the :distance_field_name key.

Unless there's another method call that populates 'distance'?

mnoack commented 10 years ago

Sorry the README is a bit out of date on that part.

I've pushed a new commit with a helper method and some tests and removes the Array sort_by_distance_from method alltogether.

See the tests for how you could use this https://github.com/geokit/geokit-rails/commit/f79bbdfb81d2a87c24c152cbfbf1638f2eacd878

xnzac commented 10 years ago

Thanks - that looks good!

On 2013年9月24日Tuesday at 下午10:17, Michael Noack wrote:

Sorry the README is a bit out of date on that part. I've pushed a new commit with a helper method and some tests and removes the Array sort_by_distance_from method alltogether. See the tests for how you could use this f79bbdf (https://github.com/geokit/geokit-rails/commit/f79bbdfb81d2a87c24c152cbfbf1638f2eacd878)

— Reply to this email directly or view it on GitHub (https://github.com/geokit/geokit-rails/pull/38#issuecomment-25007752).