neaps 0.6.1 → 0.7.0
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/index.cjs +3 -87
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -371
- package/dist/index.d.ts +9 -371
- package/dist/index.js +2 -85
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -2,8 +2,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
let _neaps_tide_database = require("@neaps/tide-database");
|
|
3
3
|
let _neaps_tide_predictor = require("@neaps/tide-predictor");
|
|
4
4
|
//#region src/index.ts
|
|
5
|
-
const feetPerMeter = 3.2808399;
|
|
6
|
-
const defaultUnits = "meters";
|
|
7
5
|
/**
|
|
8
6
|
* Get extremes prediction using the nearest station to the given position.
|
|
9
7
|
*
|
|
@@ -40,14 +38,14 @@ function getWaterLevelAtTime(options) {
|
|
|
40
38
|
function nearestStation(options) {
|
|
41
39
|
const data = (0, _neaps_tide_database.nearest)(options);
|
|
42
40
|
if (!data) throw new Error(`No stations found with options: ${JSON.stringify(options)}`);
|
|
43
|
-
return useStation(...data);
|
|
41
|
+
return (0, _neaps_tide_predictor.useStation)(...data);
|
|
44
42
|
}
|
|
45
43
|
/**
|
|
46
44
|
* Find stations near the given position.
|
|
47
45
|
* @param limit Maximum number of stations to return (default: 10)
|
|
48
46
|
*/
|
|
49
47
|
function stationsNear(options) {
|
|
50
|
-
return (0, _neaps_tide_database.near)(options).map(([station, distance]) => useStation(station, distance));
|
|
48
|
+
return (0, _neaps_tide_database.near)(options).map(([station, distance]) => (0, _neaps_tide_predictor.useStation)(station, distance));
|
|
51
49
|
}
|
|
52
50
|
/**
|
|
53
51
|
* Find a specific station by its ID or source ID.
|
|
@@ -60,88 +58,7 @@ function findStation(query) {
|
|
|
60
58
|
if (found) break;
|
|
61
59
|
}
|
|
62
60
|
if (!found) throw new Error(`Station not found: ${query}`);
|
|
63
|
-
return useStation(found);
|
|
64
|
-
}
|
|
65
|
-
function useStation(station, distance) {
|
|
66
|
-
let reference = station;
|
|
67
|
-
if (station.type === "subordinate" && station.offsets?.reference) reference = findStation(station.offsets?.reference);
|
|
68
|
-
const { datums, harmonic_constituents } = reference;
|
|
69
|
-
const defaultDatum = station.chart_datum in datums ? station.chart_datum : void 0;
|
|
70
|
-
function getPredictor({ datum = defaultDatum, nodeCorrections } = {}) {
|
|
71
|
-
let offset = 0;
|
|
72
|
-
if (datum) {
|
|
73
|
-
const datumOffset = datums?.[datum];
|
|
74
|
-
const mslOffset = datums?.["MSL"];
|
|
75
|
-
if (typeof datumOffset !== "number") throw new Error(`Station ${station.id} missing ${datum} datum. Available datums: ${Object.keys(datums).join(", ")}`);
|
|
76
|
-
if (typeof mslOffset !== "number") throw new Error(`Station ${station.id} missing MSL datum, so predictions can't be given in ${datum}.`);
|
|
77
|
-
offset = mslOffset - datumOffset;
|
|
78
|
-
}
|
|
79
|
-
return (0, _neaps_tide_predictor.createTidePredictor)(harmonic_constituents, {
|
|
80
|
-
offset,
|
|
81
|
-
nodeCorrections
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
...station,
|
|
86
|
-
distance,
|
|
87
|
-
datums,
|
|
88
|
-
harmonic_constituents,
|
|
89
|
-
defaultDatum,
|
|
90
|
-
getExtremesPrediction({ datum = defaultDatum, units = defaultUnits, nodeCorrections, ...options }) {
|
|
91
|
-
return {
|
|
92
|
-
datum,
|
|
93
|
-
units,
|
|
94
|
-
station,
|
|
95
|
-
distance,
|
|
96
|
-
extremes: getPredictor({
|
|
97
|
-
datum,
|
|
98
|
-
nodeCorrections
|
|
99
|
-
}).getExtremesPrediction({
|
|
100
|
-
...options,
|
|
101
|
-
offsets: station.offsets
|
|
102
|
-
}).map((e) => toPreferredUnits(e, units))
|
|
103
|
-
};
|
|
104
|
-
},
|
|
105
|
-
getTimelinePrediction({ datum = defaultDatum, units = defaultUnits, nodeCorrections, ...options }) {
|
|
106
|
-
return {
|
|
107
|
-
datum,
|
|
108
|
-
units,
|
|
109
|
-
station,
|
|
110
|
-
distance,
|
|
111
|
-
timeline: getPredictor({
|
|
112
|
-
datum,
|
|
113
|
-
nodeCorrections
|
|
114
|
-
}).getTimelinePrediction({
|
|
115
|
-
...options,
|
|
116
|
-
offsets: station.offsets
|
|
117
|
-
}).map((e) => toPreferredUnits(e, units))
|
|
118
|
-
};
|
|
119
|
-
},
|
|
120
|
-
getWaterLevelAtTime({ time, datum = defaultDatum, units = defaultUnits, nodeCorrections }) {
|
|
121
|
-
return {
|
|
122
|
-
datum,
|
|
123
|
-
units,
|
|
124
|
-
station,
|
|
125
|
-
distance,
|
|
126
|
-
...toPreferredUnits(getPredictor({
|
|
127
|
-
datum,
|
|
128
|
-
nodeCorrections
|
|
129
|
-
}).getWaterLevelAtTime({
|
|
130
|
-
time,
|
|
131
|
-
offsets: station.offsets
|
|
132
|
-
}), units)
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
function toPreferredUnits(prediction, units) {
|
|
138
|
-
let { level } = prediction;
|
|
139
|
-
if (units === "feet") level *= feetPerMeter;
|
|
140
|
-
else if (units !== "meters") throw new Error(`Unsupported units: ${units}`);
|
|
141
|
-
return {
|
|
142
|
-
...prediction,
|
|
143
|
-
level
|
|
144
|
-
};
|
|
61
|
+
return (0, _neaps_tide_predictor.useStation)(found);
|
|
145
62
|
}
|
|
146
63
|
//#endregion
|
|
147
64
|
exports.findStation = findStation;
|
|
@@ -150,6 +67,5 @@ exports.getTimelinePrediction = getTimelinePrediction;
|
|
|
150
67
|
exports.getWaterLevelAtTime = getWaterLevelAtTime;
|
|
151
68
|
exports.nearestStation = nearestStation;
|
|
152
69
|
exports.stationsNear = stationsNear;
|
|
153
|
-
exports.useStation = useStation;
|
|
154
70
|
|
|
155
71
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["stations"],"sources":["../src/index.ts"],"sourcesContent":["import {\n stations,\n near,\n nearest,\n type
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["stations"],"sources":["../src/index.ts"],"sourcesContent":["import {\n stations,\n near,\n nearest,\n type NearOptions,\n type NearestOptions,\n} from \"@neaps/tide-database\";\nimport {\n useStation,\n type Station,\n type StationPredictor,\n type StationExtremesOptions,\n type StationTimelineOptions,\n type StationWaterLevelOptions,\n} from \"@neaps/tide-predictor\";\n\n/**\n * Get extremes prediction using the nearest station to the given position.\n *\n * @example\n * ```ts\n * import { getExtremesPrediction } from 'neaps'\n *\n * const prediction = getExtremesPrediction({\n * latitude: 26.7, // or `lat`\n * longitude: -80.05, // or `lng` or `lon`\n * start: new Date('2025-12-17'),\n * end: new Date('2025-12-18'),\n * datum: 'MLLW', // optional, defaults to station's datum\n * })\n */\nexport function getExtremesPrediction(options: NearestOptions & StationExtremesOptions) {\n return nearestStation(options).getExtremesPrediction(options);\n}\n\n/**\n * Get timeline prediction using the nearest station to the given position.\n */\nexport function getTimelinePrediction(options: NearestOptions & StationTimelineOptions) {\n return nearestStation(options).getTimelinePrediction(options);\n}\n\n/**\n * Get water level at a specific time using the nearest station to the given position.\n */\nexport function getWaterLevelAtTime(options: NearestOptions & StationWaterLevelOptions) {\n return nearestStation(options).getWaterLevelAtTime(options);\n}\n\n/**\n * Find the nearest station to the given position.\n */\nexport function nearestStation(options: NearestOptions) {\n const data = nearest(options);\n if (!data) throw new Error(`No stations found with options: ${JSON.stringify(options)}`);\n return useStation(...data);\n}\n\n/**\n * Find stations near the given position.\n * @param limit Maximum number of stations to return (default: 10)\n */\nexport function stationsNear(options: NearOptions) {\n return near(options).map(([station, distance]) => useStation(station, distance));\n}\n\n/**\n * Find a specific station by its ID or source ID.\n */\nexport function findStation(query: string): StationPredictor {\n const searches = [(s: Station) => s.id === query, (s: Station) => s.source.id === query];\n\n let found: Station | undefined = undefined;\n\n for (const search of searches) {\n found = stations.find(search);\n if (found) break;\n }\n\n if (!found) throw new Error(`Station not found: ${query}`);\n return useStation(found);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+BA,SAAgB,sBAAsB,SAAkD;CACtF,OAAO,eAAe,OAAO,CAAC,CAAC,sBAAsB,OAAO;AAC9D;;;;AAKA,SAAgB,sBAAsB,SAAkD;CACtF,OAAO,eAAe,OAAO,CAAC,CAAC,sBAAsB,OAAO;AAC9D;;;;AAKA,SAAgB,oBAAoB,SAAoD;CACtF,OAAO,eAAe,OAAO,CAAC,CAAC,oBAAoB,OAAO;AAC5D;;;;AAKA,SAAgB,eAAe,SAAyB;CACtD,MAAM,QAAA,GAAA,qBAAA,QAAA,CAAe,OAAO;CAC5B,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,mCAAmC,KAAK,UAAU,OAAO,GAAG;CACvF,QAAA,GAAA,sBAAA,WAAA,CAAkB,GAAG,IAAI;AAC3B;;;;;AAMA,SAAgB,aAAa,SAAsB;CACjD,QAAA,GAAA,qBAAA,KAAA,CAAY,OAAO,CAAC,CAAC,KAAK,CAAC,SAAS,eAAA,GAAA,sBAAA,WAAA,CAAyB,SAAS,QAAQ,CAAC;AACjF;;;;AAKA,SAAgB,YAAY,OAAiC;CAC3D,MAAM,WAAW,EAAE,MAAe,EAAE,OAAO,QAAQ,MAAe,EAAE,OAAO,OAAO,KAAK;CAEvF,IAAI,QAA6B,KAAA;CAEjC,KAAK,MAAM,UAAU,UAAU;EAC7B,QAAQA,qBAAAA,SAAS,KAAK,MAAM;EAC5B,IAAI,OAAO;CACb;CAEA,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,sBAAsB,OAAO;CACzD,QAAA,GAAA,sBAAA,WAAA,CAAkB,KAAK;AACzB"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import * as _$_neaps_tide_database0 from "@neaps/tide-database";
|
|
4
|
-
import { NearOptions, NearestOptions, Station } from "@neaps/tide-database";
|
|
1
|
+
import { NearOptions, NearestOptions } from "@neaps/tide-database";
|
|
2
|
+
import { StationExtremesOptions, StationPredictor, StationTimelineOptions, StationWaterLevelOptions } from "@neaps/tide-predictor";
|
|
5
3
|
|
|
6
4
|
//#region src/index.d.ts
|
|
7
|
-
type Units = "meters" | "feet";
|
|
8
|
-
type PredictionOptions = {
|
|
9
|
-
/** Datum to return predictions in. Defaults to the nearest station's datum. */datum?: string; /** Units for returned water levels. Defaults to 'meters'. */
|
|
10
|
-
units?: Units; /** Nodal correction fundamentals. Defaults to 'iho'. */
|
|
11
|
-
nodeCorrections?: "iho" | "schureman";
|
|
12
|
-
};
|
|
13
|
-
type ExtremesOptions = ExtremesInput & PredictionOptions;
|
|
14
|
-
type TimelineOptions = TimelineInput & PredictionOptions;
|
|
15
|
-
type WaterLevelOptions = {
|
|
16
|
-
time: Date;
|
|
17
|
-
} & PredictionOptions;
|
|
18
5
|
/**
|
|
19
6
|
* Get extremes prediction using the nearest station to the given position.
|
|
20
7
|
*
|
|
@@ -30,377 +17,28 @@ type WaterLevelOptions = {
|
|
|
30
17
|
* datum: 'MLLW', // optional, defaults to station's datum
|
|
31
18
|
* })
|
|
32
19
|
*/
|
|
33
|
-
declare function getExtremesPrediction(options: NearestOptions &
|
|
34
|
-
datum: string | undefined;
|
|
35
|
-
units: Units;
|
|
36
|
-
station: Station;
|
|
37
|
-
distance: number | undefined;
|
|
38
|
-
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
39
|
-
};
|
|
20
|
+
declare function getExtremesPrediction(options: NearestOptions & StationExtremesOptions): import("@neaps/tide-predictor").StationExtremesPrediction;
|
|
40
21
|
/**
|
|
41
22
|
* Get timeline prediction using the nearest station to the given position.
|
|
42
23
|
*/
|
|
43
|
-
declare function getTimelinePrediction(options: NearestOptions &
|
|
44
|
-
datum: string | undefined;
|
|
45
|
-
units: Units;
|
|
46
|
-
station: Station;
|
|
47
|
-
distance: number | undefined;
|
|
48
|
-
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
49
|
-
};
|
|
24
|
+
declare function getTimelinePrediction(options: NearestOptions & StationTimelineOptions): import("@neaps/tide-predictor").StationTimelinePrediction;
|
|
50
25
|
/**
|
|
51
26
|
* Get water level at a specific time using the nearest station to the given position.
|
|
52
27
|
*/
|
|
53
|
-
declare function getWaterLevelAtTime(options: NearestOptions &
|
|
54
|
-
time: Date;
|
|
55
|
-
hour: number;
|
|
56
|
-
level: number;
|
|
57
|
-
datum: string | undefined;
|
|
58
|
-
units: Units;
|
|
59
|
-
station: Station;
|
|
60
|
-
distance: number | undefined;
|
|
61
|
-
};
|
|
28
|
+
declare function getWaterLevelAtTime(options: NearestOptions & StationWaterLevelOptions): import("@neaps/tide-predictor").StationWaterLevelPrediction;
|
|
62
29
|
/**
|
|
63
30
|
* Find the nearest station to the given position.
|
|
64
31
|
*/
|
|
65
|
-
declare function nearestStation(options: NearestOptions):
|
|
66
|
-
distance: number | undefined;
|
|
67
|
-
datums: Record<string, number>;
|
|
68
|
-
harmonic_constituents: _$_neaps_tide_database0.HarmonicConstituent[];
|
|
69
|
-
defaultDatum: string | undefined;
|
|
70
|
-
getExtremesPrediction({
|
|
71
|
-
datum,
|
|
72
|
-
units,
|
|
73
|
-
nodeCorrections,
|
|
74
|
-
...options
|
|
75
|
-
}: ExtremesOptions): {
|
|
76
|
-
datum: string | undefined;
|
|
77
|
-
units: Units;
|
|
78
|
-
station: Station;
|
|
79
|
-
distance: number | undefined;
|
|
80
|
-
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
81
|
-
};
|
|
82
|
-
getTimelinePrediction({
|
|
83
|
-
datum,
|
|
84
|
-
units,
|
|
85
|
-
nodeCorrections,
|
|
86
|
-
...options
|
|
87
|
-
}: TimelineOptions): {
|
|
88
|
-
datum: string | undefined;
|
|
89
|
-
units: Units;
|
|
90
|
-
station: Station;
|
|
91
|
-
distance: number | undefined;
|
|
92
|
-
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
93
|
-
};
|
|
94
|
-
getWaterLevelAtTime({
|
|
95
|
-
time,
|
|
96
|
-
datum,
|
|
97
|
-
units,
|
|
98
|
-
nodeCorrections
|
|
99
|
-
}: WaterLevelOptions): {
|
|
100
|
-
time: Date;
|
|
101
|
-
hour: number;
|
|
102
|
-
level: number;
|
|
103
|
-
datum: string | undefined;
|
|
104
|
-
units: Units;
|
|
105
|
-
station: Station;
|
|
106
|
-
distance: number | undefined;
|
|
107
|
-
};
|
|
108
|
-
id: string;
|
|
109
|
-
name: string;
|
|
110
|
-
continent: string;
|
|
111
|
-
country: string;
|
|
112
|
-
region?: string;
|
|
113
|
-
timezone: string;
|
|
114
|
-
disclaimers: string;
|
|
115
|
-
type: "reference" | "subordinate";
|
|
116
|
-
latitude: number;
|
|
117
|
-
longitude: number;
|
|
118
|
-
source: {
|
|
119
|
-
name: string;
|
|
120
|
-
id: string;
|
|
121
|
-
published_harmonics: boolean;
|
|
122
|
-
url: string;
|
|
123
|
-
};
|
|
124
|
-
license: {
|
|
125
|
-
type: string;
|
|
126
|
-
commercial_use: boolean;
|
|
127
|
-
url: string;
|
|
128
|
-
notes?: string;
|
|
129
|
-
};
|
|
130
|
-
offsets?: {
|
|
131
|
-
reference: string;
|
|
132
|
-
height: {
|
|
133
|
-
high: number;
|
|
134
|
-
low: number;
|
|
135
|
-
type: "ratio" | "fixed";
|
|
136
|
-
};
|
|
137
|
-
time: {
|
|
138
|
-
high: number;
|
|
139
|
-
low: number;
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
chart_datum: string;
|
|
143
|
-
epoch?: {
|
|
144
|
-
start: string;
|
|
145
|
-
end: string;
|
|
146
|
-
};
|
|
147
|
-
};
|
|
32
|
+
declare function nearestStation(options: NearestOptions): StationPredictor;
|
|
148
33
|
/**
|
|
149
34
|
* Find stations near the given position.
|
|
150
35
|
* @param limit Maximum number of stations to return (default: 10)
|
|
151
36
|
*/
|
|
152
|
-
declare function stationsNear(options: NearOptions):
|
|
153
|
-
distance: number | undefined;
|
|
154
|
-
datums: Record<string, number>;
|
|
155
|
-
harmonic_constituents: _$_neaps_tide_database0.HarmonicConstituent[];
|
|
156
|
-
defaultDatum: string | undefined;
|
|
157
|
-
getExtremesPrediction({
|
|
158
|
-
datum,
|
|
159
|
-
units,
|
|
160
|
-
nodeCorrections,
|
|
161
|
-
...options
|
|
162
|
-
}: ExtremesOptions): {
|
|
163
|
-
datum: string | undefined;
|
|
164
|
-
units: Units;
|
|
165
|
-
station: Station;
|
|
166
|
-
distance: number | undefined;
|
|
167
|
-
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
168
|
-
};
|
|
169
|
-
getTimelinePrediction({
|
|
170
|
-
datum,
|
|
171
|
-
units,
|
|
172
|
-
nodeCorrections,
|
|
173
|
-
...options
|
|
174
|
-
}: TimelineOptions): {
|
|
175
|
-
datum: string | undefined;
|
|
176
|
-
units: Units;
|
|
177
|
-
station: Station;
|
|
178
|
-
distance: number | undefined;
|
|
179
|
-
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
180
|
-
};
|
|
181
|
-
getWaterLevelAtTime({
|
|
182
|
-
time,
|
|
183
|
-
datum,
|
|
184
|
-
units,
|
|
185
|
-
nodeCorrections
|
|
186
|
-
}: WaterLevelOptions): {
|
|
187
|
-
time: Date;
|
|
188
|
-
hour: number;
|
|
189
|
-
level: number;
|
|
190
|
-
datum: string | undefined;
|
|
191
|
-
units: Units;
|
|
192
|
-
station: Station;
|
|
193
|
-
distance: number | undefined;
|
|
194
|
-
};
|
|
195
|
-
id: string;
|
|
196
|
-
name: string;
|
|
197
|
-
continent: string;
|
|
198
|
-
country: string;
|
|
199
|
-
region?: string;
|
|
200
|
-
timezone: string;
|
|
201
|
-
disclaimers: string;
|
|
202
|
-
type: "reference" | "subordinate";
|
|
203
|
-
latitude: number;
|
|
204
|
-
longitude: number;
|
|
205
|
-
source: {
|
|
206
|
-
name: string;
|
|
207
|
-
id: string;
|
|
208
|
-
published_harmonics: boolean;
|
|
209
|
-
url: string;
|
|
210
|
-
};
|
|
211
|
-
license: {
|
|
212
|
-
type: string;
|
|
213
|
-
commercial_use: boolean;
|
|
214
|
-
url: string;
|
|
215
|
-
notes?: string;
|
|
216
|
-
};
|
|
217
|
-
offsets?: {
|
|
218
|
-
reference: string;
|
|
219
|
-
height: {
|
|
220
|
-
high: number;
|
|
221
|
-
low: number;
|
|
222
|
-
type: "ratio" | "fixed";
|
|
223
|
-
};
|
|
224
|
-
time: {
|
|
225
|
-
high: number;
|
|
226
|
-
low: number;
|
|
227
|
-
};
|
|
228
|
-
};
|
|
229
|
-
chart_datum: string;
|
|
230
|
-
epoch?: {
|
|
231
|
-
start: string;
|
|
232
|
-
end: string;
|
|
233
|
-
};
|
|
234
|
-
}[];
|
|
37
|
+
declare function stationsNear(options: NearOptions): StationPredictor[];
|
|
235
38
|
/**
|
|
236
39
|
* Find a specific station by its ID or source ID.
|
|
237
40
|
*/
|
|
238
|
-
declare function findStation(query: string):
|
|
239
|
-
distance: number | undefined;
|
|
240
|
-
datums: Record<string, number>;
|
|
241
|
-
harmonic_constituents: _$_neaps_tide_database0.HarmonicConstituent[];
|
|
242
|
-
defaultDatum: string | undefined;
|
|
243
|
-
getExtremesPrediction({
|
|
244
|
-
datum,
|
|
245
|
-
units,
|
|
246
|
-
nodeCorrections,
|
|
247
|
-
...options
|
|
248
|
-
}: ExtremesOptions): {
|
|
249
|
-
datum: string | undefined;
|
|
250
|
-
units: Units;
|
|
251
|
-
station: Station;
|
|
252
|
-
distance: number | undefined;
|
|
253
|
-
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
254
|
-
};
|
|
255
|
-
getTimelinePrediction({
|
|
256
|
-
datum,
|
|
257
|
-
units,
|
|
258
|
-
nodeCorrections,
|
|
259
|
-
...options
|
|
260
|
-
}: TimelineOptions): {
|
|
261
|
-
datum: string | undefined;
|
|
262
|
-
units: Units;
|
|
263
|
-
station: Station;
|
|
264
|
-
distance: number | undefined;
|
|
265
|
-
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
266
|
-
};
|
|
267
|
-
getWaterLevelAtTime({
|
|
268
|
-
time,
|
|
269
|
-
datum,
|
|
270
|
-
units,
|
|
271
|
-
nodeCorrections
|
|
272
|
-
}: WaterLevelOptions): {
|
|
273
|
-
time: Date;
|
|
274
|
-
hour: number;
|
|
275
|
-
level: number;
|
|
276
|
-
datum: string | undefined;
|
|
277
|
-
units: Units;
|
|
278
|
-
station: Station;
|
|
279
|
-
distance: number | undefined;
|
|
280
|
-
};
|
|
281
|
-
id: string;
|
|
282
|
-
name: string;
|
|
283
|
-
continent: string;
|
|
284
|
-
country: string;
|
|
285
|
-
region?: string;
|
|
286
|
-
timezone: string;
|
|
287
|
-
disclaimers: string;
|
|
288
|
-
type: "reference" | "subordinate";
|
|
289
|
-
latitude: number;
|
|
290
|
-
longitude: number;
|
|
291
|
-
source: {
|
|
292
|
-
name: string;
|
|
293
|
-
id: string;
|
|
294
|
-
published_harmonics: boolean;
|
|
295
|
-
url: string;
|
|
296
|
-
};
|
|
297
|
-
license: {
|
|
298
|
-
type: string;
|
|
299
|
-
commercial_use: boolean;
|
|
300
|
-
url: string;
|
|
301
|
-
notes?: string;
|
|
302
|
-
};
|
|
303
|
-
offsets?: {
|
|
304
|
-
reference: string;
|
|
305
|
-
height: {
|
|
306
|
-
high: number;
|
|
307
|
-
low: number;
|
|
308
|
-
type: "ratio" | "fixed";
|
|
309
|
-
};
|
|
310
|
-
time: {
|
|
311
|
-
high: number;
|
|
312
|
-
low: number;
|
|
313
|
-
};
|
|
314
|
-
};
|
|
315
|
-
chart_datum: string;
|
|
316
|
-
epoch?: {
|
|
317
|
-
start: string;
|
|
318
|
-
end: string;
|
|
319
|
-
};
|
|
320
|
-
};
|
|
321
|
-
declare function useStation(station: Station, distance?: number): {
|
|
322
|
-
distance: number | undefined;
|
|
323
|
-
datums: Record<string, number>;
|
|
324
|
-
harmonic_constituents: _$_neaps_tide_database0.HarmonicConstituent[];
|
|
325
|
-
defaultDatum: string | undefined;
|
|
326
|
-
getExtremesPrediction({
|
|
327
|
-
datum,
|
|
328
|
-
units,
|
|
329
|
-
nodeCorrections,
|
|
330
|
-
...options
|
|
331
|
-
}: ExtremesOptions): {
|
|
332
|
-
datum: string | undefined;
|
|
333
|
-
units: Units;
|
|
334
|
-
station: Station;
|
|
335
|
-
distance: number | undefined;
|
|
336
|
-
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
337
|
-
};
|
|
338
|
-
getTimelinePrediction({
|
|
339
|
-
datum,
|
|
340
|
-
units,
|
|
341
|
-
nodeCorrections,
|
|
342
|
-
...options
|
|
343
|
-
}: TimelineOptions): {
|
|
344
|
-
datum: string | undefined;
|
|
345
|
-
units: Units;
|
|
346
|
-
station: Station;
|
|
347
|
-
distance: number | undefined;
|
|
348
|
-
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
349
|
-
};
|
|
350
|
-
getWaterLevelAtTime({
|
|
351
|
-
time,
|
|
352
|
-
datum,
|
|
353
|
-
units,
|
|
354
|
-
nodeCorrections
|
|
355
|
-
}: WaterLevelOptions): {
|
|
356
|
-
time: Date;
|
|
357
|
-
hour: number;
|
|
358
|
-
level: number;
|
|
359
|
-
datum: string | undefined;
|
|
360
|
-
units: Units;
|
|
361
|
-
station: Station;
|
|
362
|
-
distance: number | undefined;
|
|
363
|
-
};
|
|
364
|
-
id: string;
|
|
365
|
-
name: string;
|
|
366
|
-
continent: string;
|
|
367
|
-
country: string;
|
|
368
|
-
region?: string;
|
|
369
|
-
timezone: string;
|
|
370
|
-
disclaimers: string;
|
|
371
|
-
type: "reference" | "subordinate";
|
|
372
|
-
latitude: number;
|
|
373
|
-
longitude: number;
|
|
374
|
-
source: {
|
|
375
|
-
name: string;
|
|
376
|
-
id: string;
|
|
377
|
-
published_harmonics: boolean;
|
|
378
|
-
url: string;
|
|
379
|
-
};
|
|
380
|
-
license: {
|
|
381
|
-
type: string;
|
|
382
|
-
commercial_use: boolean;
|
|
383
|
-
url: string;
|
|
384
|
-
notes?: string;
|
|
385
|
-
};
|
|
386
|
-
offsets?: {
|
|
387
|
-
reference: string;
|
|
388
|
-
height: {
|
|
389
|
-
high: number;
|
|
390
|
-
low: number;
|
|
391
|
-
type: "ratio" | "fixed";
|
|
392
|
-
};
|
|
393
|
-
time: {
|
|
394
|
-
high: number;
|
|
395
|
-
low: number;
|
|
396
|
-
};
|
|
397
|
-
};
|
|
398
|
-
chart_datum: string;
|
|
399
|
-
epoch?: {
|
|
400
|
-
start: string;
|
|
401
|
-
end: string;
|
|
402
|
-
};
|
|
403
|
-
};
|
|
41
|
+
declare function findStation(query: string): StationPredictor;
|
|
404
42
|
//#endregion
|
|
405
|
-
export {
|
|
43
|
+
export { findStation, getExtremesPrediction, getTimelinePrediction, getWaterLevelAtTime, nearestStation, stationsNear };
|
|
406
44
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import * as _$_neaps_tide_predictor0 from "@neaps/tide-predictor";
|
|
4
|
-
import { ExtremesInput, TimelineInput } from "@neaps/tide-predictor";
|
|
1
|
+
import { NearOptions, NearestOptions } from "@neaps/tide-database";
|
|
2
|
+
import { StationExtremesOptions, StationPredictor, StationTimelineOptions, StationWaterLevelOptions } from "@neaps/tide-predictor";
|
|
5
3
|
|
|
6
4
|
//#region src/index.d.ts
|
|
7
|
-
type Units = "meters" | "feet";
|
|
8
|
-
type PredictionOptions = {
|
|
9
|
-
/** Datum to return predictions in. Defaults to the nearest station's datum. */datum?: string; /** Units for returned water levels. Defaults to 'meters'. */
|
|
10
|
-
units?: Units; /** Nodal correction fundamentals. Defaults to 'iho'. */
|
|
11
|
-
nodeCorrections?: "iho" | "schureman";
|
|
12
|
-
};
|
|
13
|
-
type ExtremesOptions = ExtremesInput & PredictionOptions;
|
|
14
|
-
type TimelineOptions = TimelineInput & PredictionOptions;
|
|
15
|
-
type WaterLevelOptions = {
|
|
16
|
-
time: Date;
|
|
17
|
-
} & PredictionOptions;
|
|
18
5
|
/**
|
|
19
6
|
* Get extremes prediction using the nearest station to the given position.
|
|
20
7
|
*
|
|
@@ -30,377 +17,28 @@ type WaterLevelOptions = {
|
|
|
30
17
|
* datum: 'MLLW', // optional, defaults to station's datum
|
|
31
18
|
* })
|
|
32
19
|
*/
|
|
33
|
-
declare function getExtremesPrediction(options: NearestOptions &
|
|
34
|
-
datum: string | undefined;
|
|
35
|
-
units: Units;
|
|
36
|
-
station: Station;
|
|
37
|
-
distance: number | undefined;
|
|
38
|
-
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
39
|
-
};
|
|
20
|
+
declare function getExtremesPrediction(options: NearestOptions & StationExtremesOptions): import("@neaps/tide-predictor").StationExtremesPrediction;
|
|
40
21
|
/**
|
|
41
22
|
* Get timeline prediction using the nearest station to the given position.
|
|
42
23
|
*/
|
|
43
|
-
declare function getTimelinePrediction(options: NearestOptions &
|
|
44
|
-
datum: string | undefined;
|
|
45
|
-
units: Units;
|
|
46
|
-
station: Station;
|
|
47
|
-
distance: number | undefined;
|
|
48
|
-
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
49
|
-
};
|
|
24
|
+
declare function getTimelinePrediction(options: NearestOptions & StationTimelineOptions): import("@neaps/tide-predictor").StationTimelinePrediction;
|
|
50
25
|
/**
|
|
51
26
|
* Get water level at a specific time using the nearest station to the given position.
|
|
52
27
|
*/
|
|
53
|
-
declare function getWaterLevelAtTime(options: NearestOptions &
|
|
54
|
-
time: Date;
|
|
55
|
-
hour: number;
|
|
56
|
-
level: number;
|
|
57
|
-
datum: string | undefined;
|
|
58
|
-
units: Units;
|
|
59
|
-
station: Station;
|
|
60
|
-
distance: number | undefined;
|
|
61
|
-
};
|
|
28
|
+
declare function getWaterLevelAtTime(options: NearestOptions & StationWaterLevelOptions): import("@neaps/tide-predictor").StationWaterLevelPrediction;
|
|
62
29
|
/**
|
|
63
30
|
* Find the nearest station to the given position.
|
|
64
31
|
*/
|
|
65
|
-
declare function nearestStation(options: NearestOptions):
|
|
66
|
-
distance: number | undefined;
|
|
67
|
-
datums: Record<string, number>;
|
|
68
|
-
harmonic_constituents: _$_neaps_tide_database0.HarmonicConstituent[];
|
|
69
|
-
defaultDatum: string | undefined;
|
|
70
|
-
getExtremesPrediction({
|
|
71
|
-
datum,
|
|
72
|
-
units,
|
|
73
|
-
nodeCorrections,
|
|
74
|
-
...options
|
|
75
|
-
}: ExtremesOptions): {
|
|
76
|
-
datum: string | undefined;
|
|
77
|
-
units: Units;
|
|
78
|
-
station: Station;
|
|
79
|
-
distance: number | undefined;
|
|
80
|
-
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
81
|
-
};
|
|
82
|
-
getTimelinePrediction({
|
|
83
|
-
datum,
|
|
84
|
-
units,
|
|
85
|
-
nodeCorrections,
|
|
86
|
-
...options
|
|
87
|
-
}: TimelineOptions): {
|
|
88
|
-
datum: string | undefined;
|
|
89
|
-
units: Units;
|
|
90
|
-
station: Station;
|
|
91
|
-
distance: number | undefined;
|
|
92
|
-
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
93
|
-
};
|
|
94
|
-
getWaterLevelAtTime({
|
|
95
|
-
time,
|
|
96
|
-
datum,
|
|
97
|
-
units,
|
|
98
|
-
nodeCorrections
|
|
99
|
-
}: WaterLevelOptions): {
|
|
100
|
-
time: Date;
|
|
101
|
-
hour: number;
|
|
102
|
-
level: number;
|
|
103
|
-
datum: string | undefined;
|
|
104
|
-
units: Units;
|
|
105
|
-
station: Station;
|
|
106
|
-
distance: number | undefined;
|
|
107
|
-
};
|
|
108
|
-
id: string;
|
|
109
|
-
name: string;
|
|
110
|
-
continent: string;
|
|
111
|
-
country: string;
|
|
112
|
-
region?: string;
|
|
113
|
-
timezone: string;
|
|
114
|
-
disclaimers: string;
|
|
115
|
-
type: "reference" | "subordinate";
|
|
116
|
-
latitude: number;
|
|
117
|
-
longitude: number;
|
|
118
|
-
source: {
|
|
119
|
-
name: string;
|
|
120
|
-
id: string;
|
|
121
|
-
published_harmonics: boolean;
|
|
122
|
-
url: string;
|
|
123
|
-
};
|
|
124
|
-
license: {
|
|
125
|
-
type: string;
|
|
126
|
-
commercial_use: boolean;
|
|
127
|
-
url: string;
|
|
128
|
-
notes?: string;
|
|
129
|
-
};
|
|
130
|
-
offsets?: {
|
|
131
|
-
reference: string;
|
|
132
|
-
height: {
|
|
133
|
-
high: number;
|
|
134
|
-
low: number;
|
|
135
|
-
type: "ratio" | "fixed";
|
|
136
|
-
};
|
|
137
|
-
time: {
|
|
138
|
-
high: number;
|
|
139
|
-
low: number;
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
chart_datum: string;
|
|
143
|
-
epoch?: {
|
|
144
|
-
start: string;
|
|
145
|
-
end: string;
|
|
146
|
-
};
|
|
147
|
-
};
|
|
32
|
+
declare function nearestStation(options: NearestOptions): StationPredictor;
|
|
148
33
|
/**
|
|
149
34
|
* Find stations near the given position.
|
|
150
35
|
* @param limit Maximum number of stations to return (default: 10)
|
|
151
36
|
*/
|
|
152
|
-
declare function stationsNear(options: NearOptions):
|
|
153
|
-
distance: number | undefined;
|
|
154
|
-
datums: Record<string, number>;
|
|
155
|
-
harmonic_constituents: _$_neaps_tide_database0.HarmonicConstituent[];
|
|
156
|
-
defaultDatum: string | undefined;
|
|
157
|
-
getExtremesPrediction({
|
|
158
|
-
datum,
|
|
159
|
-
units,
|
|
160
|
-
nodeCorrections,
|
|
161
|
-
...options
|
|
162
|
-
}: ExtremesOptions): {
|
|
163
|
-
datum: string | undefined;
|
|
164
|
-
units: Units;
|
|
165
|
-
station: Station;
|
|
166
|
-
distance: number | undefined;
|
|
167
|
-
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
168
|
-
};
|
|
169
|
-
getTimelinePrediction({
|
|
170
|
-
datum,
|
|
171
|
-
units,
|
|
172
|
-
nodeCorrections,
|
|
173
|
-
...options
|
|
174
|
-
}: TimelineOptions): {
|
|
175
|
-
datum: string | undefined;
|
|
176
|
-
units: Units;
|
|
177
|
-
station: Station;
|
|
178
|
-
distance: number | undefined;
|
|
179
|
-
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
180
|
-
};
|
|
181
|
-
getWaterLevelAtTime({
|
|
182
|
-
time,
|
|
183
|
-
datum,
|
|
184
|
-
units,
|
|
185
|
-
nodeCorrections
|
|
186
|
-
}: WaterLevelOptions): {
|
|
187
|
-
time: Date;
|
|
188
|
-
hour: number;
|
|
189
|
-
level: number;
|
|
190
|
-
datum: string | undefined;
|
|
191
|
-
units: Units;
|
|
192
|
-
station: Station;
|
|
193
|
-
distance: number | undefined;
|
|
194
|
-
};
|
|
195
|
-
id: string;
|
|
196
|
-
name: string;
|
|
197
|
-
continent: string;
|
|
198
|
-
country: string;
|
|
199
|
-
region?: string;
|
|
200
|
-
timezone: string;
|
|
201
|
-
disclaimers: string;
|
|
202
|
-
type: "reference" | "subordinate";
|
|
203
|
-
latitude: number;
|
|
204
|
-
longitude: number;
|
|
205
|
-
source: {
|
|
206
|
-
name: string;
|
|
207
|
-
id: string;
|
|
208
|
-
published_harmonics: boolean;
|
|
209
|
-
url: string;
|
|
210
|
-
};
|
|
211
|
-
license: {
|
|
212
|
-
type: string;
|
|
213
|
-
commercial_use: boolean;
|
|
214
|
-
url: string;
|
|
215
|
-
notes?: string;
|
|
216
|
-
};
|
|
217
|
-
offsets?: {
|
|
218
|
-
reference: string;
|
|
219
|
-
height: {
|
|
220
|
-
high: number;
|
|
221
|
-
low: number;
|
|
222
|
-
type: "ratio" | "fixed";
|
|
223
|
-
};
|
|
224
|
-
time: {
|
|
225
|
-
high: number;
|
|
226
|
-
low: number;
|
|
227
|
-
};
|
|
228
|
-
};
|
|
229
|
-
chart_datum: string;
|
|
230
|
-
epoch?: {
|
|
231
|
-
start: string;
|
|
232
|
-
end: string;
|
|
233
|
-
};
|
|
234
|
-
}[];
|
|
37
|
+
declare function stationsNear(options: NearOptions): StationPredictor[];
|
|
235
38
|
/**
|
|
236
39
|
* Find a specific station by its ID or source ID.
|
|
237
40
|
*/
|
|
238
|
-
declare function findStation(query: string):
|
|
239
|
-
distance: number | undefined;
|
|
240
|
-
datums: Record<string, number>;
|
|
241
|
-
harmonic_constituents: _$_neaps_tide_database0.HarmonicConstituent[];
|
|
242
|
-
defaultDatum: string | undefined;
|
|
243
|
-
getExtremesPrediction({
|
|
244
|
-
datum,
|
|
245
|
-
units,
|
|
246
|
-
nodeCorrections,
|
|
247
|
-
...options
|
|
248
|
-
}: ExtremesOptions): {
|
|
249
|
-
datum: string | undefined;
|
|
250
|
-
units: Units;
|
|
251
|
-
station: Station;
|
|
252
|
-
distance: number | undefined;
|
|
253
|
-
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
254
|
-
};
|
|
255
|
-
getTimelinePrediction({
|
|
256
|
-
datum,
|
|
257
|
-
units,
|
|
258
|
-
nodeCorrections,
|
|
259
|
-
...options
|
|
260
|
-
}: TimelineOptions): {
|
|
261
|
-
datum: string | undefined;
|
|
262
|
-
units: Units;
|
|
263
|
-
station: Station;
|
|
264
|
-
distance: number | undefined;
|
|
265
|
-
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
266
|
-
};
|
|
267
|
-
getWaterLevelAtTime({
|
|
268
|
-
time,
|
|
269
|
-
datum,
|
|
270
|
-
units,
|
|
271
|
-
nodeCorrections
|
|
272
|
-
}: WaterLevelOptions): {
|
|
273
|
-
time: Date;
|
|
274
|
-
hour: number;
|
|
275
|
-
level: number;
|
|
276
|
-
datum: string | undefined;
|
|
277
|
-
units: Units;
|
|
278
|
-
station: Station;
|
|
279
|
-
distance: number | undefined;
|
|
280
|
-
};
|
|
281
|
-
id: string;
|
|
282
|
-
name: string;
|
|
283
|
-
continent: string;
|
|
284
|
-
country: string;
|
|
285
|
-
region?: string;
|
|
286
|
-
timezone: string;
|
|
287
|
-
disclaimers: string;
|
|
288
|
-
type: "reference" | "subordinate";
|
|
289
|
-
latitude: number;
|
|
290
|
-
longitude: number;
|
|
291
|
-
source: {
|
|
292
|
-
name: string;
|
|
293
|
-
id: string;
|
|
294
|
-
published_harmonics: boolean;
|
|
295
|
-
url: string;
|
|
296
|
-
};
|
|
297
|
-
license: {
|
|
298
|
-
type: string;
|
|
299
|
-
commercial_use: boolean;
|
|
300
|
-
url: string;
|
|
301
|
-
notes?: string;
|
|
302
|
-
};
|
|
303
|
-
offsets?: {
|
|
304
|
-
reference: string;
|
|
305
|
-
height: {
|
|
306
|
-
high: number;
|
|
307
|
-
low: number;
|
|
308
|
-
type: "ratio" | "fixed";
|
|
309
|
-
};
|
|
310
|
-
time: {
|
|
311
|
-
high: number;
|
|
312
|
-
low: number;
|
|
313
|
-
};
|
|
314
|
-
};
|
|
315
|
-
chart_datum: string;
|
|
316
|
-
epoch?: {
|
|
317
|
-
start: string;
|
|
318
|
-
end: string;
|
|
319
|
-
};
|
|
320
|
-
};
|
|
321
|
-
declare function useStation(station: Station, distance?: number): {
|
|
322
|
-
distance: number | undefined;
|
|
323
|
-
datums: Record<string, number>;
|
|
324
|
-
harmonic_constituents: _$_neaps_tide_database0.HarmonicConstituent[];
|
|
325
|
-
defaultDatum: string | undefined;
|
|
326
|
-
getExtremesPrediction({
|
|
327
|
-
datum,
|
|
328
|
-
units,
|
|
329
|
-
nodeCorrections,
|
|
330
|
-
...options
|
|
331
|
-
}: ExtremesOptions): {
|
|
332
|
-
datum: string | undefined;
|
|
333
|
-
units: Units;
|
|
334
|
-
station: Station;
|
|
335
|
-
distance: number | undefined;
|
|
336
|
-
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
337
|
-
};
|
|
338
|
-
getTimelinePrediction({
|
|
339
|
-
datum,
|
|
340
|
-
units,
|
|
341
|
-
nodeCorrections,
|
|
342
|
-
...options
|
|
343
|
-
}: TimelineOptions): {
|
|
344
|
-
datum: string | undefined;
|
|
345
|
-
units: Units;
|
|
346
|
-
station: Station;
|
|
347
|
-
distance: number | undefined;
|
|
348
|
-
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
349
|
-
};
|
|
350
|
-
getWaterLevelAtTime({
|
|
351
|
-
time,
|
|
352
|
-
datum,
|
|
353
|
-
units,
|
|
354
|
-
nodeCorrections
|
|
355
|
-
}: WaterLevelOptions): {
|
|
356
|
-
time: Date;
|
|
357
|
-
hour: number;
|
|
358
|
-
level: number;
|
|
359
|
-
datum: string | undefined;
|
|
360
|
-
units: Units;
|
|
361
|
-
station: Station;
|
|
362
|
-
distance: number | undefined;
|
|
363
|
-
};
|
|
364
|
-
id: string;
|
|
365
|
-
name: string;
|
|
366
|
-
continent: string;
|
|
367
|
-
country: string;
|
|
368
|
-
region?: string;
|
|
369
|
-
timezone: string;
|
|
370
|
-
disclaimers: string;
|
|
371
|
-
type: "reference" | "subordinate";
|
|
372
|
-
latitude: number;
|
|
373
|
-
longitude: number;
|
|
374
|
-
source: {
|
|
375
|
-
name: string;
|
|
376
|
-
id: string;
|
|
377
|
-
published_harmonics: boolean;
|
|
378
|
-
url: string;
|
|
379
|
-
};
|
|
380
|
-
license: {
|
|
381
|
-
type: string;
|
|
382
|
-
commercial_use: boolean;
|
|
383
|
-
url: string;
|
|
384
|
-
notes?: string;
|
|
385
|
-
};
|
|
386
|
-
offsets?: {
|
|
387
|
-
reference: string;
|
|
388
|
-
height: {
|
|
389
|
-
high: number;
|
|
390
|
-
low: number;
|
|
391
|
-
type: "ratio" | "fixed";
|
|
392
|
-
};
|
|
393
|
-
time: {
|
|
394
|
-
high: number;
|
|
395
|
-
low: number;
|
|
396
|
-
};
|
|
397
|
-
};
|
|
398
|
-
chart_datum: string;
|
|
399
|
-
epoch?: {
|
|
400
|
-
start: string;
|
|
401
|
-
end: string;
|
|
402
|
-
};
|
|
403
|
-
};
|
|
41
|
+
declare function findStation(query: string): StationPredictor;
|
|
404
42
|
//#endregion
|
|
405
|
-
export {
|
|
43
|
+
export { findStation, getExtremesPrediction, getTimelinePrediction, getWaterLevelAtTime, nearestStation, stationsNear };
|
|
406
44
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { near, nearest, stations } from "@neaps/tide-database";
|
|
2
|
-
import {
|
|
2
|
+
import { useStation } from "@neaps/tide-predictor";
|
|
3
3
|
//#region src/index.ts
|
|
4
|
-
const feetPerMeter = 3.2808399;
|
|
5
|
-
const defaultUnits = "meters";
|
|
6
4
|
/**
|
|
7
5
|
* Get extremes prediction using the nearest station to the given position.
|
|
8
6
|
*
|
|
@@ -61,88 +59,7 @@ function findStation(query) {
|
|
|
61
59
|
if (!found) throw new Error(`Station not found: ${query}`);
|
|
62
60
|
return useStation(found);
|
|
63
61
|
}
|
|
64
|
-
function useStation(station, distance) {
|
|
65
|
-
let reference = station;
|
|
66
|
-
if (station.type === "subordinate" && station.offsets?.reference) reference = findStation(station.offsets?.reference);
|
|
67
|
-
const { datums, harmonic_constituents } = reference;
|
|
68
|
-
const defaultDatum = station.chart_datum in datums ? station.chart_datum : void 0;
|
|
69
|
-
function getPredictor({ datum = defaultDatum, nodeCorrections } = {}) {
|
|
70
|
-
let offset = 0;
|
|
71
|
-
if (datum) {
|
|
72
|
-
const datumOffset = datums?.[datum];
|
|
73
|
-
const mslOffset = datums?.["MSL"];
|
|
74
|
-
if (typeof datumOffset !== "number") throw new Error(`Station ${station.id} missing ${datum} datum. Available datums: ${Object.keys(datums).join(", ")}`);
|
|
75
|
-
if (typeof mslOffset !== "number") throw new Error(`Station ${station.id} missing MSL datum, so predictions can't be given in ${datum}.`);
|
|
76
|
-
offset = mslOffset - datumOffset;
|
|
77
|
-
}
|
|
78
|
-
return createTidePredictor(harmonic_constituents, {
|
|
79
|
-
offset,
|
|
80
|
-
nodeCorrections
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
...station,
|
|
85
|
-
distance,
|
|
86
|
-
datums,
|
|
87
|
-
harmonic_constituents,
|
|
88
|
-
defaultDatum,
|
|
89
|
-
getExtremesPrediction({ datum = defaultDatum, units = defaultUnits, nodeCorrections, ...options }) {
|
|
90
|
-
return {
|
|
91
|
-
datum,
|
|
92
|
-
units,
|
|
93
|
-
station,
|
|
94
|
-
distance,
|
|
95
|
-
extremes: getPredictor({
|
|
96
|
-
datum,
|
|
97
|
-
nodeCorrections
|
|
98
|
-
}).getExtremesPrediction({
|
|
99
|
-
...options,
|
|
100
|
-
offsets: station.offsets
|
|
101
|
-
}).map((e) => toPreferredUnits(e, units))
|
|
102
|
-
};
|
|
103
|
-
},
|
|
104
|
-
getTimelinePrediction({ datum = defaultDatum, units = defaultUnits, nodeCorrections, ...options }) {
|
|
105
|
-
return {
|
|
106
|
-
datum,
|
|
107
|
-
units,
|
|
108
|
-
station,
|
|
109
|
-
distance,
|
|
110
|
-
timeline: getPredictor({
|
|
111
|
-
datum,
|
|
112
|
-
nodeCorrections
|
|
113
|
-
}).getTimelinePrediction({
|
|
114
|
-
...options,
|
|
115
|
-
offsets: station.offsets
|
|
116
|
-
}).map((e) => toPreferredUnits(e, units))
|
|
117
|
-
};
|
|
118
|
-
},
|
|
119
|
-
getWaterLevelAtTime({ time, datum = defaultDatum, units = defaultUnits, nodeCorrections }) {
|
|
120
|
-
return {
|
|
121
|
-
datum,
|
|
122
|
-
units,
|
|
123
|
-
station,
|
|
124
|
-
distance,
|
|
125
|
-
...toPreferredUnits(getPredictor({
|
|
126
|
-
datum,
|
|
127
|
-
nodeCorrections
|
|
128
|
-
}).getWaterLevelAtTime({
|
|
129
|
-
time,
|
|
130
|
-
offsets: station.offsets
|
|
131
|
-
}), units)
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
function toPreferredUnits(prediction, units) {
|
|
137
|
-
let { level } = prediction;
|
|
138
|
-
if (units === "feet") level *= feetPerMeter;
|
|
139
|
-
else if (units !== "meters") throw new Error(`Unsupported units: ${units}`);
|
|
140
|
-
return {
|
|
141
|
-
...prediction,
|
|
142
|
-
level
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
62
|
//#endregion
|
|
146
|
-
export { findStation, getExtremesPrediction, getTimelinePrediction, getWaterLevelAtTime, nearestStation, stationsNear
|
|
63
|
+
export { findStation, getExtremesPrediction, getTimelinePrediction, getWaterLevelAtTime, nearestStation, stationsNear };
|
|
147
64
|
|
|
148
65
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n stations,\n near,\n nearest,\n type
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n stations,\n near,\n nearest,\n type NearOptions,\n type NearestOptions,\n} from \"@neaps/tide-database\";\nimport {\n useStation,\n type Station,\n type StationPredictor,\n type StationExtremesOptions,\n type StationTimelineOptions,\n type StationWaterLevelOptions,\n} from \"@neaps/tide-predictor\";\n\n/**\n * Get extremes prediction using the nearest station to the given position.\n *\n * @example\n * ```ts\n * import { getExtremesPrediction } from 'neaps'\n *\n * const prediction = getExtremesPrediction({\n * latitude: 26.7, // or `lat`\n * longitude: -80.05, // or `lng` or `lon`\n * start: new Date('2025-12-17'),\n * end: new Date('2025-12-18'),\n * datum: 'MLLW', // optional, defaults to station's datum\n * })\n */\nexport function getExtremesPrediction(options: NearestOptions & StationExtremesOptions) {\n return nearestStation(options).getExtremesPrediction(options);\n}\n\n/**\n * Get timeline prediction using the nearest station to the given position.\n */\nexport function getTimelinePrediction(options: NearestOptions & StationTimelineOptions) {\n return nearestStation(options).getTimelinePrediction(options);\n}\n\n/**\n * Get water level at a specific time using the nearest station to the given position.\n */\nexport function getWaterLevelAtTime(options: NearestOptions & StationWaterLevelOptions) {\n return nearestStation(options).getWaterLevelAtTime(options);\n}\n\n/**\n * Find the nearest station to the given position.\n */\nexport function nearestStation(options: NearestOptions) {\n const data = nearest(options);\n if (!data) throw new Error(`No stations found with options: ${JSON.stringify(options)}`);\n return useStation(...data);\n}\n\n/**\n * Find stations near the given position.\n * @param limit Maximum number of stations to return (default: 10)\n */\nexport function stationsNear(options: NearOptions) {\n return near(options).map(([station, distance]) => useStation(station, distance));\n}\n\n/**\n * Find a specific station by its ID or source ID.\n */\nexport function findStation(query: string): StationPredictor {\n const searches = [(s: Station) => s.id === query, (s: Station) => s.source.id === query];\n\n let found: Station | undefined = undefined;\n\n for (const search of searches) {\n found = stations.find(search);\n if (found) break;\n }\n\n if (!found) throw new Error(`Station not found: ${query}`);\n return useStation(found);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+BA,SAAgB,sBAAsB,SAAkD;CACtF,OAAO,eAAe,OAAO,CAAC,CAAC,sBAAsB,OAAO;AAC9D;;;;AAKA,SAAgB,sBAAsB,SAAkD;CACtF,OAAO,eAAe,OAAO,CAAC,CAAC,sBAAsB,OAAO;AAC9D;;;;AAKA,SAAgB,oBAAoB,SAAoD;CACtF,OAAO,eAAe,OAAO,CAAC,CAAC,oBAAoB,OAAO;AAC5D;;;;AAKA,SAAgB,eAAe,SAAyB;CACtD,MAAM,OAAO,QAAQ,OAAO;CAC5B,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,mCAAmC,KAAK,UAAU,OAAO,GAAG;CACvF,OAAO,WAAW,GAAG,IAAI;AAC3B;;;;;AAMA,SAAgB,aAAa,SAAsB;CACjD,OAAO,KAAK,OAAO,CAAC,CAAC,KAAK,CAAC,SAAS,cAAc,WAAW,SAAS,QAAQ,CAAC;AACjF;;;;AAKA,SAAgB,YAAY,OAAiC;CAC3D,MAAM,WAAW,EAAE,MAAe,EAAE,OAAO,QAAQ,MAAe,EAAE,OAAO,OAAO,KAAK;CAEvF,IAAI,QAA6B,KAAA;CAEjC,KAAK,MAAM,UAAU,UAAU;EAC7B,QAAQ,SAAS,KAAK,MAAM;EAC5B,IAAI,OAAO;CACb;CAEA,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,sBAAsB,OAAO;CACzD,OAAO,WAAW,KAAK;AACzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neaps",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Tide predictions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tides",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"prepack": "npm run build"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@neaps/tide-database": "0.
|
|
38
|
-
"@neaps/tide-predictor": "^0.
|
|
37
|
+
"@neaps/tide-database": "0.8",
|
|
38
|
+
"@neaps/tide-predictor": "^0.10.0"
|
|
39
39
|
}
|
|
40
40
|
}
|