geo_units 0.2.4 → 0.2.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/geo_units.gemspec +1 -1
  3. data/lib/geo_units.rb +34 -3
  4. metadata +12 -12
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.2.4.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{geo_units}
8
- s.version = "0.2.4"
8
+ s.version = "0.2.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Kristian Mandrup}]
@@ -81,6 +81,35 @@ module GeoUnits
81
81
  earth_radius_map[:miles] / miles_per_latitude_degree
82
82
  end
83
83
 
84
+ def degrees_to_radians(degrees)
85
+ degrees.to_f * radians_per_degree
86
+ end
87
+
88
+ def units_sphere_multiplier(units)
89
+ units = GeoUnits.key units
90
+ earth_radius_map[units]
91
+ end
92
+
93
+ def units_per_latitude_degree(units)
94
+ units = GeoUnits.key units
95
+ GeoUnits.radian_multiplier[units]
96
+ end
97
+
98
+ def units_per_longitude_degree(lat, units)
99
+ miles_per_longitude_degree = (latitude_degrees * Math.cos(lat * pi_div_rad)).abs
100
+ units = GeoUnits.key units
101
+ case units
102
+ when :feet
103
+ miles_per_longitude_degree * kms_per_mile * 1000 * meters_per_feet
104
+ when :meters
105
+ miles_per_longitude_degree * kms_per_mile * 1000
106
+ when :kms
107
+ miles_per_longitude_degree * kms_per_mile
108
+ when :miles
109
+ miles_per_longitude_degree
110
+ end
111
+ end
112
+
84
113
  module ClassMethods
85
114
  def key unit = :km
86
115
  unit = unit.to_sym
@@ -110,15 +139,17 @@ module GeoUnits
110
139
  end
111
140
 
112
141
  def earth_radius units
113
- GeoUnits.EARTH_RADIUS[units.to_sym]
142
+ units = GeoUnits.key units
143
+ GeoUnits.earth_radius_map[units]
114
144
  end
115
145
 
116
146
  def radians_per_degree
117
147
  0.017453293 # PI/180
118
148
  end
119
149
 
120
- def radians_ratio unit
121
- radians_per_degree * earth_radius[unit]
150
+ def radians_ratio units
151
+ units = GeoUnits.key units
152
+ radians_per_degree * earth_radius[units]
122
153
  end
123
154
 
124
155
  def precision
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geo_units
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-06-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sugar-high
16
- requirement: &2154333700 !ruby/object:Gem::Requirement
16
+ requirement: &2158096100 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.4.6.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2154333700
24
+ version_requirements: *2158096100
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2154333080 !ruby/object:Gem::Requirement
27
+ requirement: &2158095220 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.5.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2154333080
35
+ version_requirements: *2158095220
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &2154332400 !ruby/object:Gem::Requirement
38
+ requirement: &2158093940 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.0.6
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2154332400
46
+ version_requirements: *2158093940
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &2154331680 !ruby/object:Gem::Requirement
49
+ requirement: &2158093160 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.6.2
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2154331680
57
+ version_requirements: *2158093160
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rcov
60
- requirement: &2154330720 !ruby/object:Gem::Requirement
60
+ requirement: &2158091120 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2154330720
68
+ version_requirements: *2158091120
69
69
  description: Easily convert between different distance units such as kms, miles etc.
70
70
  email: kmandrup@gmail.com
71
71
  executables: []
@@ -108,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  segments:
110
110
  - 0
111
- hash: 4556294234362859408
111
+ hash: -3577635044061108096
112
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements: