Commit 5e86ce9b3e74bb0fcce92f94652c78c4499216a7

Authored by MoisesMachado
1 parent 79d7401c

ActionItem129: eliminated sqlite_extensions.rb from application since its now on the plugin

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1784 3f533792-8f58-4932-b0fe-aaf55b0a4547
lib/sqlite_extension.rb
@@ -1,44 +0,0 @@ @@ -1,44 +0,0 @@
1 -if ActiveRecord::Base.connection.adapter_name =~ /^sqlite$/i  
2 -  
3 - database = ActiveRecord::Base.connection.raw_connection  
4 -  
5 - database.create_function('sin', 1, :numeric) do |func, value|  
6 - func.set_result(Math.sin(value))  
7 - end  
8 -  
9 - database.create_function('cos', 1, :numeric) do |func, value|  
10 - func.set_result(Math.cos(value))  
11 - end  
12 -  
13 - database.create_function('pow', 2, :numeric) do |func, base, exponent|  
14 - func.set_result(base.to_f ** exponent.to_f)  
15 - end  
16 -  
17 - database.create_function('asin', 1, :numeric) do |func, value|  
18 - func.set_result(Math.asin(value))  
19 - end  
20 -  
21 - database.create_function('acos', 1, :numeric) do |func, value|  
22 - func.set_result(Math.acos(value))  
23 - end  
24 -  
25 - database.create_function('radians', 1, :numeric) do |func, value|  
26 - func.set_result(value.to_f * Math::PI / 180.0)  
27 - end  
28 -  
29 - database.create_function('sqrt', 1, :numeric) do |func, value|  
30 - func.set_result(Math.sqrt(value))  
31 - end  
32 -  
33 - database.create_function('spheric_distance', 5, :real) do |func, lat1, long1, lat2, long2, radius|  
34 - func.set_result(  
35 - radius.to_f * Math.acos(  
36 - [1,  
37 - Math.cos(lat1.to_f) * Math.cos(long1.to_f) * Math.cos(lat2.to_f) * Math.cos(long2.to_f) +  
38 - Math.cos(lat1.to_f) * Math.sin(long1.to_f) * Math.cos(lat2.to_f) * Math.sin(long2.to_f) +  
39 - Math.sin(lat1.to_f) * Math.sin(lat2.to_f)  
40 - ].min  
41 - )  
42 - )  
43 - end  
44 -end  
vendor/plugins/geokit/lib/geo_kit/sqlite_extension.rb
@@ -6,14 +6,14 @@ if ActiveRecord::Base.connection.adapter_name =~ /^sqlite$/i @@ -6,14 +6,14 @@ if ActiveRecord::Base.connection.adapter_name =~ /^sqlite$/i
6 func.set_result(base.to_f ** exponent.to_f) 6 func.set_result(base.to_f ** exponent.to_f)
7 end 7 end
8 8
9 - database.create_function('radians', 1, :numeric) do |func, value|  
10 - func.set_result(value.to_f * Math::PI / 180.0)  
11 - end  
12 -  
13 database.create_function('sqrt', 1, :numeric) do |func, value| 9 database.create_function('sqrt', 1, :numeric) do |func, value|
14 func.set_result(Math.sqrt(value)) 10 func.set_result(Math.sqrt(value))
15 end 11 end
16 12
  13 + database.create_function('radians', 1, :numeric) do |func, value|
  14 + func.set_result(value.to_f * Math::PI / 180.0)
  15 + end
  16 +
17 database.create_function('spheric_distance', 5, :real) do |func, lat1, long1, lat2, long2, radius| 17 database.create_function('spheric_distance', 5, :real) do |func, lat1, long1, lat2, long2, radius|
18 func.set_result( 18 func.set_result(
19 radius.to_f * Math.acos( 19 radius.to_f * Math.acos(