@hebcal/noaa 0.8.4 → 0.8.6
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 +133 -101
- package/dist/esm/index.js +133 -101
- package/dist/index.d.ts +109 -104
- 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
|
-
*
|
|
33
|
+
* GeoLocation constructor with parameters for all required fields.
|
|
32
34
|
*
|
|
33
|
-
* @
|
|
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.
|
|
34
49
|
*/
|
|
35
|
-
|
|
36
|
-
return this.elevation;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Method to set the elevation in Meters <b>above </b> sea level.
|
|
40
|
-
*
|
|
41
|
-
* @param elevation
|
|
42
|
-
* The elevation to set in Meters. An IllegalArgumentException will be thrown if the value is a negative.
|
|
43
|
-
*/
|
|
44
|
-
setElevation(elevation) {
|
|
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,39 +67,66 @@ 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) {
|
|
88
|
+
if (typeof latitude !== 'number')
|
|
89
|
+
throw new TypeError('Invalid latitude');
|
|
90
|
+
if (latitude < -90 || latitude > 90) {
|
|
91
|
+
throw new RangeError(`Latitude ${latitude} out of range [-90,90]`);
|
|
92
|
+
}
|
|
67
93
|
this.latitude = latitude;
|
|
68
94
|
}
|
|
69
95
|
/**
|
|
70
|
-
* @return Returns the latitude.
|
|
96
|
+
* @return {number} Returns the latitude.
|
|
71
97
|
*/
|
|
72
98
|
getLatitude() {
|
|
73
99
|
return this.latitude;
|
|
74
100
|
}
|
|
75
101
|
setLongitude(longitude) {
|
|
102
|
+
if (typeof longitude !== 'number')
|
|
103
|
+
throw new TypeError('Invalid longitude');
|
|
104
|
+
if (longitude < -180 || longitude > 180) {
|
|
105
|
+
throw new RangeError(`Longitude ${longitude} out of range [-180,180]`);
|
|
106
|
+
}
|
|
76
107
|
this.longitude = longitude;
|
|
77
108
|
}
|
|
78
109
|
/**
|
|
79
|
-
* @return Returns the longitude.
|
|
110
|
+
* @return {number} Returns the longitude.
|
|
80
111
|
*/
|
|
81
112
|
getLongitude() {
|
|
82
113
|
return this.longitude;
|
|
83
114
|
}
|
|
84
115
|
/**
|
|
85
|
-
* @return Returns the location name.
|
|
116
|
+
* @return {string|null} Returns the location name.
|
|
86
117
|
*/
|
|
87
118
|
getLocationName() {
|
|
88
119
|
return this.locationName;
|
|
89
120
|
}
|
|
90
121
|
/**
|
|
91
|
-
* @param name
|
|
122
|
+
* @param {string|null} name
|
|
92
123
|
* The setter method for the display name.
|
|
93
124
|
*/
|
|
94
125
|
setLocationName(name) {
|
|
95
126
|
this.locationName = name;
|
|
96
127
|
}
|
|
97
128
|
/**
|
|
98
|
-
* @return Returns the timeZone.
|
|
129
|
+
* @return {string} Returns the timeZone.
|
|
99
130
|
*/
|
|
100
131
|
getTimeZone() {
|
|
101
132
|
return this.timeZoneId;
|
|
@@ -108,7 +139,7 @@ class GeoLocation {
|
|
|
108
139
|
* AstronomicalCalendar to output times in the expected offset. This situation will arise if the
|
|
109
140
|
* AstronomicalCalendar is ever {@link AstronomicalCalendar#clone() cloned}.
|
|
110
141
|
*
|
|
111
|
-
* @param timeZone
|
|
142
|
+
* @param {string} timeZone
|
|
112
143
|
* The timeZone to set.
|
|
113
144
|
*/
|
|
114
145
|
setTimeZone(timeZoneId) {
|
|
@@ -149,7 +180,22 @@ const earthRadius = 6356.9; // in KM
|
|
|
149
180
|
*/
|
|
150
181
|
class NOAACalculator {
|
|
151
182
|
/**
|
|
152
|
-
*
|
|
183
|
+
* A constructor that takes in <a href="http://en.wikipedia.org/wiki/Geolocation">geolocation</a> information as a
|
|
184
|
+
* parameter. The default {@link AstronomicalCalculator#getDefault() AstronomicalCalculator} used for solar
|
|
185
|
+
* calculations is the the {@link NOAACalculator}.
|
|
186
|
+
*
|
|
187
|
+
* @param {GeoLocation} geoLocation
|
|
188
|
+
* The location information used for calculating astronomical sun times.
|
|
189
|
+
* @param {Temporal.PlainDate} date
|
|
190
|
+
*
|
|
191
|
+
* @see #setAstronomicalCalculator(AstronomicalCalculator) for changing the calculator class.
|
|
192
|
+
*/
|
|
193
|
+
constructor(geoLocation, date) {
|
|
194
|
+
this.date = date;
|
|
195
|
+
this.geoLocation = geoLocation;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* The getSunrise method Returns a `Date` representing the
|
|
153
199
|
* {@link AstronomicalCalculator#getElevationAdjustment(double) elevation adjusted} sunrise time. The zenith used
|
|
154
200
|
* for the calculation uses {@link #GEOMETRIC_ZENITH geometric zenith} of 90° plus
|
|
155
201
|
* {@link AstronomicalCalculator#getElevationAdjustment(double)}. This is adjusted by the
|
|
@@ -157,7 +203,7 @@ class NOAACalculator {
|
|
|
157
203
|
* and 16 archminutes for the sun's radius for a total of {@link AstronomicalCalculator#adjustZenith 90.83333°}.
|
|
158
204
|
* See documentation for the specific implementation of the {@link AstronomicalCalculator} that you are using.
|
|
159
205
|
*
|
|
160
|
-
* @return the
|
|
206
|
+
* @return {Temporal.ZonedDateTime | null} the `Date` representing the exact sunrise time. If the calculation can't be computed such as
|
|
161
207
|
* in the Arctic Circle where there is at least one day a year where the sun does not rise, and one where it
|
|
162
208
|
* does not set, a null will be returned. See detailed explanation on top of the page.
|
|
163
209
|
* @see AstronomicalCalculator#adjustZenith
|
|
@@ -176,7 +222,7 @@ class NOAACalculator {
|
|
|
176
222
|
* something that is not affected by elevation. This method returns sunrise calculated at sea level. This forms the
|
|
177
223
|
* base for dawn calculations that are calculated as a dip below the horizon before sunrise.
|
|
178
224
|
*
|
|
179
|
-
* @return the
|
|
225
|
+
* @return {Temporal.ZonedDateTime | null} the `Date` representing the exact sea-level sunrise time. If the calculation can't be computed
|
|
180
226
|
* such as in the Arctic Circle where there is at least one day a year where the sun does not rise, and one
|
|
181
227
|
* where it does not set, a null will be returned. See detailed explanation on top of the page.
|
|
182
228
|
* @see AstronomicalCalendar#getSunrise
|
|
@@ -192,7 +238,7 @@ class NOAACalculator {
|
|
|
192
238
|
/**
|
|
193
239
|
* A method that returns the beginning of civil twilight (dawn) using a zenith of {@link #CIVIL_ZENITH 96°}.
|
|
194
240
|
*
|
|
195
|
-
* @return The
|
|
241
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the beginning of civil twilight using a zenith of 96°. If the calculation
|
|
196
242
|
* can't be computed, null will be returned. See detailed explanation on top of the page.
|
|
197
243
|
* @see #CIVIL_ZENITH
|
|
198
244
|
*/
|
|
@@ -202,7 +248,7 @@ class NOAACalculator {
|
|
|
202
248
|
/**
|
|
203
249
|
* A method that returns the beginning of nautical twilight using a zenith of {@link #NAUTICAL_ZENITH 102°}.
|
|
204
250
|
*
|
|
205
|
-
* @return The
|
|
251
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the beginning of nautical twilight using a zenith of 102°. If the
|
|
206
252
|
* calculation can't be computed null will be returned. See detailed explanation on top of the page.
|
|
207
253
|
* @see #NAUTICAL_ZENITH
|
|
208
254
|
*/
|
|
@@ -213,7 +259,7 @@ class NOAACalculator {
|
|
|
213
259
|
* A method that returns the beginning of astronomical twilight using a zenith of {@link #ASTRONOMICAL_ZENITH
|
|
214
260
|
* 108°}.
|
|
215
261
|
*
|
|
216
|
-
* @return The
|
|
262
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the beginning of astronomical twilight using a zenith of 108°. If the
|
|
217
263
|
* calculation can't be computed, null will be returned. See detailed explanation on top of the page.
|
|
218
264
|
* @see #ASTRONOMICAL_ZENITH
|
|
219
265
|
*/
|
|
@@ -221,7 +267,7 @@ class NOAACalculator {
|
|
|
221
267
|
return this.getSunriseOffsetByDegrees(NOAACalculator.ASTRONOMICAL_ZENITH);
|
|
222
268
|
}
|
|
223
269
|
/**
|
|
224
|
-
* The getSunset method Returns a
|
|
270
|
+
* The getSunset method Returns a `Date` representing the
|
|
225
271
|
* {@link AstronomicalCalculator#getElevationAdjustment(double) elevation adjusted} sunset time. The zenith used for
|
|
226
272
|
* the calculation uses {@link #GEOMETRIC_ZENITH geometric zenith} of 90° plus
|
|
227
273
|
* {@link AstronomicalCalculator#getElevationAdjustment(double)}. This is adjusted by the
|
|
@@ -232,7 +278,7 @@ class NOAACalculator {
|
|
|
232
278
|
* other than the local timezone is used (calculating Los Angeles sunset using a GMT timezone for example). In this
|
|
233
279
|
* case the sunset date will be incremented to the following date.
|
|
234
280
|
*
|
|
235
|
-
* @return
|
|
281
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` representing the exact sunset time. If the calculation can't be computed such as in
|
|
236
282
|
* the Arctic Circle where there is at least one day a year where the sun does not rise, and one where it
|
|
237
283
|
* does not set, a null will be returned. See detailed explanation on top of the page.
|
|
238
284
|
* @see AstronomicalCalculator#adjustZenith
|
|
@@ -251,7 +297,7 @@ class NOAACalculator {
|
|
|
251
297
|
* something that is not affected by elevation. This method returns sunset calculated at sea level. This forms the
|
|
252
298
|
* base for dusk calculations that are calculated as a dip below the horizon after sunset.
|
|
253
299
|
*
|
|
254
|
-
* @return
|
|
300
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` representing the exact sea-level sunset time. If the calculation can't be computed
|
|
255
301
|
* such as in the Arctic Circle where there is at least one day a year where the sun does not rise, and one
|
|
256
302
|
* where it does not set, a null will be returned. See detailed explanation on top of the page.
|
|
257
303
|
* @see AstronomicalCalendar#getSunset
|
|
@@ -266,7 +312,7 @@ class NOAACalculator {
|
|
|
266
312
|
/**
|
|
267
313
|
* A method that returns the end of civil twilight using a zenith of {@link #CIVIL_ZENITH 96°}.
|
|
268
314
|
*
|
|
269
|
-
* @return The
|
|
315
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the end of civil twilight using a zenith of {@link #CIVIL_ZENITH 96°}. If
|
|
270
316
|
* the calculation can't be computed, null will be returned. See detailed explanation on top of the page.
|
|
271
317
|
* @see #CIVIL_ZENITH
|
|
272
318
|
*/
|
|
@@ -276,7 +322,7 @@ class NOAACalculator {
|
|
|
276
322
|
/**
|
|
277
323
|
* A method that returns the end of nautical twilight using a zenith of {@link #NAUTICAL_ZENITH 102°}.
|
|
278
324
|
*
|
|
279
|
-
* @return The
|
|
325
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the end of nautical twilight using a zenith of {@link #NAUTICAL_ZENITH 102°}
|
|
280
326
|
* . If the calculation can't be computed, null will be returned. See detailed explanation on top of the
|
|
281
327
|
* page.
|
|
282
328
|
* @see #NAUTICAL_ZENITH
|
|
@@ -287,7 +333,7 @@ class NOAACalculator {
|
|
|
287
333
|
/**
|
|
288
334
|
* A method that returns the end of astronomical twilight using a zenith of {@link #ASTRONOMICAL_ZENITH 108°}.
|
|
289
335
|
*
|
|
290
|
-
* @return
|
|
336
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the end of astronomical twilight using a zenith of {@link #ASTRONOMICAL_ZENITH
|
|
291
337
|
* 108°}. If the calculation can't be computed, null will be returned. See detailed explanation on top
|
|
292
338
|
* of the page.
|
|
293
339
|
* @see #ASTRONOMICAL_ZENITH
|
|
@@ -301,11 +347,11 @@ class NOAACalculator {
|
|
|
301
347
|
* after sunset with the intent of getting a rough "level of light" calculation, the sunrise or sunset time passed
|
|
302
348
|
* to this method should be sea level sunrise and sunset.
|
|
303
349
|
*
|
|
304
|
-
* @param time
|
|
350
|
+
* @param {Temporal.ZonedDateTime | null} time
|
|
305
351
|
* the start time
|
|
306
|
-
* @param offset
|
|
352
|
+
* @param {number} offset
|
|
307
353
|
* the offset in milliseconds to add to the time.
|
|
308
|
-
* @return
|
|
354
|
+
* @return {Temporal.ZonedDateTime | null} the `Date` with the offset in milliseconds added to it
|
|
309
355
|
*/
|
|
310
356
|
static getTimeOffset(time, offset) {
|
|
311
357
|
if (time === null || offset === Long_MIN_VALUE || Number.isNaN(offset)) {
|
|
@@ -318,12 +364,12 @@ class NOAACalculator {
|
|
|
318
364
|
* {@link #getSunrise() sunrise}. Note that the degree offset is from the vertical, so for a calculation of 14°
|
|
319
365
|
* before sunrise, an offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a parameter.
|
|
320
366
|
*
|
|
321
|
-
* @param offsetZenith
|
|
367
|
+
* @param {number} offsetZenith
|
|
322
368
|
* the degrees before {@link #getSunrise()} to use in the calculation. For time after sunrise use
|
|
323
369
|
* negative numbers. Note that the degree offset is from the vertical, so for a calculation of 14°
|
|
324
370
|
* before sunrise, an offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a
|
|
325
371
|
* parameter.
|
|
326
|
-
* @return
|
|
372
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the offset after (or before) {@link #getSunrise()}. If the calculation
|
|
327
373
|
* can't be computed such as in the Arctic Circle where there is at least one day a year where the sun does
|
|
328
374
|
* not rise, and one where it does not set, a null will be returned. See detailed explanation on top of the
|
|
329
375
|
* page.
|
|
@@ -339,11 +385,11 @@ class NOAACalculator {
|
|
|
339
385
|
* sunset}. Note that the degree offset is from the vertical, so for a calculation of 14° after sunset, an
|
|
340
386
|
* offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a parameter.
|
|
341
387
|
*
|
|
342
|
-
* @param offsetZenith
|
|
388
|
+
* @param {number} offsetZenith
|
|
343
389
|
* the degrees after {@link #getSunset()} to use in the calculation. For time before sunset use negative
|
|
344
390
|
* numbers. Note that the degree offset is from the vertical, so for a calculation of 14° after
|
|
345
391
|
* sunset, an offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a parameter.
|
|
346
|
-
* @return The
|
|
392
|
+
* @return {Temporal.ZonedDateTime | null} The `Date`of the offset after (or before) {@link #getSunset()}. If the calculation can't
|
|
347
393
|
* be computed such as in the Arctic Circle where there is at least one day a year where the sun does not
|
|
348
394
|
* rise, and one where it does not set, a null will be returned. See detailed explanation on top of the
|
|
349
395
|
* page.
|
|
@@ -354,27 +400,13 @@ class NOAACalculator {
|
|
|
354
400
|
return null;
|
|
355
401
|
return this.getDateFromTime(sunset, false);
|
|
356
402
|
}
|
|
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
403
|
/**
|
|
372
404
|
* A method that returns the sunrise in UTC time without correction for time zone offset from GMT and without using
|
|
373
405
|
* daylight savings time.
|
|
374
406
|
*
|
|
375
|
-
* @param zenith
|
|
407
|
+
* @param {number} zenith
|
|
376
408
|
* 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
|
|
409
|
+
* @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
410
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
379
411
|
* not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
|
|
380
412
|
*/
|
|
@@ -387,9 +419,9 @@ class NOAACalculator {
|
|
|
387
419
|
* light, something that is not affected by elevation. This method returns UTC sunrise calculated at sea level. This
|
|
388
420
|
* forms the base for dawn calculations that are calculated as a dip below the horizon before sunrise.
|
|
389
421
|
*
|
|
390
|
-
* @param zenith
|
|
422
|
+
* @param {number} zenith
|
|
391
423
|
* 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
|
|
424
|
+
* @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
425
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
394
426
|
* not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
|
|
395
427
|
* @see AstronomicalCalendar#getUTCSunrise
|
|
@@ -402,9 +434,9 @@ class NOAACalculator {
|
|
|
402
434
|
* A method that returns the sunset in UTC time without correction for time zone offset from GMT and without using
|
|
403
435
|
* daylight savings time.
|
|
404
436
|
*
|
|
405
|
-
* @param zenith
|
|
437
|
+
* @param {number} zenith
|
|
406
438
|
* 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
|
|
439
|
+
* @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
440
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
409
441
|
* not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
|
|
410
442
|
* @see AstronomicalCalendar#getUTCSeaLevelSunset
|
|
@@ -419,9 +451,9 @@ class NOAACalculator {
|
|
|
419
451
|
* at sea level. This forms the base for dusk calculations that are calculated as a dip below the horizon after
|
|
420
452
|
* sunset.
|
|
421
453
|
*
|
|
422
|
-
* @param zenith
|
|
454
|
+
* @param {number} zenith
|
|
423
455
|
* 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
|
|
456
|
+
* @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
457
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
426
458
|
* not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
|
|
427
459
|
* @see AstronomicalCalendar#getUTCSunset
|
|
@@ -460,9 +492,9 @@ class NOAACalculator {
|
|
|
460
492
|
* elevationAdjustment = 0.0347 * Math.sqrt(elevationMeters);
|
|
461
493
|
* </pre>
|
|
462
494
|
*
|
|
463
|
-
* @param elevation
|
|
495
|
+
* @param {number} elevation
|
|
464
496
|
* elevation in Meters.
|
|
465
|
-
* @return the adjusted zenith
|
|
497
|
+
* @return {number} the adjusted zenith
|
|
466
498
|
*/
|
|
467
499
|
getElevationAdjustment(elevation) {
|
|
468
500
|
// double elevationAdjustment = 0.0347 * Math.sqrt(elevation);
|
|
@@ -489,15 +521,15 @@ class NOAACalculator {
|
|
|
489
521
|
* {@link ZmanimCalendar#ZENITH_16_POINT_1 16.1°} dip used in
|
|
490
522
|
* {@link ComplexZmanimCalendar#getAlos16Point1Degrees()}.
|
|
491
523
|
*
|
|
492
|
-
* @param zenith
|
|
524
|
+
* @param {number} zenith
|
|
493
525
|
* the azimuth below the vertical zenith of 90°. For sunset typically the {@link #adjustZenith
|
|
494
526
|
* zenith} used for the calculation uses geometric zenith of 90° and {@link #adjustZenith adjusts}
|
|
495
527
|
* this slightly to account for solar refraction and the sun's radius. Another example would be
|
|
496
528
|
* {@link AstronomicalCalendar#getEndNauticalTwilight()} that passes
|
|
497
529
|
* {@link AstronomicalCalendar#NAUTICAL_ZENITH} to this method.
|
|
498
|
-
* @param elevation
|
|
530
|
+
* @param {number} elevation
|
|
499
531
|
* elevation in Meters.
|
|
500
|
-
* @return The zenith adjusted to include the {@link #getSolarRadius sun's radius}, {@link #getRefraction
|
|
532
|
+
* @return {number} The zenith adjusted to include the {@link #getSolarRadius sun's radius}, {@link #getRefraction
|
|
501
533
|
* refraction} and {@link #getElevationAdjustment elevation} adjustment. This will only be adjusted for
|
|
502
534
|
* sunrise and sunset (if the zenith == 90°)
|
|
503
535
|
* @see #getElevationAdjustment(double)
|
|
@@ -556,21 +588,21 @@ class NOAACalculator {
|
|
|
556
588
|
* non-elevation adjusted temporal hour by passing in {@link #getSeaLevelSunrise() sea level sunrise} and
|
|
557
589
|
* {@link #getSeaLevelSunset() sea level sunset} as parameters.
|
|
558
590
|
*
|
|
559
|
-
* @param
|
|
591
|
+
* @param {Temporal.ZonedDateTime | null} startOfDay
|
|
560
592
|
* The start of the day.
|
|
561
|
-
* @param endOfDay
|
|
593
|
+
* @param {Temporal.ZonedDateTime | null} endOfDay
|
|
562
594
|
* The end of the day.
|
|
563
595
|
*
|
|
564
|
-
* @return the <code>long</code> millisecond length of the temporal hour. If the calculation can't be computed a
|
|
596
|
+
* @return {number} the <code>long</code> millisecond length of the temporal hour. If the calculation can't be computed a
|
|
565
597
|
* {@link Long#MIN_VALUE} will be returned. See detailed explanation on top of the page.
|
|
566
598
|
*
|
|
567
599
|
* @see #getTemporalHour()
|
|
568
600
|
*/
|
|
569
|
-
getTemporalHour(
|
|
570
|
-
if (
|
|
601
|
+
getTemporalHour(startOfDay = this.getSeaLevelSunrise(), endOfDay = this.getSeaLevelSunset()) {
|
|
602
|
+
if (startOfDay === null || endOfDay === null) {
|
|
571
603
|
return Long_MIN_VALUE;
|
|
572
604
|
}
|
|
573
|
-
const delta = endOfDay.epochMilliseconds -
|
|
605
|
+
const delta = endOfDay.epochMilliseconds - startOfDay.epochMilliseconds;
|
|
574
606
|
return Math.floor(delta / 12);
|
|
575
607
|
}
|
|
576
608
|
/**
|
|
@@ -580,14 +612,14 @@ class NOAACalculator {
|
|
|
580
612
|
* calculated as halfway between the sunrise and sunset passed to this method. This time can be slightly off the
|
|
581
613
|
* real transit time due to changes in declination (the lengthening or shortening day).
|
|
582
614
|
*
|
|
583
|
-
* @param startOfDay
|
|
615
|
+
* @param {Temporal.ZonedDateTime | null} startOfDay
|
|
584
616
|
* the start of day for calculating the sun's transit. This can be sea level sunrise, visual sunrise (or
|
|
585
617
|
* any arbitrary start of day) passed to this method.
|
|
586
|
-
* @param endOfDay
|
|
618
|
+
* @param {Temporal.ZonedDateTime | null} endOfDay
|
|
587
619
|
* the end of day for calculating the sun's transit. This can be sea level sunset, visual sunset (or any
|
|
588
620
|
* arbitrary end of day) passed to this method.
|
|
589
621
|
*
|
|
590
|
-
* @return
|
|
622
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` representing Sun's transit. If the calculation can't be computed such as in the
|
|
591
623
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
592
624
|
* not set, null will be returned. See detailed explanation on top of the page.
|
|
593
625
|
*/
|
|
@@ -596,13 +628,13 @@ class NOAACalculator {
|
|
|
596
628
|
return NOAACalculator.getTimeOffset(startOfDay, temporalHour * 6);
|
|
597
629
|
}
|
|
598
630
|
/**
|
|
599
|
-
* A method that returns a
|
|
631
|
+
* A method that returns a `Date` from the time passed in as a parameter.
|
|
600
632
|
* @protected
|
|
601
|
-
* @param time
|
|
602
|
-
* The time to be set as the time for the
|
|
633
|
+
* @param {number} time
|
|
634
|
+
* The time to be set as the time for the `Date`. The time expected is in the format: 18.75
|
|
603
635
|
* for 6:45:00 PM.
|
|
604
|
-
* @param isSunrise true if the time is sunrise, and false if it is sunset
|
|
605
|
-
* @return The Date.
|
|
636
|
+
* @param {boolean} isSunrise true if the time is sunrise, and false if it is sunset
|
|
637
|
+
* @return {Temporal.ZonedDateTime | null} The Date.
|
|
606
638
|
*/
|
|
607
639
|
getDateFromTime(time, isSunrise) {
|
|
608
640
|
if (Number.isNaN(time)) {
|
|
@@ -637,7 +669,7 @@ class NOAACalculator {
|
|
|
637
669
|
/**
|
|
638
670
|
* Return the <a href="http://en.wikipedia.org/wiki/Julian_day">Julian day</a> from a Java Calendar
|
|
639
671
|
* @private
|
|
640
|
-
* @param
|
|
672
|
+
* @param {Temporal.ZonedDateTime} date
|
|
641
673
|
* The Java Calendar
|
|
642
674
|
* @return the Julian day corresponding to the date Note: Number is returned for start of day. Fractional days
|
|
643
675
|
* should be added later.
|
|
@@ -833,11 +865,11 @@ class NOAACalculator {
|
|
|
833
865
|
* Return the <a href="http://en.wikipedia.org/wiki/Hour_angle">hour angle</a> of the sun at sunrise for the
|
|
834
866
|
* latitude.
|
|
835
867
|
* @private
|
|
836
|
-
* @param lat
|
|
868
|
+
* @param {number} lat
|
|
837
869
|
* , the latitude of observer in degrees
|
|
838
870
|
* @param solarDec
|
|
839
871
|
* the declination angle of sun in degrees
|
|
840
|
-
* @param zenith
|
|
872
|
+
* @param {number} zenith
|
|
841
873
|
* the zenith
|
|
842
874
|
* @return hour angle of sunrise in radians
|
|
843
875
|
*/
|
|
@@ -853,11 +885,11 @@ class NOAACalculator {
|
|
|
853
885
|
* latitude. TODO: use - {@link #getSunHourAngleAtSunrise(double, double, double)} implementation to avoid
|
|
854
886
|
* duplication of code.
|
|
855
887
|
* @private
|
|
856
|
-
* @param lat
|
|
888
|
+
* @param {number} lat
|
|
857
889
|
* the latitude of observer in degrees
|
|
858
890
|
* @param solarDec
|
|
859
891
|
* the declination angle of sun in degrees
|
|
860
|
-
* @param zenith
|
|
892
|
+
* @param {number} zenith
|
|
861
893
|
* the zenith
|
|
862
894
|
* @return the hour angle of sunset in radians
|
|
863
895
|
*/
|
|
@@ -874,13 +906,13 @@ class NOAACalculator {
|
|
|
874
906
|
* horizontal coordinate system at the given location at the given time. Can be negative if the sun is below the
|
|
875
907
|
* horizon. Not corrected for altitude.
|
|
876
908
|
*
|
|
877
|
-
* @param
|
|
909
|
+
* @param {Temporal.ZonedDateTime} date
|
|
878
910
|
* time of calculation
|
|
879
|
-
* @param lat
|
|
911
|
+
* @param {number} lat
|
|
880
912
|
* latitude of location for calculation
|
|
881
|
-
* @param lon
|
|
913
|
+
* @param {number} lon
|
|
882
914
|
* longitude of location for calculation
|
|
883
|
-
* @return solar elevation in degrees - horizon is 0 degrees, civil twilight is -6 degrees
|
|
915
|
+
* @return {number} solar elevation in degrees - horizon is 0 degrees, civil twilight is -6 degrees
|
|
884
916
|
*/
|
|
885
917
|
static getSolarElevation(date, lat, lon) {
|
|
886
918
|
const julianDay = NOAACalculator.getJulianDay(date.toPlainDate());
|
|
@@ -900,13 +932,13 @@ class NOAACalculator {
|
|
|
900
932
|
* horizontal coordinate system at the given location at the given time. Not corrected for altitude. True south is 0
|
|
901
933
|
* degrees.
|
|
902
934
|
*
|
|
903
|
-
* @param
|
|
935
|
+
* @param {Temporal.ZonedDateTime} date
|
|
904
936
|
* time of calculation
|
|
905
|
-
* @param latitude
|
|
937
|
+
* @param {number} latitude
|
|
906
938
|
* latitude of location for calculation
|
|
907
|
-
* @param lon
|
|
939
|
+
* @param {number} lon
|
|
908
940
|
* longitude of location for calculation
|
|
909
|
-
* @return
|
|
941
|
+
* @return {number}
|
|
910
942
|
*/
|
|
911
943
|
static getSolarAzimuth(date, latitude, lon) {
|
|
912
944
|
const julianDay = NOAACalculator.getJulianDay(date.toPlainDate());
|
|
@@ -928,11 +960,11 @@ class NOAACalculator {
|
|
|
928
960
|
* @private
|
|
929
961
|
* @param julianDay
|
|
930
962
|
* the Julian day
|
|
931
|
-
* @param latitude
|
|
963
|
+
* @param {number} latitude
|
|
932
964
|
* the latitude of observer in degrees
|
|
933
|
-
* @param longitude
|
|
965
|
+
* @param {number} longitude
|
|
934
966
|
* the longitude of observer in degrees
|
|
935
|
-
* @param zenith
|
|
967
|
+
* @param {number} zenith
|
|
936
968
|
* the zenith
|
|
937
969
|
* @return the time in minutes from zero UTC
|
|
938
970
|
*/
|
|
@@ -967,7 +999,7 @@ class NOAACalculator {
|
|
|
967
999
|
* @private
|
|
968
1000
|
* @param julianCenturies
|
|
969
1001
|
* the number of Julian centuries since J2000.0
|
|
970
|
-
* @param longitude
|
|
1002
|
+
* @param {number} longitude
|
|
971
1003
|
* the longitude of observer in degrees
|
|
972
1004
|
* @return the time in minutes from zero UTC
|
|
973
1005
|
*/
|
|
@@ -989,11 +1021,11 @@ class NOAACalculator {
|
|
|
989
1021
|
* @private
|
|
990
1022
|
* @param julianDay
|
|
991
1023
|
* the Julian day
|
|
992
|
-
* @param latitude
|
|
1024
|
+
* @param {number} latitude
|
|
993
1025
|
* the latitude of observer in degrees
|
|
994
|
-
* @param longitude
|
|
1026
|
+
* @param {number} longitude
|
|
995
1027
|
* : longitude of observer in degrees
|
|
996
|
-
* @param zenith
|
|
1028
|
+
* @param {number} zenith
|
|
997
1029
|
* the zenith
|
|
998
1030
|
* @return the time in minutes from zero Universal Coordinated Time (UTC)
|
|
999
1031
|
*/
|