sun_calc 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sun_calc.rb +8 -2
- data/lib/sun_calc/version.rb +1 -1
- 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: 32bdf5ac53d3d2a9ab67f764b2a401e77228d56d
|
4
|
+
data.tar.gz: 805161944065ec395d06ab120c212141c44d11f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a3b8a0207164af43b9b010ee162cde90f60099ce03778c6c9fd096f0888590882a86926f7179b1a28e8d4e2469e17612a583c23ce5de1a8cc27d5ade73714cb
|
7
|
+
data.tar.gz: 4b7c7d23ad5694cdb413e1dc85fef915f041a68332af91ca6c7a98293ccc83d1ecfecb683b7c90ad8e3769ba8ce7798b14727bc9e28d60f6e9e768ff51494c41
|
data/lib/sun_calc.rb
CHANGED
@@ -98,10 +98,12 @@ class SunCalc
|
|
98
98
|
hc = 0.133 * ONE_RADIAN
|
99
99
|
h0 = SunCalc.moon_position(t, lat, lng)[:altitude] - hc
|
100
100
|
ye = 0
|
101
|
+
max = nil
|
102
|
+
min = nil
|
101
103
|
rise = nil
|
102
104
|
set = nil
|
103
105
|
# Iterate in 2-hour steps checking if a 3-point quadratic curve crosses zero
|
104
|
-
# (which means rise or set).
|
106
|
+
# (which means rise or set). Assumes x values -1, 0, +1.
|
105
107
|
(1...24).step(2).each do |i|
|
106
108
|
h1 = SunCalc.moon_position(hours_later(t, i), lat, lng)[:altitude] - hc
|
107
109
|
h2 = SunCalc.moon_position(
|
@@ -115,6 +117,8 @@ class SunCalc
|
|
115
117
|
roots = 0
|
116
118
|
x1 = 0
|
117
119
|
x2 = 0
|
120
|
+
min = i + xe if xe.abs <= 1 && ye < 0
|
121
|
+
max = i + xe if xe.abs <= 1 && ye > 0
|
118
122
|
if d >= 0
|
119
123
|
dx = Math.sqrt(d) / (a.abs * 2)
|
120
124
|
x1 = xe - dx
|
@@ -133,10 +137,12 @@ class SunCalc
|
|
133
137
|
rise = i + (ye < 0 ? x2 : x1)
|
134
138
|
set = i + (ye < 0 ? x1 : x2)
|
135
139
|
end
|
136
|
-
break if rise && set
|
140
|
+
break if rise && set && min && max
|
137
141
|
h0 = h2
|
138
142
|
end
|
139
143
|
{}.tap do |result|
|
144
|
+
result[:nadir] = hours_later(t, min) if min
|
145
|
+
result[:lunar_noon] = hours_later(t, max) if max
|
140
146
|
result[:moonrise] = hours_later(t, rise) if rise
|
141
147
|
result[:moonset] = hours_later(t, set) if set
|
142
148
|
result[ye > 0 ? :always_up : :always_down] = true if !rise && !set
|
data/lib/sun_calc/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sun_calc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Cederblad
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-05-
|
12
|
+
date: 2018-05-11 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|