geo_calc 0.7.1 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -1
- data/README.textile +8 -59
- data/VERSION +1 -1
- data/geo_calc.gemspec +15 -22
- data/lib/geo_calc/calc/bearing.rb +1 -1
- data/lib/geo_calc/calc/destination.rb +3 -2
- data/lib/geo_calc/calc/distance.rb +1 -1
- data/lib/geo_calc/calc/intersection.rb +8 -8
- data/lib/geo_calc/calc/midpoint.rb +8 -6
- data/lib/geo_calc/calc/rhumb.rb +35 -16
- data/lib/geo_calc/calc.rb +15 -21
- data/lib/geo_calc/extensions/array.rb +1 -3
- data/lib/geo_calc/extensions/hash.rb +1 -3
- data/lib/geo_calc/extensions/string.rb +8 -17
- data/lib/geo_calc/extensions.rb +0 -1
- data/lib/geo_calc/pretty_print.rb +14 -14
- data/lib/geo_calc.rb +7 -4
- data/spec/geo_calc/calculations_spec.rb +2 -1
- data/spec/geo_calc/core_ext/array_ext_spec.rb +1 -9
- data/spec/geo_calc/core_ext/hash_ext_spec.rb +3 -9
- data/spec/geo_calc/core_ext/string_ext_spec.rb +1 -9
- data/spec/geo_calc/core_ext_spec.rb +1 -7
- data/spec/geo_calc/include_apis_spec.rb +32 -0
- data/spec/spec_helper.rb +13 -5
- metadata +52 -35
- data/lib/geo_calc/dms/converter.rb +0 -106
- data/lib/geo_calc/dms.rb +0 -5
- data/lib/geo_calc/extensions/math.rb +0 -6
- data/lib/geo_calc/extensions/numeric.rb +0 -24
- data/lib/geo_calc/geo_point/class_methods.rb +0 -15
- data/lib/geo_calc/geo_point/core_extension.rb +0 -11
- data/lib/geo_calc/geo_point/shared.rb +0 -29
- data/lib/geo_calc/geo_point.rb +0 -135
- data/lib/geo_units/converter.rb +0 -123
- data/lib/geo_units/numeric_ext.rb +0 -117
- data/lib/geo_units.rb +0 -21
- data/spec/geo_calc/dms/converter_spec.rb +0 -60
- data/spec/geo_calc/geo_point/class_methods_spec.rb +0 -31
- data/spec/geo_calc/geo_point/initializer_spec.rb +0 -148
- data/spec/geo_calc/geo_point/lat_lon.rb +0 -115
- data/spec/geo_calc/geo_point_spec.rb +0 -99
- data/spec/geo_units/converter_spec.rb +0 -57
@@ -1,99 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
# - www.movable-type.co.uk/scripts/latlong.html
|
4
|
-
describe GeoPoint do
|
5
|
-
describe '#reverse_point' do
|
6
|
-
before :each do
|
7
|
-
@p = GeoPoint.new -2, 5
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'should return reverse GeoPoint (2, -5)' do
|
11
|
-
@p2 = @p.reverse_point
|
12
|
-
@p2.should_not == @p
|
13
|
-
@p2.lat.should == 2
|
14
|
-
@p2.lng.should == -5
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '#reverse_point!' do
|
19
|
-
before :each do
|
20
|
-
@p = GeoPoint.new -2, 5
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should return reverse GeoPoint (2, -5)' do
|
24
|
-
@p.reverse_point!
|
25
|
-
@p.lat.should == 2
|
26
|
-
@p.lng.should == -5
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe '#to_s' do
|
31
|
-
before :each do
|
32
|
-
@p1 = GeoPoint.new 50.1, 5
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'should return GeoPoint as a dms formatted String' do
|
36
|
-
@p1.to_s.should match /50.+5/
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should return GeoPoint as a dms formatted String' do
|
40
|
-
@p1.to_s(:dm, 2).should match /50.+5/
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '#[]' do
|
45
|
-
before :each do
|
46
|
-
@p1 = GeoPoint.new 50, 5
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'index of 0 should return latitude' do
|
50
|
-
@p1[0].should == 50
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'index of 1 should return longitude' do
|
54
|
-
@p1[1].should == 5
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'index of 2 should raise error' do
|
58
|
-
lambda {@p1[2]}.should raise_error
|
59
|
-
end
|
60
|
-
|
61
|
-
it ':lat should return latitude' do
|
62
|
-
@p1[:lat].should == 50
|
63
|
-
end
|
64
|
-
|
65
|
-
it ':long should return longitude' do
|
66
|
-
@p1[:long].should == 5
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe '#to_a' do
|
71
|
-
before :each do
|
72
|
-
@p1 = GeoPoint.new 50, 5
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'should return GeoPoint as an array depending on state of reverse_arr' do
|
76
|
-
@p1.to_a.should == [50, 5]
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe '#to_lat_lng' do
|
81
|
-
before :each do
|
82
|
-
@p1 = GeoPoint.new 50, 5
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'should return GeoPoint as an array of [lat, lng]' do
|
86
|
-
@p1.to_lat_lng.should == [50, 5]
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe '#to_lng_lat' do
|
91
|
-
before :each do
|
92
|
-
@p1 = GeoPoint.new 50, 5
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'should return GeoPoint as an array of [lng, lat]' do
|
96
|
-
@p1.to_lng_lat.should == [5, 50]
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class Converter
|
4
|
-
include GeoUnits::Converter
|
5
|
-
end
|
6
|
-
|
7
|
-
def converter
|
8
|
-
Converter.new
|
9
|
-
end
|
10
|
-
|
11
|
-
# - www.movable-type.co.uk/scripts/latlong.html
|
12
|
-
describe GeoUnits::Converter do
|
13
|
-
# deg, format, dp
|
14
|
-
describe '#to_lat' do
|
15
|
-
it 'should convert 58.3 to a latitude String in North direction' do
|
16
|
-
str_lat = converter.to_lat(58.3)
|
17
|
-
str_lat.should be_a(String)
|
18
|
-
expr = Regexp.escape "58".concat("\u00B0", "18", "\u2032", "00", "\u2033", "N")
|
19
|
-
str_lat.should match expr
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'should convert -58.3 to a latitude String in South direction' do
|
23
|
-
str_lat = converter.to_lat(-58.3)
|
24
|
-
str_lat.should be_a(String)
|
25
|
-
expr = Regexp.escape "58".concat("\u00B0", "18", "\u2032", "00", "\u2033", "S")
|
26
|
-
str_lat.should match expr
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# deg, format, dp
|
31
|
-
describe '#to_lon' do
|
32
|
-
it 'should convert 58.3 to a longitude String' do
|
33
|
-
str_lat = converter.to_lon(58.3)
|
34
|
-
str_lat.should be_a(String)
|
35
|
-
expr = Regexp.escape "58".concat("\u00B0", "18", "\u2032", "00", "\u2033", "E")
|
36
|
-
str_lat.should match expr
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should convert 58.3 to a longitude String' do
|
40
|
-
str_lat = converter.to_lon(-58.3)
|
41
|
-
str_lat.should be_a(String)
|
42
|
-
expr = Regexp.escape "58".concat("\u00B0", "18", "\u2032", "00", "\u2033", "W")
|
43
|
-
str_lat.should match expr
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# Convert numeric degrees to deg/min/sec as a bearing (0º..360º)
|
48
|
-
# deg, format, dp
|
49
|
-
describe '#to_brng' do
|
50
|
-
it 'should convert 58.3 to a longitude String' do
|
51
|
-
brng = converter.to_brng(-58.3)
|
52
|
-
brng.to_f.should be_between(0, 360)
|
53
|
-
expr = Regexp.escape "301".concat("\u00B0", "42", "\u2032", "00")
|
54
|
-
brng.should match expr
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|