module Geokit
module Adapters
class SQLite < Abstract
def sphere_distance_sql(lat, lng, multiplier)
case multiplier
when Geokit::Mappable::EARTH_RADIUS_IN_KMS
units = :kms
else
units = :miles
end
%|
((#{units_per_latitude_degree(units)}*ABS(#{rad2deg(lat)}-#{qualified_lat_column_name})) +
(#{units_per_longitude_degree(rad2deg(lat), units)}*ABS(#{rad2deg(lng)}-#{qualified_lng_column_name})))
|
end
def flat_distance_sql(origin, lat_degree_units, lng_degree_units)
%|
((#{lat_degree_units}*ABS(#{origin.lat}-#{qualified_lat_column_name})) +
(#{lng_degree_units}*ABS(#{origin.lng}-#{qualified_lng_column_name})))
|
end
end
end
end