gpsutils 0.1.1 → 0.1.2
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 +4 -4
- data/README.md +4 -0
- data/lib/gpsutils/version.rb +1 -1
- data/lib/gpsutils.rb +38 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13f60e90df69b5df1eb2e4bc8ae38bbc4a85552d
|
4
|
+
data.tar.gz: 185af0e83814dbbb3dbd72e25d7d6cc8e1afd601
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e603405c2410a019078df94458d2c4844e08ad860486ef82c01693c1799e5ba17f4d2356d178374a25fdea7e8b0e047fbc2e9fffa91b93c093f3dfbd366f1538
|
7
|
+
data.tar.gz: 58463a2addc7e96469fb9a9a056062a3619e2aed678e6ac0ebf8e88c3ff796914544ae07553b0e9ea03664c86eeccf7a452ad44fc228c9783d728b8bd783d916
|
data/README.md
CHANGED
@@ -21,11 +21,13 @@ You can install the package from rubygems or github using Bundler or create your
|
|
21
21
|
### Using Bundler with rubygems
|
22
22
|
|
23
23
|
Edit you Gemfile and add the following line:
|
24
|
+
|
24
25
|
```ruby
|
25
26
|
gem 'gpsutils'
|
26
27
|
```
|
27
28
|
|
28
29
|
Then run:
|
30
|
+
|
29
31
|
```bash
|
30
32
|
$ bundle install
|
31
33
|
```
|
@@ -33,11 +35,13 @@ $ bundle install
|
|
33
35
|
### Using Bundler with github
|
34
36
|
|
35
37
|
Edit you Gemfile and add the following line:
|
38
|
+
|
36
39
|
```ruby
|
37
40
|
gem 'gpsutils', :git => 'https://github.com/megamoose/gpsutils.git'
|
38
41
|
```
|
39
42
|
|
40
43
|
Then run:
|
44
|
+
|
41
45
|
```bash
|
42
46
|
$ bundle install
|
43
47
|
```
|
data/lib/gpsutils/version.rb
CHANGED
data/lib/gpsutils.rb
CHANGED
@@ -1,8 +1,18 @@
|
|
1
1
|
module GpsUtils
|
2
2
|
|
3
3
|
class Point
|
4
|
-
|
5
|
-
|
4
|
+
# @!attribute [r] lat
|
5
|
+
# @return [Float, Integer] Latitude
|
6
|
+
attr_reader :lat
|
7
|
+
|
8
|
+
# @!attribute [r] lng
|
9
|
+
# @return [Float, Integer] Longitude
|
10
|
+
attr_reader :lng
|
11
|
+
|
12
|
+
# Initialize Point.
|
13
|
+
#
|
14
|
+
# @param lat [Integer, Float] Latitude
|
15
|
+
# @param lng [Integer, Float] Langitude
|
6
16
|
def initialize(lat, lng)
|
7
17
|
unless lat.is_a? Float or lat.is_a? Integer
|
8
18
|
raise ArgumentError.new 'lat must be float or integer.'
|
@@ -16,6 +26,8 @@ module GpsUtils
|
|
16
26
|
@lng = lng
|
17
27
|
end
|
18
28
|
|
29
|
+
# @return [Array] Array with latitude and longitude as Float or Integer
|
30
|
+
# values, as used when object was initialized
|
19
31
|
def to_a
|
20
32
|
[@lat, @lng]
|
21
33
|
end
|
@@ -26,9 +38,27 @@ module GpsUtils
|
|
26
38
|
end
|
27
39
|
|
28
40
|
class BoundingBox
|
29
|
-
|
30
|
-
|
41
|
+
# @!attribute [r] nw
|
42
|
+
# @return [Point] North-West corner
|
43
|
+
attr_reader :nw
|
44
|
+
|
45
|
+
# @!attribute [r] nw
|
46
|
+
# @return [Point] South-East corner
|
47
|
+
attr_reader :se
|
48
|
+
|
49
|
+
# Initialize BoundingBox.
|
50
|
+
#
|
51
|
+
# @param nw_point [Point] North-West corner
|
52
|
+
# @param se_point [Point] South-East corner
|
31
53
|
def initialize(nw_point, se_point)
|
54
|
+
unless nw_point.is_a? Point
|
55
|
+
raise ArgumentError.new 'nw_point must be a Point.'
|
56
|
+
end
|
57
|
+
|
58
|
+
unless se_point.is_a? Point
|
59
|
+
raise ArgumentError.new 'se_point must be a Point.'
|
60
|
+
end
|
61
|
+
|
32
62
|
@nw = nw_point
|
33
63
|
@se = se_point
|
34
64
|
|
@@ -39,15 +69,16 @@ module GpsUtils
|
|
39
69
|
@p41ms = @p41 ** 2
|
40
70
|
end
|
41
71
|
|
72
|
+
# Determine whether point is inside bounding box.
|
73
|
+
#
|
74
|
+
# @param point [Point]
|
42
75
|
def cover?(point)
|
43
|
-
return false if @nw.lat == @se.lat and @nw.lng == @se.lng
|
44
|
-
|
45
76
|
p = [point.lat - @nw.lat, point.lng - @se.lng]
|
46
77
|
|
47
78
|
p21x = p[0] * @p21
|
48
79
|
p41x = p[1] * @p41
|
49
80
|
|
50
|
-
0
|
81
|
+
0 < p21x and p21x < @p21ms and 0 <= p41x and p41x <= @p41ms
|
51
82
|
end
|
52
83
|
|
53
84
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gpsutils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ronnie Mose
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|