gps_unit_conversion 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/gps-unit-conversion.gemspec +1 -1
- data/lib/gps_unit_conversion/minutes_to_decimal/latitude.rb +2 -2
- data/lib/gps_unit_conversion/minutes_to_decimal/longitude.rb +5 -6
- data/spec/gps_unit_conversion/minutes_to_decimal/latitude_spec.rb +20 -0
- data/spec/gps_unit_conversion/minutes_to_decimal/longitude_spec.rb +11 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d16dd1f0f2586ad60b3727db529554c366557363f2378fa58878d581cea9d757
|
4
|
+
data.tar.gz: 749a94a17b2fad0e94a939120c0423eeb5feb54a496f011d02e2afd2a7eead73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e4762bb355b933b6f9c15ae37c737c011f13778dbe4380d70076a981b2e58c3b40126dbc858988a77454f77962262d7a41565c593f5ecd09dd7ce21169848e4
|
7
|
+
data.tar.gz: ce37935bbc3a9fb349752f7db914509ae7763252dee5fb33a4b99ec8f00d4e738773753ef0e70710f94c69c43ed87bf1c8e4a4cfc1bb9cc8ad9df901183f9b0d
|
data/Gemfile.lock
CHANGED
data/gps-unit-conversion.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'gps_unit_conversion'
|
5
|
-
s.version = '0.1.
|
5
|
+
s.version = '0.1.2'
|
6
6
|
s.summary = 'Converts longitude and latitude minutes/decimals values'
|
7
7
|
s.description = 'Converts longitude and latitude minutes/decimals values'
|
8
8
|
s.authors = ['Stanislaw Zawadzki']
|
@@ -16,21 +16,20 @@ module GpsUnitConversion
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def value
|
19
|
-
|
20
|
-
@value ||= numbers[0] == '0' ? numbers[1..-1] : numbers
|
19
|
+
@value ||= longitude.gsub(/\D/, "")
|
21
20
|
end
|
22
21
|
|
23
22
|
def degrees
|
24
|
-
value[0..
|
23
|
+
value[0..2].to_i
|
25
24
|
end
|
26
25
|
|
27
26
|
def minutes
|
28
|
-
value[
|
27
|
+
value[3..4].to_i
|
29
28
|
end
|
30
29
|
|
31
30
|
def seconds
|
32
|
-
|
33
|
-
|
31
|
+
base = value[5..-1]
|
32
|
+
base.length > 2 ? base.insert(2, '.').to_f : base.to_f
|
34
33
|
end
|
35
34
|
end
|
36
35
|
end
|
@@ -7,6 +7,26 @@ RSpec.describe GpsUnitConversion::MinutesToDecimal::Latitude do
|
|
7
7
|
expect(described_class.new(latitude: latitude_with_minutes).convert).to eq 53.81205
|
8
8
|
end
|
9
9
|
|
10
|
+
it 'converts latitude with mored digits' do
|
11
|
+
latitude_with_minutes = '5348.43380000'
|
12
|
+
|
13
|
+
expect(described_class.new(latitude: latitude_with_minutes).convert).to eq 53.81205
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'more examples' do
|
17
|
+
latitude_with_minutes = '434343.3416'
|
18
|
+
expect(described_class.new(latitude: latitude_with_minutes).convert).to eq 43.728706
|
19
|
+
|
20
|
+
latitude_with_minutes = '115900.1234'
|
21
|
+
expect(described_class.new(latitude: latitude_with_minutes).convert).to eq 11.983368
|
22
|
+
|
23
|
+
latitude_with_minutes = '811112.0006'
|
24
|
+
expect(described_class.new(latitude: latitude_with_minutes).convert).to eq 81.186667
|
25
|
+
|
26
|
+
latitude_with_minutes = '295423.8926'
|
27
|
+
expect(described_class.new(latitude: latitude_with_minutes).convert).to eq 29.906637
|
28
|
+
end
|
29
|
+
|
10
30
|
it 'converts on southern hemisphere' do
|
11
31
|
latitude_with_minutes = '5348.4338'
|
12
32
|
|
@@ -7,6 +7,17 @@ RSpec.describe GpsUnitConversion::MinutesToDecimal::Longitude do
|
|
7
7
|
expect(described_class.new(longitude: longitude_with_minutes).convert).to eq 20.578047
|
8
8
|
end
|
9
9
|
|
10
|
+
it 'more examples' do
|
11
|
+
longitude_with_minutes = '0120050.8824'
|
12
|
+
expect(described_class.new(longitude: longitude_with_minutes).convert).to eq 12.014134
|
13
|
+
|
14
|
+
longitude_with_minutes = '0695959.5959'
|
15
|
+
expect(described_class.new(longitude: longitude_with_minutes).convert).to eq 69.999888
|
16
|
+
|
17
|
+
longitude_with_minutes = '1125612.3972'
|
18
|
+
expect(described_class.new(longitude: longitude_with_minutes).convert).to eq 112.936777
|
19
|
+
end
|
20
|
+
|
10
21
|
it 'converts on western hemisphere' do
|
11
22
|
longitude_with_minutes = '02034.4097'
|
12
23
|
|