vincenty 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +2 -0
- data/README.txt +12 -2
- data/Rakefile +1 -0
- data/lib/coordinate.rb +1 -0
- data/lib/track_and_distance.rb +9 -2
- data/lib/vincenty.rb +1 -1
- data/test/ts_all.rb +4 -2
- data/test/ts_angle.rb +1 -0
- data/test/ts_coordinate.rb +18 -0
- data/test/ts_track_and_distance.rb +16 -0
- metadata +4 -2
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -33,8 +33,18 @@
|
|
33
33
|
|
34
34
|
== SYNOPSIS:
|
35
35
|
|
36
|
-
|
37
|
-
|
36
|
+
flindersPeak = Vincenty.new("-37°57′3.72030″", "144°25′29.52440″" )
|
37
|
+
buninyong = Vincenty.new("-37° 39' 10.15610''", "143° 55' 35.38390''")
|
38
|
+
track_and_bearing = flindersPeak.distanceAndAngle( buninyong )
|
39
|
+
puts track_and_bearing
|
40
|
+
|
41
|
+
#or the reverse
|
42
|
+
destination = flindersPeak.destination(TrackAndDistance.new("306° 52' 5.37\"", 54972.271))
|
43
|
+
puts destination
|
44
|
+
|
45
|
+
#Angles is the parent class of Latitude and Longitude
|
46
|
+
Angle.new("-37°01′.125").strf( "The angle is %d°%2m′%2.5s″%N" ) -> "The angle is 37°01′07.50000″S"
|
47
|
+
|
38
48
|
== REQUIREMENTS:
|
39
49
|
|
40
50
|
* require 'rubygems'
|
data/Rakefile
CHANGED
@@ -11,5 +11,6 @@ Hoe.new('vincenty', Vincenty::VERSION) do |s|
|
|
11
11
|
#s.url = "http://rubyforge.org/projects/vincenty/"
|
12
12
|
#s.summary = "Vincenty Algorithm for Distance, Bearing between Map Coordinates."
|
13
13
|
#s.description = s.paragraphs_of('README.txt', 1..4).join("\n\n")
|
14
|
+
s.remote_rdoc_dir = '' # Release to root
|
14
15
|
end
|
15
16
|
|
data/lib/coordinate.rb
CHANGED
data/lib/track_and_distance.rb
CHANGED
@@ -11,9 +11,16 @@ class TrackAndDistance
|
|
11
11
|
@distance = distance
|
12
12
|
end
|
13
13
|
|
14
|
+
#format string fmt is currently just for the bearing angle.
|
15
|
+
#Need to change this to include the distance is single format string.
|
14
16
|
#Returns: Bearing angle and distance in a string.
|
15
|
-
def to_s
|
16
|
-
|
17
|
+
def to_s(fmt = nil)
|
18
|
+
if(fmt)
|
19
|
+
#needs work to include distance as well as angle fmt.
|
20
|
+
"#{@bearing.strf(fmt)} #{distance.round(4)}m"
|
21
|
+
else
|
22
|
+
"#{@bearing.strf} #{distance.round(4)}m"
|
23
|
+
end
|
17
24
|
end
|
18
25
|
|
19
26
|
def to_ary
|
data/lib/vincenty.rb
CHANGED
@@ -12,7 +12,7 @@ require 'track_and_distance.rb'
|
|
12
12
|
require 'coordinate.rb'
|
13
13
|
|
14
14
|
class Vincenty < Coordinate
|
15
|
-
VERSION = '1.0.
|
15
|
+
VERSION = '1.0.2'
|
16
16
|
#Great Circle formulae http://en.wikipedia.org/wiki/Great-circle_distance
|
17
17
|
#Reference calculation for testing, assumes the earth is a sphere, which it isn't.
|
18
18
|
#This gives us an approximation to verify Vincenty algorithm.
|
data/test/ts_all.rb
CHANGED
data/test/ts_angle.rb
CHANGED
@@ -24,6 +24,7 @@ class TestAngle< Test::Unit::TestCase
|
|
24
24
|
|
25
25
|
def test_strf
|
26
26
|
a = Angle.new("S37°01′7.5″")
|
27
|
+
assert_equal("-37°01′07.5000″", a.strf) #default format of strf
|
27
28
|
assert_equal("37°01′07.50000″S", a.strf( "%d°%2m′%2.5s″%N" ))
|
28
29
|
assert_equal("37°01′07.50000″W", a.strf("%d°%2m′%2.5s″%E" ))
|
29
30
|
assert_equal("-37°01′07.5000″", a.strf("%d°%2m′%2.4s″" ))
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'vincenty.rb'
|
3
|
+
|
4
|
+
class TestAngle< Test::Unit::TestCase
|
5
|
+
#test Coordinate
|
6
|
+
def test_coordinate
|
7
|
+
c = Coordinate.new(-36.9923293459124, 174.485341187381,13.5)
|
8
|
+
ca = c.to_ary
|
9
|
+
assert_equal(-36.9923293459124, ca[0].to_d)
|
10
|
+
assert_equal(174.485341187381, ca[1].to_d)
|
11
|
+
assert_equal(13.5, ca[2])
|
12
|
+
ch = c.to_hash
|
13
|
+
assert_equal(-36.9923293459124, ch[:latitude].to_d)
|
14
|
+
assert_equal(174.485341187381, ch[:longitude].to_d)
|
15
|
+
assert_equal(13.5, ch[:altitude])
|
16
|
+
assert_equal("36°59′32.3856″S 174°29′07.2283″E 13.5m", c.to_s)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'vincenty.rb'
|
3
|
+
|
4
|
+
class TestAngle< Test::Unit::TestCase
|
5
|
+
#test TrackAndDistance
|
6
|
+
def test_track_and_distance
|
7
|
+
assert_equal("140°14′10.0000″ 12.0m", TrackAndDistance.new(Angle.new("320,14,10").reverse, 12.0).to_s)
|
8
|
+
assert_equal("215°03′00.0000″ 19.73m", TrackAndDistance.new("215,3,0", 19.73 ).to_s)
|
9
|
+
a = TrackAndDistance.new("215,3,0", 19.73 ).to_ary
|
10
|
+
assert_equal("215°03′00.0000″", a[0].strf)
|
11
|
+
assert_equal("19.73", a[1].to_s)
|
12
|
+
a = TrackAndDistance.new("215,3,0", 19.73 ).to_hash
|
13
|
+
assert_equal("215°03′00.0000″", a[:bearing].strf)
|
14
|
+
assert_equal("19.73", a[:distance].to_s)
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vincenty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Burrowes
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-06 00:00:00 +13:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -50,6 +50,8 @@ files:
|
|
50
50
|
- test/ts_latitude.rb
|
51
51
|
- test/ts_longitude.rb
|
52
52
|
- test/ts_vincenty.rb
|
53
|
+
- test/ts_coordinate.rb
|
54
|
+
- test/ts_track_and_distance.rb
|
53
55
|
has_rdoc: true
|
54
56
|
homepage: "\"http://rubyforge.org/projects/vincenty/\""
|
55
57
|
post_install_message:
|