vincenty 1.0.6 → 1.0.10

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.
data/test/ts_vincenty.rb CHANGED
@@ -1,96 +1,105 @@
1
+ #!/usr/bin/env ruby
1
2
  require 'test/unit'
2
- require 'vincenty.rb'
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
- 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 ),
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
- 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
- ]
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.to_deg}, #{next_p.latitude.to_deg}\n"
46
- @path.each_with_index do |leg,i|
47
- next_p, spherical_ans = next_p.destination( leg ) , next_p.sphereDestination(leg)
48
-
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
+
49
50
  assert_equal(@waypoints[i].longitude.to_deg.round(12), next_p.longitude.to_deg.round(12))
50
51
  assert_equal(@waypoints[i].latitude.to_deg.round(12), next_p.latitude.to_deg.round(12))
51
- # print "Expect #{waypoints[i].longitude.to_deg.round(4)}, #{waypoints[i].latitude.to_deg.round(4)}\n"
52
- # 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"
53
- # 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"
54
- # puts
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
- # assert_equal(0, next_p.distanceAndAngle(start).distance)
57
- # puts "distance from end to start should be 0. Actual #{next_p.distanceAndAngle(start)}"
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.to_deg}, #{next_p.latitude.to_deg}\n"
67
- @waypoints.each_with_index do |point,i|
68
- vtrack_and_bearing = next_p.distanceAndAngle( point )
69
- # strack_and_bearing = next_p.sphericalDistanceAndAngle( point )
70
-
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
+
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
- # 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"
74
- # 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"
75
- # 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"
76
- # puts
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
- # assert_equal(0, next_p.distanceAndAngle(start).distance)
80
- # puts "distance from end to start should be 0. Actual #{next_p.distanceAndAngle(start)}\n"
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
- #Run the Australian Geoscience site example.
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 )
96
+ buninyong = Vincenty.new("-37 39 ' 10.15610 ''", "143 55 ' 35.38390 ''") # Buninyong
97
+ track_and_bearing = flindersPeak.distanceAndAngle( buninyong )
88
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
102
  assert_equal(buninyong.latitude.to_deg.round(4), destination.latitude.to_deg.round(4))
93
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vincenty
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Burrowes
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-23 00:00:00.000000000 Z
11
+ date: 2021-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hoe-yard
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.2
19
+ version: 0.1.3
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.2
26
+ version: 0.1.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: hoe
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.12'
33
+ version: '3.23'
34
34
  type: :development
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: '3.12'
40
+ version: '3.23'
41
41
  description: "* Vincenty wrote an algorithm for calculating the bearing and distance
42
42
  between two coordinates on the earth\n and an algorithm for finding a second coordinate,
43
43
  given a starting coordinate, bearing and destination.\n The algorithms model the
@@ -70,7 +70,6 @@ extra_rdoc_files:
70
70
  - Manifest.txt
71
71
  - README.md
72
72
  files:
73
- - ".gemtest"
74
73
  - History.txt
75
74
  - Manifest.txt
76
75
  - README.md
@@ -89,17 +88,17 @@ files:
89
88
  - test/ts_longitude.rb
90
89
  - test/ts_track_and_distance.rb
91
90
  - test/ts_vincenty.rb
92
- homepage: http://rbur004.github.com/vincenty/
91
+ homepage: http://rbur004.github.io/vincenty/
93
92
  licenses:
94
93
  - MIT
95
94
  metadata: {}
96
- post_install_message:
95
+ post_install_message:
97
96
  rdoc_options:
98
97
  - "--markup"
99
98
  - markdown
100
99
  - "--protected"
101
100
  - "--title"
102
- - Vincenty
101
+ - vincenty
103
102
  - "--quiet"
104
103
  require_paths:
105
104
  - lib
@@ -114,9 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
113
  - !ruby/object:Gem::Version
115
114
  version: '0'
116
115
  requirements: []
117
- rubyforge_project:
118
- rubygems_version: 2.2.2
119
- signing_key:
116
+ rubygems_version: 3.2.22
117
+ signing_key:
120
118
  specification_version: 4
121
119
  summary: "* Vincenty wrote an algorithm for calculating the bearing and distance between
122
120
  two coordinates on the earth and an algorithm for finding a second coordinate, given
data/.gemtest DELETED
File without changes