geo_calc 0.6.1 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/README.textile +12 -0
- data/VERSION +1 -1
- data/geo_calc.gemspec +29 -6
- data/lib/geo_calc/calc/destination.rb +1 -1
- data/lib/geo_calc/calc/distance.rb +1 -1
- data/lib/geo_calc/calc/rhumb.rb +2 -2
- data/lib/geo_calc/calc.rb +20 -21
- data/lib/geo_calc/dms/converter.rb +106 -0
- data/lib/geo_calc/dms.rb +5 -0
- data/lib/geo_calc/extensions/array.rb +26 -0
- data/lib/geo_calc/extensions/hash.rb +23 -0
- data/lib/geo_calc/extensions/math.rb +6 -0
- data/lib/geo_calc/extensions/numeric.rb +24 -0
- data/lib/geo_calc/extensions/string.rb +44 -0
- data/lib/geo_calc/extensions/symbol.rb +9 -0
- data/lib/geo_calc/extensions.rb +4 -0
- data/lib/geo_calc/geo_point/class_methods.rb +15 -0
- data/lib/geo_calc/geo_point/core_extension.rb +11 -0
- data/lib/geo_calc/geo_point/shared.rb +29 -0
- data/lib/geo_calc/geo_point.rb +42 -40
- data/lib/geo_calc/pretty_print.rb +2 -2
- data/lib/geo_calc.rb +5 -0
- data/lib/geo_units/converter.rb +123 -0
- data/lib/geo_units/numeric_ext.rb +117 -0
- data/lib/geo_units.rb +21 -0
- data/spec/geo_calc/core_ext/numeric_geo_ext_spec.rb +48 -50
- data/spec/geo_calc/core_ext_spec.rb +49 -51
- data/spec/geo_calc/dms/converter_spec.rb +60 -0
- data/spec/geo_calc/geo_point/class_methods_spec.rb +31 -0
- data/spec/geo_calc/geo_point/initializer_spec.rb +148 -0
- data/spec/geo_calc/geo_point/lat_lon.rb +115 -0
- data/spec/geo_calc/geo_point_spec.rb +4 -274
- data/spec/geo_units/converter_spec.rb +57 -0
- metadata +56 -17
- data/lib/geo_calc/core_ext.rb +0 -318
- data/lib/geo_calc/geo.rb +0 -171
- data/spec/geo_calc/geo_spec.rb +0 -99
data/spec/geo_calc/geo_spec.rb
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
# - www.movable-type.co.uk/scripts/latlong.html
|
4
|
-
describe GeoPoint do
|
5
|
-
describe Geo do
|
6
|
-
|
7
|
-
# # @param {String|Number} dmsStr: Degrees or deg/min/sec in variety of formats
|
8
|
-
# @returns {Number} Degrees as decimal number
|
9
|
-
describe '#parse_dms' do
|
10
|
-
it 'should convert "58 38 38N" to a Float of degrees (58..59)' do
|
11
|
-
deg = Geo.parse_dms("58 38 38N")
|
12
|
-
deg.should be_a(Float)
|
13
|
-
deg.should be_between(58, 59)
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should convert "01 38 38W" to a Float of degrees (1..2)' do
|
17
|
-
deg = Geo.parse_dms("01 38 38W")
|
18
|
-
deg.should be_a(Float)
|
19
|
-
deg.should < 0
|
20
|
-
deg.should > -2
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should convert "005 38 E" to a Float of degrees (5..6)' do
|
24
|
-
deg = Geo.parse_dms("005 38 E")
|
25
|
-
deg.should be_a(Float)
|
26
|
-
deg.should be_between(5, 6)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# deg, format = :dms, dp = 0
|
31
|
-
describe '#to_dms' do
|
32
|
-
it 'should convert 58.3 to a String in DMS format' do
|
33
|
-
dms = Geo.to_dms(58.3)
|
34
|
-
dms.should be_a(String)
|
35
|
-
expr = Regexp.escape "058".concat("\u00B0", "18", "\u2032", "00", "\u2033")
|
36
|
-
dms.should match expr
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should convert 58.3 to a String in DM format' do
|
40
|
-
dm = Geo.to_dms(58.3, :dm, 2)
|
41
|
-
dm.should be_a(String)
|
42
|
-
expr = Regexp.escape "058".concat("\u00B0", "18", "\u2032")
|
43
|
-
dm.should match expr
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should convert 58.3 to a String in D format' do
|
47
|
-
d = Geo.to_dms(58.3, :d, 2)
|
48
|
-
d.should be_a(String)
|
49
|
-
m = Regexp.escape "058".concat("\u00B0")
|
50
|
-
d.should match m
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# deg, format, dp
|
55
|
-
describe '#to_lat' do
|
56
|
-
it 'should convert 58.3 to a latitude String in North direction' do
|
57
|
-
str_lat = Geo.to_lat(58.3)
|
58
|
-
str_lat.should be_a(String)
|
59
|
-
expr = Regexp.escape "58".concat("\u00B0", "18", "\u2032", "00", "\u2033", "N")
|
60
|
-
str_lat.should match expr
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'should convert -58.3 to a latitude String in South direction' do
|
64
|
-
str_lat = Geo.to_lat(-58.3)
|
65
|
-
str_lat.should be_a(String)
|
66
|
-
expr = Regexp.escape "58".concat("\u00B0", "18", "\u2032", "00", "\u2033", "S")
|
67
|
-
str_lat.should match expr
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# deg, format, dp
|
72
|
-
describe '#to_lon' do
|
73
|
-
it 'should convert 58.3 to a longitude String' do
|
74
|
-
str_lat = Geo.to_lon(58.3)
|
75
|
-
str_lat.should be_a(String)
|
76
|
-
expr = Regexp.escape "58".concat("\u00B0", "18", "\u2032", "00", "\u2033", "E")
|
77
|
-
str_lat.should match expr
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'should convert 58.3 to a longitude String' do
|
81
|
-
str_lat = Geo.to_lon(-58.3)
|
82
|
-
str_lat.should be_a(String)
|
83
|
-
expr = Regexp.escape "58".concat("\u00B0", "18", "\u2032", "00", "\u2033", "W")
|
84
|
-
str_lat.should match expr
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
# Convert numeric degrees to deg/min/sec as a bearing (0º..360º)
|
89
|
-
# deg, format, dp
|
90
|
-
describe '#to_brng' do
|
91
|
-
it 'should convert 58.3 to a longitude String' do
|
92
|
-
brng = Geo.to_brng(-58.3)
|
93
|
-
brng.to_f.should be_between(0, 360)
|
94
|
-
expr = Regexp.escape "301".concat("\u00B0", "42", "\u2032", "00")
|
95
|
-
brng.should match expr
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|