@hebcal/noaa 0.8.4 → 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 +123 -101
- package/dist/index.d.ts +109 -104
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Temporal } from 'temporal-polyfill';
|
|
2
2
|
/**
|
|
3
3
|
* java.lang.Math.toRadians
|
|
4
|
+
* @private
|
|
4
5
|
* @param degrees
|
|
5
6
|
*/
|
|
6
7
|
function degreesToRadians(degrees) {
|
|
@@ -8,6 +9,7 @@ function degreesToRadians(degrees) {
|
|
|
8
9
|
}
|
|
9
10
|
/**
|
|
10
11
|
* java.lang.Math.toDegrees
|
|
12
|
+
* @private
|
|
11
13
|
* @param radians
|
|
12
14
|
*/
|
|
13
15
|
function radiansToDegrees(radians) {
|
|
@@ -25,24 +27,26 @@ const Long_MIN_VALUE = NaN;
|
|
|
25
27
|
*/
|
|
26
28
|
export class GeoLocation {
|
|
27
29
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @return Returns the elevation in Meters.
|
|
31
|
-
*/
|
|
32
|
-
getElevation() {
|
|
33
|
-
return this.elevation;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Method to set the elevation in Meters <b>above </b> sea level.
|
|
30
|
+
* GeoLocation constructor with parameters for all required fields.
|
|
37
31
|
*
|
|
38
|
-
* @param
|
|
39
|
-
* The
|
|
32
|
+
* @param {string} name
|
|
33
|
+
* The location name for display use such as "Lakewood, NJ"
|
|
34
|
+
* @param {number} latitude
|
|
35
|
+
* the latitude in a double format such as 40.095965 for Lakewood, NJ.
|
|
36
|
+
* <b>Note: </b> For latitudes south of the equator, a negative value should be used.
|
|
37
|
+
* @param {number} longitude
|
|
38
|
+
* double the longitude in a double format such as -74.222130 for Lakewood, NJ.
|
|
39
|
+
* <b>Note: </b> For longitudes east of the <a href="http://en.wikipedia.org/wiki/Prime_Meridian">Prime
|
|
40
|
+
* Meridian </a> (Greenwich), a negative value should be used.
|
|
41
|
+
* @param {number} elevation
|
|
42
|
+
* the elevation above sea level in Meters. Elevation is not used in most algorithms used for calculating
|
|
43
|
+
* sunrise and set.
|
|
44
|
+
* @param {string} timeZoneId
|
|
45
|
+
* the <code>TimeZone</code> for the location.
|
|
40
46
|
*/
|
|
41
|
-
|
|
42
|
-
this.elevation = elevation;
|
|
43
|
-
}
|
|
44
|
-
constructor(name = 'Greenwich, England', latitude = 51.4772, longitude = 0, elevationOrTimeZoneId, timeZoneId) {
|
|
47
|
+
constructor(name, latitude, longitude, elevationOrTimeZoneId, timeZoneId) {
|
|
45
48
|
/**
|
|
49
|
+
* @private
|
|
46
50
|
* @see #getLocationName()
|
|
47
51
|
* @see #setLocationName(String)
|
|
48
52
|
*/
|
|
@@ -60,11 +64,28 @@ export class GeoLocation {
|
|
|
60
64
|
this.setElevation(elevation);
|
|
61
65
|
this.setTimeZone(timeZoneId);
|
|
62
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Method to get the elevation in Meters.
|
|
69
|
+
*
|
|
70
|
+
* @return {number} Returns the elevation in Meters.
|
|
71
|
+
*/
|
|
72
|
+
getElevation() {
|
|
73
|
+
return this.elevation;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Method to set the elevation in Meters <b>above </b> sea level.
|
|
77
|
+
*
|
|
78
|
+
* @param {number} elevation
|
|
79
|
+
* The elevation to set in Meters. An IllegalArgumentException will be thrown if the value is a negative.
|
|
80
|
+
*/
|
|
81
|
+
setElevation(elevation) {
|
|
82
|
+
this.elevation = elevation;
|
|
83
|
+
}
|
|
63
84
|
setLatitude(latitude) {
|
|
64
85
|
this.latitude = latitude;
|
|
65
86
|
}
|
|
66
87
|
/**
|
|
67
|
-
* @return Returns the latitude.
|
|
88
|
+
* @return {number} Returns the latitude.
|
|
68
89
|
*/
|
|
69
90
|
getLatitude() {
|
|
70
91
|
return this.latitude;
|
|
@@ -73,26 +94,26 @@ export class GeoLocation {
|
|
|
73
94
|
this.longitude = longitude;
|
|
74
95
|
}
|
|
75
96
|
/**
|
|
76
|
-
* @return Returns the longitude.
|
|
97
|
+
* @return {number} Returns the longitude.
|
|
77
98
|
*/
|
|
78
99
|
getLongitude() {
|
|
79
100
|
return this.longitude;
|
|
80
101
|
}
|
|
81
102
|
/**
|
|
82
|
-
* @return Returns the location name.
|
|
103
|
+
* @return {string|null} Returns the location name.
|
|
83
104
|
*/
|
|
84
105
|
getLocationName() {
|
|
85
106
|
return this.locationName;
|
|
86
107
|
}
|
|
87
108
|
/**
|
|
88
|
-
* @param name
|
|
109
|
+
* @param {string|null} name
|
|
89
110
|
* The setter method for the display name.
|
|
90
111
|
*/
|
|
91
112
|
setLocationName(name) {
|
|
92
113
|
this.locationName = name;
|
|
93
114
|
}
|
|
94
115
|
/**
|
|
95
|
-
* @return Returns the timeZone.
|
|
116
|
+
* @return {string} Returns the timeZone.
|
|
96
117
|
*/
|
|
97
118
|
getTimeZone() {
|
|
98
119
|
return this.timeZoneId;
|
|
@@ -105,7 +126,7 @@ export class GeoLocation {
|
|
|
105
126
|
* AstronomicalCalendar to output times in the expected offset. This situation will arise if the
|
|
106
127
|
* AstronomicalCalendar is ever {@link AstronomicalCalendar#clone() cloned}.
|
|
107
128
|
*
|
|
108
|
-
* @param timeZone
|
|
129
|
+
* @param {string} timeZone
|
|
109
130
|
* The timeZone to set.
|
|
110
131
|
*/
|
|
111
132
|
setTimeZone(timeZoneId) {
|
|
@@ -145,7 +166,22 @@ const earthRadius = 6356.9; // in KM
|
|
|
145
166
|
*/
|
|
146
167
|
export class NOAACalculator {
|
|
147
168
|
/**
|
|
148
|
-
*
|
|
169
|
+
* A constructor that takes in <a href="http://en.wikipedia.org/wiki/Geolocation">geolocation</a> information as a
|
|
170
|
+
* parameter. The default {@link AstronomicalCalculator#getDefault() AstronomicalCalculator} used for solar
|
|
171
|
+
* calculations is the the {@link NOAACalculator}.
|
|
172
|
+
*
|
|
173
|
+
* @param {GeoLocation} geoLocation
|
|
174
|
+
* The location information used for calculating astronomical sun times.
|
|
175
|
+
* @param {Temporal.PlainDate} date
|
|
176
|
+
*
|
|
177
|
+
* @see #setAstronomicalCalculator(AstronomicalCalculator) for changing the calculator class.
|
|
178
|
+
*/
|
|
179
|
+
constructor(geoLocation, date) {
|
|
180
|
+
this.date = date;
|
|
181
|
+
this.geoLocation = geoLocation;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* The getSunrise method Returns a `Date` representing the
|
|
149
185
|
* {@link AstronomicalCalculator#getElevationAdjustment(double) elevation adjusted} sunrise time. The zenith used
|
|
150
186
|
* for the calculation uses {@link #GEOMETRIC_ZENITH geometric zenith} of 90° plus
|
|
151
187
|
* {@link AstronomicalCalculator#getElevationAdjustment(double)}. This is adjusted by the
|
|
@@ -153,7 +189,7 @@ export class NOAACalculator {
|
|
|
153
189
|
* and 16 archminutes for the sun's radius for a total of {@link AstronomicalCalculator#adjustZenith 90.83333°}.
|
|
154
190
|
* See documentation for the specific implementation of the {@link AstronomicalCalculator} that you are using.
|
|
155
191
|
*
|
|
156
|
-
* @return the
|
|
192
|
+
* @return {Temporal.ZonedDateTime | null} the `Date` representing the exact sunrise time. If the calculation can't be computed such as
|
|
157
193
|
* in the Arctic Circle where there is at least one day a year where the sun does not rise, and one where it
|
|
158
194
|
* does not set, a null will be returned. See detailed explanation on top of the page.
|
|
159
195
|
* @see AstronomicalCalculator#adjustZenith
|
|
@@ -172,7 +208,7 @@ export class NOAACalculator {
|
|
|
172
208
|
* something that is not affected by elevation. This method returns sunrise calculated at sea level. This forms the
|
|
173
209
|
* base for dawn calculations that are calculated as a dip below the horizon before sunrise.
|
|
174
210
|
*
|
|
175
|
-
* @return the
|
|
211
|
+
* @return {Temporal.ZonedDateTime | null} the `Date` representing the exact sea-level sunrise time. If the calculation can't be computed
|
|
176
212
|
* such as in the Arctic Circle where there is at least one day a year where the sun does not rise, and one
|
|
177
213
|
* where it does not set, a null will be returned. See detailed explanation on top of the page.
|
|
178
214
|
* @see AstronomicalCalendar#getSunrise
|
|
@@ -188,7 +224,7 @@ export class NOAACalculator {
|
|
|
188
224
|
/**
|
|
189
225
|
* A method that returns the beginning of civil twilight (dawn) using a zenith of {@link #CIVIL_ZENITH 96°}.
|
|
190
226
|
*
|
|
191
|
-
* @return The
|
|
227
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the beginning of civil twilight using a zenith of 96°. If the calculation
|
|
192
228
|
* can't be computed, null will be returned. See detailed explanation on top of the page.
|
|
193
229
|
* @see #CIVIL_ZENITH
|
|
194
230
|
*/
|
|
@@ -198,7 +234,7 @@ export class NOAACalculator {
|
|
|
198
234
|
/**
|
|
199
235
|
* A method that returns the beginning of nautical twilight using a zenith of {@link #NAUTICAL_ZENITH 102°}.
|
|
200
236
|
*
|
|
201
|
-
* @return The
|
|
237
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the beginning of nautical twilight using a zenith of 102°. If the
|
|
202
238
|
* calculation can't be computed null will be returned. See detailed explanation on top of the page.
|
|
203
239
|
* @see #NAUTICAL_ZENITH
|
|
204
240
|
*/
|
|
@@ -209,7 +245,7 @@ export class NOAACalculator {
|
|
|
209
245
|
* A method that returns the beginning of astronomical twilight using a zenith of {@link #ASTRONOMICAL_ZENITH
|
|
210
246
|
* 108°}.
|
|
211
247
|
*
|
|
212
|
-
* @return The
|
|
248
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the beginning of astronomical twilight using a zenith of 108°. If the
|
|
213
249
|
* calculation can't be computed, null will be returned. See detailed explanation on top of the page.
|
|
214
250
|
* @see #ASTRONOMICAL_ZENITH
|
|
215
251
|
*/
|
|
@@ -217,7 +253,7 @@ export class NOAACalculator {
|
|
|
217
253
|
return this.getSunriseOffsetByDegrees(NOAACalculator.ASTRONOMICAL_ZENITH);
|
|
218
254
|
}
|
|
219
255
|
/**
|
|
220
|
-
* The getSunset method Returns a
|
|
256
|
+
* The getSunset method Returns a `Date` representing the
|
|
221
257
|
* {@link AstronomicalCalculator#getElevationAdjustment(double) elevation adjusted} sunset time. The zenith used for
|
|
222
258
|
* the calculation uses {@link #GEOMETRIC_ZENITH geometric zenith} of 90° plus
|
|
223
259
|
* {@link AstronomicalCalculator#getElevationAdjustment(double)}. This is adjusted by the
|
|
@@ -228,7 +264,7 @@ export class NOAACalculator {
|
|
|
228
264
|
* other than the local timezone is used (calculating Los Angeles sunset using a GMT timezone for example). In this
|
|
229
265
|
* case the sunset date will be incremented to the following date.
|
|
230
266
|
*
|
|
231
|
-
* @return
|
|
267
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` representing the exact sunset time. If the calculation can't be computed such as in
|
|
232
268
|
* the Arctic Circle where there is at least one day a year where the sun does not rise, and one where it
|
|
233
269
|
* does not set, a null will be returned. See detailed explanation on top of the page.
|
|
234
270
|
* @see AstronomicalCalculator#adjustZenith
|
|
@@ -247,7 +283,7 @@ export class NOAACalculator {
|
|
|
247
283
|
* something that is not affected by elevation. This method returns sunset calculated at sea level. This forms the
|
|
248
284
|
* base for dusk calculations that are calculated as a dip below the horizon after sunset.
|
|
249
285
|
*
|
|
250
|
-
* @return
|
|
286
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` representing the exact sea-level sunset time. If the calculation can't be computed
|
|
251
287
|
* such as in the Arctic Circle where there is at least one day a year where the sun does not rise, and one
|
|
252
288
|
* where it does not set, a null will be returned. See detailed explanation on top of the page.
|
|
253
289
|
* @see AstronomicalCalendar#getSunset
|
|
@@ -262,7 +298,7 @@ export class NOAACalculator {
|
|
|
262
298
|
/**
|
|
263
299
|
* A method that returns the end of civil twilight using a zenith of {@link #CIVIL_ZENITH 96°}.
|
|
264
300
|
*
|
|
265
|
-
* @return The
|
|
301
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the end of civil twilight using a zenith of {@link #CIVIL_ZENITH 96°}. If
|
|
266
302
|
* the calculation can't be computed, null will be returned. See detailed explanation on top of the page.
|
|
267
303
|
* @see #CIVIL_ZENITH
|
|
268
304
|
*/
|
|
@@ -272,7 +308,7 @@ export class NOAACalculator {
|
|
|
272
308
|
/**
|
|
273
309
|
* A method that returns the end of nautical twilight using a zenith of {@link #NAUTICAL_ZENITH 102°}.
|
|
274
310
|
*
|
|
275
|
-
* @return The
|
|
311
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the end of nautical twilight using a zenith of {@link #NAUTICAL_ZENITH 102°}
|
|
276
312
|
* . If the calculation can't be computed, null will be returned. See detailed explanation on top of the
|
|
277
313
|
* page.
|
|
278
314
|
* @see #NAUTICAL_ZENITH
|
|
@@ -283,7 +319,7 @@ export class NOAACalculator {
|
|
|
283
319
|
/**
|
|
284
320
|
* A method that returns the end of astronomical twilight using a zenith of {@link #ASTRONOMICAL_ZENITH 108°}.
|
|
285
321
|
*
|
|
286
|
-
* @return
|
|
322
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the end of astronomical twilight using a zenith of {@link #ASTRONOMICAL_ZENITH
|
|
287
323
|
* 108°}. If the calculation can't be computed, null will be returned. See detailed explanation on top
|
|
288
324
|
* of the page.
|
|
289
325
|
* @see #ASTRONOMICAL_ZENITH
|
|
@@ -297,11 +333,11 @@ export class NOAACalculator {
|
|
|
297
333
|
* after sunset with the intent of getting a rough "level of light" calculation, the sunrise or sunset time passed
|
|
298
334
|
* to this method should be sea level sunrise and sunset.
|
|
299
335
|
*
|
|
300
|
-
* @param time
|
|
336
|
+
* @param {Temporal.ZonedDateTime | null} time
|
|
301
337
|
* the start time
|
|
302
|
-
* @param offset
|
|
338
|
+
* @param {number} offset
|
|
303
339
|
* the offset in milliseconds to add to the time.
|
|
304
|
-
* @return
|
|
340
|
+
* @return {Temporal.ZonedDateTime | null} the `Date` with the offset in milliseconds added to it
|
|
305
341
|
*/
|
|
306
342
|
static getTimeOffset(time, offset) {
|
|
307
343
|
if (time === null || offset === Long_MIN_VALUE || Number.isNaN(offset)) {
|
|
@@ -314,12 +350,12 @@ export class NOAACalculator {
|
|
|
314
350
|
* {@link #getSunrise() sunrise}. Note that the degree offset is from the vertical, so for a calculation of 14°
|
|
315
351
|
* before sunrise, an offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a parameter.
|
|
316
352
|
*
|
|
317
|
-
* @param offsetZenith
|
|
353
|
+
* @param {number} offsetZenith
|
|
318
354
|
* the degrees before {@link #getSunrise()} to use in the calculation. For time after sunrise use
|
|
319
355
|
* negative numbers. Note that the degree offset is from the vertical, so for a calculation of 14°
|
|
320
356
|
* before sunrise, an offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a
|
|
321
357
|
* parameter.
|
|
322
|
-
* @return
|
|
358
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the offset after (or before) {@link #getSunrise()}. If the calculation
|
|
323
359
|
* can't be computed such as in the Arctic Circle where there is at least one day a year where the sun does
|
|
324
360
|
* not rise, and one where it does not set, a null will be returned. See detailed explanation on top of the
|
|
325
361
|
* page.
|
|
@@ -335,11 +371,11 @@ export class NOAACalculator {
|
|
|
335
371
|
* sunset}. Note that the degree offset is from the vertical, so for a calculation of 14° after sunset, an
|
|
336
372
|
* offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a parameter.
|
|
337
373
|
*
|
|
338
|
-
* @param offsetZenith
|
|
374
|
+
* @param {number} offsetZenith
|
|
339
375
|
* the degrees after {@link #getSunset()} to use in the calculation. For time before sunset use negative
|
|
340
376
|
* numbers. Note that the degree offset is from the vertical, so for a calculation of 14° after
|
|
341
377
|
* sunset, an offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a parameter.
|
|
342
|
-
* @return The
|
|
378
|
+
* @return {Temporal.ZonedDateTime | null} The `Date`of the offset after (or before) {@link #getSunset()}. If the calculation can't
|
|
343
379
|
* be computed such as in the Arctic Circle where there is at least one day a year where the sun does not
|
|
344
380
|
* rise, and one where it does not set, a null will be returned. See detailed explanation on top of the
|
|
345
381
|
* page.
|
|
@@ -350,27 +386,13 @@ export class NOAACalculator {
|
|
|
350
386
|
return null;
|
|
351
387
|
return this.getDateFromTime(sunset, false);
|
|
352
388
|
}
|
|
353
|
-
/**
|
|
354
|
-
* A constructor that takes in <a href="http://en.wikipedia.org/wiki/Geolocation">geolocation</a> information as a
|
|
355
|
-
* parameter. The default {@link AstronomicalCalculator#getDefault() AstronomicalCalculator} used for solar
|
|
356
|
-
* calculations is the the {@link NOAACalculator}.
|
|
357
|
-
*
|
|
358
|
-
* @param geoLocation
|
|
359
|
-
* The location information used for calculating astronomical sun times.
|
|
360
|
-
*
|
|
361
|
-
* @see #setAstronomicalCalculator(AstronomicalCalculator) for changing the calculator class.
|
|
362
|
-
*/
|
|
363
|
-
constructor(geoLocation, date) {
|
|
364
|
-
this.date = date;
|
|
365
|
-
this.geoLocation = geoLocation;
|
|
366
|
-
}
|
|
367
389
|
/**
|
|
368
390
|
* A method that returns the sunrise in UTC time without correction for time zone offset from GMT and without using
|
|
369
391
|
* daylight savings time.
|
|
370
392
|
*
|
|
371
|
-
* @param zenith
|
|
393
|
+
* @param {number} zenith
|
|
372
394
|
* the degrees below the horizon. For time after sunrise use negative numbers.
|
|
373
|
-
* @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
|
|
395
|
+
* @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
|
|
374
396
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
375
397
|
* not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
|
|
376
398
|
*/
|
|
@@ -383,9 +405,9 @@ export class NOAACalculator {
|
|
|
383
405
|
* light, something that is not affected by elevation. This method returns UTC sunrise calculated at sea level. This
|
|
384
406
|
* forms the base for dawn calculations that are calculated as a dip below the horizon before sunrise.
|
|
385
407
|
*
|
|
386
|
-
* @param zenith
|
|
408
|
+
* @param {number} zenith
|
|
387
409
|
* the degrees below the horizon. For time after sunrise use negative numbers.
|
|
388
|
-
* @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
|
|
410
|
+
* @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
|
|
389
411
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
390
412
|
* not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
|
|
391
413
|
* @see AstronomicalCalendar#getUTCSunrise
|
|
@@ -398,9 +420,9 @@ export class NOAACalculator {
|
|
|
398
420
|
* A method that returns the sunset in UTC time without correction for time zone offset from GMT and without using
|
|
399
421
|
* daylight savings time.
|
|
400
422
|
*
|
|
401
|
-
* @param zenith
|
|
423
|
+
* @param {number} zenith
|
|
402
424
|
* the degrees below the horizon. For time after sunset use negative numbers.
|
|
403
|
-
* @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
|
|
425
|
+
* @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
|
|
404
426
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
405
427
|
* not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
|
|
406
428
|
* @see AstronomicalCalendar#getUTCSeaLevelSunset
|
|
@@ -415,9 +437,9 @@ export class NOAACalculator {
|
|
|
415
437
|
* at sea level. This forms the base for dusk calculations that are calculated as a dip below the horizon after
|
|
416
438
|
* sunset.
|
|
417
439
|
*
|
|
418
|
-
* @param zenith
|
|
440
|
+
* @param {number} zenith
|
|
419
441
|
* the degrees below the horizon. For time before sunset use negative numbers.
|
|
420
|
-
* @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
|
|
442
|
+
* @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
|
|
421
443
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
422
444
|
* not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
|
|
423
445
|
* @see AstronomicalCalendar#getUTCSunset
|
|
@@ -456,9 +478,9 @@ export class NOAACalculator {
|
|
|
456
478
|
* elevationAdjustment = 0.0347 * Math.sqrt(elevationMeters);
|
|
457
479
|
* </pre>
|
|
458
480
|
*
|
|
459
|
-
* @param elevation
|
|
481
|
+
* @param {number} elevation
|
|
460
482
|
* elevation in Meters.
|
|
461
|
-
* @return the adjusted zenith
|
|
483
|
+
* @return {number} the adjusted zenith
|
|
462
484
|
*/
|
|
463
485
|
getElevationAdjustment(elevation) {
|
|
464
486
|
// double elevationAdjustment = 0.0347 * Math.sqrt(elevation);
|
|
@@ -485,15 +507,15 @@ export class NOAACalculator {
|
|
|
485
507
|
* {@link ZmanimCalendar#ZENITH_16_POINT_1 16.1°} dip used in
|
|
486
508
|
* {@link ComplexZmanimCalendar#getAlos16Point1Degrees()}.
|
|
487
509
|
*
|
|
488
|
-
* @param zenith
|
|
510
|
+
* @param {number} zenith
|
|
489
511
|
* the azimuth below the vertical zenith of 90°. For sunset typically the {@link #adjustZenith
|
|
490
512
|
* zenith} used for the calculation uses geometric zenith of 90° and {@link #adjustZenith adjusts}
|
|
491
513
|
* this slightly to account for solar refraction and the sun's radius. Another example would be
|
|
492
514
|
* {@link AstronomicalCalendar#getEndNauticalTwilight()} that passes
|
|
493
515
|
* {@link AstronomicalCalendar#NAUTICAL_ZENITH} to this method.
|
|
494
|
-
* @param elevation
|
|
516
|
+
* @param {number} elevation
|
|
495
517
|
* elevation in Meters.
|
|
496
|
-
* @return The zenith adjusted to include the {@link #getSolarRadius sun's radius}, {@link #getRefraction
|
|
518
|
+
* @return {number} The zenith adjusted to include the {@link #getSolarRadius sun's radius}, {@link #getRefraction
|
|
497
519
|
* refraction} and {@link #getElevationAdjustment elevation} adjustment. This will only be adjusted for
|
|
498
520
|
* sunrise and sunset (if the zenith == 90°)
|
|
499
521
|
* @see #getElevationAdjustment(double)
|
|
@@ -552,21 +574,21 @@ export class NOAACalculator {
|
|
|
552
574
|
* non-elevation adjusted temporal hour by passing in {@link #getSeaLevelSunrise() sea level sunrise} and
|
|
553
575
|
* {@link #getSeaLevelSunset() sea level sunset} as parameters.
|
|
554
576
|
*
|
|
555
|
-
* @param
|
|
577
|
+
* @param {Temporal.ZonedDateTime | null} startOfDay
|
|
556
578
|
* The start of the day.
|
|
557
|
-
* @param endOfDay
|
|
579
|
+
* @param {Temporal.ZonedDateTime | null} endOfDay
|
|
558
580
|
* The end of the day.
|
|
559
581
|
*
|
|
560
|
-
* @return the <code>long</code> millisecond length of the temporal hour. If the calculation can't be computed a
|
|
582
|
+
* @return {number} the <code>long</code> millisecond length of the temporal hour. If the calculation can't be computed a
|
|
561
583
|
* {@link Long#MIN_VALUE} will be returned. See detailed explanation on top of the page.
|
|
562
584
|
*
|
|
563
585
|
* @see #getTemporalHour()
|
|
564
586
|
*/
|
|
565
|
-
getTemporalHour(
|
|
566
|
-
if (
|
|
587
|
+
getTemporalHour(startOfDay = this.getSeaLevelSunrise(), endOfDay = this.getSeaLevelSunset()) {
|
|
588
|
+
if (startOfDay === null || endOfDay === null) {
|
|
567
589
|
return Long_MIN_VALUE;
|
|
568
590
|
}
|
|
569
|
-
const delta = endOfDay.epochMilliseconds -
|
|
591
|
+
const delta = endOfDay.epochMilliseconds - startOfDay.epochMilliseconds;
|
|
570
592
|
return Math.floor(delta / 12);
|
|
571
593
|
}
|
|
572
594
|
/**
|
|
@@ -576,14 +598,14 @@ export class NOAACalculator {
|
|
|
576
598
|
* calculated as halfway between the sunrise and sunset passed to this method. This time can be slightly off the
|
|
577
599
|
* real transit time due to changes in declination (the lengthening or shortening day).
|
|
578
600
|
*
|
|
579
|
-
* @param startOfDay
|
|
601
|
+
* @param {Temporal.ZonedDateTime | null} startOfDay
|
|
580
602
|
* the start of day for calculating the sun's transit. This can be sea level sunrise, visual sunrise (or
|
|
581
603
|
* any arbitrary start of day) passed to this method.
|
|
582
|
-
* @param endOfDay
|
|
604
|
+
* @param {Temporal.ZonedDateTime | null} endOfDay
|
|
583
605
|
* the end of day for calculating the sun's transit. This can be sea level sunset, visual sunset (or any
|
|
584
606
|
* arbitrary end of day) passed to this method.
|
|
585
607
|
*
|
|
586
|
-
* @return
|
|
608
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` representing Sun's transit. If the calculation can't be computed such as in the
|
|
587
609
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
588
610
|
* not set, null will be returned. See detailed explanation on top of the page.
|
|
589
611
|
*/
|
|
@@ -592,13 +614,13 @@ export class NOAACalculator {
|
|
|
592
614
|
return NOAACalculator.getTimeOffset(startOfDay, temporalHour * 6);
|
|
593
615
|
}
|
|
594
616
|
/**
|
|
595
|
-
* A method that returns a
|
|
617
|
+
* A method that returns a `Date` from the time passed in as a parameter.
|
|
596
618
|
* @protected
|
|
597
|
-
* @param time
|
|
598
|
-
* The time to be set as the time for the
|
|
619
|
+
* @param {number} time
|
|
620
|
+
* The time to be set as the time for the `Date`. The time expected is in the format: 18.75
|
|
599
621
|
* for 6:45:00 PM.
|
|
600
|
-
* @param isSunrise true if the time is sunrise, and false if it is sunset
|
|
601
|
-
* @return The Date.
|
|
622
|
+
* @param {boolean} isSunrise true if the time is sunrise, and false if it is sunset
|
|
623
|
+
* @return {Temporal.ZonedDateTime | null} The Date.
|
|
602
624
|
*/
|
|
603
625
|
getDateFromTime(time, isSunrise) {
|
|
604
626
|
if (Number.isNaN(time)) {
|
|
@@ -633,7 +655,7 @@ export class NOAACalculator {
|
|
|
633
655
|
/**
|
|
634
656
|
* Return the <a href="http://en.wikipedia.org/wiki/Julian_day">Julian day</a> from a Java Calendar
|
|
635
657
|
* @private
|
|
636
|
-
* @param
|
|
658
|
+
* @param {Temporal.ZonedDateTime} date
|
|
637
659
|
* The Java Calendar
|
|
638
660
|
* @return the Julian day corresponding to the date Note: Number is returned for start of day. Fractional days
|
|
639
661
|
* should be added later.
|
|
@@ -829,11 +851,11 @@ export class NOAACalculator {
|
|
|
829
851
|
* Return the <a href="http://en.wikipedia.org/wiki/Hour_angle">hour angle</a> of the sun at sunrise for the
|
|
830
852
|
* latitude.
|
|
831
853
|
* @private
|
|
832
|
-
* @param lat
|
|
854
|
+
* @param {number} lat
|
|
833
855
|
* , the latitude of observer in degrees
|
|
834
856
|
* @param solarDec
|
|
835
857
|
* the declination angle of sun in degrees
|
|
836
|
-
* @param zenith
|
|
858
|
+
* @param {number} zenith
|
|
837
859
|
* the zenith
|
|
838
860
|
* @return hour angle of sunrise in radians
|
|
839
861
|
*/
|
|
@@ -849,11 +871,11 @@ export class NOAACalculator {
|
|
|
849
871
|
* latitude. TODO: use - {@link #getSunHourAngleAtSunrise(double, double, double)} implementation to avoid
|
|
850
872
|
* duplication of code.
|
|
851
873
|
* @private
|
|
852
|
-
* @param lat
|
|
874
|
+
* @param {number} lat
|
|
853
875
|
* the latitude of observer in degrees
|
|
854
876
|
* @param solarDec
|
|
855
877
|
* the declination angle of sun in degrees
|
|
856
|
-
* @param zenith
|
|
878
|
+
* @param {number} zenith
|
|
857
879
|
* the zenith
|
|
858
880
|
* @return the hour angle of sunset in radians
|
|
859
881
|
*/
|
|
@@ -870,13 +892,13 @@ export class NOAACalculator {
|
|
|
870
892
|
* horizontal coordinate system at the given location at the given time. Can be negative if the sun is below the
|
|
871
893
|
* horizon. Not corrected for altitude.
|
|
872
894
|
*
|
|
873
|
-
* @param
|
|
895
|
+
* @param {Temporal.ZonedDateTime} date
|
|
874
896
|
* time of calculation
|
|
875
|
-
* @param lat
|
|
897
|
+
* @param {number} lat
|
|
876
898
|
* latitude of location for calculation
|
|
877
|
-
* @param lon
|
|
899
|
+
* @param {number} lon
|
|
878
900
|
* longitude of location for calculation
|
|
879
|
-
* @return solar elevation in degrees - horizon is 0 degrees, civil twilight is -6 degrees
|
|
901
|
+
* @return {number} solar elevation in degrees - horizon is 0 degrees, civil twilight is -6 degrees
|
|
880
902
|
*/
|
|
881
903
|
static getSolarElevation(date, lat, lon) {
|
|
882
904
|
const julianDay = NOAACalculator.getJulianDay(date.toPlainDate());
|
|
@@ -896,13 +918,13 @@ export class NOAACalculator {
|
|
|
896
918
|
* horizontal coordinate system at the given location at the given time. Not corrected for altitude. True south is 0
|
|
897
919
|
* degrees.
|
|
898
920
|
*
|
|
899
|
-
* @param
|
|
921
|
+
* @param {Temporal.ZonedDateTime} date
|
|
900
922
|
* time of calculation
|
|
901
|
-
* @param latitude
|
|
923
|
+
* @param {number} latitude
|
|
902
924
|
* latitude of location for calculation
|
|
903
|
-
* @param lon
|
|
925
|
+
* @param {number} lon
|
|
904
926
|
* longitude of location for calculation
|
|
905
|
-
* @return
|
|
927
|
+
* @return {number}
|
|
906
928
|
*/
|
|
907
929
|
static getSolarAzimuth(date, latitude, lon) {
|
|
908
930
|
const julianDay = NOAACalculator.getJulianDay(date.toPlainDate());
|
|
@@ -924,11 +946,11 @@ export class NOAACalculator {
|
|
|
924
946
|
* @private
|
|
925
947
|
* @param julianDay
|
|
926
948
|
* the Julian day
|
|
927
|
-
* @param latitude
|
|
949
|
+
* @param {number} latitude
|
|
928
950
|
* the latitude of observer in degrees
|
|
929
|
-
* @param longitude
|
|
951
|
+
* @param {number} longitude
|
|
930
952
|
* the longitude of observer in degrees
|
|
931
|
-
* @param zenith
|
|
953
|
+
* @param {number} zenith
|
|
932
954
|
* the zenith
|
|
933
955
|
* @return the time in minutes from zero UTC
|
|
934
956
|
*/
|
|
@@ -963,7 +985,7 @@ export class NOAACalculator {
|
|
|
963
985
|
* @private
|
|
964
986
|
* @param julianCenturies
|
|
965
987
|
* the number of Julian centuries since J2000.0
|
|
966
|
-
* @param longitude
|
|
988
|
+
* @param {number} longitude
|
|
967
989
|
* the longitude of observer in degrees
|
|
968
990
|
* @return the time in minutes from zero UTC
|
|
969
991
|
*/
|
|
@@ -985,11 +1007,11 @@ export class NOAACalculator {
|
|
|
985
1007
|
* @private
|
|
986
1008
|
* @param julianDay
|
|
987
1009
|
* the Julian day
|
|
988
|
-
* @param latitude
|
|
1010
|
+
* @param {number} latitude
|
|
989
1011
|
* the latitude of observer in degrees
|
|
990
|
-
* @param longitude
|
|
1012
|
+
* @param {number} longitude
|
|
991
1013
|
* : longitude of observer in degrees
|
|
992
|
-
* @param zenith
|
|
1014
|
+
* @param {number} zenith
|
|
993
1015
|
* the zenith
|
|
994
1016
|
* @return the time in minutes from zero Universal Coordinated Time (UTC)
|
|
995
1017
|
*/
|