gps_unit_conversion 0.1.0
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +101 -0
- data/README.md +24 -0
- data/gps-unit-conversion.gemspec +22 -0
- data/lib/gps-unit-conversion.rb +7 -0
- data/lib/gps_unit_conversion/decimal_to_minutes/latitude.rb +0 -0
- data/lib/gps_unit_conversion/decimal_to_minutes/longitude.rb +0 -0
- data/lib/gps_unit_conversion/minutes_to_decimal/latitude.rb +36 -0
- data/lib/gps_unit_conversion/minutes_to_decimal/longitude.rb +36 -0
- data/spec/gps_unit_conversion/minutes_to_decimal/latitude_spec.rb +15 -0
- data/spec/gps_unit_conversion/minutes_to_decimal/longitude_spec.rb +15 -0
- data/spec/spec_helper.rb +14 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 80aec1d511e6d2f07605865dce71bde528a2a40aced18426dbb9bb3bbc121049
|
4
|
+
data.tar.gz: eab0cfadafd7165f4e3b59c09d45e43d8963a3eae98093789cf3990c53b51fb8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9993be60f0eb67322cb5fb20ab627b8557b3eb858961cecdef3fb84b10b7a4f183a501be428b166a62de3f9414e980bcadcfdea2a7b95f849ff118ba5b056823
|
7
|
+
data.tar.gz: 43d57b56a105abfd6fb9c7fee313747306c7938a67147918b003b61f5daee9cc97d975c8a37769d2cae60de029334e159cfd9cbbd1e22094f65b4edd09145d63
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
gps_unit_conversion (0.1.0)
|
5
|
+
activesupport (~> 7.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (7.1.3.3)
|
11
|
+
base64
|
12
|
+
bigdecimal
|
13
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
+
connection_pool (>= 2.2.5)
|
15
|
+
drb
|
16
|
+
i18n (>= 1.6, < 2)
|
17
|
+
minitest (>= 5.1)
|
18
|
+
mutex_m
|
19
|
+
tzinfo (~> 2.0)
|
20
|
+
ast (2.4.2)
|
21
|
+
base64 (0.2.0)
|
22
|
+
bigdecimal (3.1.8)
|
23
|
+
coderay (1.1.3)
|
24
|
+
concurrent-ruby (1.2.3)
|
25
|
+
connection_pool (2.4.1)
|
26
|
+
diff-lcs (1.5.1)
|
27
|
+
drb (2.2.1)
|
28
|
+
i18n (1.14.5)
|
29
|
+
concurrent-ruby (~> 1.0)
|
30
|
+
json (2.7.2)
|
31
|
+
language_server-protocol (3.17.0.3)
|
32
|
+
method_source (1.1.0)
|
33
|
+
minitest (5.23.0)
|
34
|
+
mutex_m (0.2.0)
|
35
|
+
parallel (1.24.0)
|
36
|
+
parser (3.3.1.0)
|
37
|
+
ast (~> 2.4.1)
|
38
|
+
racc
|
39
|
+
pry (0.14.2)
|
40
|
+
coderay (~> 1.1)
|
41
|
+
method_source (~> 1.0)
|
42
|
+
racc (1.8.0)
|
43
|
+
rainbow (3.1.1)
|
44
|
+
regexp_parser (2.9.2)
|
45
|
+
rexml (3.2.8)
|
46
|
+
strscan (>= 3.0.9)
|
47
|
+
rspec (3.13.0)
|
48
|
+
rspec-core (~> 3.13.0)
|
49
|
+
rspec-expectations (~> 3.13.0)
|
50
|
+
rspec-mocks (~> 3.13.0)
|
51
|
+
rspec-core (3.13.0)
|
52
|
+
rspec-support (~> 3.13.0)
|
53
|
+
rspec-expectations (3.13.0)
|
54
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
+
rspec-support (~> 3.13.0)
|
56
|
+
rspec-mocks (3.13.1)
|
57
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
58
|
+
rspec-support (~> 3.13.0)
|
59
|
+
rspec-support (3.13.1)
|
60
|
+
rubocop (1.63.5)
|
61
|
+
json (~> 2.3)
|
62
|
+
language_server-protocol (>= 3.17.0)
|
63
|
+
parallel (~> 1.10)
|
64
|
+
parser (>= 3.3.0.2)
|
65
|
+
rainbow (>= 2.2.2, < 4.0)
|
66
|
+
regexp_parser (>= 1.8, < 3.0)
|
67
|
+
rexml (>= 3.2.5, < 4.0)
|
68
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
69
|
+
ruby-progressbar (~> 1.7)
|
70
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
71
|
+
rubocop-ast (1.31.3)
|
72
|
+
parser (>= 3.3.1.0)
|
73
|
+
rubocop-capybara (2.20.0)
|
74
|
+
rubocop (~> 1.41)
|
75
|
+
rubocop-factory_bot (2.25.1)
|
76
|
+
rubocop (~> 1.41)
|
77
|
+
rubocop-rspec (2.29.2)
|
78
|
+
rubocop (~> 1.40)
|
79
|
+
rubocop-capybara (~> 2.17)
|
80
|
+
rubocop-factory_bot (~> 2.22)
|
81
|
+
rubocop-rspec_rails (~> 2.28)
|
82
|
+
rubocop-rspec_rails (2.28.3)
|
83
|
+
rubocop (~> 1.40)
|
84
|
+
ruby-progressbar (1.13.0)
|
85
|
+
strscan (3.1.0)
|
86
|
+
tzinfo (2.0.6)
|
87
|
+
concurrent-ruby (~> 1.0)
|
88
|
+
unicode-display_width (2.5.0)
|
89
|
+
|
90
|
+
PLATFORMS
|
91
|
+
x86_64-linux
|
92
|
+
|
93
|
+
DEPENDENCIES
|
94
|
+
gps_unit_conversion!
|
95
|
+
pry (~> 0.13)
|
96
|
+
rspec (~> 3.9)
|
97
|
+
rubocop (~> 1.0)
|
98
|
+
rubocop-rspec (~> 2.2)
|
99
|
+
|
100
|
+
BUNDLED WITH
|
101
|
+
2.4.10
|
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# gps-unit-conversion
|
2
|
+
Converts GPS minutes to decimals and other way around
|
3
|
+
|
4
|
+
## Instalation
|
5
|
+
|
6
|
+
The gps-unit-conversion gem is available at rubygems.org. You can install with:
|
7
|
+
|
8
|
+
`gem install gps-unit-conversion`
|
9
|
+
|
10
|
+
Alternatively, you can install the gem with bundler:
|
11
|
+
|
12
|
+
\# Gemfile
|
13
|
+
|
14
|
+
`gem 'gps-unit-conversion'`
|
15
|
+
|
16
|
+
After doing bundle install, you should have the gem installed in your bundle.
|
17
|
+
|
18
|
+
## Development
|
19
|
+
|
20
|
+
Building gem locally (you can change file name, ofc):
|
21
|
+
gem build *.gemspec -o pkg/gps-unit-conversion.gem
|
22
|
+
|
23
|
+
Installing:
|
24
|
+
gem install pkg/gps-unit-conversion.gem
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'gps_unit_conversion'
|
5
|
+
s.version = '0.1.0'
|
6
|
+
s.summary = 'Converts longitude and latitude minutes/decimals values'
|
7
|
+
s.description = 'Converts longitude and latitude minutes/decimals values'
|
8
|
+
s.authors = ['Stanislaw Zawadzki']
|
9
|
+
s.email = 'st.zawadzki@gmail.com'
|
10
|
+
|
11
|
+
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
12
|
+
s.require_paths = ['lib']
|
13
|
+
s.license = 'MIT'
|
14
|
+
s.required_ruby_version = '>= 3.1'
|
15
|
+
s.add_dependency 'activesupport', '~> 7.0'
|
16
|
+
s.add_development_dependency 'pry', '~> 0.13'
|
17
|
+
s.add_development_dependency 'rspec', '~> 3.9'
|
18
|
+
s.add_development_dependency 'rubocop', '~> 1.0'
|
19
|
+
s.add_development_dependency 'rubocop-rspec', '~> 2.2'
|
20
|
+
s.metadata['rubygems_mfa_required'] = 'false'
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,7 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require File.expand_path('gps_unit_conversion/decimal_to_minutes/longitude.rb', __dir__)
|
3
|
+
require File.expand_path('gps_unit_conversion/decimal_to_minutes/latitude.rb', __dir__)
|
4
|
+
require File.expand_path('gps_unit_conversion/minutes_to_decimal/longitude.rb', __dir__)
|
5
|
+
require File.expand_path('gps_unit_conversion/minutes_to_decimal/latitude.rb', __dir__)
|
6
|
+
|
7
|
+
DEFAULT_DECIMALS = 6
|
File without changes
|
File without changes
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module GpsUnitConversion
|
2
|
+
module MinutesToDecimal
|
3
|
+
class Latitude
|
4
|
+
attr_reader :latitude, :direction
|
5
|
+
|
6
|
+
def initialize(latitude:, direction: 'N')
|
7
|
+
@latitude = latitude
|
8
|
+
@direction = direction
|
9
|
+
end
|
10
|
+
|
11
|
+
def convert
|
12
|
+
decimal = (degrees + (minutes/60.0) + (seconds/3600.0)).round(DEFAULT_DECIMALS)
|
13
|
+
direction == 'N' ? decimal : -decimal
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def value
|
19
|
+
numbers = latitude.gsub(/\D/, "")
|
20
|
+
@value ||= numbers[0] == '0' ? numbers[1..-1] : numbers
|
21
|
+
end
|
22
|
+
|
23
|
+
def degrees
|
24
|
+
value[0..1].to_i
|
25
|
+
end
|
26
|
+
|
27
|
+
def minutes
|
28
|
+
value[2..3].to_i
|
29
|
+
end
|
30
|
+
|
31
|
+
def seconds
|
32
|
+
value[4..-1].to_f / 100.0
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module GpsUnitConversion
|
2
|
+
module MinutesToDecimal
|
3
|
+
class Longitude
|
4
|
+
attr_reader :longitude, :direction
|
5
|
+
|
6
|
+
def initialize(longitude:, direction: 'E')
|
7
|
+
@longitude = longitude
|
8
|
+
@direction = direction
|
9
|
+
end
|
10
|
+
|
11
|
+
def convert
|
12
|
+
decimal = (degrees + (minutes/60.0) + (seconds/3600.0)).round(DEFAULT_DECIMALS)
|
13
|
+
direction == 'E' ? decimal : -decimal
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def value
|
19
|
+
numbers = longitude.gsub(/\D/, "")
|
20
|
+
@value ||= numbers[0] == '0' ? numbers[1..-1] : numbers
|
21
|
+
end
|
22
|
+
|
23
|
+
def degrees
|
24
|
+
value[0..1].to_i
|
25
|
+
end
|
26
|
+
|
27
|
+
def minutes
|
28
|
+
value[2..3].to_i
|
29
|
+
end
|
30
|
+
|
31
|
+
def seconds
|
32
|
+
value[4..-1].to_f / 100.0
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe GpsUnitConversion::MinutesToDecimal::Latitude do
|
4
|
+
it 'converts latitude' do
|
5
|
+
latitude_with_minutes = '5348.4338'
|
6
|
+
|
7
|
+
expect(described_class.new(latitude: latitude_with_minutes).convert).to eq 53.81205
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'converts on southern hemisphere' do
|
11
|
+
latitude_with_minutes = '5348.4338'
|
12
|
+
|
13
|
+
expect(described_class.new(latitude: latitude_with_minutes, direction: 'S').convert).to eq -53.81205
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe GpsUnitConversion::MinutesToDecimal::Longitude do
|
4
|
+
it 'converts longitude' do
|
5
|
+
longitude_with_minutes = '02034.4097'
|
6
|
+
|
7
|
+
expect(described_class.new(longitude: longitude_with_minutes).convert).to eq 20.578047
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'converts on western hemisphere' do
|
11
|
+
longitude_with_minutes = '02034.4097'
|
12
|
+
|
13
|
+
expect(described_class.new(longitude: longitude_with_minutes, direction: 'W').convert).to eq -20.578047
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative '../lib/gps-unit-conversion'
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.expect_with :rspec do |expectations|
|
5
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
6
|
+
end
|
7
|
+
|
8
|
+
config.mock_with :rspec do |mocks|
|
9
|
+
mocks.verify_partial_doubles = true
|
10
|
+
end
|
11
|
+
|
12
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
13
|
+
end
|
14
|
+
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gps_unit_conversion
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stanislaw Zawadzki
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-05-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '7.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '7.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.13'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.13'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.9'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop-rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.2'
|
83
|
+
description: Converts longitude and latitude minutes/decimals values
|
84
|
+
email: st.zawadzki@gmail.com
|
85
|
+
executables: []
|
86
|
+
extensions: []
|
87
|
+
extra_rdoc_files: []
|
88
|
+
files:
|
89
|
+
- CHANGELOG.md
|
90
|
+
- Gemfile
|
91
|
+
- Gemfile.lock
|
92
|
+
- README.md
|
93
|
+
- gps-unit-conversion.gemspec
|
94
|
+
- lib/gps-unit-conversion.rb
|
95
|
+
- lib/gps_unit_conversion/decimal_to_minutes/latitude.rb
|
96
|
+
- lib/gps_unit_conversion/decimal_to_minutes/longitude.rb
|
97
|
+
- lib/gps_unit_conversion/minutes_to_decimal/latitude.rb
|
98
|
+
- lib/gps_unit_conversion/minutes_to_decimal/longitude.rb
|
99
|
+
- spec/gps_unit_conversion/minutes_to_decimal/latitude_spec.rb
|
100
|
+
- spec/gps_unit_conversion/minutes_to_decimal/longitude_spec.rb
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
homepage:
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata:
|
106
|
+
rubygems_mfa_required: 'false'
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '3.1'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubygems_version: 3.4.10
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: Converts longitude and latitude minutes/decimals values
|
126
|
+
test_files: []
|