geo_calc 0.5.1

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.
@@ -0,0 +1,99 @@
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 "42".concat("\u00B0", "42", "\u2032", "00")
95
+ brng.should match expr
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'geo_calc'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: geo_calc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kristian Mandrup
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-05-13 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &2152964520 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.5.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *2152964520
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ requirement: &2152963980 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2152963980
36
+ - !ruby/object:Gem::Dependency
37
+ name: jeweler
38
+ requirement: &2152955240 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.5.2
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2152955240
47
+ - !ruby/object:Gem::Dependency
48
+ name: rcov
49
+ requirement: &2152954660 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *2152954660
58
+ description: Geo calculations in ruby and javascript
59
+ email: kmandrup@gmail.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files:
63
+ - LICENSE.txt
64
+ - README.textile
65
+ files:
66
+ - .document
67
+ - .rspec
68
+ - Gemfile
69
+ - LICENSE.txt
70
+ - README.textile
71
+ - Rakefile
72
+ - VERSION
73
+ - geo_calc.gemspec
74
+ - lib/geo_calc.rb
75
+ - lib/geo_calc/calculations.rb
76
+ - lib/geo_calc/core_ext.rb
77
+ - lib/geo_calc/geo.rb
78
+ - lib/geo_calc/geo_point.rb
79
+ - lib/geo_calc/js/geo_calc.js
80
+ - spec/geo_calc/calculations_spec.rb
81
+ - spec/geo_calc/core_ext_spec.rb
82
+ - spec/geo_calc/geo_point_spec.rb
83
+ - spec/geo_calc/geo_spec.rb
84
+ - spec/spec_helper.rb
85
+ homepage: http://github.com/kristianmandrup/geo_calc
86
+ licenses:
87
+ - MIT
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ segments:
99
+ - 0
100
+ hash: 4431488091185684901
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 1.8.0
110
+ signing_key:
111
+ specification_version: 3
112
+ summary: Geo calculation library
113
+ test_files:
114
+ - spec/geo_calc/calculations_spec.rb
115
+ - spec/geo_calc/core_ext_spec.rb
116
+ - spec/geo_calc/geo_point_spec.rb
117
+ - spec/geo_calc/geo_spec.rb
118
+ - spec/spec_helper.rb