geocoder-oracle 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in geocoder-oracle.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Curtis Schiewek
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Geocoder::Oracle
2
+
3
+ Adds Oracle compatability to the wonderful [geocoder](http://www.rubygeocoder.com) gem.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'geocoder-oracle'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ And then run the generator to create custom functions that Oracle's missing:
16
+
17
+ $ rails generate geocoder:oracle:functions
18
+
19
+ ## Usage
20
+
21
+ See the [gecoder](http://rubygeocoder.com) documentation.
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'geocoder/oracle/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "geocoder-oracle"
8
+ spec.version = Geocoder::Oracle::VERSION
9
+ spec.authors = ["Curtis Schiewek"]
10
+ spec.email = ["curtis.schiewek@gmail.com"]
11
+ spec.description = %q{Adds Oracle support to the geocoder gem}
12
+ spec.summary = spec.description
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+
25
+ spec.add_dependency "geocoder", "~> 1.1"
26
+ end
@@ -0,0 +1,53 @@
1
+ require 'rails/generators'
2
+
3
+ module Geocoder
4
+ module Oracle
5
+ class FunctionsGenerator < Rails::Generators::Base
6
+ ActiveRecord::Base.establish_connection
7
+
8
+ desc 'Creates a custom functions required for geocoding in the Oracle database'
9
+
10
+ def pi_function
11
+ function = %q(
12
+ CREATE OR REPLACE FUNCTION PI
13
+ RETURN NUMBER DETERMINISTIC IS
14
+ PI NUMBER;
15
+ BEGIN
16
+ SELECT ACOS(-1) INTO PI FROM DUAL;
17
+ RETURN PI;
18
+ END PI;
19
+ )
20
+ ActiveRecord::Base.connection().execute(function)
21
+ puts 'PI() function added.'
22
+ end
23
+
24
+ def degrees_function
25
+ function = %q(
26
+ CREATE OR REPLACE FUNCTION DEGREES(RADIAN IN NUMBER)
27
+ RETURN NUMBER DETERMINISTIC IS
28
+ DEGREES NUMBER;
29
+ BEGIN
30
+ SELECT RADIAN * 57.2957795 INTO DEGREES FROM DUAL;
31
+ RETURN DEGREES;
32
+ END DEGREES;
33
+ )
34
+ ActiveRecord::Base.connection().execute(function)
35
+ puts 'DEGREES(RADIAN) function added.'
36
+ end
37
+
38
+ def radians_function
39
+ function = %q(
40
+ CREATE OR REPLACE FUNCTION RADIANS(DEGREE IN NUMBER)
41
+ RETURN NUMBER DETERMINISTIC IS
42
+ RADIANS NUMBER;
43
+ BEGIN
44
+ SELECT DEGREE / 57.2957795 INTO RADIANS FROM DUAL;
45
+ RETURN RADIANS;
46
+ END RADIANS;
47
+ )
48
+ ActiveRecord::Base.connection().execute(function)
49
+ puts 'RADIANS(DEGREE) function added.'
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,48 @@
1
+ require 'geocoder/oracle/version'
2
+ require 'geocoder/sql'
3
+
4
+ module Geocoder
5
+ module Oracle
6
+
7
+ end
8
+
9
+ module Sql
10
+ extend self
11
+
12
+ ##
13
+ # Fairly accurate bearing calculation. Takes a latitude, longitude,
14
+ # and an options hash which must include a :bearing value
15
+ # (:linear or :spherical).
16
+ #
17
+ # Based on:
18
+ # http://www.beginningspatial.com/calculating_bearing_one_point_another
19
+ #
20
+ # Overridden for Oracle as Oracle has no support for modulo % operator.
21
+ ##
22
+ def full_bearing(latitude, longitude, lat_attr, lon_attr, options = {})
23
+ case options[:bearing] || Geocoder.config.distances
24
+ when :linear
25
+ "MOD(" +
26
+ "CAST(" +
27
+ "DEGREES(ATAN2( " +
28
+ "RADIANS(#{lon_attr} - #{longitude.to_f}), " +
29
+ "RADIANS(#{lat_attr} - #{latitude.to_f})" +
30
+ ")) + 360 " +
31
+ "AS decimal), 360)"
32
+ when :spherical
33
+ "MOD(" +
34
+ "CAST(" +
35
+ "DEGREES(ATAN2( " +
36
+ "SIN(RADIANS(#{lon_attr} - #{longitude.to_f})) * " +
37
+ "COS(RADIANS(#{lat_attr})), (" +
38
+ "COS(RADIANS(#{latitude.to_f})) * SIN(RADIANS(#{lat_attr}))" +
39
+ ") - (" +
40
+ "SIN(RADIANS(#{latitude.to_f})) * COS(RADIANS(#{lat_attr})) * " +
41
+ "COS(RADIANS(#{lon_attr} - #{longitude.to_f}))" +
42
+ ")" +
43
+ ")) + 360 " +
44
+ "AS decimal), 360)"
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,5 @@
1
+ module Geocoder
2
+ module Oracle
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,12 @@
1
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
2
+ RSpec.configure do |config|
3
+ config.treat_symbols_as_metadata_keys_with_true_values = true
4
+ config.run_all_when_everything_filtered = true
5
+ config.filter_run :focus
6
+
7
+ # Run specs in random order to surface order dependencies. If you find an
8
+ # order dependency and want to debug it, you can fix the order by providing
9
+ # the seed, which is printed after each run.
10
+ # --seed 1234
11
+ config.order = 'random'
12
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: geocoder-oracle
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Curtis Schiewek
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-10-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: geocoder
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '1.1'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '1.1'
78
+ description: Adds Oracle support to the geocoder gem
79
+ email:
80
+ - curtis.schiewek@gmail.com
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - .gitignore
86
+ - .rspec
87
+ - Gemfile
88
+ - LICENSE.txt
89
+ - README.md
90
+ - Rakefile
91
+ - geocoder-oracle.gemspec
92
+ - lib/generators/geocoder/oracle/functions_generator.rb
93
+ - lib/geocoder/oracle.rb
94
+ - lib/geocoder/oracle/version.rb
95
+ - spec/spec_helper.rb
96
+ homepage: ''
97
+ licenses:
98
+ - MIT
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ segments:
110
+ - 0
111
+ hash: -2165558385267549859
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ segments:
119
+ - 0
120
+ hash: -2165558385267549859
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 1.8.23
124
+ signing_key:
125
+ specification_version: 3
126
+ summary: Adds Oracle support to the geocoder gem
127
+ test_files:
128
+ - spec/spec_helper.rb