geo_point 0.2.1 → 0.2.3
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/Gemfile +2 -2
- data/README.textile +13 -8
- data/VERSION +1 -1
- data/geo_point.gemspec +9 -9
- data/lib/geo_point/calc.rb +2 -2
- data/lib/geo_point/core_extension.rb +1 -1
- data/lib/geo_point.rb +2 -2
- data/spec/geo_point/coord_mode_spec.rb +36 -0
- data/spec/geo_point/{lat_lon.rb → lat_lon_spec.rb} +0 -0
- metadata +18 -18
data/Gemfile
CHANGED
data/README.textile
CHANGED
@@ -7,7 +7,7 @@ Adds the concept of a GeoPoint for geo libraries. A GeoPoint encapsulates latitu
|
|
7
7
|
* parsing from various String, Hash or Array formats, including from DMS string format, such as "58 38 38N, 003 04 12W"
|
8
8
|
|
9
9
|
Using GeoPoints makes it much easier and more efficient to transport location point data and various geo libraries adds additional functionality such as
|
10
|
-
vector operations on top (see fx
|
10
|
+
vector operations on top (see fx "geo_vectors":https://github.com/kristianmandrup/geo_vectors gem). Enjoy!
|
11
11
|
|
12
12
|
h2. Install
|
13
13
|
|
@@ -77,14 +77,19 @@ h2. GeoPoint functionality
|
|
77
77
|
|
78
78
|
A GeoPoint always has the following calculation API available:
|
79
79
|
|
80
|
-
*
|
81
|
-
*
|
82
|
-
*
|
83
|
-
*
|
84
|
-
*
|
85
|
-
*
|
80
|
+
* bearing_to(point)
|
81
|
+
* final_bearing_to(point)
|
82
|
+
* destination_point(brng, dist)
|
83
|
+
* distance_to(point)
|
84
|
+
* intersection_point(brng1, p2, brng2)
|
85
|
+
* midpoint_to(point)
|
86
86
|
|
87
|
-
|
87
|
+
Rhumb: (see "Rhumb_line":http://en.wikipedia.org/wiki/Rhumb_line)
|
88
|
+
* rhumb_distance_to(point)
|
89
|
+
* rhumb_bearing_to(point)
|
90
|
+
* rhumb_destination_point(brng, dist)
|
91
|
+
|
92
|
+
See the "geo_calc":https://github.com/kristianmandrup/geo_calc gem for details on how to use this Api
|
88
93
|
|
89
94
|
h2. Contributing to geo_point
|
90
95
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/geo_point.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{geo_point}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Kristian Mandrup}]
|
12
|
-
s.date = %q{2011-06-
|
12
|
+
s.date = %q{2011-06-19}
|
13
13
|
s.description = %q{Allows for easy parsing of Strings, Hashes and Arrays into a GeoPoint with lat/long}
|
14
14
|
s.email = %q{kmandrup@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
"spec/geo_point/class_methods_spec.rb",
|
34
34
|
"spec/geo_point/coord_mode_spec.rb",
|
35
35
|
"spec/geo_point/initializer_spec.rb",
|
36
|
-
"spec/geo_point/
|
36
|
+
"spec/geo_point/lat_lon_spec.rb",
|
37
37
|
"spec/geo_point_spec.rb",
|
38
38
|
"spec/spec_helper.rb"
|
39
39
|
]
|
@@ -47,23 +47,23 @@ Gem::Specification.new do |s|
|
|
47
47
|
s.specification_version = 3
|
48
48
|
|
49
49
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
-
s.add_runtime_dependency(%q<geo_calc>, ["~> 0.7.
|
51
|
-
s.add_runtime_dependency(%q<geo_units>, [">= 0.2.
|
50
|
+
s.add_runtime_dependency(%q<geo_calc>, ["~> 0.7.4"])
|
51
|
+
s.add_runtime_dependency(%q<geo_units>, [">= 0.2.1"])
|
52
52
|
s.add_development_dependency(%q<rspec>, [">= 2.6.0"])
|
53
53
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.6"])
|
54
54
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
|
55
55
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
56
56
|
else
|
57
|
-
s.add_dependency(%q<geo_calc>, ["~> 0.7.
|
58
|
-
s.add_dependency(%q<geo_units>, [">= 0.2.
|
57
|
+
s.add_dependency(%q<geo_calc>, ["~> 0.7.4"])
|
58
|
+
s.add_dependency(%q<geo_units>, [">= 0.2.1"])
|
59
59
|
s.add_dependency(%q<rspec>, [">= 2.6.0"])
|
60
60
|
s.add_dependency(%q<bundler>, ["~> 1.0.6"])
|
61
61
|
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
62
62
|
s.add_dependency(%q<rcov>, [">= 0"])
|
63
63
|
end
|
64
64
|
else
|
65
|
-
s.add_dependency(%q<geo_calc>, ["~> 0.7.
|
66
|
-
s.add_dependency(%q<geo_units>, [">= 0.2.
|
65
|
+
s.add_dependency(%q<geo_calc>, ["~> 0.7.4"])
|
66
|
+
s.add_dependency(%q<geo_units>, [">= 0.2.1"])
|
67
67
|
s.add_dependency(%q<rspec>, [">= 2.6.0"])
|
68
68
|
s.add_dependency(%q<bundler>, ["~> 1.0.6"])
|
69
69
|
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
data/lib/geo_point/calc.rb
CHANGED
@@ -28,13 +28,13 @@ class GeoPoint
|
|
28
28
|
module Intersection
|
29
29
|
# see(#intersection)
|
30
30
|
# @returns [GeoPoint] Destination point (null if no unique intersection defined)
|
31
|
-
def self.intersection_point p1, brng1, p2, brng2
|
31
|
+
def self.intersection_point p1, brng1, p2, brng2
|
32
32
|
GeoPoint.new GeoCalc::Intersection.intersection(p1, brng1, p2, brng2).to_coords
|
33
33
|
end
|
34
34
|
|
35
35
|
# see(#intersection)
|
36
36
|
# @returns [GeoPoint] Destination point (null if no unique intersection defined)
|
37
|
-
def intersection_point brng1, p2, brng2
|
37
|
+
def intersection_point brng1, p2, brng2
|
38
38
|
GeoPoint.new GeoCalc::Intersection.intersection(self, brng1, p2, brng2).to_coords
|
39
39
|
end
|
40
40
|
end
|
data/lib/geo_point.rb
CHANGED
@@ -132,9 +132,9 @@ class GeoPoint
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def create_from_one args
|
135
|
-
args = args.first
|
135
|
+
args = args.first
|
136
136
|
array = to_coords(args)
|
137
|
-
array = coord_mode == :lng_lat ? array.reverse : array
|
137
|
+
array = (coord_mode == :lng_lat && args.is_a?(Hash) ) ? array.reverse : array
|
138
138
|
create_from_two *array
|
139
139
|
end
|
140
140
|
|
@@ -33,4 +33,40 @@ describe Array do
|
|
33
33
|
[5, 2].to_lng.should == 2
|
34
34
|
end
|
35
35
|
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe Hash do
|
39
|
+
describe '#coord_mode' do
|
40
|
+
it 'should parse as lng, lat' do
|
41
|
+
GeoPoint.coord_mode = :lng_lat
|
42
|
+
p = {:lng => 2, :lat => 5}.geo_point
|
43
|
+
p.to_lat.should == 5
|
44
|
+
p.to_lng.should == 2
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should parse as lat, lng' do
|
48
|
+
GeoPoint.coord_mode = :lat_lng
|
49
|
+
p = {:lng => 2, :lat => 5}.geo_point
|
50
|
+
p.to_lat.should == 5
|
51
|
+
p.to_lng.should == 2
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe String do
|
57
|
+
describe '#coord_mode' do
|
58
|
+
it 'should parse as lng, lat' do
|
59
|
+
GeoPoint.coord_mode = :lng_lat
|
60
|
+
p = "2, 5".geo_point
|
61
|
+
p.to_lat.should == 5
|
62
|
+
p.to_lng.should == 2
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should parse as lat, lng' do
|
66
|
+
GeoPoint.coord_mode = :lat_lng
|
67
|
+
p = "2, 5".geo_point
|
68
|
+
p.to_lat.should == 2
|
69
|
+
p.to_lng.should == 5
|
70
|
+
end
|
71
|
+
end
|
36
72
|
end
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geo_point
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,33 +9,33 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-06-
|
12
|
+
date: 2011-06-19 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: geo_calc
|
16
|
-
requirement: &
|
16
|
+
requirement: &2154397860 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.7.
|
21
|
+
version: 0.7.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2154397860
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: geo_units
|
27
|
-
requirement: &
|
27
|
+
requirement: &2154397280 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.2.
|
32
|
+
version: 0.2.1
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2154397280
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &2154396740 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.6.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2154396740
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
|
-
requirement: &
|
49
|
+
requirement: &2154396220 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.0.6
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2154396220
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: jeweler
|
60
|
-
requirement: &
|
60
|
+
requirement: &2154395620 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.6.2
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2154395620
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rcov
|
71
|
-
requirement: &
|
71
|
+
requirement: &2154395040 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2154395040
|
80
80
|
description: Allows for easy parsing of Strings, Hashes and Arrays into a GeoPoint
|
81
81
|
with lat/long
|
82
82
|
email: kmandrup@gmail.com
|
@@ -102,7 +102,7 @@ files:
|
|
102
102
|
- spec/geo_point/class_methods_spec.rb
|
103
103
|
- spec/geo_point/coord_mode_spec.rb
|
104
104
|
- spec/geo_point/initializer_spec.rb
|
105
|
-
- spec/geo_point/
|
105
|
+
- spec/geo_point/lat_lon_spec.rb
|
106
106
|
- spec/geo_point_spec.rb
|
107
107
|
- spec/spec_helper.rb
|
108
108
|
homepage: http://github.com/kristianmandrup/geo_point
|
@@ -120,7 +120,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
segments:
|
122
122
|
- 0
|
123
|
-
hash:
|
123
|
+
hash: 1136387806736178930
|
124
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
125
|
none: false
|
126
126
|
requirements:
|