@hebcal/noaa 0.8.3 → 0.8.5
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.
- package/README.md +623 -5
- package/dist/cjs/index.js +123 -101
- package/dist/esm/index.js +1075 -0
- package/dist/index.d.ts +720 -0
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.NOAACalculator = exports.GeoLocation = void 0;
|
|
|
4
4
|
const temporal_polyfill_1 = require("temporal-polyfill");
|
|
5
5
|
/**
|
|
6
6
|
* java.lang.Math.toRadians
|
|
7
|
+
* @private
|
|
7
8
|
* @param degrees
|
|
8
9
|
*/
|
|
9
10
|
function degreesToRadians(degrees) {
|
|
@@ -11,6 +12,7 @@ function degreesToRadians(degrees) {
|
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
14
|
* java.lang.Math.toDegrees
|
|
15
|
+
* @private
|
|
14
16
|
* @param radians
|
|
15
17
|
*/
|
|
16
18
|
function radiansToDegrees(radians) {
|
|
@@ -28,24 +30,26 @@ const Long_MIN_VALUE = NaN;
|
|
|
28
30
|
*/
|
|
29
31
|
class GeoLocation {
|
|
30
32
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* @return Returns the elevation in Meters.
|
|
34
|
-
*/
|
|
35
|
-
getElevation() {
|
|
36
|
-
return this.elevation;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Method to set the elevation in Meters <b>above </b> sea level.
|
|
33
|
+
* GeoLocation constructor with parameters for all required fields.
|
|
40
34
|
*
|
|
41
|
-
* @param
|
|
42
|
-
* The
|
|
35
|
+
* @param {string} name
|
|
36
|
+
* The location name for display use such as "Lakewood, NJ"
|
|
37
|
+
* @param {number} latitude
|
|
38
|
+
* the latitude in a double format such as 40.095965 for Lakewood, NJ.
|
|
39
|
+
* <b>Note: </b> For latitudes south of the equator, a negative value should be used.
|
|
40
|
+
* @param {number} longitude
|
|
41
|
+
* double the longitude in a double format such as -74.222130 for Lakewood, NJ.
|
|
42
|
+
* <b>Note: </b> For longitudes east of the <a href="http://en.wikipedia.org/wiki/Prime_Meridian">Prime
|
|
43
|
+
* Meridian </a> (Greenwich), a negative value should be used.
|
|
44
|
+
* @param {number} elevation
|
|
45
|
+
* the elevation above sea level in Meters. Elevation is not used in most algorithms used for calculating
|
|
46
|
+
* sunrise and set.
|
|
47
|
+
* @param {string} timeZoneId
|
|
48
|
+
* the <code>TimeZone</code> for the location.
|
|
43
49
|
*/
|
|
44
|
-
|
|
45
|
-
this.elevation = elevation;
|
|
46
|
-
}
|
|
47
|
-
constructor(name = 'Greenwich, England', latitude = 51.4772, longitude = 0, elevationOrTimeZoneId, timeZoneId) {
|
|
50
|
+
constructor(name, latitude, longitude, elevationOrTimeZoneId, timeZoneId) {
|
|
48
51
|
/**
|
|
52
|
+
* @private
|
|
49
53
|
* @see #getLocationName()
|
|
50
54
|
* @see #setLocationName(String)
|
|
51
55
|
*/
|
|
@@ -63,11 +67,28 @@ class GeoLocation {
|
|
|
63
67
|
this.setElevation(elevation);
|
|
64
68
|
this.setTimeZone(timeZoneId);
|
|
65
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Method to get the elevation in Meters.
|
|
72
|
+
*
|
|
73
|
+
* @return {number} Returns the elevation in Meters.
|
|
74
|
+
*/
|
|
75
|
+
getElevation() {
|
|
76
|
+
return this.elevation;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Method to set the elevation in Meters <b>above </b> sea level.
|
|
80
|
+
*
|
|
81
|
+
* @param {number} elevation
|
|
82
|
+
* The elevation to set in Meters. An IllegalArgumentException will be thrown if the value is a negative.
|
|
83
|
+
*/
|
|
84
|
+
setElevation(elevation) {
|
|
85
|
+
this.elevation = elevation;
|
|
86
|
+
}
|
|
66
87
|
setLatitude(latitude) {
|
|
67
88
|
this.latitude = latitude;
|
|
68
89
|
}
|
|
69
90
|
/**
|
|
70
|
-
* @return Returns the latitude.
|
|
91
|
+
* @return {number} Returns the latitude.
|
|
71
92
|
*/
|
|
72
93
|
getLatitude() {
|
|
73
94
|
return this.latitude;
|
|
@@ -76,26 +97,26 @@ class GeoLocation {
|
|
|
76
97
|
this.longitude = longitude;
|
|
77
98
|
}
|
|
78
99
|
/**
|
|
79
|
-
* @return Returns the longitude.
|
|
100
|
+
* @return {number} Returns the longitude.
|
|
80
101
|
*/
|
|
81
102
|
getLongitude() {
|
|
82
103
|
return this.longitude;
|
|
83
104
|
}
|
|
84
105
|
/**
|
|
85
|
-
* @return Returns the location name.
|
|
106
|
+
* @return {string|null} Returns the location name.
|
|
86
107
|
*/
|
|
87
108
|
getLocationName() {
|
|
88
109
|
return this.locationName;
|
|
89
110
|
}
|
|
90
111
|
/**
|
|
91
|
-
* @param name
|
|
112
|
+
* @param {string|null} name
|
|
92
113
|
* The setter method for the display name.
|
|
93
114
|
*/
|
|
94
115
|
setLocationName(name) {
|
|
95
116
|
this.locationName = name;
|
|
96
117
|
}
|
|
97
118
|
/**
|
|
98
|
-
* @return Returns the timeZone.
|
|
119
|
+
* @return {string} Returns the timeZone.
|
|
99
120
|
*/
|
|
100
121
|
getTimeZone() {
|
|
101
122
|
return this.timeZoneId;
|
|
@@ -108,7 +129,7 @@ class GeoLocation {
|
|
|
108
129
|
* AstronomicalCalendar to output times in the expected offset. This situation will arise if the
|
|
109
130
|
* AstronomicalCalendar is ever {@link AstronomicalCalendar#clone() cloned}.
|
|
110
131
|
*
|
|
111
|
-
* @param timeZone
|
|
132
|
+
* @param {string} timeZone
|
|
112
133
|
* The timeZone to set.
|
|
113
134
|
*/
|
|
114
135
|
setTimeZone(timeZoneId) {
|
|
@@ -149,7 +170,22 @@ const earthRadius = 6356.9; // in KM
|
|
|
149
170
|
*/
|
|
150
171
|
class NOAACalculator {
|
|
151
172
|
/**
|
|
152
|
-
*
|
|
173
|
+
* A constructor that takes in <a href="http://en.wikipedia.org/wiki/Geolocation">geolocation</a> information as a
|
|
174
|
+
* parameter. The default {@link AstronomicalCalculator#getDefault() AstronomicalCalculator} used for solar
|
|
175
|
+
* calculations is the the {@link NOAACalculator}.
|
|
176
|
+
*
|
|
177
|
+
* @param {GeoLocation} geoLocation
|
|
178
|
+
* The location information used for calculating astronomical sun times.
|
|
179
|
+
* @param {Temporal.PlainDate} date
|
|
180
|
+
*
|
|
181
|
+
* @see #setAstronomicalCalculator(AstronomicalCalculator) for changing the calculator class.
|
|
182
|
+
*/
|
|
183
|
+
constructor(geoLocation, date) {
|
|
184
|
+
this.date = date;
|
|
185
|
+
this.geoLocation = geoLocation;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* The getSunrise method Returns a `Date` representing the
|
|
153
189
|
* {@link AstronomicalCalculator#getElevationAdjustment(double) elevation adjusted} sunrise time. The zenith used
|
|
154
190
|
* for the calculation uses {@link #GEOMETRIC_ZENITH geometric zenith} of 90° plus
|
|
155
191
|
* {@link AstronomicalCalculator#getElevationAdjustment(double)}. This is adjusted by the
|
|
@@ -157,7 +193,7 @@ class NOAACalculator {
|
|
|
157
193
|
* and 16 archminutes for the sun's radius for a total of {@link AstronomicalCalculator#adjustZenith 90.83333°}.
|
|
158
194
|
* See documentation for the specific implementation of the {@link AstronomicalCalculator} that you are using.
|
|
159
195
|
*
|
|
160
|
-
* @return the
|
|
196
|
+
* @return {Temporal.ZonedDateTime | null} the `Date` representing the exact sunrise time. If the calculation can't be computed such as
|
|
161
197
|
* in the Arctic Circle where there is at least one day a year where the sun does not rise, and one where it
|
|
162
198
|
* does not set, a null will be returned. See detailed explanation on top of the page.
|
|
163
199
|
* @see AstronomicalCalculator#adjustZenith
|
|
@@ -176,7 +212,7 @@ class NOAACalculator {
|
|
|
176
212
|
* something that is not affected by elevation. This method returns sunrise calculated at sea level. This forms the
|
|
177
213
|
* base for dawn calculations that are calculated as a dip below the horizon before sunrise.
|
|
178
214
|
*
|
|
179
|
-
* @return the
|
|
215
|
+
* @return {Temporal.ZonedDateTime | null} the `Date` representing the exact sea-level sunrise time. If the calculation can't be computed
|
|
180
216
|
* such as in the Arctic Circle where there is at least one day a year where the sun does not rise, and one
|
|
181
217
|
* where it does not set, a null will be returned. See detailed explanation on top of the page.
|
|
182
218
|
* @see AstronomicalCalendar#getSunrise
|
|
@@ -192,7 +228,7 @@ class NOAACalculator {
|
|
|
192
228
|
/**
|
|
193
229
|
* A method that returns the beginning of civil twilight (dawn) using a zenith of {@link #CIVIL_ZENITH 96°}.
|
|
194
230
|
*
|
|
195
|
-
* @return The
|
|
231
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the beginning of civil twilight using a zenith of 96°. If the calculation
|
|
196
232
|
* can't be computed, null will be returned. See detailed explanation on top of the page.
|
|
197
233
|
* @see #CIVIL_ZENITH
|
|
198
234
|
*/
|
|
@@ -202,7 +238,7 @@ class NOAACalculator {
|
|
|
202
238
|
/**
|
|
203
239
|
* A method that returns the beginning of nautical twilight using a zenith of {@link #NAUTICAL_ZENITH 102°}.
|
|
204
240
|
*
|
|
205
|
-
* @return The
|
|
241
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the beginning of nautical twilight using a zenith of 102°. If the
|
|
206
242
|
* calculation can't be computed null will be returned. See detailed explanation on top of the page.
|
|
207
243
|
* @see #NAUTICAL_ZENITH
|
|
208
244
|
*/
|
|
@@ -213,7 +249,7 @@ class NOAACalculator {
|
|
|
213
249
|
* A method that returns the beginning of astronomical twilight using a zenith of {@link #ASTRONOMICAL_ZENITH
|
|
214
250
|
* 108°}.
|
|
215
251
|
*
|
|
216
|
-
* @return The
|
|
252
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the beginning of astronomical twilight using a zenith of 108°. If the
|
|
217
253
|
* calculation can't be computed, null will be returned. See detailed explanation on top of the page.
|
|
218
254
|
* @see #ASTRONOMICAL_ZENITH
|
|
219
255
|
*/
|
|
@@ -221,7 +257,7 @@ class NOAACalculator {
|
|
|
221
257
|
return this.getSunriseOffsetByDegrees(NOAACalculator.ASTRONOMICAL_ZENITH);
|
|
222
258
|
}
|
|
223
259
|
/**
|
|
224
|
-
* The getSunset method Returns a
|
|
260
|
+
* The getSunset method Returns a `Date` representing the
|
|
225
261
|
* {@link AstronomicalCalculator#getElevationAdjustment(double) elevation adjusted} sunset time. The zenith used for
|
|
226
262
|
* the calculation uses {@link #GEOMETRIC_ZENITH geometric zenith} of 90° plus
|
|
227
263
|
* {@link AstronomicalCalculator#getElevationAdjustment(double)}. This is adjusted by the
|
|
@@ -232,7 +268,7 @@ class NOAACalculator {
|
|
|
232
268
|
* other than the local timezone is used (calculating Los Angeles sunset using a GMT timezone for example). In this
|
|
233
269
|
* case the sunset date will be incremented to the following date.
|
|
234
270
|
*
|
|
235
|
-
* @return
|
|
271
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` representing the exact sunset time. If the calculation can't be computed such as in
|
|
236
272
|
* the Arctic Circle where there is at least one day a year where the sun does not rise, and one where it
|
|
237
273
|
* does not set, a null will be returned. See detailed explanation on top of the page.
|
|
238
274
|
* @see AstronomicalCalculator#adjustZenith
|
|
@@ -251,7 +287,7 @@ class NOAACalculator {
|
|
|
251
287
|
* something that is not affected by elevation. This method returns sunset calculated at sea level. This forms the
|
|
252
288
|
* base for dusk calculations that are calculated as a dip below the horizon after sunset.
|
|
253
289
|
*
|
|
254
|
-
* @return
|
|
290
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` representing the exact sea-level sunset time. If the calculation can't be computed
|
|
255
291
|
* such as in the Arctic Circle where there is at least one day a year where the sun does not rise, and one
|
|
256
292
|
* where it does not set, a null will be returned. See detailed explanation on top of the page.
|
|
257
293
|
* @see AstronomicalCalendar#getSunset
|
|
@@ -266,7 +302,7 @@ class NOAACalculator {
|
|
|
266
302
|
/**
|
|
267
303
|
* A method that returns the end of civil twilight using a zenith of {@link #CIVIL_ZENITH 96°}.
|
|
268
304
|
*
|
|
269
|
-
* @return The
|
|
305
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the end of civil twilight using a zenith of {@link #CIVIL_ZENITH 96°}. If
|
|
270
306
|
* the calculation can't be computed, null will be returned. See detailed explanation on top of the page.
|
|
271
307
|
* @see #CIVIL_ZENITH
|
|
272
308
|
*/
|
|
@@ -276,7 +312,7 @@ class NOAACalculator {
|
|
|
276
312
|
/**
|
|
277
313
|
* A method that returns the end of nautical twilight using a zenith of {@link #NAUTICAL_ZENITH 102°}.
|
|
278
314
|
*
|
|
279
|
-
* @return The
|
|
315
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the end of nautical twilight using a zenith of {@link #NAUTICAL_ZENITH 102°}
|
|
280
316
|
* . If the calculation can't be computed, null will be returned. See detailed explanation on top of the
|
|
281
317
|
* page.
|
|
282
318
|
* @see #NAUTICAL_ZENITH
|
|
@@ -287,7 +323,7 @@ class NOAACalculator {
|
|
|
287
323
|
/**
|
|
288
324
|
* A method that returns the end of astronomical twilight using a zenith of {@link #ASTRONOMICAL_ZENITH 108°}.
|
|
289
325
|
*
|
|
290
|
-
* @return
|
|
326
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the end of astronomical twilight using a zenith of {@link #ASTRONOMICAL_ZENITH
|
|
291
327
|
* 108°}. If the calculation can't be computed, null will be returned. See detailed explanation on top
|
|
292
328
|
* of the page.
|
|
293
329
|
* @see #ASTRONOMICAL_ZENITH
|
|
@@ -301,11 +337,11 @@ class NOAACalculator {
|
|
|
301
337
|
* after sunset with the intent of getting a rough "level of light" calculation, the sunrise or sunset time passed
|
|
302
338
|
* to this method should be sea level sunrise and sunset.
|
|
303
339
|
*
|
|
304
|
-
* @param time
|
|
340
|
+
* @param {Temporal.ZonedDateTime | null} time
|
|
305
341
|
* the start time
|
|
306
|
-
* @param offset
|
|
342
|
+
* @param {number} offset
|
|
307
343
|
* the offset in milliseconds to add to the time.
|
|
308
|
-
* @return
|
|
344
|
+
* @return {Temporal.ZonedDateTime | null} the `Date` with the offset in milliseconds added to it
|
|
309
345
|
*/
|
|
310
346
|
static getTimeOffset(time, offset) {
|
|
311
347
|
if (time === null || offset === Long_MIN_VALUE || Number.isNaN(offset)) {
|
|
@@ -318,12 +354,12 @@ class NOAACalculator {
|
|
|
318
354
|
* {@link #getSunrise() sunrise}. Note that the degree offset is from the vertical, so for a calculation of 14°
|
|
319
355
|
* before sunrise, an offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a parameter.
|
|
320
356
|
*
|
|
321
|
-
* @param offsetZenith
|
|
357
|
+
* @param {number} offsetZenith
|
|
322
358
|
* the degrees before {@link #getSunrise()} to use in the calculation. For time after sunrise use
|
|
323
359
|
* negative numbers. Note that the degree offset is from the vertical, so for a calculation of 14°
|
|
324
360
|
* before sunrise, an offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a
|
|
325
361
|
* parameter.
|
|
326
|
-
* @return
|
|
362
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the offset after (or before) {@link #getSunrise()}. If the calculation
|
|
327
363
|
* can't be computed such as in the Arctic Circle where there is at least one day a year where the sun does
|
|
328
364
|
* not rise, and one where it does not set, a null will be returned. See detailed explanation on top of the
|
|
329
365
|
* page.
|
|
@@ -339,11 +375,11 @@ class NOAACalculator {
|
|
|
339
375
|
* sunset}. Note that the degree offset is from the vertical, so for a calculation of 14° after sunset, an
|
|
340
376
|
* offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a parameter.
|
|
341
377
|
*
|
|
342
|
-
* @param offsetZenith
|
|
378
|
+
* @param {number} offsetZenith
|
|
343
379
|
* the degrees after {@link #getSunset()} to use in the calculation. For time before sunset use negative
|
|
344
380
|
* numbers. Note that the degree offset is from the vertical, so for a calculation of 14° after
|
|
345
381
|
* sunset, an offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a parameter.
|
|
346
|
-
* @return The
|
|
382
|
+
* @return {Temporal.ZonedDateTime | null} The `Date`of the offset after (or before) {@link #getSunset()}. If the calculation can't
|
|
347
383
|
* be computed such as in the Arctic Circle where there is at least one day a year where the sun does not
|
|
348
384
|
* rise, and one where it does not set, a null will be returned. See detailed explanation on top of the
|
|
349
385
|
* page.
|
|
@@ -354,27 +390,13 @@ class NOAACalculator {
|
|
|
354
390
|
return null;
|
|
355
391
|
return this.getDateFromTime(sunset, false);
|
|
356
392
|
}
|
|
357
|
-
/**
|
|
358
|
-
* A constructor that takes in <a href="http://en.wikipedia.org/wiki/Geolocation">geolocation</a> information as a
|
|
359
|
-
* parameter. The default {@link AstronomicalCalculator#getDefault() AstronomicalCalculator} used for solar
|
|
360
|
-
* calculations is the the {@link NOAACalculator}.
|
|
361
|
-
*
|
|
362
|
-
* @param geoLocation
|
|
363
|
-
* The location information used for calculating astronomical sun times.
|
|
364
|
-
*
|
|
365
|
-
* @see #setAstronomicalCalculator(AstronomicalCalculator) for changing the calculator class.
|
|
366
|
-
*/
|
|
367
|
-
constructor(geoLocation, date) {
|
|
368
|
-
this.date = date;
|
|
369
|
-
this.geoLocation = geoLocation;
|
|
370
|
-
}
|
|
371
393
|
/**
|
|
372
394
|
* A method that returns the sunrise in UTC time without correction for time zone offset from GMT and without using
|
|
373
395
|
* daylight savings time.
|
|
374
396
|
*
|
|
375
|
-
* @param zenith
|
|
397
|
+
* @param {number} zenith
|
|
376
398
|
* the degrees below the horizon. For time after sunrise use negative numbers.
|
|
377
|
-
* @return The time in the format: 18.75 for 18:45:00 UTC/GMT. If the calculation can't be computed such as in the
|
|
399
|
+
* @return {number} The time in the format: 18.75 for 18:45:00 UTC/GMT. If the calculation can't be computed such as in the
|
|
378
400
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
379
401
|
* not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
|
|
380
402
|
*/
|
|
@@ -387,9 +409,9 @@ class NOAACalculator {
|
|
|
387
409
|
* light, something that is not affected by elevation. This method returns UTC sunrise calculated at sea level. This
|
|
388
410
|
* forms the base for dawn calculations that are calculated as a dip below the horizon before sunrise.
|
|
389
411
|
*
|
|
390
|
-
* @param zenith
|
|
412
|
+
* @param {number} zenith
|
|
391
413
|
* the degrees below the horizon. For time after sunrise use negative numbers.
|
|
392
|
-
* @return The time in the format: 18.75 for 18:45:00 UTC/GMT. If the calculation can't be computed such as in the
|
|
414
|
+
* @return {number} The time in the format: 18.75 for 18:45:00 UTC/GMT. If the calculation can't be computed such as in the
|
|
393
415
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
394
416
|
* not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
|
|
395
417
|
* @see AstronomicalCalendar#getUTCSunrise
|
|
@@ -402,9 +424,9 @@ class NOAACalculator {
|
|
|
402
424
|
* A method that returns the sunset in UTC time without correction for time zone offset from GMT and without using
|
|
403
425
|
* daylight savings time.
|
|
404
426
|
*
|
|
405
|
-
* @param zenith
|
|
427
|
+
* @param {number} zenith
|
|
406
428
|
* the degrees below the horizon. For time after sunset use negative numbers.
|
|
407
|
-
* @return The time in the format: 18.75 for 18:45:00 UTC/GMT. If the calculation can't be computed such as in the
|
|
429
|
+
* @return {number} The time in the format: 18.75 for 18:45:00 UTC/GMT. If the calculation can't be computed such as in the
|
|
408
430
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
409
431
|
* not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
|
|
410
432
|
* @see AstronomicalCalendar#getUTCSeaLevelSunset
|
|
@@ -419,9 +441,9 @@ class NOAACalculator {
|
|
|
419
441
|
* at sea level. This forms the base for dusk calculations that are calculated as a dip below the horizon after
|
|
420
442
|
* sunset.
|
|
421
443
|
*
|
|
422
|
-
* @param zenith
|
|
444
|
+
* @param {number} zenith
|
|
423
445
|
* the degrees below the horizon. For time before sunset use negative numbers.
|
|
424
|
-
* @return The time in the format: 18.75 for 18:45:00 UTC/GMT. If the calculation can't be computed such as in the
|
|
446
|
+
* @return {number} The time in the format: 18.75 for 18:45:00 UTC/GMT. If the calculation can't be computed such as in the
|
|
425
447
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
426
448
|
* not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
|
|
427
449
|
* @see AstronomicalCalendar#getUTCSunset
|
|
@@ -460,9 +482,9 @@ class NOAACalculator {
|
|
|
460
482
|
* elevationAdjustment = 0.0347 * Math.sqrt(elevationMeters);
|
|
461
483
|
* </pre>
|
|
462
484
|
*
|
|
463
|
-
* @param elevation
|
|
485
|
+
* @param {number} elevation
|
|
464
486
|
* elevation in Meters.
|
|
465
|
-
* @return the adjusted zenith
|
|
487
|
+
* @return {number} the adjusted zenith
|
|
466
488
|
*/
|
|
467
489
|
getElevationAdjustment(elevation) {
|
|
468
490
|
// double elevationAdjustment = 0.0347 * Math.sqrt(elevation);
|
|
@@ -489,15 +511,15 @@ class NOAACalculator {
|
|
|
489
511
|
* {@link ZmanimCalendar#ZENITH_16_POINT_1 16.1°} dip used in
|
|
490
512
|
* {@link ComplexZmanimCalendar#getAlos16Point1Degrees()}.
|
|
491
513
|
*
|
|
492
|
-
* @param zenith
|
|
514
|
+
* @param {number} zenith
|
|
493
515
|
* the azimuth below the vertical zenith of 90°. For sunset typically the {@link #adjustZenith
|
|
494
516
|
* zenith} used for the calculation uses geometric zenith of 90° and {@link #adjustZenith adjusts}
|
|
495
517
|
* this slightly to account for solar refraction and the sun's radius. Another example would be
|
|
496
518
|
* {@link AstronomicalCalendar#getEndNauticalTwilight()} that passes
|
|
497
519
|
* {@link AstronomicalCalendar#NAUTICAL_ZENITH} to this method.
|
|
498
|
-
* @param elevation
|
|
520
|
+
* @param {number} elevation
|
|
499
521
|
* elevation in Meters.
|
|
500
|
-
* @return The zenith adjusted to include the {@link #getSolarRadius sun's radius}, {@link #getRefraction
|
|
522
|
+
* @return {number} The zenith adjusted to include the {@link #getSolarRadius sun's radius}, {@link #getRefraction
|
|
501
523
|
* refraction} and {@link #getElevationAdjustment elevation} adjustment. This will only be adjusted for
|
|
502
524
|
* sunrise and sunset (if the zenith == 90°)
|
|
503
525
|
* @see #getElevationAdjustment(double)
|
|
@@ -556,21 +578,21 @@ class NOAACalculator {
|
|
|
556
578
|
* non-elevation adjusted temporal hour by passing in {@link #getSeaLevelSunrise() sea level sunrise} and
|
|
557
579
|
* {@link #getSeaLevelSunset() sea level sunset} as parameters.
|
|
558
580
|
*
|
|
559
|
-
* @param
|
|
581
|
+
* @param {Temporal.ZonedDateTime | null} startOfDay
|
|
560
582
|
* The start of the day.
|
|
561
|
-
* @param endOfDay
|
|
583
|
+
* @param {Temporal.ZonedDateTime | null} endOfDay
|
|
562
584
|
* The end of the day.
|
|
563
585
|
*
|
|
564
|
-
* @return the <code>long</code> millisecond length of the temporal hour. If the calculation can't be computed a
|
|
586
|
+
* @return {number} the <code>long</code> millisecond length of the temporal hour. If the calculation can't be computed a
|
|
565
587
|
* {@link Long#MIN_VALUE} will be returned. See detailed explanation on top of the page.
|
|
566
588
|
*
|
|
567
589
|
* @see #getTemporalHour()
|
|
568
590
|
*/
|
|
569
|
-
getTemporalHour(
|
|
570
|
-
if (
|
|
591
|
+
getTemporalHour(startOfDay = this.getSeaLevelSunrise(), endOfDay = this.getSeaLevelSunset()) {
|
|
592
|
+
if (startOfDay === null || endOfDay === null) {
|
|
571
593
|
return Long_MIN_VALUE;
|
|
572
594
|
}
|
|
573
|
-
const delta = endOfDay.epochMilliseconds -
|
|
595
|
+
const delta = endOfDay.epochMilliseconds - startOfDay.epochMilliseconds;
|
|
574
596
|
return Math.floor(delta / 12);
|
|
575
597
|
}
|
|
576
598
|
/**
|
|
@@ -580,14 +602,14 @@ class NOAACalculator {
|
|
|
580
602
|
* calculated as halfway between the sunrise and sunset passed to this method. This time can be slightly off the
|
|
581
603
|
* real transit time due to changes in declination (the lengthening or shortening day).
|
|
582
604
|
*
|
|
583
|
-
* @param startOfDay
|
|
605
|
+
* @param {Temporal.ZonedDateTime | null} startOfDay
|
|
584
606
|
* the start of day for calculating the sun's transit. This can be sea level sunrise, visual sunrise (or
|
|
585
607
|
* any arbitrary start of day) passed to this method.
|
|
586
|
-
* @param endOfDay
|
|
608
|
+
* @param {Temporal.ZonedDateTime | null} endOfDay
|
|
587
609
|
* the end of day for calculating the sun's transit. This can be sea level sunset, visual sunset (or any
|
|
588
610
|
* arbitrary end of day) passed to this method.
|
|
589
611
|
*
|
|
590
|
-
* @return
|
|
612
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` representing Sun's transit. If the calculation can't be computed such as in the
|
|
591
613
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
592
614
|
* not set, null will be returned. See detailed explanation on top of the page.
|
|
593
615
|
*/
|
|
@@ -596,13 +618,13 @@ class NOAACalculator {
|
|
|
596
618
|
return NOAACalculator.getTimeOffset(startOfDay, temporalHour * 6);
|
|
597
619
|
}
|
|
598
620
|
/**
|
|
599
|
-
* A method that returns a
|
|
621
|
+
* A method that returns a `Date` from the time passed in as a parameter.
|
|
600
622
|
* @protected
|
|
601
|
-
* @param time
|
|
602
|
-
* The time to be set as the time for the
|
|
623
|
+
* @param {number} time
|
|
624
|
+
* The time to be set as the time for the `Date`. The time expected is in the format: 18.75
|
|
603
625
|
* for 6:45:00 PM.
|
|
604
|
-
* @param isSunrise true if the time is sunrise, and false if it is sunset
|
|
605
|
-
* @return The Date.
|
|
626
|
+
* @param {boolean} isSunrise true if the time is sunrise, and false if it is sunset
|
|
627
|
+
* @return {Temporal.ZonedDateTime | null} The Date.
|
|
606
628
|
*/
|
|
607
629
|
getDateFromTime(time, isSunrise) {
|
|
608
630
|
if (Number.isNaN(time)) {
|
|
@@ -637,7 +659,7 @@ class NOAACalculator {
|
|
|
637
659
|
/**
|
|
638
660
|
* Return the <a href="http://en.wikipedia.org/wiki/Julian_day">Julian day</a> from a Java Calendar
|
|
639
661
|
* @private
|
|
640
|
-
* @param
|
|
662
|
+
* @param {Temporal.ZonedDateTime} date
|
|
641
663
|
* The Java Calendar
|
|
642
664
|
* @return the Julian day corresponding to the date Note: Number is returned for start of day. Fractional days
|
|
643
665
|
* should be added later.
|
|
@@ -833,11 +855,11 @@ class NOAACalculator {
|
|
|
833
855
|
* Return the <a href="http://en.wikipedia.org/wiki/Hour_angle">hour angle</a> of the sun at sunrise for the
|
|
834
856
|
* latitude.
|
|
835
857
|
* @private
|
|
836
|
-
* @param lat
|
|
858
|
+
* @param {number} lat
|
|
837
859
|
* , the latitude of observer in degrees
|
|
838
860
|
* @param solarDec
|
|
839
861
|
* the declination angle of sun in degrees
|
|
840
|
-
* @param zenith
|
|
862
|
+
* @param {number} zenith
|
|
841
863
|
* the zenith
|
|
842
864
|
* @return hour angle of sunrise in radians
|
|
843
865
|
*/
|
|
@@ -853,11 +875,11 @@ class NOAACalculator {
|
|
|
853
875
|
* latitude. TODO: use - {@link #getSunHourAngleAtSunrise(double, double, double)} implementation to avoid
|
|
854
876
|
* duplication of code.
|
|
855
877
|
* @private
|
|
856
|
-
* @param lat
|
|
878
|
+
* @param {number} lat
|
|
857
879
|
* the latitude of observer in degrees
|
|
858
880
|
* @param solarDec
|
|
859
881
|
* the declination angle of sun in degrees
|
|
860
|
-
* @param zenith
|
|
882
|
+
* @param {number} zenith
|
|
861
883
|
* the zenith
|
|
862
884
|
* @return the hour angle of sunset in radians
|
|
863
885
|
*/
|
|
@@ -874,13 +896,13 @@ class NOAACalculator {
|
|
|
874
896
|
* horizontal coordinate system at the given location at the given time. Can be negative if the sun is below the
|
|
875
897
|
* horizon. Not corrected for altitude.
|
|
876
898
|
*
|
|
877
|
-
* @param
|
|
899
|
+
* @param {Temporal.ZonedDateTime} date
|
|
878
900
|
* time of calculation
|
|
879
|
-
* @param lat
|
|
901
|
+
* @param {number} lat
|
|
880
902
|
* latitude of location for calculation
|
|
881
|
-
* @param lon
|
|
903
|
+
* @param {number} lon
|
|
882
904
|
* longitude of location for calculation
|
|
883
|
-
* @return solar elevation in degrees - horizon is 0 degrees, civil twilight is -6 degrees
|
|
905
|
+
* @return {number} solar elevation in degrees - horizon is 0 degrees, civil twilight is -6 degrees
|
|
884
906
|
*/
|
|
885
907
|
static getSolarElevation(date, lat, lon) {
|
|
886
908
|
const julianDay = NOAACalculator.getJulianDay(date.toPlainDate());
|
|
@@ -900,13 +922,13 @@ class NOAACalculator {
|
|
|
900
922
|
* horizontal coordinate system at the given location at the given time. Not corrected for altitude. True south is 0
|
|
901
923
|
* degrees.
|
|
902
924
|
*
|
|
903
|
-
* @param
|
|
925
|
+
* @param {Temporal.ZonedDateTime} date
|
|
904
926
|
* time of calculation
|
|
905
|
-
* @param latitude
|
|
927
|
+
* @param {number} latitude
|
|
906
928
|
* latitude of location for calculation
|
|
907
|
-
* @param lon
|
|
929
|
+
* @param {number} lon
|
|
908
930
|
* longitude of location for calculation
|
|
909
|
-
* @return
|
|
931
|
+
* @return {number}
|
|
910
932
|
*/
|
|
911
933
|
static getSolarAzimuth(date, latitude, lon) {
|
|
912
934
|
const julianDay = NOAACalculator.getJulianDay(date.toPlainDate());
|
|
@@ -928,11 +950,11 @@ class NOAACalculator {
|
|
|
928
950
|
* @private
|
|
929
951
|
* @param julianDay
|
|
930
952
|
* the Julian day
|
|
931
|
-
* @param latitude
|
|
953
|
+
* @param {number} latitude
|
|
932
954
|
* the latitude of observer in degrees
|
|
933
|
-
* @param longitude
|
|
955
|
+
* @param {number} longitude
|
|
934
956
|
* the longitude of observer in degrees
|
|
935
|
-
* @param zenith
|
|
957
|
+
* @param {number} zenith
|
|
936
958
|
* the zenith
|
|
937
959
|
* @return the time in minutes from zero UTC
|
|
938
960
|
*/
|
|
@@ -967,7 +989,7 @@ class NOAACalculator {
|
|
|
967
989
|
* @private
|
|
968
990
|
* @param julianCenturies
|
|
969
991
|
* the number of Julian centuries since J2000.0
|
|
970
|
-
* @param longitude
|
|
992
|
+
* @param {number} longitude
|
|
971
993
|
* the longitude of observer in degrees
|
|
972
994
|
* @return the time in minutes from zero UTC
|
|
973
995
|
*/
|
|
@@ -989,11 +1011,11 @@ class NOAACalculator {
|
|
|
989
1011
|
* @private
|
|
990
1012
|
* @param julianDay
|
|
991
1013
|
* the Julian day
|
|
992
|
-
* @param latitude
|
|
1014
|
+
* @param {number} latitude
|
|
993
1015
|
* the latitude of observer in degrees
|
|
994
|
-
* @param longitude
|
|
1016
|
+
* @param {number} longitude
|
|
995
1017
|
* : longitude of observer in degrees
|
|
996
|
-
* @param zenith
|
|
1018
|
+
* @param {number} zenith
|
|
997
1019
|
* the zenith
|
|
998
1020
|
* @return the time in minutes from zero Universal Coordinated Time (UTC)
|
|
999
1021
|
*/
|