I haven't made a pull request for this yet because it needs tested, mongo store needs to be made compatible with my changes (and I'm not a mongo person, so I'm not the best one to do that) and docs would need to be updated. Oh, and the way that I modified things aren't backwards compatible.
BUT, my fork https://github.com/DaveSanders/geocoder includes code that allows you to do one or more location fields on your model and have them all work together. So if I have a model like called Trip with:
class Trip < ActiveRecord::Base
attr_accessible :origin_latitude, :origin_longitude, :origin_address, :destination_latitude, :destination_longitude, :destination_address
then I can define my geocoded_by like so:
geocoded_by :prefixes=>['origin', 'destination']
This will create new scopes on the class like:
which can be combined nicely. (and yes prefixes is a bad term in this case - I need to fix that.)
And if you don't specify any prefixes, the old scopes still work as usual.
I did change the definition of geocoded_by to not take one field (address field) and a bunch of options. I simply made everything options - which makes more sense to me. So, if you decided you wanted your properties on your model to be :lat, :long, and :full_address, then you simply define it like so:
geocoded_by :prefixes=>['origin', 'destination'], :address=>:full_address, :longitude=>:long, :latitude=>:lat
and if you are just using the model straight up, and name everything the right way, then you should be able to just write "geocoded_by" and be done. (though that's awkward grammar - should rename it to is_geocoded or something.)
Next steps: I don't have time this moment to do the tasks I mentioned at the top. If someone wants to contribute to my fork and help finish those off, then I can pull request back into the main repo. Otherwise, feel free to use my fork and give feedback until I can free up to finish it off. Or I can pull request it into a branch you setup and then contribute there.
Closing until this is more polished (tests added, naming improved, app-breaking changes removed) but I'm also not sure this isn't beyond the scope of what Geocoder should do.
Understood. As far as need, anyone with multiple lat longs in one model who needs to geocode or, in my case, perform searches with multiple ordered distances will need this. The gem is great for geocoding, but it's really limited for searching. I tried meeting my requirements several different ways and looked at a couple other gems before I gave up and just modified this one. (And I'm not the only one looking for a solution to this, I saw several people asking for solutions for this for other gems on stack, and I believe here in the issues. )
Will try to make it more polished, and get tests, but likely backwards compatibility WILL be broken because the way the geocoded_by is defined doesn't make sense in a multiple field scenario. Not did I want to have a different method for doing the exact same thing.
But that's the beauty of forks right? :). My main purpose was just to let everyone know it existed and that the "hard" stuff has been figured out. Feel free to review and integrate whatever changes you want.
The gem is limited for searching, and that's partly by design. The gem's focus is on the actual process of geocoding. Limited search functionality is there as a convenience.
I definitely appreciate your contribution, however, and haven't ruled it out 100%.