geo_units 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -1
- data/Gemfile +7 -7
- data/VERSION +1 -1
- data/geo_units.gemspec +34 -34
- data/lib/geo_units.rb +11 -10
- data/lib/geo_units/converter/units.rb +10 -10
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9d37448edec9e1463eac1d5fd72aa28b0682d95
|
4
|
+
data.tar.gz: fcf8bd5f5f5d2917723a7a2b11336eaadc99f460
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcfa870d3be80f1003d24c801612d14bf46809e0527c3efa128861b6c698630169d99080444021edb585b12703a0da1a3b72cde525c03eb502aaacbba9e3fb71
|
7
|
+
data.tar.gz: 22e69d41df11969180d2971f5485c3ab8274159f20288865a9f976cb6a7e8fcc506cca6a51fa6951a90d265057ff2a1ec5869b54c4a4bc488f3882917c850d25
|
data/.rspec
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--color --format
|
1
|
+
--color --format documentation
|
data/Gemfile
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
# Add dependencies required to use your gem here.
|
3
3
|
|
4
|
-
gem "sugar-high", '~>0.7.2'
|
5
|
-
gem 'sweetloader'
|
6
|
-
gem 'i18n'
|
7
|
-
gem 'activesupport'
|
4
|
+
gem "sugar-high", '~> 0.7.2'
|
5
|
+
gem 'sweetloader', '~> 0.1.6'
|
6
|
+
gem 'i18n', '>= 0.8'
|
7
|
+
gem 'activesupport', '>= 4'
|
8
8
|
|
9
9
|
# Add dependencies to develop your gem here.
|
10
10
|
# Include everything needed to run rake, tests, features, etc.
|
11
11
|
group :development do
|
12
|
-
gem "rspec", ">= 2.
|
13
|
-
gem "bundler", ">= 1.
|
14
|
-
gem "jeweler", ">=
|
12
|
+
gem "rspec", ">= 2.6.0"
|
13
|
+
gem "bundler", ">= 1.10.0"
|
14
|
+
gem "jeweler", ">= 2.3.0"
|
15
15
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.4
|
data/geo_units.gemspec
CHANGED
@@ -2,18 +2,18 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: geo_units 0.3.
|
5
|
+
# stub: geo_units 0.3.4 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
|
-
s.name = "geo_units"
|
9
|
-
s.version = "0.3.
|
8
|
+
s.name = "geo_units".freeze
|
9
|
+
s.version = "0.3.4"
|
10
10
|
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
-
s.require_paths = ["lib"]
|
13
|
-
s.authors = ["Kristian Mandrup"]
|
14
|
-
s.date = "
|
15
|
-
s.description = "Easily convert between different distance units such as kms, miles etc."
|
16
|
-
s.email = "kmandrup@gmail.com"
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib".freeze]
|
13
|
+
s.authors = ["Kristian Mandrup".freeze]
|
14
|
+
s.date = "2017-10-12"
|
15
|
+
s.description = "Easily convert between different distance units such as kms, miles etc.".freeze
|
16
|
+
s.email = "kmandrup@gmail.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE.txt",
|
19
19
|
"README.textile"
|
@@ -55,39 +55,39 @@ Gem::Specification.new do |s|
|
|
55
55
|
"spec/geo_units_spec.rb",
|
56
56
|
"spec/spec_helper.rb"
|
57
57
|
]
|
58
|
-
s.homepage = "http://github.com/kristianmandrup/geo_units"
|
59
|
-
s.licenses = ["MIT"]
|
60
|
-
s.rubygems_version = "2.
|
61
|
-
s.summary = "Distance unit modules and functionality for use in geo libraries"
|
58
|
+
s.homepage = "http://github.com/kristianmandrup/geo_units".freeze
|
59
|
+
s.licenses = ["MIT".freeze]
|
60
|
+
s.rubygems_version = "2.6.14".freeze
|
61
|
+
s.summary = "Distance unit modules and functionality for use in geo libraries".freeze
|
62
62
|
|
63
63
|
if s.respond_to? :specification_version then
|
64
64
|
s.specification_version = 4
|
65
65
|
|
66
66
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
67
|
-
s.add_runtime_dependency(%q<sugar-high
|
68
|
-
s.add_runtime_dependency(%q<sweetloader
|
69
|
-
s.add_runtime_dependency(%q<i18n
|
70
|
-
s.add_runtime_dependency(%q<activesupport
|
71
|
-
s.add_development_dependency(%q<rspec
|
72
|
-
s.add_development_dependency(%q<bundler
|
73
|
-
s.add_development_dependency(%q<jeweler
|
67
|
+
s.add_runtime_dependency(%q<sugar-high>.freeze, ["~> 0.7.2"])
|
68
|
+
s.add_runtime_dependency(%q<sweetloader>.freeze, ["~> 0.1.6"])
|
69
|
+
s.add_runtime_dependency(%q<i18n>.freeze, [">= 0.8"])
|
70
|
+
s.add_runtime_dependency(%q<activesupport>.freeze, [">= 4"])
|
71
|
+
s.add_development_dependency(%q<rspec>.freeze, [">= 2.6.0"])
|
72
|
+
s.add_development_dependency(%q<bundler>.freeze, [">= 1.10.0"])
|
73
|
+
s.add_development_dependency(%q<jeweler>.freeze, [">= 2.3.0"])
|
74
74
|
else
|
75
|
-
s.add_dependency(%q<sugar-high
|
76
|
-
s.add_dependency(%q<sweetloader
|
77
|
-
s.add_dependency(%q<i18n
|
78
|
-
s.add_dependency(%q<activesupport
|
79
|
-
s.add_dependency(%q<rspec
|
80
|
-
s.add_dependency(%q<bundler
|
81
|
-
s.add_dependency(%q<jeweler
|
75
|
+
s.add_dependency(%q<sugar-high>.freeze, ["~> 0.7.2"])
|
76
|
+
s.add_dependency(%q<sweetloader>.freeze, ["~> 0.1.6"])
|
77
|
+
s.add_dependency(%q<i18n>.freeze, [">= 0.8"])
|
78
|
+
s.add_dependency(%q<activesupport>.freeze, [">= 4"])
|
79
|
+
s.add_dependency(%q<rspec>.freeze, [">= 2.6.0"])
|
80
|
+
s.add_dependency(%q<bundler>.freeze, [">= 1.10.0"])
|
81
|
+
s.add_dependency(%q<jeweler>.freeze, [">= 2.3.0"])
|
82
82
|
end
|
83
83
|
else
|
84
|
-
s.add_dependency(%q<sugar-high
|
85
|
-
s.add_dependency(%q<sweetloader
|
86
|
-
s.add_dependency(%q<i18n
|
87
|
-
s.add_dependency(%q<activesupport
|
88
|
-
s.add_dependency(%q<rspec
|
89
|
-
s.add_dependency(%q<bundler
|
90
|
-
s.add_dependency(%q<jeweler
|
84
|
+
s.add_dependency(%q<sugar-high>.freeze, ["~> 0.7.2"])
|
85
|
+
s.add_dependency(%q<sweetloader>.freeze, ["~> 0.1.6"])
|
86
|
+
s.add_dependency(%q<i18n>.freeze, [">= 0.8"])
|
87
|
+
s.add_dependency(%q<activesupport>.freeze, [">= 4"])
|
88
|
+
s.add_dependency(%q<rspec>.freeze, [">= 2.6.0"])
|
89
|
+
s.add_dependency(%q<bundler>.freeze, [">= 1.10.0"])
|
90
|
+
s.add_dependency(%q<jeweler>.freeze, [">= 2.3.0"])
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
data/lib/geo_units.rb
CHANGED
@@ -1,20 +1,21 @@
|
|
1
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2
2
|
# Geodesy representation conversion functions (c) Chris Veness 2002-2010
|
3
3
|
# - www.movable-type.co.uk/scripts/latlong.html
|
4
4
|
#
|
5
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
5
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
6
6
|
|
7
7
|
# Parses string representing degrees/minutes/seconds into numeric degrees
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# This is very flexible on formats, allowing signed decimal degrees, or deg-min-sec optionally
|
10
|
-
# suffixed by compass direction (NSEW). A variety of separators are accepted (eg 3º 37' 09"W)
|
11
|
-
# or fixed-width format without separators (eg 0033709W). Seconds and minutes may be omitted.
|
10
|
+
# suffixed by compass direction (NSEW). A variety of separators are accepted (eg 3º 37' 09"W)
|
11
|
+
# or fixed-width format without separators (eg 0033709W). Seconds and minutes may be omitted.
|
12
12
|
# (Note minimal validation is done).
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# @param [String|Number] Degrees or deg/min/sec in variety of formats
|
15
15
|
# @returns [Number] Degrees as decimal number
|
16
16
|
# @throws ArgumentError
|
17
17
|
|
18
|
+
require 'active_support'
|
18
19
|
require 'sugar-high/numeric'
|
19
20
|
require 'sweetloader'
|
20
21
|
|
@@ -30,7 +31,7 @@ module GeoUnits
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def self.included(base)
|
33
|
-
[:Maps, :Constants, :"Converter::Units"].each do |module_name|
|
34
|
+
[:Maps, :Constants, :"Converter::Units"].each do |module_name|
|
34
35
|
module_name = "GeoUnits::#{module_name.to_s.camelize}".constantize
|
35
36
|
base.send :include, module_name
|
36
37
|
base.extend module_name
|
@@ -43,9 +44,9 @@ module GeoUnits
|
|
43
44
|
|
44
45
|
(units - [:radians]).each do |unit_type|
|
45
46
|
define_singleton_method "#{unit_type}_to" do |unit, number = 0|
|
46
|
-
return 0 if number <= 0
|
47
|
+
return 0 if number <= 0
|
47
48
|
unit = normalized(unit)
|
48
|
-
|
49
|
+
|
49
50
|
converter = GeoUnits::Maps::Meters
|
50
51
|
from = converter.from_unit[unit_type]
|
51
52
|
to = converter.to_unit[unit]
|
@@ -58,7 +59,7 @@ module GeoUnits
|
|
58
59
|
unit = normalized(unit)
|
59
60
|
# factor = GeoUnits::Converter::Units.units_per_longitude_degree(lat, unit)
|
60
61
|
# puts "factor: #{factor} - #{unit}"
|
61
|
-
(GeoUnits::Maps::Earth.distance_per_latitude_degree[unit] * number.to_f)
|
62
|
+
(GeoUnits::Maps::Earth.distance_per_latitude_degree[unit] * number.to_f)
|
62
63
|
end
|
63
64
|
|
64
65
|
module ClassMethods
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module GeoUnits
|
2
2
|
module Converter
|
3
3
|
module Units
|
4
|
-
def degrees_to_radians(degrees)
|
4
|
+
def degrees_to_radians(degrees)
|
5
5
|
degrees.to_f * GeoUnits::Constants.radians_per_degree
|
6
6
|
end
|
7
7
|
|
8
8
|
def units_sphere_multiplier(units)
|
9
9
|
units = GeoUnits.key units
|
10
|
-
GeoUnits::
|
10
|
+
GeoUnits::Map::Earth.radius[units]
|
11
11
|
end
|
12
12
|
|
13
13
|
def units_per_latitude_degree(units)
|
@@ -20,22 +20,22 @@ module GeoUnits
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def units_per_longitude_degree(lat, units)
|
23
|
-
miles_per_longitude_degree = (lat * Math.cos(lat * pi_div_rad)).abs
|
23
|
+
miles_per_longitude_degree = (lat * Math.cos(lat * pi_div_rad)).abs
|
24
24
|
units = GeoUnits.key units
|
25
25
|
miles_per_longitude_degree.miles_to(units)
|
26
|
-
end
|
27
|
-
|
26
|
+
end
|
27
|
+
|
28
28
|
def earth_radius units
|
29
29
|
units = GeoUnits.key units
|
30
|
-
GeoUnits::Maps.
|
30
|
+
GeoUnits::Maps::Earth.radius[units]
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def radians_ratio units
|
34
34
|
units = GeoUnits.key units
|
35
35
|
radians_per_degree * earth_radius(units)
|
36
36
|
end
|
37
|
-
|
38
|
-
extend self
|
37
|
+
|
38
|
+
extend self
|
39
39
|
end
|
40
40
|
end
|
41
|
-
end
|
41
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geo_units
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kristian Mandrup
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sugar-high
|
@@ -28,86 +28,86 @@ dependencies:
|
|
28
28
|
name: sweetloader
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.1.6
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.1.6
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: i18n
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
47
|
+
version: '0.8'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '0.8'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: activesupport
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '4'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '4'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 2.
|
75
|
+
version: 2.6.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 2.
|
82
|
+
version: 2.6.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.
|
89
|
+
version: 1.10.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.
|
96
|
+
version: 1.10.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: jeweler
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 2.3.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 2.3.0
|
111
111
|
description: Easily convert between different distance units such as kms, miles etc.
|
112
112
|
email: kmandrup@gmail.com
|
113
113
|
executables: []
|
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
171
|
version: '0'
|
172
172
|
requirements: []
|
173
173
|
rubyforge_project:
|
174
|
-
rubygems_version: 2.
|
174
|
+
rubygems_version: 2.6.14
|
175
175
|
signing_key:
|
176
176
|
specification_version: 4
|
177
177
|
summary: Distance unit modules and functionality for use in geo libraries
|