geo_units 0.2.3 → 0.2.4

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 +36 -13
  4. metadata +12 -12
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
data/geo_units.gemspec CHANGED
@@ -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.3"
8
+ s.version = "0.2.4"
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}]
data/lib/geo_units.rb CHANGED
@@ -22,41 +22,64 @@ module GeoUnits
22
22
  autoload :DmsConverter, 'geo_units/dms_converter'
23
23
  autoload :NumericExt, 'geo_units/numeric_ext'
24
24
 
25
- EARTH_RADIUS = {
25
+ def earth_radius_map
26
+ {
26
27
  :miles => 3963.1676,
27
28
  :kilometers => 6378.135,
28
29
  :meters => 6378135,
29
30
  :feet => 20925639.8
30
- }
31
+ }
32
+ end
31
33
 
32
- EARTH_MAJOR_AXIS_RADIUS = {
34
+ def earth_major_axis_radius_map
35
+ {
33
36
  :miles => 3963.19059,
34
37
  :kilometers => 6378.137,
35
38
  :meters => 6378137,
36
39
  :feet => 20925646.36
37
- }
40
+ }
41
+ end
38
42
 
39
- EARTH_MINOR_AXIS_RADIUS = {
43
+ def earth_minor_axis_radius_map
44
+ {
40
45
  :kilometers => 6356.7523142,
41
46
  :miles => 3949.90276,
42
47
  :meters => 6356752.3142,
43
48
  :feet => 20855486.627
44
- }
49
+ }
50
+ end
45
51
 
46
- RADIAN_PER_DEGREE = Math::PI / 180.0
52
+ def radians_per_degree
53
+ Math::PI / 180.0
54
+ end
47
55
 
48
56
  # Haversine Formula
49
57
  # Adapted from Geokit Gem
50
58
  # https://github.com/andre/geokit-gem.git
51
59
  # By: Andre Lewis
52
- PI_DIV_RAD = 0.0174
60
+ def pi_div_rad
61
+ 0.0174
62
+ end
63
+
64
+ def kms_per_mile
65
+ 1.609
66
+ end
67
+
68
+ def meters_per_feet
69
+ 3.2808399
70
+ end
53
71
 
54
- KMS_PER_MILE = 1.609
55
- METERS_PER_FEET = 3.2808399
72
+ def miles_per_latitude_degree
73
+ 69.1
74
+ end
75
+
76
+ def kms_per_latitude_degree
77
+ miles_per_latitude_degree * kms_per_mile
78
+ end
56
79
 
57
- MILES_PER_LATITUDE_DEGREE = 69.1
58
- KMS_PER_LATITUDE_DEGREE = MILES_PER_LATITUDE_DEGREE * KMS_PER_MILE
59
- LATITUDE_DEGREES = EARTH_RADIUS[:miles] / MILES_PER_LATITUDE_DEGREE
80
+ def latitude_degrees
81
+ earth_radius_map[:miles] / miles_per_latitude_degree
82
+ end
60
83
 
61
84
  module ClassMethods
62
85
  def key unit = :km
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.3
4
+ version: 0.2.4
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: &2153948000 !ruby/object:Gem::Requirement
16
+ requirement: &2154333700 !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: *2153948000
24
+ version_requirements: *2154333700
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2153947180 !ruby/object:Gem::Requirement
27
+ requirement: &2154333080 !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: *2153947180
35
+ version_requirements: *2154333080
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &2153940460 !ruby/object:Gem::Requirement
38
+ requirement: &2154332400 !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: *2153940460
46
+ version_requirements: *2154332400
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &2153939720 !ruby/object:Gem::Requirement
49
+ requirement: &2154331680 !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: *2153939720
57
+ version_requirements: *2154331680
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rcov
60
- requirement: &2153938740 !ruby/object:Gem::Requirement
60
+ requirement: &2154330720 !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: *2153938740
68
+ version_requirements: *2154330720
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: -2024456778129613620
111
+ hash: 4556294234362859408
112
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements: