Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added NULL lat/lng handling for SQLite

  • Loading branch information...
commit 1df71db199c2065dafa6bae53f1975ddb34020b6 1 parent 8140359
@instanceofme instanceofme authored
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/geokit-rails3/adapters/sqlite.rb
View
4 lib/geokit-rails3/adapters/sqlite.rb
@@ -31,16 +31,20 @@ def load(klass)
def sphere_distance_sql(lat, lng, multiplier)
%|
+ (CASE WHEN #{qualified_lat_column_name} IS NULL OR #{qualified_lng_column_name} IS NULL THEN NULL ELSE
(ACOS(least(1,COS(#{lat})*COS(#{lng})*COS(RADIANS(#{qualified_lat_column_name}))*COS(RADIANS(#{qualified_lng_column_name}))+
COS(#{lat})*SIN(#{lng})*COS(RADIANS(#{qualified_lat_column_name}))*SIN(RADIANS(#{qualified_lng_column_name}))+
SIN(#{lat})*SIN(RADIANS(#{qualified_lat_column_name}))))*#{multiplier})
+ END)
|
end
def flat_distance_sql(origin, lat_degree_units, lng_degree_units)
%|
+ (CASE WHEN #{qualified_lat_column_name} IS NULL OR #{qualified_lng_column_name} IS NULL THEN NULL ELSE
SQRT(POW(#{lat_degree_units}*(#{origin.lat}-#{qualified_lat_column_name}),2)+
POW(#{lng_degree_units}*(#{origin.lng}-#{qualified_lng_column_name}),2))
+ END)
|
end
Please sign in to comment.
Something went wrong with that request. Please try again.