Skip to content
Snippets Groups Projects
Commit 00731db1 authored by Alex Reisner's avatar Alex Reisner
Browse files

Add forward/reverse geocoding attributes warning.

parent 7eacfeea
No related branches found
No related tags found
No related merge requests found
......@@ -113,6 +113,33 @@ and make sure it has +latitude+ and +longitude+ attributes, as well as an +addre
reverse_geocoded_by :lat, :lon, :address => :location
== Forward and Reverse Geocoding in the Same Model
If you apply both forward and reverse geocoding functionality to the same model, you can provide different methods for storing the fetched address (reverse geocoding) and providing an address to use when fetching coordinates (forward geocoding), for example:
class Venue
# build an address from street, city, and state attributes
geocoded_by :address_from_components
# store the Google-provided address in the full_address attribute
reverse_geocoded_by :latitude, :longitude, :address => :full_address
end
However, there can be only one set of latitude/longitude attributes, and whichever you specify last will be used. For example:
class Venue
geocoded_by :address,
:latitude => :fetched_latitude, # this will be overridden by the below
:longitude => :fetched_longitude # same here
reverse_geocoded_by :latitude, :longitude
end
The reason for this is that we don't want ambiguity when doing distance calculations. We need a single, authoritative source for coordinates!
== SQLite
SQLite's lack of trigonometric functions requires an alternate implementation of the +near+ method (scope). When using SQLite, Geocoder will automatically use a less accurate algorithm for finding objects near a given point. Results of this algorithm should not be trusted too much as it will return objects that are outside the given radius.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment