def self.normalize(thing,other=nil)
thing=[thing,other] if other
if thing.is_a?(String)
thing.strip!
if match=thing.match(/(\-?\d+\.?\d*)[, ] ?(\-?\d+\.?\d*)$/)
return Geokit::LatLng.new(match[1],match[2])
else
res = Geokit::Geocoders::MultiGeocoder.geocode(thing)
return res if res.success?
raise Geokit::Geocoders::GeocodeError
end
elsif thing.is_a?(Array) && thing.size==2
return Geokit::LatLng.new(thing[0],thing[1])
elsif thing.is_a?(LatLng)
return thing
elsif thing.class.respond_to?(:acts_as_mappable) && thing.class.respond_to?(:distance_column_name)
return thing.to_lat_lng
end
raise ArgumentError.new("#{thing} (#{thing.class}) cannot be normalized to a LatLng. We tried interpreting it as an array, string, Mappable, etc., but no dice.")
end