gstatsat 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gstatsat.rb +23 -15
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e11b22e10d7b531331b0290b2977a003ad145c5b
|
4
|
+
data.tar.gz: 8cabcd3a6a28754d8eb087cada35fe09ad39d629
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fd35ff06641e175885c8fae13ccd3ada9745b42d33a4d73860812856cf02a9d24530e5fd746cdc345bc02efb403982f1b8d1f52a5f496ed7cc4ec77676fa0ba
|
7
|
+
data.tar.gz: 9e52d6a4b02f5e4f08e53ab392a8dd8b7a359ff69266d41bb30f748d209b584499bf490881ae8586f012ab4bad72d8180c0c57501ee18db713cffe0792cf5632
|
data/lib/gstatsat.rb
CHANGED
@@ -6,11 +6,12 @@ module Gstatsat
|
|
6
6
|
@longitude = params.fetch(:longitude)
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
private
|
10
|
+
def validate(params)
|
11
|
+
longitude = params.fetch(:longitude)
|
12
|
+
raise KeyError, 'longitude is not numeric' unless longitude.is_a? Numeric
|
13
|
+
raise KeyError, 'invalid longitude value' unless longitude >= -180 && longitude <= 180
|
14
|
+
end
|
14
15
|
end
|
15
16
|
|
16
17
|
class BaseStation
|
@@ -21,19 +22,21 @@ module Gstatsat
|
|
21
22
|
@longitude = params.fetch(:longitude)
|
22
23
|
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
private
|
26
|
+
def validate(params)
|
27
|
+
longitude = params.fetch(:longitude)
|
28
|
+
latitude = params.fetch(:latitude)
|
29
|
+
raise KeyError, 'longitude is not numeric' unless longitude.is_a? Numeric
|
30
|
+
raise KeyError, 'latitude is not numeric' unless latitude.is_a? Numeric
|
31
|
+
raise KeyError, 'invalid longitude value' unless longitude >= -180 && longitude <= 180
|
32
|
+
raise KeyError, 'invalid latitude value' unless latitude >= -90 && latitude <= 90
|
33
|
+
end
|
32
34
|
end
|
33
35
|
|
34
36
|
class SatelliteBearing
|
35
37
|
attr_accessor :azimuth, :elevation
|
36
38
|
def initialize(params = {})
|
39
|
+
validate(params)
|
37
40
|
@satellite = params.fetch(:satellite)
|
38
41
|
@base_station = params.fetch(:base_station)
|
39
42
|
calculate_bearing
|
@@ -52,8 +55,8 @@ module Gstatsat
|
|
52
55
|
sigma = earths_radius.to_f / ( earths_radius + satellite_height )
|
53
56
|
beta = Math.acos(Math.cos(base_station_latitude_rads) * Math.cos(azimuthal_angle_rads))
|
54
57
|
|
55
|
-
@elevation = to_degrees(Math.atan((
|
56
|
-
@azimuth = to_degrees(Math::PI + Math::atan(Math::tan(azimuthal_angle_rads)/Math::sin(base_station_latitude_rads))).round(1)
|
58
|
+
@elevation = to_degrees(Math.atan((Math.cos(beta) - sigma) / Math.sin(beta))).round(1)
|
59
|
+
@azimuth = to_degrees(Math::PI + Math::atan(Math::tan(azimuthal_angle_rads) / Math::sin(base_station_latitude_rads))).round(1)
|
57
60
|
end
|
58
61
|
|
59
62
|
def to_radians(degrees)
|
@@ -63,5 +66,10 @@ module Gstatsat
|
|
63
66
|
def to_degrees(radians)
|
64
67
|
radians * 180 / Math::PI
|
65
68
|
end
|
69
|
+
|
70
|
+
def validate(params)
|
71
|
+
raise KeyError, 'satellite is not Gstatsat::Satellite class' unless params.fetch(:satellite).is_a? Gstatsat::Satellite
|
72
|
+
raise KeyError, 'base_station is not Gstatsat::BaseStation class' unless params.fetch(:base_station).is_a? Gstatsat::BaseStation
|
73
|
+
end
|
66
74
|
end
|
67
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gstatsat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Clarke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple gem for calculating bearings of geostationary satellites
|
14
14
|
email: greg@gho.st
|
@@ -37,7 +37,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
37
|
version: '0'
|
38
38
|
requirements: []
|
39
39
|
rubyforge_project:
|
40
|
-
rubygems_version: 2.
|
40
|
+
rubygems_version: 2.6.10
|
41
41
|
signing_key:
|
42
42
|
specification_version: 4
|
43
43
|
summary: Calculate bearings of geostationary satellites
|