@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/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
|
-
*
|
|
30
|
+
* GeoLocation constructor with parameters for all required fields.
|
|
29
31
|
*
|
|
30
|
-
* @
|
|
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.
|
|
31
46
|
*/
|
|
32
|
-
|
|
33
|
-
return this.elevation;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Method to set the elevation in Meters <b>above </b> sea level.
|
|
37
|
-
*
|
|
38
|
-
* @param elevation
|
|
39
|
-
* The elevation to set in Meters. An IllegalArgumentException will be thrown if the value is a negative.
|
|
40
|
-
*/
|
|
41
|
-
setElevation(elevation) {
|
|
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,39 +64,66 @@ 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) {
|
|
85
|
+
if (typeof latitude !== 'number')
|
|
86
|
+
throw new TypeError('Invalid latitude');
|
|
87
|
+
if (latitude < -90 || latitude > 90) {
|
|
88
|
+
throw new RangeError(`Latitude ${latitude} out of range [-90,90]`);
|
|
89
|
+
}
|
|
64
90
|
this.latitude = latitude;
|
|
65
91
|
}
|
|
66
92
|
/**
|
|
67
|
-
* @return Returns the latitude.
|
|
93
|
+
* @return {number} Returns the latitude.
|
|
68
94
|
*/
|
|
69
95
|
getLatitude() {
|
|
70
96
|
return this.latitude;
|
|
71
97
|
}
|
|
72
98
|
setLongitude(longitude) {
|
|
99
|
+
if (typeof longitude !== 'number')
|
|
100
|
+
throw new TypeError('Invalid longitude');
|
|
101
|
+
if (longitude < -180 || longitude > 180) {
|
|
102
|
+
throw new RangeError(`Longitude ${longitude} out of range [-180,180]`);
|
|
103
|
+
}
|
|
73
104
|
this.longitude = longitude;
|
|
74
105
|
}
|
|
75
106
|
/**
|
|
76
|
-
* @return Returns the longitude.
|
|
107
|
+
* @return {number} Returns the longitude.
|
|
77
108
|
*/
|
|
78
109
|
getLongitude() {
|
|
79
110
|
return this.longitude;
|
|
80
111
|
}
|
|
81
112
|
/**
|
|
82
|
-
* @return Returns the location name.
|
|
113
|
+
* @return {string|null} Returns the location name.
|
|
83
114
|
*/
|
|
84
115
|
getLocationName() {
|
|
85
116
|
return this.locationName;
|
|
86
117
|
}
|
|
87
118
|
/**
|
|
88
|
-
* @param name
|
|
119
|
+
* @param {string|null} name
|
|
89
120
|
* The setter method for the display name.
|
|
90
121
|
*/
|
|
91
122
|
setLocationName(name) {
|
|
92
123
|
this.locationName = name;
|
|
93
124
|
}
|
|
94
125
|
/**
|
|
95
|
-
* @return Returns the timeZone.
|
|
126
|
+
* @return {string} Returns the timeZone.
|
|
96
127
|
*/
|
|
97
128
|
getTimeZone() {
|
|
98
129
|
return this.timeZoneId;
|
|
@@ -105,7 +136,7 @@ export class GeoLocation {
|
|
|
105
136
|
* AstronomicalCalendar to output times in the expected offset. This situation will arise if the
|
|
106
137
|
* AstronomicalCalendar is ever {@link AstronomicalCalendar#clone() cloned}.
|
|
107
138
|
*
|
|
108
|
-
* @param timeZone
|
|
139
|
+
* @param {string} timeZone
|
|
109
140
|
* The timeZone to set.
|
|
110
141
|
*/
|
|
111
142
|
setTimeZone(timeZoneId) {
|
|
@@ -145,7 +176,22 @@ const earthRadius = 6356.9; // in KM
|
|
|
145
176
|
*/
|
|
146
177
|
export class NOAACalculator {
|
|
147
178
|
/**
|
|
148
|
-
*
|
|
179
|
+
* A constructor that takes in <a href="http://en.wikipedia.org/wiki/Geolocation">geolocation</a> information as a
|
|
180
|
+
* parameter. The default {@link AstronomicalCalculator#getDefault() AstronomicalCalculator} used for solar
|
|
181
|
+
* calculations is the the {@link NOAACalculator}.
|
|
182
|
+
*
|
|
183
|
+
* @param {GeoLocation} geoLocation
|
|
184
|
+
* The location information used for calculating astronomical sun times.
|
|
185
|
+
* @param {Temporal.PlainDate} date
|
|
186
|
+
*
|
|
187
|
+
* @see #setAstronomicalCalculator(AstronomicalCalculator) for changing the calculator class.
|
|
188
|
+
*/
|
|
189
|
+
constructor(geoLocation, date) {
|
|
190
|
+
this.date = date;
|
|
191
|
+
this.geoLocation = geoLocation;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* The getSunrise method Returns a `Date` representing the
|
|
149
195
|
* {@link AstronomicalCalculator#getElevationAdjustment(double) elevation adjusted} sunrise time. The zenith used
|
|
150
196
|
* for the calculation uses {@link #GEOMETRIC_ZENITH geometric zenith} of 90° plus
|
|
151
197
|
* {@link AstronomicalCalculator#getElevationAdjustment(double)}. This is adjusted by the
|
|
@@ -153,7 +199,7 @@ export class NOAACalculator {
|
|
|
153
199
|
* and 16 archminutes for the sun's radius for a total of {@link AstronomicalCalculator#adjustZenith 90.83333°}.
|
|
154
200
|
* See documentation for the specific implementation of the {@link AstronomicalCalculator} that you are using.
|
|
155
201
|
*
|
|
156
|
-
* @return the
|
|
202
|
+
* @return {Temporal.ZonedDateTime | null} the `Date` representing the exact sunrise time. If the calculation can't be computed such as
|
|
157
203
|
* in the Arctic Circle where there is at least one day a year where the sun does not rise, and one where it
|
|
158
204
|
* does not set, a null will be returned. See detailed explanation on top of the page.
|
|
159
205
|
* @see AstronomicalCalculator#adjustZenith
|
|
@@ -172,7 +218,7 @@ export class NOAACalculator {
|
|
|
172
218
|
* something that is not affected by elevation. This method returns sunrise calculated at sea level. This forms the
|
|
173
219
|
* base for dawn calculations that are calculated as a dip below the horizon before sunrise.
|
|
174
220
|
*
|
|
175
|
-
* @return the
|
|
221
|
+
* @return {Temporal.ZonedDateTime | null} the `Date` representing the exact sea-level sunrise time. If the calculation can't be computed
|
|
176
222
|
* such as in the Arctic Circle where there is at least one day a year where the sun does not rise, and one
|
|
177
223
|
* where it does not set, a null will be returned. See detailed explanation on top of the page.
|
|
178
224
|
* @see AstronomicalCalendar#getSunrise
|
|
@@ -188,7 +234,7 @@ export class NOAACalculator {
|
|
|
188
234
|
/**
|
|
189
235
|
* A method that returns the beginning of civil twilight (dawn) using a zenith of {@link #CIVIL_ZENITH 96°}.
|
|
190
236
|
*
|
|
191
|
-
* @return The
|
|
237
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the beginning of civil twilight using a zenith of 96°. If the calculation
|
|
192
238
|
* can't be computed, null will be returned. See detailed explanation on top of the page.
|
|
193
239
|
* @see #CIVIL_ZENITH
|
|
194
240
|
*/
|
|
@@ -198,7 +244,7 @@ export class NOAACalculator {
|
|
|
198
244
|
/**
|
|
199
245
|
* A method that returns the beginning of nautical twilight using a zenith of {@link #NAUTICAL_ZENITH 102°}.
|
|
200
246
|
*
|
|
201
|
-
* @return The
|
|
247
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the beginning of nautical twilight using a zenith of 102°. If the
|
|
202
248
|
* calculation can't be computed null will be returned. See detailed explanation on top of the page.
|
|
203
249
|
* @see #NAUTICAL_ZENITH
|
|
204
250
|
*/
|
|
@@ -209,7 +255,7 @@ export class NOAACalculator {
|
|
|
209
255
|
* A method that returns the beginning of astronomical twilight using a zenith of {@link #ASTRONOMICAL_ZENITH
|
|
210
256
|
* 108°}.
|
|
211
257
|
*
|
|
212
|
-
* @return The
|
|
258
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the beginning of astronomical twilight using a zenith of 108°. If the
|
|
213
259
|
* calculation can't be computed, null will be returned. See detailed explanation on top of the page.
|
|
214
260
|
* @see #ASTRONOMICAL_ZENITH
|
|
215
261
|
*/
|
|
@@ -217,7 +263,7 @@ export class NOAACalculator {
|
|
|
217
263
|
return this.getSunriseOffsetByDegrees(NOAACalculator.ASTRONOMICAL_ZENITH);
|
|
218
264
|
}
|
|
219
265
|
/**
|
|
220
|
-
* The getSunset method Returns a
|
|
266
|
+
* The getSunset method Returns a `Date` representing the
|
|
221
267
|
* {@link AstronomicalCalculator#getElevationAdjustment(double) elevation adjusted} sunset time. The zenith used for
|
|
222
268
|
* the calculation uses {@link #GEOMETRIC_ZENITH geometric zenith} of 90° plus
|
|
223
269
|
* {@link AstronomicalCalculator#getElevationAdjustment(double)}. This is adjusted by the
|
|
@@ -228,7 +274,7 @@ export class NOAACalculator {
|
|
|
228
274
|
* other than the local timezone is used (calculating Los Angeles sunset using a GMT timezone for example). In this
|
|
229
275
|
* case the sunset date will be incremented to the following date.
|
|
230
276
|
*
|
|
231
|
-
* @return
|
|
277
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` representing the exact sunset time. If the calculation can't be computed such as in
|
|
232
278
|
* the Arctic Circle where there is at least one day a year where the sun does not rise, and one where it
|
|
233
279
|
* does not set, a null will be returned. See detailed explanation on top of the page.
|
|
234
280
|
* @see AstronomicalCalculator#adjustZenith
|
|
@@ -247,7 +293,7 @@ export class NOAACalculator {
|
|
|
247
293
|
* something that is not affected by elevation. This method returns sunset calculated at sea level. This forms the
|
|
248
294
|
* base for dusk calculations that are calculated as a dip below the horizon after sunset.
|
|
249
295
|
*
|
|
250
|
-
* @return
|
|
296
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` representing the exact sea-level sunset time. If the calculation can't be computed
|
|
251
297
|
* such as in the Arctic Circle where there is at least one day a year where the sun does not rise, and one
|
|
252
298
|
* where it does not set, a null will be returned. See detailed explanation on top of the page.
|
|
253
299
|
* @see AstronomicalCalendar#getSunset
|
|
@@ -262,7 +308,7 @@ export class NOAACalculator {
|
|
|
262
308
|
/**
|
|
263
309
|
* A method that returns the end of civil twilight using a zenith of {@link #CIVIL_ZENITH 96°}.
|
|
264
310
|
*
|
|
265
|
-
* @return The
|
|
311
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the end of civil twilight using a zenith of {@link #CIVIL_ZENITH 96°}. If
|
|
266
312
|
* the calculation can't be computed, null will be returned. See detailed explanation on top of the page.
|
|
267
313
|
* @see #CIVIL_ZENITH
|
|
268
314
|
*/
|
|
@@ -272,7 +318,7 @@ export class NOAACalculator {
|
|
|
272
318
|
/**
|
|
273
319
|
* A method that returns the end of nautical twilight using a zenith of {@link #NAUTICAL_ZENITH 102°}.
|
|
274
320
|
*
|
|
275
|
-
* @return The
|
|
321
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the end of nautical twilight using a zenith of {@link #NAUTICAL_ZENITH 102°}
|
|
276
322
|
* . If the calculation can't be computed, null will be returned. See detailed explanation on top of the
|
|
277
323
|
* page.
|
|
278
324
|
* @see #NAUTICAL_ZENITH
|
|
@@ -283,7 +329,7 @@ export class NOAACalculator {
|
|
|
283
329
|
/**
|
|
284
330
|
* A method that returns the end of astronomical twilight using a zenith of {@link #ASTRONOMICAL_ZENITH 108°}.
|
|
285
331
|
*
|
|
286
|
-
* @return
|
|
332
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the end of astronomical twilight using a zenith of {@link #ASTRONOMICAL_ZENITH
|
|
287
333
|
* 108°}. If the calculation can't be computed, null will be returned. See detailed explanation on top
|
|
288
334
|
* of the page.
|
|
289
335
|
* @see #ASTRONOMICAL_ZENITH
|
|
@@ -297,11 +343,11 @@ export class NOAACalculator {
|
|
|
297
343
|
* after sunset with the intent of getting a rough "level of light" calculation, the sunrise or sunset time passed
|
|
298
344
|
* to this method should be sea level sunrise and sunset.
|
|
299
345
|
*
|
|
300
|
-
* @param time
|
|
346
|
+
* @param {Temporal.ZonedDateTime | null} time
|
|
301
347
|
* the start time
|
|
302
|
-
* @param offset
|
|
348
|
+
* @param {number} offset
|
|
303
349
|
* the offset in milliseconds to add to the time.
|
|
304
|
-
* @return
|
|
350
|
+
* @return {Temporal.ZonedDateTime | null} the `Date` with the offset in milliseconds added to it
|
|
305
351
|
*/
|
|
306
352
|
static getTimeOffset(time, offset) {
|
|
307
353
|
if (time === null || offset === Long_MIN_VALUE || Number.isNaN(offset)) {
|
|
@@ -314,12 +360,12 @@ export class NOAACalculator {
|
|
|
314
360
|
* {@link #getSunrise() sunrise}. Note that the degree offset is from the vertical, so for a calculation of 14°
|
|
315
361
|
* before sunrise, an offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a parameter.
|
|
316
362
|
*
|
|
317
|
-
* @param offsetZenith
|
|
363
|
+
* @param {number} offsetZenith
|
|
318
364
|
* the degrees before {@link #getSunrise()} to use in the calculation. For time after sunrise use
|
|
319
365
|
* negative numbers. Note that the degree offset is from the vertical, so for a calculation of 14°
|
|
320
366
|
* before sunrise, an offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a
|
|
321
367
|
* parameter.
|
|
322
|
-
* @return
|
|
368
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` of the offset after (or before) {@link #getSunrise()}. If the calculation
|
|
323
369
|
* can't be computed such as in the Arctic Circle where there is at least one day a year where the sun does
|
|
324
370
|
* not rise, and one where it does not set, a null will be returned. See detailed explanation on top of the
|
|
325
371
|
* page.
|
|
@@ -335,11 +381,11 @@ export class NOAACalculator {
|
|
|
335
381
|
* sunset}. Note that the degree offset is from the vertical, so for a calculation of 14° after sunset, an
|
|
336
382
|
* offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a parameter.
|
|
337
383
|
*
|
|
338
|
-
* @param offsetZenith
|
|
384
|
+
* @param {number} offsetZenith
|
|
339
385
|
* the degrees after {@link #getSunset()} to use in the calculation. For time before sunset use negative
|
|
340
386
|
* numbers. Note that the degree offset is from the vertical, so for a calculation of 14° after
|
|
341
387
|
* sunset, an offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a parameter.
|
|
342
|
-
* @return The
|
|
388
|
+
* @return {Temporal.ZonedDateTime | null} The `Date`of the offset after (or before) {@link #getSunset()}. If the calculation can't
|
|
343
389
|
* be computed such as in the Arctic Circle where there is at least one day a year where the sun does not
|
|
344
390
|
* rise, and one where it does not set, a null will be returned. See detailed explanation on top of the
|
|
345
391
|
* page.
|
|
@@ -350,27 +396,13 @@ export class NOAACalculator {
|
|
|
350
396
|
return null;
|
|
351
397
|
return this.getDateFromTime(sunset, false);
|
|
352
398
|
}
|
|
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
399
|
/**
|
|
368
400
|
* A method that returns the sunrise in UTC time without correction for time zone offset from GMT and without using
|
|
369
401
|
* daylight savings time.
|
|
370
402
|
*
|
|
371
|
-
* @param zenith
|
|
403
|
+
* @param {number} zenith
|
|
372
404
|
* 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
|
|
405
|
+
* @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
406
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
375
407
|
* not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
|
|
376
408
|
*/
|
|
@@ -383,9 +415,9 @@ export class NOAACalculator {
|
|
|
383
415
|
* light, something that is not affected by elevation. This method returns UTC sunrise calculated at sea level. This
|
|
384
416
|
* forms the base for dawn calculations that are calculated as a dip below the horizon before sunrise.
|
|
385
417
|
*
|
|
386
|
-
* @param zenith
|
|
418
|
+
* @param {number} zenith
|
|
387
419
|
* 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
|
|
420
|
+
* @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
421
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
390
422
|
* not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
|
|
391
423
|
* @see AstronomicalCalendar#getUTCSunrise
|
|
@@ -398,9 +430,9 @@ export class NOAACalculator {
|
|
|
398
430
|
* A method that returns the sunset in UTC time without correction for time zone offset from GMT and without using
|
|
399
431
|
* daylight savings time.
|
|
400
432
|
*
|
|
401
|
-
* @param zenith
|
|
433
|
+
* @param {number} zenith
|
|
402
434
|
* 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
|
|
435
|
+
* @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
436
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
405
437
|
* not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
|
|
406
438
|
* @see AstronomicalCalendar#getUTCSeaLevelSunset
|
|
@@ -415,9 +447,9 @@ export class NOAACalculator {
|
|
|
415
447
|
* at sea level. This forms the base for dusk calculations that are calculated as a dip below the horizon after
|
|
416
448
|
* sunset.
|
|
417
449
|
*
|
|
418
|
-
* @param zenith
|
|
450
|
+
* @param {number} zenith
|
|
419
451
|
* 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
|
|
452
|
+
* @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
453
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
422
454
|
* not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
|
|
423
455
|
* @see AstronomicalCalendar#getUTCSunset
|
|
@@ -456,9 +488,9 @@ export class NOAACalculator {
|
|
|
456
488
|
* elevationAdjustment = 0.0347 * Math.sqrt(elevationMeters);
|
|
457
489
|
* </pre>
|
|
458
490
|
*
|
|
459
|
-
* @param elevation
|
|
491
|
+
* @param {number} elevation
|
|
460
492
|
* elevation in Meters.
|
|
461
|
-
* @return the adjusted zenith
|
|
493
|
+
* @return {number} the adjusted zenith
|
|
462
494
|
*/
|
|
463
495
|
getElevationAdjustment(elevation) {
|
|
464
496
|
// double elevationAdjustment = 0.0347 * Math.sqrt(elevation);
|
|
@@ -485,15 +517,15 @@ export class NOAACalculator {
|
|
|
485
517
|
* {@link ZmanimCalendar#ZENITH_16_POINT_1 16.1°} dip used in
|
|
486
518
|
* {@link ComplexZmanimCalendar#getAlos16Point1Degrees()}.
|
|
487
519
|
*
|
|
488
|
-
* @param zenith
|
|
520
|
+
* @param {number} zenith
|
|
489
521
|
* the azimuth below the vertical zenith of 90°. For sunset typically the {@link #adjustZenith
|
|
490
522
|
* zenith} used for the calculation uses geometric zenith of 90° and {@link #adjustZenith adjusts}
|
|
491
523
|
* this slightly to account for solar refraction and the sun's radius. Another example would be
|
|
492
524
|
* {@link AstronomicalCalendar#getEndNauticalTwilight()} that passes
|
|
493
525
|
* {@link AstronomicalCalendar#NAUTICAL_ZENITH} to this method.
|
|
494
|
-
* @param elevation
|
|
526
|
+
* @param {number} elevation
|
|
495
527
|
* elevation in Meters.
|
|
496
|
-
* @return The zenith adjusted to include the {@link #getSolarRadius sun's radius}, {@link #getRefraction
|
|
528
|
+
* @return {number} The zenith adjusted to include the {@link #getSolarRadius sun's radius}, {@link #getRefraction
|
|
497
529
|
* refraction} and {@link #getElevationAdjustment elevation} adjustment. This will only be adjusted for
|
|
498
530
|
* sunrise and sunset (if the zenith == 90°)
|
|
499
531
|
* @see #getElevationAdjustment(double)
|
|
@@ -552,21 +584,21 @@ export class NOAACalculator {
|
|
|
552
584
|
* non-elevation adjusted temporal hour by passing in {@link #getSeaLevelSunrise() sea level sunrise} and
|
|
553
585
|
* {@link #getSeaLevelSunset() sea level sunset} as parameters.
|
|
554
586
|
*
|
|
555
|
-
* @param
|
|
587
|
+
* @param {Temporal.ZonedDateTime | null} startOfDay
|
|
556
588
|
* The start of the day.
|
|
557
|
-
* @param endOfDay
|
|
589
|
+
* @param {Temporal.ZonedDateTime | null} endOfDay
|
|
558
590
|
* The end of the day.
|
|
559
591
|
*
|
|
560
|
-
* @return the <code>long</code> millisecond length of the temporal hour. If the calculation can't be computed a
|
|
592
|
+
* @return {number} the <code>long</code> millisecond length of the temporal hour. If the calculation can't be computed a
|
|
561
593
|
* {@link Long#MIN_VALUE} will be returned. See detailed explanation on top of the page.
|
|
562
594
|
*
|
|
563
595
|
* @see #getTemporalHour()
|
|
564
596
|
*/
|
|
565
|
-
getTemporalHour(
|
|
566
|
-
if (
|
|
597
|
+
getTemporalHour(startOfDay = this.getSeaLevelSunrise(), endOfDay = this.getSeaLevelSunset()) {
|
|
598
|
+
if (startOfDay === null || endOfDay === null) {
|
|
567
599
|
return Long_MIN_VALUE;
|
|
568
600
|
}
|
|
569
|
-
const delta = endOfDay.epochMilliseconds -
|
|
601
|
+
const delta = endOfDay.epochMilliseconds - startOfDay.epochMilliseconds;
|
|
570
602
|
return Math.floor(delta / 12);
|
|
571
603
|
}
|
|
572
604
|
/**
|
|
@@ -576,14 +608,14 @@ export class NOAACalculator {
|
|
|
576
608
|
* calculated as halfway between the sunrise and sunset passed to this method. This time can be slightly off the
|
|
577
609
|
* real transit time due to changes in declination (the lengthening or shortening day).
|
|
578
610
|
*
|
|
579
|
-
* @param startOfDay
|
|
611
|
+
* @param {Temporal.ZonedDateTime | null} startOfDay
|
|
580
612
|
* the start of day for calculating the sun's transit. This can be sea level sunrise, visual sunrise (or
|
|
581
613
|
* any arbitrary start of day) passed to this method.
|
|
582
|
-
* @param endOfDay
|
|
614
|
+
* @param {Temporal.ZonedDateTime | null} endOfDay
|
|
583
615
|
* the end of day for calculating the sun's transit. This can be sea level sunset, visual sunset (or any
|
|
584
616
|
* arbitrary end of day) passed to this method.
|
|
585
617
|
*
|
|
586
|
-
* @return
|
|
618
|
+
* @return {Temporal.ZonedDateTime | null} The `Date` representing Sun's transit. If the calculation can't be computed such as in the
|
|
587
619
|
* Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
|
|
588
620
|
* not set, null will be returned. See detailed explanation on top of the page.
|
|
589
621
|
*/
|
|
@@ -592,13 +624,13 @@ export class NOAACalculator {
|
|
|
592
624
|
return NOAACalculator.getTimeOffset(startOfDay, temporalHour * 6);
|
|
593
625
|
}
|
|
594
626
|
/**
|
|
595
|
-
* A method that returns a
|
|
627
|
+
* A method that returns a `Date` from the time passed in as a parameter.
|
|
596
628
|
* @protected
|
|
597
|
-
* @param time
|
|
598
|
-
* The time to be set as the time for the
|
|
629
|
+
* @param {number} time
|
|
630
|
+
* The time to be set as the time for the `Date`. The time expected is in the format: 18.75
|
|
599
631
|
* for 6:45:00 PM.
|
|
600
|
-
* @param isSunrise true if the time is sunrise, and false if it is sunset
|
|
601
|
-
* @return The Date.
|
|
632
|
+
* @param {boolean} isSunrise true if the time is sunrise, and false if it is sunset
|
|
633
|
+
* @return {Temporal.ZonedDateTime | null} The Date.
|
|
602
634
|
*/
|
|
603
635
|
getDateFromTime(time, isSunrise) {
|
|
604
636
|
if (Number.isNaN(time)) {
|
|
@@ -633,7 +665,7 @@ export class NOAACalculator {
|
|
|
633
665
|
/**
|
|
634
666
|
* Return the <a href="http://en.wikipedia.org/wiki/Julian_day">Julian day</a> from a Java Calendar
|
|
635
667
|
* @private
|
|
636
|
-
* @param
|
|
668
|
+
* @param {Temporal.ZonedDateTime} date
|
|
637
669
|
* The Java Calendar
|
|
638
670
|
* @return the Julian day corresponding to the date Note: Number is returned for start of day. Fractional days
|
|
639
671
|
* should be added later.
|
|
@@ -829,11 +861,11 @@ export class NOAACalculator {
|
|
|
829
861
|
* Return the <a href="http://en.wikipedia.org/wiki/Hour_angle">hour angle</a> of the sun at sunrise for the
|
|
830
862
|
* latitude.
|
|
831
863
|
* @private
|
|
832
|
-
* @param lat
|
|
864
|
+
* @param {number} lat
|
|
833
865
|
* , the latitude of observer in degrees
|
|
834
866
|
* @param solarDec
|
|
835
867
|
* the declination angle of sun in degrees
|
|
836
|
-
* @param zenith
|
|
868
|
+
* @param {number} zenith
|
|
837
869
|
* the zenith
|
|
838
870
|
* @return hour angle of sunrise in radians
|
|
839
871
|
*/
|
|
@@ -849,11 +881,11 @@ export class NOAACalculator {
|
|
|
849
881
|
* latitude. TODO: use - {@link #getSunHourAngleAtSunrise(double, double, double)} implementation to avoid
|
|
850
882
|
* duplication of code.
|
|
851
883
|
* @private
|
|
852
|
-
* @param lat
|
|
884
|
+
* @param {number} lat
|
|
853
885
|
* the latitude of observer in degrees
|
|
854
886
|
* @param solarDec
|
|
855
887
|
* the declination angle of sun in degrees
|
|
856
|
-
* @param zenith
|
|
888
|
+
* @param {number} zenith
|
|
857
889
|
* the zenith
|
|
858
890
|
* @return the hour angle of sunset in radians
|
|
859
891
|
*/
|
|
@@ -870,13 +902,13 @@ export class NOAACalculator {
|
|
|
870
902
|
* horizontal coordinate system at the given location at the given time. Can be negative if the sun is below the
|
|
871
903
|
* horizon. Not corrected for altitude.
|
|
872
904
|
*
|
|
873
|
-
* @param
|
|
905
|
+
* @param {Temporal.ZonedDateTime} date
|
|
874
906
|
* time of calculation
|
|
875
|
-
* @param lat
|
|
907
|
+
* @param {number} lat
|
|
876
908
|
* latitude of location for calculation
|
|
877
|
-
* @param lon
|
|
909
|
+
* @param {number} lon
|
|
878
910
|
* longitude of location for calculation
|
|
879
|
-
* @return solar elevation in degrees - horizon is 0 degrees, civil twilight is -6 degrees
|
|
911
|
+
* @return {number} solar elevation in degrees - horizon is 0 degrees, civil twilight is -6 degrees
|
|
880
912
|
*/
|
|
881
913
|
static getSolarElevation(date, lat, lon) {
|
|
882
914
|
const julianDay = NOAACalculator.getJulianDay(date.toPlainDate());
|
|
@@ -896,13 +928,13 @@ export class NOAACalculator {
|
|
|
896
928
|
* horizontal coordinate system at the given location at the given time. Not corrected for altitude. True south is 0
|
|
897
929
|
* degrees.
|
|
898
930
|
*
|
|
899
|
-
* @param
|
|
931
|
+
* @param {Temporal.ZonedDateTime} date
|
|
900
932
|
* time of calculation
|
|
901
|
-
* @param latitude
|
|
933
|
+
* @param {number} latitude
|
|
902
934
|
* latitude of location for calculation
|
|
903
|
-
* @param lon
|
|
935
|
+
* @param {number} lon
|
|
904
936
|
* longitude of location for calculation
|
|
905
|
-
* @return
|
|
937
|
+
* @return {number}
|
|
906
938
|
*/
|
|
907
939
|
static getSolarAzimuth(date, latitude, lon) {
|
|
908
940
|
const julianDay = NOAACalculator.getJulianDay(date.toPlainDate());
|
|
@@ -924,11 +956,11 @@ export class NOAACalculator {
|
|
|
924
956
|
* @private
|
|
925
957
|
* @param julianDay
|
|
926
958
|
* the Julian day
|
|
927
|
-
* @param latitude
|
|
959
|
+
* @param {number} latitude
|
|
928
960
|
* the latitude of observer in degrees
|
|
929
|
-
* @param longitude
|
|
961
|
+
* @param {number} longitude
|
|
930
962
|
* the longitude of observer in degrees
|
|
931
|
-
* @param zenith
|
|
963
|
+
* @param {number} zenith
|
|
932
964
|
* the zenith
|
|
933
965
|
* @return the time in minutes from zero UTC
|
|
934
966
|
*/
|
|
@@ -963,7 +995,7 @@ export class NOAACalculator {
|
|
|
963
995
|
* @private
|
|
964
996
|
* @param julianCenturies
|
|
965
997
|
* the number of Julian centuries since J2000.0
|
|
966
|
-
* @param longitude
|
|
998
|
+
* @param {number} longitude
|
|
967
999
|
* the longitude of observer in degrees
|
|
968
1000
|
* @return the time in minutes from zero UTC
|
|
969
1001
|
*/
|
|
@@ -985,11 +1017,11 @@ export class NOAACalculator {
|
|
|
985
1017
|
* @private
|
|
986
1018
|
* @param julianDay
|
|
987
1019
|
* the Julian day
|
|
988
|
-
* @param latitude
|
|
1020
|
+
* @param {number} latitude
|
|
989
1021
|
* the latitude of observer in degrees
|
|
990
|
-
* @param longitude
|
|
1022
|
+
* @param {number} longitude
|
|
991
1023
|
* : longitude of observer in degrees
|
|
992
|
-
* @param zenith
|
|
1024
|
+
* @param {number} zenith
|
|
993
1025
|
* the zenith
|
|
994
1026
|
* @return the time in minutes from zero Universal Coordinated Time (UTC)
|
|
995
1027
|
*/
|