Class: Geokit::Adapters::MySQL

Inherits:
Abstract
  • Object
show all
Defined in:
lib/geokit-rails/adapters/mysql.rb

Direct Known Subclasses

Mysql2, Mysql2Spatial

Instance Method Summary collapse

Methods inherited from Abstract

#initialize, load, #method_missing

Constructor Details

This class inherits a constructor from Geokit::Adapters::Abstract

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Geokit::Adapters::Abstract

Instance Method Details

#flat_distance_sql(origin, lat_degree_units, lng_degree_units) ⇒ Object



13
14
15
16
17
18
# File 'lib/geokit-rails/adapters/mysql.rb', line 13

def flat_distance_sql(origin, lat_degree_units, lng_degree_units)
  %|
    SQRT(POW(#{lat_degree_units}*(#{origin.lat}-#{qualified_lat_column_name}),2)+
    POW(#{lng_degree_units}*(#{origin.lng}-#{qualified_lng_column_name}),2))
   |
end

#sphere_distance_sql(lat, lng, multiplier) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/geokit-rails/adapters/mysql.rb', line 5

def sphere_distance_sql(lat, lng, multiplier)
  %|
    (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