geo_position 0.0.2 → 0.0.3
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.
- data/README.md +17 -5
- data/lib/geo_position/conversion/dms.rb +3 -2
- data/lib/geo_position/version.rb +1 -1
- data/spec/conversion/dms_spec.rb +6 -0
- metadata +3 -3
data/README.md
CHANGED
@@ -24,24 +24,36 @@ Or install it yourself as:
|
|
24
24
|
Usage is very simple right now:
|
25
25
|
|
26
26
|
```ruby
|
27
|
-
|
27
|
+
# This can be any positive number between 0 and 360. It will be coerced
|
28
|
+
# to a float and absoluted.
|
29
|
+
degrees = 12
|
30
|
+
|
31
|
+
# Minutes
|
32
|
+
minutes = 3
|
33
|
+
|
34
|
+
# Seconds
|
35
|
+
seconds = 42.42
|
36
|
+
|
37
|
+
# Direction must be one of N, S, E, or W
|
38
|
+
direction = 'w'
|
39
|
+
|
40
|
+
conversion = GeoPosition::Conversion::Dms.new(degrees, minutes, seconds,
|
41
|
+
direction)
|
28
42
|
|
29
43
|
conversion.to_s
|
30
|
-
=> "12 deg 3' 42.
|
44
|
+
=> "12 deg 3' 42.42\" W"
|
31
45
|
|
32
46
|
conversion.to_f
|
33
47
|
=> -12.061783333333333
|
34
48
|
```
|
35
49
|
|
36
|
-
The only requirement is that you pass in a valid direction of N, S, E,
|
37
|
-
or W. Everything else will be coerced to a float.
|
38
|
-
|
39
50
|
## Todo
|
40
51
|
|
41
52
|
* Add ability to parse from the EXIF string and extract into the
|
42
53
|
conversion object
|
43
54
|
* Add ability to convert from lat/lon to DMS
|
44
55
|
* Add simple methods in the root object to handle conversions
|
56
|
+
* Add a command line component
|
45
57
|
|
46
58
|
## Contributing
|
47
59
|
|
@@ -13,6 +13,7 @@ module GeoPosition
|
|
13
13
|
# => -12.061783333333333
|
14
14
|
#
|
15
15
|
class Dms
|
16
|
+
ALLOWED_DEGREES = (0.0..360.0)
|
16
17
|
ALLOWED_DIRECTIONS = %w( N n E e S s W w )
|
17
18
|
MINUTES_CONVERSION = 60
|
18
19
|
SECONDS_CONVERSION = 3600
|
@@ -63,7 +64,7 @@ module GeoPosition
|
|
63
64
|
#
|
64
65
|
# @return [String] Uppercase direction
|
65
66
|
def direction
|
66
|
-
@direction.to_s.upcase
|
67
|
+
@direction.to_s[0,1].upcase
|
67
68
|
end
|
68
69
|
|
69
70
|
# Returns the formatted string
|
@@ -90,7 +91,7 @@ module GeoPosition
|
|
90
91
|
end
|
91
92
|
|
92
93
|
def valid_degrees?(deg)
|
93
|
-
deg.to_f.abs
|
94
|
+
ALLOWED_DEGREES.include?(deg.to_f.abs)
|
94
95
|
end
|
95
96
|
|
96
97
|
def convert!
|
data/lib/geo_position/version.rb
CHANGED
data/spec/conversion/dms_spec.rb
CHANGED
@@ -42,6 +42,12 @@ describe GeoPosition::Conversion::Dms do
|
|
42
42
|
gp.direction.should == 'N'
|
43
43
|
end
|
44
44
|
|
45
|
+
it "takes the first letter of the direction" do
|
46
|
+
gp = described_class.new(12, 12, 12, 'north')
|
47
|
+
gp.direction.should == 'N'
|
48
|
+
end
|
49
|
+
|
50
|
+
|
45
51
|
it "returns the formatted string" do
|
46
52
|
subject.to_s.should == "12 deg 3' 42.42\" W"
|
47
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geo_position
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -116,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
116
|
version: '0'
|
117
117
|
segments:
|
118
118
|
- 0
|
119
|
-
hash:
|
119
|
+
hash: -3480515325090187080
|
120
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
121
|
none: false
|
122
122
|
requirements:
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
segments:
|
127
127
|
- 0
|
128
|
-
hash:
|
128
|
+
hash: -3480515325090187080
|
129
129
|
requirements: []
|
130
130
|
rubyforge_project:
|
131
131
|
rubygems_version: 1.8.24
|