Method: Geocoder::Calculations#extract_coordinates
- Defined in:
- lib/geocoder/calculations.rb
#extract_coordinates(point) ⇒ Object
Takes an object which is a [lat,lon] array, a geocodable string, or an object that implements to_coordinates
and returns a
- lat,lon
-
array. Note that if a string is passed this may be a slow-
running method and may return nil.
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
# File 'lib/geocoder/calculations.rb', line 397 def extract_coordinates(point) case point when Array if point.size == 2 lat, lon = point if !lat.nil? && lat.respond_to?(:to_f) and !lon.nil? && lon.respond_to?(:to_f) then return [ lat.to_f, lon.to_f ] end end when String point = Geocoder.coordinates(point) and return point else if point.respond_to?(:to_coordinates) if Array === array = point.to_coordinates return extract_coordinates(array) end end end [ NAN, NAN ] end |