vincenty 1.0.4 → 1.0.9
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/History.txt +62 -52
- data/README.md +3 -3
- data/Rakefile +17 -10
- data/lib/angle.rb +215 -203
- data/lib/coordinate.rb +24 -23
- data/lib/core_extensions.rb +67 -59
- data/lib/latitude.rb +30 -29
- data/lib/longitude.rb +22 -23
- data/lib/track_and_distance.rb +36 -32
- data/lib/vincenty.rb +153 -143
- data/test/ts_all.rb +8 -8
- data/test/ts_angle.rb +55 -54
- data/test/ts_coordinate.rb +10 -9
- data/test/ts_latitude.rb +20 -17
- data/test/ts_longitude.rb +14 -11
- data/test/ts_track_and_distance.rb +12 -9
- data/test/ts_vincenty.rb +80 -71
- metadata +33 -39
- data/.gemtest +0 -0
@@ -1,16 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
1
2
|
require 'test/unit'
|
2
|
-
|
3
|
+
require_relative '../lib/vincenty.rb'
|
3
4
|
|
4
|
-
class
|
5
|
-
#test TrackAndDistance
|
5
|
+
class TestTrackAndDistance < Test::Unit::TestCase
|
6
|
+
# test TrackAndDistance
|
6
7
|
def test_track_and_distance
|
7
|
-
assert_equal("140 14'10.0000\" 12.0m", TrackAndDistance.new(Angle.new(
|
8
|
-
assert_equal("215 03'00.0000\" 19.73m", TrackAndDistance.new(
|
9
|
-
|
8
|
+
assert_equal("140 14'10.0000\" 12.0m", TrackAndDistance.new(Angle.new('320,14,10').reverse, 12.0).to_s)
|
9
|
+
assert_equal("215 03'00.0000\" 19.73m", TrackAndDistance.new('215,3,0', 19.73 ).to_s)
|
10
|
+
|
11
|
+
a = TrackAndDistance.new('215,3,0', 19.73 ).to_ary
|
10
12
|
assert_equal("215 03'00.0000\"", a[0].strf)
|
11
|
-
assert_equal(
|
12
|
-
|
13
|
+
assert_equal('19.73', a[1].to_s)
|
14
|
+
|
15
|
+
a = TrackAndDistance.new('215,3,0', 19.73 ).to_hash
|
13
16
|
assert_equal("215 03'00.0000\"", a[:bearing].strf)
|
14
|
-
assert_equal(
|
17
|
+
assert_equal('19.73', a[:distance].to_s)
|
15
18
|
end
|
16
19
|
end
|
data/test/ts_vincenty.rb
CHANGED
@@ -1,96 +1,105 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
1
2
|
require 'test/unit'
|
2
|
-
|
3
|
-
|
4
|
-
class TestVincenty< Test::Unit::TestCase
|
3
|
+
require_relative '../lib/vincenty.rb'
|
5
4
|
|
5
|
+
class TestVincenty < Test::Unit::TestCase
|
6
6
|
def initialize(x)
|
7
7
|
super(x)
|
8
|
-
|
9
|
-
@path = [ #Path starting at peg by kanaka at end of drive
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
8
|
+
|
9
|
+
@path = [ # Path starting at peg by kanaka at end of drive
|
10
|
+
TrackAndDistance.new('215,3,0', 19.73 ),
|
11
|
+
TrackAndDistance.new(Angle.new('320,14,10').reverse, 12.0), # Note don't need to add the radians=true argument as Angle has to_radians function
|
12
|
+
TrackAndDistance.new(Angle.new('281,44,40').reverse, 35.23 ),
|
13
|
+
TrackAndDistance.new(Angle.new('247,24,0').reverse, 40.23 ),
|
14
|
+
TrackAndDistance.new(Angle.new('218,19,0').reverse, 378.98 ),
|
15
|
+
TrackAndDistance.new(Angle.new('158,25,0').reverse, 128.39 ),
|
16
|
+
TrackAndDistance.new(Angle.new('17,7,40').reverse, 122.41 ),
|
17
|
+
TrackAndDistance.new(Angle.new('51,1,0').reverse, 288.89 ),
|
18
|
+
TrackAndDistance.new('158,47,30', 61.78 ),
|
19
|
+
TrackAndDistance.new('189,16,10', 26.26 ),
|
20
|
+
TrackAndDistance.new('217,14,0', 21.87 )
|
21
21
|
]
|
22
22
|
|
23
23
|
@waypoints = [
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
]
|
24
|
+
Vincenty.new(-36.9923293459124, 174.485341187381),
|
25
|
+
Vincenty.new(-36.992412464006, 174.485427409127),
|
26
|
+
Vincenty.new(-36.9924770796644, 174.485814875954),
|
27
|
+
Vincenty.new(-36.9923377696042, 174.486232091137),
|
28
|
+
Vincenty.new(-36.9896584018239, 174.488871503953),
|
29
|
+
Vincenty.new(-36.988582616694, 174.488340992344),
|
30
|
+
Vincenty.new(-36.9896367145752, 174.487936042043),
|
31
|
+
Vincenty.new(-36.9912743090293, 174.48541348615),
|
32
|
+
Vincenty.new(-36.9917932943506, 174.485664544705),
|
33
|
+
Vincenty.new(-36.9920268289562, 174.485617028991),
|
34
|
+
Vincenty.new(-36.9921837292671, 174.485468381511)
|
35
|
+
]
|
36
36
|
end
|
37
37
|
|
38
|
-
#The path in @path was entered from the property survey map, with distance and bearings which should form a closed loop
|
39
|
-
#verified on google map of my property by creating a KML file and loading the map over the satellite image and checking the
|
40
|
-
#coordinates in google earth, and visually checking the route created was a closed loop (it was with a tiny error).
|
38
|
+
# The path in @path was entered from the property survey map, with distance and bearings which should form a closed loop
|
39
|
+
# verified on google map of my property by creating a KML file and loading the map over the satellite image and checking the
|
40
|
+
# coordinates in google earth, and visually checking the route created was a closed loop (it was with a tiny error).
|
41
41
|
def test_vincenty_destination
|
42
|
-
start = Vincenty.new(-36.9921838030711, 174.485468469841)
|
42
|
+
start = Vincenty.new(-36.9921838030711, 174.485468469841)
|
43
43
|
|
44
44
|
next_p = start
|
45
|
-
# print "Start at coordinate #{next_p.longitude.
|
46
|
-
@path.each_with_index do |leg,i|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
assert_equal(@waypoints[i].
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
45
|
+
# print "Start at coordinate #{next_p.longitude.to_deg}, #{next_p.latitude.to_deg}\n"
|
46
|
+
@path.each_with_index do |leg, i|
|
47
|
+
spherical_ans = next_p.sphereDestination(leg)
|
48
|
+
next_p = next_p.destination( leg )
|
49
|
+
|
50
|
+
assert_equal(@waypoints[i].longitude.to_deg.round(12), next_p.longitude.to_deg.round(12))
|
51
|
+
assert_equal(@waypoints[i].latitude.to_deg.round(12), next_p.latitude.to_deg.round(12))
|
52
|
+
# print "Expect #{waypoints[i].longitude.to_deg.round(4)}, #{waypoints[i].latitude.to_deg.round(4)}\n"
|
53
|
+
# print "Moved #{leg.bearing.to_deg.round(4)} #{leg.distance.round(4)}m to #{next_p.longitude.to_deg.round(4)}, #{next_p.latitude.to_deg.round(4)}\n"
|
54
|
+
# print "Spherical #{leg.bearing.to_deg.round(4)} #{leg.distance.round(4)}m to #{spherical_ans.longitude.to_deg.round(4)}, #{spherical_ans.latitude.to_deg.round(4)}\n"
|
55
|
+
# puts
|
55
56
|
end
|
56
|
-
|
57
|
-
|
57
|
+
# assert_equal(0, next_p.distanceAndAngle(start).distance)
|
58
|
+
# puts "distance from end to start should be 0. Actual #{next_p.distanceAndAngle(start)}"
|
58
59
|
end
|
59
|
-
|
60
|
-
#The waypoints are the latitudes and longitudes of the corners of my property.
|
61
|
-
#The resulting bearing and distances between them should match those in @path.
|
60
|
+
|
61
|
+
# The waypoints are the latitudes and longitudes of the corners of my property.
|
62
|
+
# The resulting bearing and distances between them should match those in @path.
|
62
63
|
def test_vincenty_distance_and_angle
|
63
|
-
start = Vincenty.new(-36.9921838030711, 174.485468469841)
|
64
|
+
start = Vincenty.new(-36.9921838030711, 174.485468469841)
|
64
65
|
next_p = start
|
65
|
-
# print "\nReverse test, c\n"
|
66
|
-
# print "Start at coordinate #{next_p.longitude.
|
67
|
-
@waypoints.each_with_index do |point,i|
|
68
|
-
vtrack_and_bearing = next_p.distanceAndAngle( point )
|
69
|
-
|
70
|
-
|
71
|
-
assert_equal(@path[i].bearing.
|
66
|
+
# print "\nReverse test, c\n"
|
67
|
+
# print "Start at coordinate #{next_p.longitude.to_deg}, #{next_p.latitude.to_deg}\n"
|
68
|
+
@waypoints.each_with_index do |point, i|
|
69
|
+
vtrack_and_bearing = next_p.distanceAndAngle( point )
|
70
|
+
# strack_and_bearing = next_p.sphericalDistanceAndAngle( point )
|
71
|
+
|
72
|
+
assert_equal(@path[i].bearing.to_deg.round(4), vtrack_and_bearing.bearing.to_deg.round(4))
|
72
73
|
assert_equal(@path[i].distance.round(4), vtrack_and_bearing.distance.round(4))
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
# print "Expected #{path[i].bearing.to_deg.round(4)}(#{((path[i].bearing.to_deg+180)%360).round(4)}), #{path[i].distance.round(4)}m\n"
|
75
|
+
# print "WGS-84 track #{vtrack_and_bearing.bearing.to_deg.round(4)} #{vtrack_and_bearing.distance.round(4)}m from #{next_p.longitude.to_deg.round(4)}, #{next_p.latitude.to_deg.round(4)} to #{point.longitude.to_deg.round(4)}, #{point.latitude.to_deg.round(4)}\n"
|
76
|
+
# print "Spherical track #{strack_and_bearing.bearing.to_deg.round(4)} #{strack_and_bearing.distance.round(4)}m from #{next_p.longitude.to_deg.round(4)}, #{next_p.latitude.to_deg.round(4)} to #{point.longitude.to_deg.round(4)}, #{point.latitude.to_deg.round(4)}\n"
|
77
|
+
# puts
|
77
78
|
next_p = point
|
78
79
|
end
|
79
|
-
|
80
|
-
|
80
|
+
# assert_equal(0, next_p.distanceAndAngle(start).distance)
|
81
|
+
# puts "distance from end to start should be 0. Actual #{next_p.distanceAndAngle(start)}\n"
|
81
82
|
end
|
82
|
-
|
83
|
-
#
|
83
|
+
|
84
|
+
# Edge case, when points are at same location
|
85
|
+
def test_vincenty_distance_and_angle_when_0
|
86
|
+
start = Vincenty.new(-36.9921838030711, 174.485468469841)
|
87
|
+
vtrack_and_bearing = start.distanceAndAngle( start )
|
88
|
+
|
89
|
+
assert_equal(0, vtrack_and_bearing.bearing.to_deg.round(4))
|
90
|
+
assert_equal(0, vtrack_and_bearing.distance.round(4))
|
91
|
+
end
|
92
|
+
|
93
|
+
# Run the Australian Geoscience site example.
|
84
94
|
def test_geoscience_au
|
85
95
|
flindersPeak = Vincenty.new("-37 57'3.72030″", "144 25'29.52440″" )
|
86
|
-
buninyong = Vincenty.new("-37 39 ' 10.15610 ''", "143 55 ' 35.38390 ''") #Buninyong
|
87
|
-
track_and_bearing = flindersPeak.distanceAndAngle( buninyong )
|
88
|
-
assert_equal(Angle.new("306 52 ' 5.37 ''").
|
96
|
+
buninyong = Vincenty.new("-37 39 ' 10.15610 ''", "143 55 ' 35.38390 ''") # Buninyong
|
97
|
+
track_and_bearing = flindersPeak.distanceAndAngle( buninyong )
|
98
|
+
assert_equal(Angle.new("306 52 ' 5.37 ''").to_deg.round(4), track_and_bearing.bearing.to_deg.round(4))
|
89
99
|
assert_equal(54972.271, track_and_bearing.distance.round(3))
|
90
|
-
|
100
|
+
|
91
101
|
destination = flindersPeak.destination(TrackAndDistance.new("306 52 ' 5.37 ''", 54972.271))
|
92
|
-
assert_equal(buninyong.latitude.
|
93
|
-
assert_equal(buninyong.longitude.
|
102
|
+
assert_equal(buninyong.latitude.to_deg.round(4), destination.latitude.to_deg.round(4))
|
103
|
+
assert_equal(buninyong.longitude.to_deg.round(4), destination.longitude.to_deg.round(4))
|
94
104
|
end
|
95
|
-
|
96
|
-
end
|
105
|
+
end
|
metadata
CHANGED
@@ -1,49 +1,44 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vincenty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.9
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Rob Burrowes
|
9
|
-
autorequire:
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2021-10-09 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: hoe-yard
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.1.
|
19
|
+
version: 0.1.3
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.1.
|
26
|
+
version: 0.1.3
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: hoe
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version: '3.
|
33
|
+
version: '3.23'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version: '3.
|
46
|
-
description:
|
40
|
+
version: '3.23'
|
41
|
+
description: "* Vincenty wrote an algorithm for calculating the bearing and distance
|
47
42
|
between two coordinates on the earth\n and an algorithm for finding a second coordinate,
|
48
43
|
given a starting coordinate, bearing and destination.\n The algorithms model the
|
49
44
|
earth as an ellipsoid, using the WGS-84 model. This is the common GPS model for\n
|
@@ -73,6 +68,7 @@ extensions: []
|
|
73
68
|
extra_rdoc_files:
|
74
69
|
- History.txt
|
75
70
|
- Manifest.txt
|
71
|
+
- README.md
|
76
72
|
files:
|
77
73
|
- History.txt
|
78
74
|
- Manifest.txt
|
@@ -87,42 +83,40 @@ files:
|
|
87
83
|
- lib/vincenty.rb
|
88
84
|
- test/ts_all.rb
|
89
85
|
- test/ts_angle.rb
|
86
|
+
- test/ts_coordinate.rb
|
90
87
|
- test/ts_latitude.rb
|
91
88
|
- test/ts_longitude.rb
|
92
|
-
- test/ts_vincenty.rb
|
93
|
-
- test/ts_coordinate.rb
|
94
89
|
- test/ts_track_and_distance.rb
|
95
|
-
- .
|
96
|
-
homepage: http://rbur004.github.
|
97
|
-
licenses:
|
98
|
-
|
90
|
+
- test/ts_vincenty.rb
|
91
|
+
homepage: http://rbur004.github.io/vincenty/
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
99
96
|
rdoc_options:
|
100
|
-
- --markup
|
97
|
+
- "--markup"
|
101
98
|
- markdown
|
102
|
-
- --protected
|
103
|
-
- --title
|
104
|
-
-
|
105
|
-
- --quiet
|
99
|
+
- "--protected"
|
100
|
+
- "--title"
|
101
|
+
- vincenty
|
102
|
+
- "--quiet"
|
106
103
|
require_paths:
|
107
104
|
- lib
|
108
105
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
-
none: false
|
110
106
|
requirements:
|
111
|
-
- -
|
107
|
+
- - ">="
|
112
108
|
- !ruby/object:Gem::Version
|
113
109
|
version: '0'
|
114
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
-
none: false
|
116
111
|
requirements:
|
117
|
-
- -
|
112
|
+
- - ">="
|
118
113
|
- !ruby/object:Gem::Version
|
119
114
|
version: '0'
|
120
115
|
requirements: []
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
given a starting coordinate, bearing and destination'
|
116
|
+
rubygems_version: 3.2.22
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: "* Vincenty wrote an algorithm for calculating the bearing and distance between
|
120
|
+
two coordinates on the earth and an algorithm for finding a second coordinate, given
|
121
|
+
a starting coordinate, bearing and destination"
|
128
122
|
test_files: []
|
data/.gemtest
DELETED
File without changes
|