@hebcal/noaa 0.8.7 → 0.8.9
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/dist/{cjs/index.js → index.cjs} +3 -25
- package/dist/index.d.ts +17 -1
- package/dist/{esm/index.js → index.js} +79 -79
- package/package.json +17 -9
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NOAACalculator = exports.GeoLocation = void 0;
|
|
4
|
-
|
|
5
|
-
if (typeof Temporal !== 'function') {
|
|
6
|
-
await Promise.resolve().then(() => require('temporal-polyfill/global'));
|
|
7
|
-
}
|
|
8
|
-
})();
|
|
4
|
+
const temporal_polyfill_1 = require("temporal-polyfill");
|
|
9
5
|
/**
|
|
10
6
|
* java.lang.Math.toRadians
|
|
11
7
|
* @private
|
|
@@ -33,24 +29,6 @@ const Long_MIN_VALUE = NaN;
|
|
|
33
29
|
* @version 1.1
|
|
34
30
|
*/
|
|
35
31
|
class GeoLocation {
|
|
36
|
-
/**
|
|
37
|
-
* GeoLocation constructor with parameters for all required fields.
|
|
38
|
-
*
|
|
39
|
-
* @param {string} name
|
|
40
|
-
* The location name for display use such as "Lakewood, NJ"
|
|
41
|
-
* @param {number} latitude
|
|
42
|
-
* the latitude in a double format such as 40.095965 for Lakewood, NJ.
|
|
43
|
-
* <b>Note: </b> For latitudes south of the equator, a negative value should be used.
|
|
44
|
-
* @param {number} longitude
|
|
45
|
-
* double the longitude in a double format such as -74.222130 for Lakewood, NJ.
|
|
46
|
-
* <b>Note: </b> For longitudes west of the <a href="http://en.wikipedia.org/wiki/Prime_Meridian">Prime
|
|
47
|
-
* Meridian </a> (Greenwich), a negative value should be used.
|
|
48
|
-
* @param {number} elevation
|
|
49
|
-
* the elevation above sea level in Meters. Elevation is not used in most algorithms used for calculating
|
|
50
|
-
* sunrise and set.
|
|
51
|
-
* @param {string} timeZoneId
|
|
52
|
-
* the <code>TimeZone</code> for the location.
|
|
53
|
-
*/
|
|
54
32
|
constructor(name, latitude, longitude, elevationOrTimeZoneId, timeZoneId) {
|
|
55
33
|
/**
|
|
56
34
|
* @private
|
|
@@ -143,7 +121,7 @@ class GeoLocation {
|
|
|
143
121
|
* AstronomicalCalendar to output times in the expected offset. This situation will arise if the
|
|
144
122
|
* AstronomicalCalendar is ever {@link AstronomicalCalendar#clone() cloned}.
|
|
145
123
|
*
|
|
146
|
-
* @param {string}
|
|
124
|
+
* @param {string} timeZoneId
|
|
147
125
|
* The timeZone to set.
|
|
148
126
|
*/
|
|
149
127
|
setTimeZone(timeZoneId) {
|
|
@@ -666,7 +644,7 @@ class NOAACalculator {
|
|
|
666
644
|
return cal
|
|
667
645
|
.toZonedDateTime({
|
|
668
646
|
timeZone: 'UTC',
|
|
669
|
-
plainTime: new Temporal.PlainTime(hours, minutes, seconds, Math.trunc(calculatedTime * 1000)),
|
|
647
|
+
plainTime: new temporal_polyfill_1.Temporal.PlainTime(hours, minutes, seconds, Math.trunc(calculatedTime * 1000)),
|
|
670
648
|
})
|
|
671
649
|
.withTimeZone(this.geoLocation.getTimeZone());
|
|
672
650
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Temporal } from 'temporal-polyfill';
|
|
1
2
|
/**
|
|
2
3
|
* A class that contains location information such as latitude and longitude required for astronomical calculations. The
|
|
3
4
|
* elevation field may not be used by some calculation engines and would be ignored if set. Check the documentation for
|
|
@@ -27,6 +28,21 @@ export declare class GeoLocation {
|
|
|
27
28
|
* the <code>TimeZone</code> for the location.
|
|
28
29
|
*/
|
|
29
30
|
constructor(name: string | null, latitude: number, longitude: number, elevation: number, timeZoneId?: string);
|
|
31
|
+
/**
|
|
32
|
+
* GeoLocation constructor with parameters for all required fields.
|
|
33
|
+
*
|
|
34
|
+
* @param {string} name
|
|
35
|
+
* The location name for display use such as "Lakewood, NJ"
|
|
36
|
+
* @param {number} latitude
|
|
37
|
+
* the latitude in a double format such as 40.095965 for Lakewood, NJ.
|
|
38
|
+
* <b>Note: </b> For latitudes south of the equator, a negative value should be used.
|
|
39
|
+
* @param {number} longitude
|
|
40
|
+
* double the longitude in a double format such as -74.222130 for Lakewood, NJ.
|
|
41
|
+
* <b>Note: </b> For longitudes west of the <a href="http://en.wikipedia.org/wiki/Prime_Meridian">Prime
|
|
42
|
+
* Meridian </a> (Greenwich), a negative value should be used.
|
|
43
|
+
* @param {string} timeZoneId
|
|
44
|
+
* the <code>TimeZone</code> for the location.
|
|
45
|
+
*/
|
|
30
46
|
constructor(name: string | null, latitude: number, longitude: number, timeZoneId: string);
|
|
31
47
|
/**
|
|
32
48
|
* @private
|
|
@@ -104,7 +120,7 @@ export declare class GeoLocation {
|
|
|
104
120
|
* AstronomicalCalendar to output times in the expected offset. This situation will arise if the
|
|
105
121
|
* AstronomicalCalendar is ever {@link AstronomicalCalendar#clone() cloned}.
|
|
106
122
|
*
|
|
107
|
-
* @param {string}
|
|
123
|
+
* @param {string} timeZoneId
|
|
108
124
|
* The timeZone to set.
|
|
109
125
|
*/
|
|
110
126
|
setTimeZone(timeZoneId: string): void;
|
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.NOAACalculator = exports.GeoLocation = void 0;
|
|
13
|
-
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
-
if (typeof Temporal !== 'function') {
|
|
15
|
-
yield import('temporal-polyfill/global');
|
|
16
|
-
}
|
|
17
|
-
}))();
|
|
1
|
+
import { Temporal } from 'temporal-polyfill';
|
|
18
2
|
/**
|
|
19
3
|
* java.lang.Math.toRadians
|
|
20
4
|
* @private
|
|
@@ -41,32 +25,8 @@ const Long_MIN_VALUE = NaN;
|
|
|
41
25
|
* @author © Eliyahu Hershfeld 2004 - 2016
|
|
42
26
|
* @version 1.1
|
|
43
27
|
*/
|
|
44
|
-
class GeoLocation {
|
|
45
|
-
/**
|
|
46
|
-
* GeoLocation constructor with parameters for all required fields.
|
|
47
|
-
*
|
|
48
|
-
* @param {string} name
|
|
49
|
-
* The location name for display use such as "Lakewood, NJ"
|
|
50
|
-
* @param {number} latitude
|
|
51
|
-
* the latitude in a double format such as 40.095965 for Lakewood, NJ.
|
|
52
|
-
* <b>Note: </b> For latitudes south of the equator, a negative value should be used.
|
|
53
|
-
* @param {number} longitude
|
|
54
|
-
* double the longitude in a double format such as -74.222130 for Lakewood, NJ.
|
|
55
|
-
* <b>Note: </b> For longitudes west of the <a href="http://en.wikipedia.org/wiki/Prime_Meridian">Prime
|
|
56
|
-
* Meridian </a> (Greenwich), a negative value should be used.
|
|
57
|
-
* @param {number} elevation
|
|
58
|
-
* the elevation above sea level in Meters. Elevation is not used in most algorithms used for calculating
|
|
59
|
-
* sunrise and set.
|
|
60
|
-
* @param {string} timeZoneId
|
|
61
|
-
* the <code>TimeZone</code> for the location.
|
|
62
|
-
*/
|
|
28
|
+
export class GeoLocation {
|
|
63
29
|
constructor(name, latitude, longitude, elevationOrTimeZoneId, timeZoneId) {
|
|
64
|
-
/**
|
|
65
|
-
* @private
|
|
66
|
-
* @see #getLocationName()
|
|
67
|
-
* @see #setLocationName(String)
|
|
68
|
-
*/
|
|
69
|
-
this.locationName = null;
|
|
70
30
|
let elevation = 0;
|
|
71
31
|
if (timeZoneId) {
|
|
72
32
|
elevation = elevationOrTimeZoneId;
|
|
@@ -80,6 +40,38 @@ class GeoLocation {
|
|
|
80
40
|
this.setElevation(elevation);
|
|
81
41
|
this.setTimeZone(timeZoneId);
|
|
82
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* @private
|
|
45
|
+
* @see #getLatitude()
|
|
46
|
+
* @see #setLatitude(double)
|
|
47
|
+
* @see #setLatitude(int, int, double, String)
|
|
48
|
+
*/
|
|
49
|
+
latitude;
|
|
50
|
+
/**
|
|
51
|
+
* @private
|
|
52
|
+
* @see #getLongitude()
|
|
53
|
+
* @see #setLongitude(double)
|
|
54
|
+
* @see #setLongitude(int, int, double, String)
|
|
55
|
+
*/
|
|
56
|
+
longitude;
|
|
57
|
+
/**
|
|
58
|
+
* @private
|
|
59
|
+
* @see #getLocationName()
|
|
60
|
+
* @see #setLocationName(String)
|
|
61
|
+
*/
|
|
62
|
+
locationName = null;
|
|
63
|
+
/**
|
|
64
|
+
* @private
|
|
65
|
+
* @see #getTimeZone()
|
|
66
|
+
* @see #setTimeZone(TimeZone)
|
|
67
|
+
*/
|
|
68
|
+
timeZoneId;
|
|
69
|
+
/**
|
|
70
|
+
* @private
|
|
71
|
+
* @see #getElevation()
|
|
72
|
+
* @see #setElevation(double)
|
|
73
|
+
*/
|
|
74
|
+
elevation;
|
|
83
75
|
/**
|
|
84
76
|
* Method to get the elevation in Meters.
|
|
85
77
|
*
|
|
@@ -152,14 +144,13 @@ class GeoLocation {
|
|
|
152
144
|
* AstronomicalCalendar to output times in the expected offset. This situation will arise if the
|
|
153
145
|
* AstronomicalCalendar is ever {@link AstronomicalCalendar#clone() cloned}.
|
|
154
146
|
*
|
|
155
|
-
* @param {string}
|
|
147
|
+
* @param {string} timeZoneId
|
|
156
148
|
* The timeZone to set.
|
|
157
149
|
*/
|
|
158
150
|
setTimeZone(timeZoneId) {
|
|
159
151
|
this.timeZoneId = timeZoneId;
|
|
160
152
|
}
|
|
161
153
|
}
|
|
162
|
-
exports.GeoLocation = GeoLocation;
|
|
163
154
|
/**
|
|
164
155
|
* The commonly used average solar refraction. Calendrical Calculations lists a more accurate global average of
|
|
165
156
|
* 34.478885263888294
|
|
@@ -191,7 +182,7 @@ const earthRadius = 6356.9; // in KM
|
|
|
191
182
|
*
|
|
192
183
|
* @author © Eliyahu Hershfeld 2011 - 2019
|
|
193
184
|
*/
|
|
194
|
-
class NOAACalculator {
|
|
185
|
+
export class NOAACalculator {
|
|
195
186
|
/**
|
|
196
187
|
* A constructor that takes in <a href="http://en.wikipedia.org/wiki/Geolocation">geolocation</a> information as a
|
|
197
188
|
* parameter. The default {@link AstronomicalCalculator#getDefault() AstronomicalCalculator} used for solar
|
|
@@ -207,6 +198,39 @@ class NOAACalculator {
|
|
|
207
198
|
this.date = date;
|
|
208
199
|
this.geoLocation = geoLocation;
|
|
209
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* The zenith of astronomical sunrise and sunset. The sun is 90° from the vertical 0°
|
|
203
|
+
* @private
|
|
204
|
+
*/
|
|
205
|
+
static GEOMETRIC_ZENITH = 90;
|
|
206
|
+
/**
|
|
207
|
+
* Default value for Sun's zenith and true rise/set Zenith (used in this class and subclasses) is the angle that the
|
|
208
|
+
* center of the Sun makes to a line perpendicular to the Earth's surface. If the Sun were a point and the Earth
|
|
209
|
+
* were without an atmosphere, true sunset and sunrise would correspond to a 90° zenith. Because the Sun is not
|
|
210
|
+
* a point, and because the atmosphere refracts light, this 90° zenith does not, in fact, correspond to true
|
|
211
|
+
* sunset or sunrise, instead the center of the Sun's disk must lie just below the horizon for the upper edge to be
|
|
212
|
+
* obscured. This means that a zenith of just above 90° must be used. The Sun subtends an angle of 16 minutes of
|
|
213
|
+
* arc (this can be changed via the {@link #setSunRadius(double)} method , and atmospheric refraction accounts for
|
|
214
|
+
* 34 minutes or so (this can be changed via the {@link #setRefraction(double)} method), giving a total of 50
|
|
215
|
+
* arcminutes. The total value for ZENITH is 90+(5/6) or 90.8333333° for true sunrise/sunset.
|
|
216
|
+
*/
|
|
217
|
+
// const ZENITH: number = GEOMETRIC_ZENITH + 5.0 / 6.0;
|
|
218
|
+
/** Sun's zenith at civil twilight (96°). */
|
|
219
|
+
static CIVIL_ZENITH = 96;
|
|
220
|
+
/** Sun's zenith at nautical twilight (102°). */
|
|
221
|
+
static NAUTICAL_ZENITH = 102;
|
|
222
|
+
/** Sun's zenith at astronomical twilight (108°). */
|
|
223
|
+
static ASTRONOMICAL_ZENITH = 108;
|
|
224
|
+
/**
|
|
225
|
+
* The Java Calendar encapsulated by this class to track the current date used by the class
|
|
226
|
+
* @private
|
|
227
|
+
*/
|
|
228
|
+
date;
|
|
229
|
+
/**
|
|
230
|
+
* the {@link GeoLocation} used for calculations.
|
|
231
|
+
* @private
|
|
232
|
+
*/
|
|
233
|
+
geoLocation;
|
|
210
234
|
/**
|
|
211
235
|
* The getSunrise method Returns a `Date` representing the
|
|
212
236
|
* {@link AstronomicalCalculator#getElevationAdjustment(double) elevation adjusted} sunrise time. The zenith used
|
|
@@ -557,6 +581,16 @@ class NOAACalculator {
|
|
|
557
581
|
}
|
|
558
582
|
return adjustedZenith;
|
|
559
583
|
}
|
|
584
|
+
/**
|
|
585
|
+
* The <a href="http://en.wikipedia.org/wiki/Julian_day">Julian day</a> of January 1, 2000
|
|
586
|
+
* @private
|
|
587
|
+
*/
|
|
588
|
+
static JULIAN_DAY_JAN_1_2000 = 2451545;
|
|
589
|
+
/**
|
|
590
|
+
* Julian days per century
|
|
591
|
+
* @private
|
|
592
|
+
*/
|
|
593
|
+
static JULIAN_DAYS_PER_CENTURY = 36525;
|
|
560
594
|
/**
|
|
561
595
|
* @see AstronomicalCalculator#getUTCSunrise(Calendar, GeoLocation, double, boolean)
|
|
562
596
|
*/
|
|
@@ -1067,37 +1101,3 @@ class NOAACalculator {
|
|
|
1067
1101
|
return timeUTC;
|
|
1068
1102
|
}
|
|
1069
1103
|
}
|
|
1070
|
-
exports.NOAACalculator = NOAACalculator;
|
|
1071
|
-
/**
|
|
1072
|
-
* The zenith of astronomical sunrise and sunset. The sun is 90° from the vertical 0°
|
|
1073
|
-
* @private
|
|
1074
|
-
*/
|
|
1075
|
-
NOAACalculator.GEOMETRIC_ZENITH = 90;
|
|
1076
|
-
/**
|
|
1077
|
-
* Default value for Sun's zenith and true rise/set Zenith (used in this class and subclasses) is the angle that the
|
|
1078
|
-
* center of the Sun makes to a line perpendicular to the Earth's surface. If the Sun were a point and the Earth
|
|
1079
|
-
* were without an atmosphere, true sunset and sunrise would correspond to a 90° zenith. Because the Sun is not
|
|
1080
|
-
* a point, and because the atmosphere refracts light, this 90° zenith does not, in fact, correspond to true
|
|
1081
|
-
* sunset or sunrise, instead the center of the Sun's disk must lie just below the horizon for the upper edge to be
|
|
1082
|
-
* obscured. This means that a zenith of just above 90° must be used. The Sun subtends an angle of 16 minutes of
|
|
1083
|
-
* arc (this can be changed via the {@link #setSunRadius(double)} method , and atmospheric refraction accounts for
|
|
1084
|
-
* 34 minutes or so (this can be changed via the {@link #setRefraction(double)} method), giving a total of 50
|
|
1085
|
-
* arcminutes. The total value for ZENITH is 90+(5/6) or 90.8333333° for true sunrise/sunset.
|
|
1086
|
-
*/
|
|
1087
|
-
// const ZENITH: number = GEOMETRIC_ZENITH + 5.0 / 6.0;
|
|
1088
|
-
/** Sun's zenith at civil twilight (96°). */
|
|
1089
|
-
NOAACalculator.CIVIL_ZENITH = 96;
|
|
1090
|
-
/** Sun's zenith at nautical twilight (102°). */
|
|
1091
|
-
NOAACalculator.NAUTICAL_ZENITH = 102;
|
|
1092
|
-
/** Sun's zenith at astronomical twilight (108°). */
|
|
1093
|
-
NOAACalculator.ASTRONOMICAL_ZENITH = 108;
|
|
1094
|
-
/**
|
|
1095
|
-
* The <a href="http://en.wikipedia.org/wiki/Julian_day">Julian day</a> of January 1, 2000
|
|
1096
|
-
* @private
|
|
1097
|
-
*/
|
|
1098
|
-
NOAACalculator.JULIAN_DAY_JAN_1_2000 = 2451545;
|
|
1099
|
-
/**
|
|
1100
|
-
* Julian days per century
|
|
1101
|
-
* @private
|
|
1102
|
-
*/
|
|
1103
|
-
NOAACalculator.JULIAN_DAYS_PER_CENTURY = 36525;
|
package/package.json
CHANGED
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hebcal/noaa",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.9",
|
|
4
4
|
"description": "sunrise and sunset via NOAA algorithm with elevation, based on KosherJava",
|
|
5
5
|
"author": "Michael J. Radwin (https://github.com/mjradwin)",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"BehindTheMath (https://github.com/BehindTheMath)",
|
|
8
|
-
"Eliyahu Hershfeld (https://github.com/KosherJava)"
|
|
8
|
+
"Eliyahu Hershfeld (https://github.com/KosherJava)",
|
|
9
|
+
"Benny Powers (https://github.com/bennypowers)"
|
|
9
10
|
],
|
|
10
11
|
"license": "LGPL-3.0",
|
|
11
12
|
"repository": {
|
|
12
13
|
"type": "git",
|
|
13
14
|
"url": "git+https://github.com/hebcal/noaa.git"
|
|
14
15
|
},
|
|
15
|
-
"main": "dist/
|
|
16
|
-
"module": "dist/
|
|
16
|
+
"main": "dist/index.cjs",
|
|
17
|
+
"module": "dist/index.js",
|
|
17
18
|
"typings": "dist/index.d.ts",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"require": "./dist/index.cjs",
|
|
23
|
+
"types": "./dist/index.d.ts"
|
|
24
|
+
},
|
|
18
25
|
"scripts": {
|
|
19
26
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
20
|
-
"build": "npm run build:
|
|
21
|
-
"build:cjs": "tsc",
|
|
22
|
-
"build:es6": "tsc
|
|
23
|
-
"build:types": "tsc -p ./tsconfig-types.json",
|
|
27
|
+
"build": "npm run build:cjs && mv dist/index.js dist/index.cjs && npm run build:es6",
|
|
28
|
+
"build:cjs": "tsc -p ./tsconfig-cjs.json",
|
|
29
|
+
"build:es6": "tsc",
|
|
24
30
|
"lint": "gts lint",
|
|
25
31
|
"clean": "gts clean",
|
|
26
32
|
"compile": "tsc",
|
|
@@ -42,7 +48,9 @@
|
|
|
42
48
|
"devDependencies": {
|
|
43
49
|
"@types/node": "20.10.0",
|
|
44
50
|
"gts": "^5.2.0",
|
|
45
|
-
"temporal-polyfill": "^0.1.1",
|
|
46
51
|
"typescript": "^5.3.2"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"temporal-polyfill": "^0.1.1"
|
|
47
55
|
}
|
|
48
56
|
}
|