sun_calc 0.0.1 → 0.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a3f04d3ad8fb0b03c8aa0944f880e38aef08d21
4
- data.tar.gz: fbfa83fc6d4e7b9a6d1507cb5d6d5e39c34b0ab1
3
+ metadata.gz: 32bdf5ac53d3d2a9ab67f764b2a401e77228d56d
4
+ data.tar.gz: 805161944065ec395d06ab120c212141c44d11f9
5
5
  SHA512:
6
- metadata.gz: 647287232b4fa0ba2548789ca692811bb222a71ee883910e23207f8cd249519870134508e5c62c2c57fcaf3b9b05418409f28fc2fdbd595b0f9811b4923862ac
7
- data.tar.gz: b9acc4bc213f343686ec17a265a52239cec0b4a656767fd63cd949e338c8758282a85fe1a578dca697532621c24b98747528a194ca40206584a19ed8cc8d8717
6
+ metadata.gz: 5a3b8a0207164af43b9b010ee162cde90f60099ce03778c6c9fd096f0888590882a86926f7179b1a28e8d4e2469e17612a583c23ce5de1a8cc27d5ade73714cb
7
+ data.tar.gz: 4b7c7d23ad5694cdb413e1dc85fef915f041a68332af91ca6c7a98293ccc83d1ecfecb683b7c90ad8e3769ba8ce7798b14727bc9e28d60f6e9e768ff51494c41
@@ -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
@@ -2,5 +2,5 @@
2
2
 
3
3
  # :nodoc:
4
4
  class SunCalc
5
- VERSION = '0.0.1'.freeze
5
+ VERSION = '0.1.0'.freeze
6
6
  end
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.1
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-04 00:00:00.000000000 Z
12
+ date: 2018-05-11 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: