neaps 0.5.1 → 0.6.1
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 +10 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -16
- package/dist/index.d.ts +16 -16
- package/dist/index.js +9 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
1
|
+
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
|
-
|
|
5
4
|
//#region src/index.ts
|
|
6
5
|
const feetPerMeter = 3.2808399;
|
|
7
6
|
const defaultUnits = "meters";
|
|
@@ -104,7 +103,6 @@ function useStation(station, distance) {
|
|
|
104
103
|
};
|
|
105
104
|
},
|
|
106
105
|
getTimelinePrediction({ datum = defaultDatum, units = defaultUnits, nodeCorrections, ...options }) {
|
|
107
|
-
if (station.type === "subordinate") throw new Error(`Timeline predictions are not supported for subordinate stations.`);
|
|
108
106
|
return {
|
|
109
107
|
datum,
|
|
110
108
|
units,
|
|
@@ -113,11 +111,13 @@ function useStation(station, distance) {
|
|
|
113
111
|
timeline: getPredictor({
|
|
114
112
|
datum,
|
|
115
113
|
nodeCorrections
|
|
116
|
-
}).getTimelinePrediction(
|
|
114
|
+
}).getTimelinePrediction({
|
|
115
|
+
...options,
|
|
116
|
+
offsets: station.offsets
|
|
117
|
+
}).map((e) => toPreferredUnits(e, units))
|
|
117
118
|
};
|
|
118
119
|
},
|
|
119
120
|
getWaterLevelAtTime({ time, datum = defaultDatum, units = defaultUnits, nodeCorrections }) {
|
|
120
|
-
if (station.type === "subordinate") throw new Error(`Water level predictions are not supported for subordinate stations.`);
|
|
121
121
|
return {
|
|
122
122
|
datum,
|
|
123
123
|
units,
|
|
@@ -126,7 +126,10 @@ function useStation(station, distance) {
|
|
|
126
126
|
...toPreferredUnits(getPredictor({
|
|
127
127
|
datum,
|
|
128
128
|
nodeCorrections
|
|
129
|
-
}).getWaterLevelAtTime({
|
|
129
|
+
}).getWaterLevelAtTime({
|
|
130
|
+
time,
|
|
131
|
+
offsets: station.offsets
|
|
132
|
+
}), units)
|
|
130
133
|
};
|
|
131
134
|
}
|
|
132
135
|
};
|
|
@@ -140,7 +143,6 @@ function toPreferredUnits(prediction, units) {
|
|
|
140
143
|
level
|
|
141
144
|
};
|
|
142
145
|
}
|
|
143
|
-
|
|
144
146
|
//#endregion
|
|
145
147
|
exports.findStation = findStation;
|
|
146
148
|
exports.getExtremesPrediction = getExtremesPrediction;
|
|
@@ -149,4 +151,5 @@ exports.getWaterLevelAtTime = getWaterLevelAtTime;
|
|
|
149
151
|
exports.nearestStation = nearestStation;
|
|
150
152
|
exports.stationsNear = stationsNear;
|
|
151
153
|
exports.useStation = useStation;
|
|
154
|
+
|
|
152
155
|
//# 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 Station,\n type NearOptions,\n type NearestOptions,\n} from \"@neaps/tide-database\";\nimport { createTidePredictor, type ExtremesInput, type TimelineInput } from \"@neaps/tide-predictor\";\n\ntype Units = \"meters\" | \"feet\";\ntype PredictionOptions = {\n /** Datum to return predictions in. Defaults to the nearest station's datum. */\n datum?: string;\n\n /** Units for returned water levels. Defaults to 'meters'. */\n units?: Units;\n\n /** Nodal correction fundamentals. Defaults to 'iho'. */\n nodeCorrections?: \"iho\" | \"schureman\";\n};\n\nexport type ExtremesOptions = ExtremesInput & PredictionOptions;\nexport type TimelineOptions = TimelineInput & PredictionOptions;\nexport type WaterLevelOptions = { time: Date } & PredictionOptions;\n\nconst feetPerMeter = 3.2808399;\nconst defaultUnits: Units = \"meters\";\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 & ExtremesOptions) {\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 & TimelineOptions) {\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 & WaterLevelOptions) {\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) {\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\n return useStation(found);\n}\n\nexport function useStation(station: Station, distance?: number) {\n // If subordinate station, use the reference station for datums and constituents\n let reference = station;\n if (station.type === \"subordinate\" && station.offsets?.reference) {\n reference = findStation(station.offsets?.reference);\n }\n const { datums, harmonic_constituents } = reference;\n\n // Use station chart datum as the default datum if available\n const defaultDatum = station.chart_datum in datums ? station.chart_datum : undefined;\n\n function getPredictor({ datum = defaultDatum, nodeCorrections }: PredictionOptions = {}) {\n let offset = 0;\n\n if (datum) {\n const datumOffset = datums?.[datum];\n const mslOffset = datums?.[\"MSL\"];\n\n if (typeof datumOffset !== \"number\") {\n throw new Error(\n `Station ${station.id} missing ${datum} datum. Available datums: ${Object.keys(datums).join(\", \")}`,\n );\n }\n\n if (typeof mslOffset !== \"number\") {\n throw new Error(\n `Station ${station.id} missing MSL datum, so predictions can't be given in ${datum}.`,\n );\n }\n\n offset = mslOffset - datumOffset;\n }\n\n return createTidePredictor(harmonic_constituents, { offset, nodeCorrections });\n }\n\n return {\n ...station,\n distance,\n datums,\n harmonic_constituents,\n defaultDatum,\n getExtremesPrediction({\n datum = defaultDatum,\n units = defaultUnits,\n nodeCorrections,\n ...options\n }: ExtremesOptions) {\n const extremes = getPredictor({ datum, nodeCorrections })\n .getExtremesPrediction({ ...options, offsets: station.offsets })\n .map((e) => toPreferredUnits(e, units));\n\n return { datum, units, station, distance, extremes };\n },\n\n getTimelinePrediction({\n datum = defaultDatum,\n units = defaultUnits,\n nodeCorrections,\n ...options\n }: TimelineOptions) {\n
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["stations"],"sources":["../src/index.ts"],"sourcesContent":["import {\n stations,\n near,\n nearest,\n type Station,\n type NearOptions,\n type NearestOptions,\n} from \"@neaps/tide-database\";\nimport { createTidePredictor, type ExtremesInput, type TimelineInput } from \"@neaps/tide-predictor\";\n\ntype Units = \"meters\" | \"feet\";\ntype PredictionOptions = {\n /** Datum to return predictions in. Defaults to the nearest station's datum. */\n datum?: string;\n\n /** Units for returned water levels. Defaults to 'meters'. */\n units?: Units;\n\n /** Nodal correction fundamentals. Defaults to 'iho'. */\n nodeCorrections?: \"iho\" | \"schureman\";\n};\n\nexport type ExtremesOptions = ExtremesInput & PredictionOptions;\nexport type TimelineOptions = TimelineInput & PredictionOptions;\nexport type WaterLevelOptions = { time: Date } & PredictionOptions;\n\nconst feetPerMeter = 3.2808399;\nconst defaultUnits: Units = \"meters\";\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 & ExtremesOptions) {\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 & TimelineOptions) {\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 & WaterLevelOptions) {\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) {\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\n return useStation(found);\n}\n\nexport function useStation(station: Station, distance?: number) {\n // If subordinate station, use the reference station for datums and constituents\n let reference = station;\n if (station.type === \"subordinate\" && station.offsets?.reference) {\n reference = findStation(station.offsets?.reference);\n }\n const { datums, harmonic_constituents } = reference;\n\n // Use station chart datum as the default datum if available\n const defaultDatum = station.chart_datum in datums ? station.chart_datum : undefined;\n\n function getPredictor({ datum = defaultDatum, nodeCorrections }: PredictionOptions = {}) {\n let offset = 0;\n\n if (datum) {\n const datumOffset = datums?.[datum];\n const mslOffset = datums?.[\"MSL\"];\n\n if (typeof datumOffset !== \"number\") {\n throw new Error(\n `Station ${station.id} missing ${datum} datum. Available datums: ${Object.keys(datums).join(\", \")}`,\n );\n }\n\n if (typeof mslOffset !== \"number\") {\n throw new Error(\n `Station ${station.id} missing MSL datum, so predictions can't be given in ${datum}.`,\n );\n }\n\n offset = mslOffset - datumOffset;\n }\n\n return createTidePredictor(harmonic_constituents, { offset, nodeCorrections });\n }\n\n return {\n ...station,\n distance,\n datums,\n harmonic_constituents,\n defaultDatum,\n getExtremesPrediction({\n datum = defaultDatum,\n units = defaultUnits,\n nodeCorrections,\n ...options\n }: ExtremesOptions) {\n const extremes = getPredictor({ datum, nodeCorrections })\n .getExtremesPrediction({ ...options, offsets: station.offsets })\n .map((e) => toPreferredUnits(e, units));\n\n return { datum, units, station, distance, extremes };\n },\n\n getTimelinePrediction({\n datum = defaultDatum,\n units = defaultUnits,\n nodeCorrections,\n ...options\n }: TimelineOptions) {\n const timeline = getPredictor({ datum, nodeCorrections })\n .getTimelinePrediction({ ...options, offsets: station.offsets })\n .map((e) => toPreferredUnits(e, units));\n\n return { datum, units, station, distance, timeline };\n },\n\n getWaterLevelAtTime({\n time,\n datum = defaultDatum,\n units = defaultUnits,\n nodeCorrections,\n }: WaterLevelOptions) {\n const prediction = toPreferredUnits(\n getPredictor({ datum, nodeCorrections }).getWaterLevelAtTime({\n time,\n offsets: station.offsets,\n }),\n units,\n );\n\n return { datum, units, station, distance, ...prediction };\n },\n };\n}\n\nfunction toPreferredUnits<T extends { level: number }>(prediction: T, units: Units): T {\n let { level } = prediction;\n if (units === \"feet\") level *= feetPerMeter;\n else if (units !== \"meters\") throw new Error(`Unsupported units: ${units}`);\n return { ...prediction, level };\n}\n"],"mappings":";;;;AA0BA,MAAM,eAAe;AACrB,MAAM,eAAsB;;;;;;;;;;;;;;;;AAiB5B,SAAgB,s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AAE,GAAG;EAAY;EAAO"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as _neaps_tide_predictor0 from "@neaps/tide-predictor";
|
|
1
|
+
import * as _$_neaps_tide_predictor0 from "@neaps/tide-predictor";
|
|
2
2
|
import { ExtremesInput, TimelineInput } from "@neaps/tide-predictor";
|
|
3
|
-
import * as _neaps_tide_database0 from "@neaps/tide-database";
|
|
3
|
+
import * as _$_neaps_tide_database0 from "@neaps/tide-database";
|
|
4
4
|
import { NearOptions, NearestOptions, Station } from "@neaps/tide-database";
|
|
5
5
|
|
|
6
6
|
//#region src/index.d.ts
|
|
@@ -35,7 +35,7 @@ declare function getExtremesPrediction(options: NearestOptions & ExtremesOptions
|
|
|
35
35
|
units: Units;
|
|
36
36
|
station: Station;
|
|
37
37
|
distance: number | undefined;
|
|
38
|
-
extremes: _neaps_tide_predictor0.Extreme[];
|
|
38
|
+
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
39
39
|
};
|
|
40
40
|
/**
|
|
41
41
|
* Get timeline prediction using the nearest station to the given position.
|
|
@@ -45,7 +45,7 @@ declare function getTimelinePrediction(options: NearestOptions & TimelineOptions
|
|
|
45
45
|
units: Units;
|
|
46
46
|
station: Station;
|
|
47
47
|
distance: number | undefined;
|
|
48
|
-
timeline: _neaps_tide_predictor0.TimelinePoint[];
|
|
48
|
+
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
49
49
|
};
|
|
50
50
|
/**
|
|
51
51
|
* Get water level at a specific time using the nearest station to the given position.
|
|
@@ -65,7 +65,7 @@ declare function getWaterLevelAtTime(options: NearestOptions & WaterLevelOptions
|
|
|
65
65
|
declare function nearestStation(options: NearestOptions): {
|
|
66
66
|
distance: number | undefined;
|
|
67
67
|
datums: Record<string, number>;
|
|
68
|
-
harmonic_constituents: _neaps_tide_database0.HarmonicConstituent[];
|
|
68
|
+
harmonic_constituents: _$_neaps_tide_database0.HarmonicConstituent[];
|
|
69
69
|
defaultDatum: string | undefined;
|
|
70
70
|
getExtremesPrediction({
|
|
71
71
|
datum,
|
|
@@ -77,7 +77,7 @@ declare function nearestStation(options: NearestOptions): {
|
|
|
77
77
|
units: Units;
|
|
78
78
|
station: Station;
|
|
79
79
|
distance: number | undefined;
|
|
80
|
-
extremes: _neaps_tide_predictor0.Extreme[];
|
|
80
|
+
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
81
81
|
};
|
|
82
82
|
getTimelinePrediction({
|
|
83
83
|
datum,
|
|
@@ -89,7 +89,7 @@ declare function nearestStation(options: NearestOptions): {
|
|
|
89
89
|
units: Units;
|
|
90
90
|
station: Station;
|
|
91
91
|
distance: number | undefined;
|
|
92
|
-
timeline: _neaps_tide_predictor0.TimelinePoint[];
|
|
92
|
+
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
93
93
|
};
|
|
94
94
|
getWaterLevelAtTime({
|
|
95
95
|
time,
|
|
@@ -152,7 +152,7 @@ declare function nearestStation(options: NearestOptions): {
|
|
|
152
152
|
declare function stationsNear(options: NearOptions): {
|
|
153
153
|
distance: number | undefined;
|
|
154
154
|
datums: Record<string, number>;
|
|
155
|
-
harmonic_constituents: _neaps_tide_database0.HarmonicConstituent[];
|
|
155
|
+
harmonic_constituents: _$_neaps_tide_database0.HarmonicConstituent[];
|
|
156
156
|
defaultDatum: string | undefined;
|
|
157
157
|
getExtremesPrediction({
|
|
158
158
|
datum,
|
|
@@ -164,7 +164,7 @@ declare function stationsNear(options: NearOptions): {
|
|
|
164
164
|
units: Units;
|
|
165
165
|
station: Station;
|
|
166
166
|
distance: number | undefined;
|
|
167
|
-
extremes: _neaps_tide_predictor0.Extreme[];
|
|
167
|
+
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
168
168
|
};
|
|
169
169
|
getTimelinePrediction({
|
|
170
170
|
datum,
|
|
@@ -176,7 +176,7 @@ declare function stationsNear(options: NearOptions): {
|
|
|
176
176
|
units: Units;
|
|
177
177
|
station: Station;
|
|
178
178
|
distance: number | undefined;
|
|
179
|
-
timeline: _neaps_tide_predictor0.TimelinePoint[];
|
|
179
|
+
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
180
180
|
};
|
|
181
181
|
getWaterLevelAtTime({
|
|
182
182
|
time,
|
|
@@ -238,7 +238,7 @@ declare function stationsNear(options: NearOptions): {
|
|
|
238
238
|
declare function findStation(query: string): {
|
|
239
239
|
distance: number | undefined;
|
|
240
240
|
datums: Record<string, number>;
|
|
241
|
-
harmonic_constituents: _neaps_tide_database0.HarmonicConstituent[];
|
|
241
|
+
harmonic_constituents: _$_neaps_tide_database0.HarmonicConstituent[];
|
|
242
242
|
defaultDatum: string | undefined;
|
|
243
243
|
getExtremesPrediction({
|
|
244
244
|
datum,
|
|
@@ -250,7 +250,7 @@ declare function findStation(query: string): {
|
|
|
250
250
|
units: Units;
|
|
251
251
|
station: Station;
|
|
252
252
|
distance: number | undefined;
|
|
253
|
-
extremes: _neaps_tide_predictor0.Extreme[];
|
|
253
|
+
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
254
254
|
};
|
|
255
255
|
getTimelinePrediction({
|
|
256
256
|
datum,
|
|
@@ -262,7 +262,7 @@ declare function findStation(query: string): {
|
|
|
262
262
|
units: Units;
|
|
263
263
|
station: Station;
|
|
264
264
|
distance: number | undefined;
|
|
265
|
-
timeline: _neaps_tide_predictor0.TimelinePoint[];
|
|
265
|
+
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
266
266
|
};
|
|
267
267
|
getWaterLevelAtTime({
|
|
268
268
|
time,
|
|
@@ -321,7 +321,7 @@ declare function findStation(query: string): {
|
|
|
321
321
|
declare function useStation(station: Station, distance?: number): {
|
|
322
322
|
distance: number | undefined;
|
|
323
323
|
datums: Record<string, number>;
|
|
324
|
-
harmonic_constituents: _neaps_tide_database0.HarmonicConstituent[];
|
|
324
|
+
harmonic_constituents: _$_neaps_tide_database0.HarmonicConstituent[];
|
|
325
325
|
defaultDatum: string | undefined;
|
|
326
326
|
getExtremesPrediction({
|
|
327
327
|
datum,
|
|
@@ -333,7 +333,7 @@ declare function useStation(station: Station, distance?: number): {
|
|
|
333
333
|
units: Units;
|
|
334
334
|
station: Station;
|
|
335
335
|
distance: number | undefined;
|
|
336
|
-
extremes: _neaps_tide_predictor0.Extreme[];
|
|
336
|
+
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
337
337
|
};
|
|
338
338
|
getTimelinePrediction({
|
|
339
339
|
datum,
|
|
@@ -345,7 +345,7 @@ declare function useStation(station: Station, distance?: number): {
|
|
|
345
345
|
units: Units;
|
|
346
346
|
station: Station;
|
|
347
347
|
distance: number | undefined;
|
|
348
|
-
timeline: _neaps_tide_predictor0.TimelinePoint[];
|
|
348
|
+
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
349
349
|
};
|
|
350
350
|
getWaterLevelAtTime({
|
|
351
351
|
time,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as _neaps_tide_database0 from "@neaps/tide-database";
|
|
1
|
+
import * as _$_neaps_tide_database0 from "@neaps/tide-database";
|
|
2
2
|
import { NearOptions, NearestOptions, Station } from "@neaps/tide-database";
|
|
3
|
-
import * as _neaps_tide_predictor0 from "@neaps/tide-predictor";
|
|
3
|
+
import * as _$_neaps_tide_predictor0 from "@neaps/tide-predictor";
|
|
4
4
|
import { ExtremesInput, TimelineInput } from "@neaps/tide-predictor";
|
|
5
5
|
|
|
6
6
|
//#region src/index.d.ts
|
|
@@ -35,7 +35,7 @@ declare function getExtremesPrediction(options: NearestOptions & ExtremesOptions
|
|
|
35
35
|
units: Units;
|
|
36
36
|
station: Station;
|
|
37
37
|
distance: number | undefined;
|
|
38
|
-
extremes: _neaps_tide_predictor0.Extreme[];
|
|
38
|
+
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
39
39
|
};
|
|
40
40
|
/**
|
|
41
41
|
* Get timeline prediction using the nearest station to the given position.
|
|
@@ -45,7 +45,7 @@ declare function getTimelinePrediction(options: NearestOptions & TimelineOptions
|
|
|
45
45
|
units: Units;
|
|
46
46
|
station: Station;
|
|
47
47
|
distance: number | undefined;
|
|
48
|
-
timeline: _neaps_tide_predictor0.TimelinePoint[];
|
|
48
|
+
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
49
49
|
};
|
|
50
50
|
/**
|
|
51
51
|
* Get water level at a specific time using the nearest station to the given position.
|
|
@@ -65,7 +65,7 @@ declare function getWaterLevelAtTime(options: NearestOptions & WaterLevelOptions
|
|
|
65
65
|
declare function nearestStation(options: NearestOptions): {
|
|
66
66
|
distance: number | undefined;
|
|
67
67
|
datums: Record<string, number>;
|
|
68
|
-
harmonic_constituents: _neaps_tide_database0.HarmonicConstituent[];
|
|
68
|
+
harmonic_constituents: _$_neaps_tide_database0.HarmonicConstituent[];
|
|
69
69
|
defaultDatum: string | undefined;
|
|
70
70
|
getExtremesPrediction({
|
|
71
71
|
datum,
|
|
@@ -77,7 +77,7 @@ declare function nearestStation(options: NearestOptions): {
|
|
|
77
77
|
units: Units;
|
|
78
78
|
station: Station;
|
|
79
79
|
distance: number | undefined;
|
|
80
|
-
extremes: _neaps_tide_predictor0.Extreme[];
|
|
80
|
+
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
81
81
|
};
|
|
82
82
|
getTimelinePrediction({
|
|
83
83
|
datum,
|
|
@@ -89,7 +89,7 @@ declare function nearestStation(options: NearestOptions): {
|
|
|
89
89
|
units: Units;
|
|
90
90
|
station: Station;
|
|
91
91
|
distance: number | undefined;
|
|
92
|
-
timeline: _neaps_tide_predictor0.TimelinePoint[];
|
|
92
|
+
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
93
93
|
};
|
|
94
94
|
getWaterLevelAtTime({
|
|
95
95
|
time,
|
|
@@ -152,7 +152,7 @@ declare function nearestStation(options: NearestOptions): {
|
|
|
152
152
|
declare function stationsNear(options: NearOptions): {
|
|
153
153
|
distance: number | undefined;
|
|
154
154
|
datums: Record<string, number>;
|
|
155
|
-
harmonic_constituents: _neaps_tide_database0.HarmonicConstituent[];
|
|
155
|
+
harmonic_constituents: _$_neaps_tide_database0.HarmonicConstituent[];
|
|
156
156
|
defaultDatum: string | undefined;
|
|
157
157
|
getExtremesPrediction({
|
|
158
158
|
datum,
|
|
@@ -164,7 +164,7 @@ declare function stationsNear(options: NearOptions): {
|
|
|
164
164
|
units: Units;
|
|
165
165
|
station: Station;
|
|
166
166
|
distance: number | undefined;
|
|
167
|
-
extremes: _neaps_tide_predictor0.Extreme[];
|
|
167
|
+
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
168
168
|
};
|
|
169
169
|
getTimelinePrediction({
|
|
170
170
|
datum,
|
|
@@ -176,7 +176,7 @@ declare function stationsNear(options: NearOptions): {
|
|
|
176
176
|
units: Units;
|
|
177
177
|
station: Station;
|
|
178
178
|
distance: number | undefined;
|
|
179
|
-
timeline: _neaps_tide_predictor0.TimelinePoint[];
|
|
179
|
+
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
180
180
|
};
|
|
181
181
|
getWaterLevelAtTime({
|
|
182
182
|
time,
|
|
@@ -238,7 +238,7 @@ declare function stationsNear(options: NearOptions): {
|
|
|
238
238
|
declare function findStation(query: string): {
|
|
239
239
|
distance: number | undefined;
|
|
240
240
|
datums: Record<string, number>;
|
|
241
|
-
harmonic_constituents: _neaps_tide_database0.HarmonicConstituent[];
|
|
241
|
+
harmonic_constituents: _$_neaps_tide_database0.HarmonicConstituent[];
|
|
242
242
|
defaultDatum: string | undefined;
|
|
243
243
|
getExtremesPrediction({
|
|
244
244
|
datum,
|
|
@@ -250,7 +250,7 @@ declare function findStation(query: string): {
|
|
|
250
250
|
units: Units;
|
|
251
251
|
station: Station;
|
|
252
252
|
distance: number | undefined;
|
|
253
|
-
extremes: _neaps_tide_predictor0.Extreme[];
|
|
253
|
+
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
254
254
|
};
|
|
255
255
|
getTimelinePrediction({
|
|
256
256
|
datum,
|
|
@@ -262,7 +262,7 @@ declare function findStation(query: string): {
|
|
|
262
262
|
units: Units;
|
|
263
263
|
station: Station;
|
|
264
264
|
distance: number | undefined;
|
|
265
|
-
timeline: _neaps_tide_predictor0.TimelinePoint[];
|
|
265
|
+
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
266
266
|
};
|
|
267
267
|
getWaterLevelAtTime({
|
|
268
268
|
time,
|
|
@@ -321,7 +321,7 @@ declare function findStation(query: string): {
|
|
|
321
321
|
declare function useStation(station: Station, distance?: number): {
|
|
322
322
|
distance: number | undefined;
|
|
323
323
|
datums: Record<string, number>;
|
|
324
|
-
harmonic_constituents: _neaps_tide_database0.HarmonicConstituent[];
|
|
324
|
+
harmonic_constituents: _$_neaps_tide_database0.HarmonicConstituent[];
|
|
325
325
|
defaultDatum: string | undefined;
|
|
326
326
|
getExtremesPrediction({
|
|
327
327
|
datum,
|
|
@@ -333,7 +333,7 @@ declare function useStation(station: Station, distance?: number): {
|
|
|
333
333
|
units: Units;
|
|
334
334
|
station: Station;
|
|
335
335
|
distance: number | undefined;
|
|
336
|
-
extremes: _neaps_tide_predictor0.Extreme[];
|
|
336
|
+
extremes: _$_neaps_tide_predictor0.Extreme[];
|
|
337
337
|
};
|
|
338
338
|
getTimelinePrediction({
|
|
339
339
|
datum,
|
|
@@ -345,7 +345,7 @@ declare function useStation(station: Station, distance?: number): {
|
|
|
345
345
|
units: Units;
|
|
346
346
|
station: Station;
|
|
347
347
|
distance: number | undefined;
|
|
348
|
-
timeline: _neaps_tide_predictor0.TimelinePoint[];
|
|
348
|
+
timeline: _$_neaps_tide_predictor0.TimelinePoint[];
|
|
349
349
|
};
|
|
350
350
|
getWaterLevelAtTime({
|
|
351
351
|
time,
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { near, nearest, stations } from "@neaps/tide-database";
|
|
2
2
|
import { createTidePredictor } from "@neaps/tide-predictor";
|
|
3
|
-
|
|
4
3
|
//#region src/index.ts
|
|
5
4
|
const feetPerMeter = 3.2808399;
|
|
6
5
|
const defaultUnits = "meters";
|
|
@@ -103,7 +102,6 @@ function useStation(station, distance) {
|
|
|
103
102
|
};
|
|
104
103
|
},
|
|
105
104
|
getTimelinePrediction({ datum = defaultDatum, units = defaultUnits, nodeCorrections, ...options }) {
|
|
106
|
-
if (station.type === "subordinate") throw new Error(`Timeline predictions are not supported for subordinate stations.`);
|
|
107
105
|
return {
|
|
108
106
|
datum,
|
|
109
107
|
units,
|
|
@@ -112,11 +110,13 @@ function useStation(station, distance) {
|
|
|
112
110
|
timeline: getPredictor({
|
|
113
111
|
datum,
|
|
114
112
|
nodeCorrections
|
|
115
|
-
}).getTimelinePrediction(
|
|
113
|
+
}).getTimelinePrediction({
|
|
114
|
+
...options,
|
|
115
|
+
offsets: station.offsets
|
|
116
|
+
}).map((e) => toPreferredUnits(e, units))
|
|
116
117
|
};
|
|
117
118
|
},
|
|
118
119
|
getWaterLevelAtTime({ time, datum = defaultDatum, units = defaultUnits, nodeCorrections }) {
|
|
119
|
-
if (station.type === "subordinate") throw new Error(`Water level predictions are not supported for subordinate stations.`);
|
|
120
120
|
return {
|
|
121
121
|
datum,
|
|
122
122
|
units,
|
|
@@ -125,7 +125,10 @@ function useStation(station, distance) {
|
|
|
125
125
|
...toPreferredUnits(getPredictor({
|
|
126
126
|
datum,
|
|
127
127
|
nodeCorrections
|
|
128
|
-
}).getWaterLevelAtTime({
|
|
128
|
+
}).getWaterLevelAtTime({
|
|
129
|
+
time,
|
|
130
|
+
offsets: station.offsets
|
|
131
|
+
}), units)
|
|
129
132
|
};
|
|
130
133
|
}
|
|
131
134
|
};
|
|
@@ -139,7 +142,7 @@ function toPreferredUnits(prediction, units) {
|
|
|
139
142
|
level
|
|
140
143
|
};
|
|
141
144
|
}
|
|
142
|
-
|
|
143
145
|
//#endregion
|
|
144
146
|
export { findStation, getExtremesPrediction, getTimelinePrediction, getWaterLevelAtTime, nearestStation, stationsNear, useStation };
|
|
147
|
+
|
|
145
148
|
//# 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 Station,\n type NearOptions,\n type NearestOptions,\n} from \"@neaps/tide-database\";\nimport { createTidePredictor, type ExtremesInput, type TimelineInput } from \"@neaps/tide-predictor\";\n\ntype Units = \"meters\" | \"feet\";\ntype PredictionOptions = {\n /** Datum to return predictions in. Defaults to the nearest station's datum. */\n datum?: string;\n\n /** Units for returned water levels. Defaults to 'meters'. */\n units?: Units;\n\n /** Nodal correction fundamentals. Defaults to 'iho'. */\n nodeCorrections?: \"iho\" | \"schureman\";\n};\n\nexport type ExtremesOptions = ExtremesInput & PredictionOptions;\nexport type TimelineOptions = TimelineInput & PredictionOptions;\nexport type WaterLevelOptions = { time: Date } & PredictionOptions;\n\nconst feetPerMeter = 3.2808399;\nconst defaultUnits: Units = \"meters\";\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 & ExtremesOptions) {\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 & TimelineOptions) {\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 & WaterLevelOptions) {\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) {\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\n return useStation(found);\n}\n\nexport function useStation(station: Station, distance?: number) {\n // If subordinate station, use the reference station for datums and constituents\n let reference = station;\n if (station.type === \"subordinate\" && station.offsets?.reference) {\n reference = findStation(station.offsets?.reference);\n }\n const { datums, harmonic_constituents } = reference;\n\n // Use station chart datum as the default datum if available\n const defaultDatum = station.chart_datum in datums ? station.chart_datum : undefined;\n\n function getPredictor({ datum = defaultDatum, nodeCorrections }: PredictionOptions = {}) {\n let offset = 0;\n\n if (datum) {\n const datumOffset = datums?.[datum];\n const mslOffset = datums?.[\"MSL\"];\n\n if (typeof datumOffset !== \"number\") {\n throw new Error(\n `Station ${station.id} missing ${datum} datum. Available datums: ${Object.keys(datums).join(\", \")}`,\n );\n }\n\n if (typeof mslOffset !== \"number\") {\n throw new Error(\n `Station ${station.id} missing MSL datum, so predictions can't be given in ${datum}.`,\n );\n }\n\n offset = mslOffset - datumOffset;\n }\n\n return createTidePredictor(harmonic_constituents, { offset, nodeCorrections });\n }\n\n return {\n ...station,\n distance,\n datums,\n harmonic_constituents,\n defaultDatum,\n getExtremesPrediction({\n datum = defaultDatum,\n units = defaultUnits,\n nodeCorrections,\n ...options\n }: ExtremesOptions) {\n const extremes = getPredictor({ datum, nodeCorrections })\n .getExtremesPrediction({ ...options, offsets: station.offsets })\n .map((e) => toPreferredUnits(e, units));\n\n return { datum, units, station, distance, extremes };\n },\n\n getTimelinePrediction({\n datum = defaultDatum,\n units = defaultUnits,\n nodeCorrections,\n ...options\n }: TimelineOptions) {\n
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n stations,\n near,\n nearest,\n type Station,\n type NearOptions,\n type NearestOptions,\n} from \"@neaps/tide-database\";\nimport { createTidePredictor, type ExtremesInput, type TimelineInput } from \"@neaps/tide-predictor\";\n\ntype Units = \"meters\" | \"feet\";\ntype PredictionOptions = {\n /** Datum to return predictions in. Defaults to the nearest station's datum. */\n datum?: string;\n\n /** Units for returned water levels. Defaults to 'meters'. */\n units?: Units;\n\n /** Nodal correction fundamentals. Defaults to 'iho'. */\n nodeCorrections?: \"iho\" | \"schureman\";\n};\n\nexport type ExtremesOptions = ExtremesInput & PredictionOptions;\nexport type TimelineOptions = TimelineInput & PredictionOptions;\nexport type WaterLevelOptions = { time: Date } & PredictionOptions;\n\nconst feetPerMeter = 3.2808399;\nconst defaultUnits: Units = \"meters\";\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 & ExtremesOptions) {\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 & TimelineOptions) {\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 & WaterLevelOptions) {\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) {\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\n return useStation(found);\n}\n\nexport function useStation(station: Station, distance?: number) {\n // If subordinate station, use the reference station for datums and constituents\n let reference = station;\n if (station.type === \"subordinate\" && station.offsets?.reference) {\n reference = findStation(station.offsets?.reference);\n }\n const { datums, harmonic_constituents } = reference;\n\n // Use station chart datum as the default datum if available\n const defaultDatum = station.chart_datum in datums ? station.chart_datum : undefined;\n\n function getPredictor({ datum = defaultDatum, nodeCorrections }: PredictionOptions = {}) {\n let offset = 0;\n\n if (datum) {\n const datumOffset = datums?.[datum];\n const mslOffset = datums?.[\"MSL\"];\n\n if (typeof datumOffset !== \"number\") {\n throw new Error(\n `Station ${station.id} missing ${datum} datum. Available datums: ${Object.keys(datums).join(\", \")}`,\n );\n }\n\n if (typeof mslOffset !== \"number\") {\n throw new Error(\n `Station ${station.id} missing MSL datum, so predictions can't be given in ${datum}.`,\n );\n }\n\n offset = mslOffset - datumOffset;\n }\n\n return createTidePredictor(harmonic_constituents, { offset, nodeCorrections });\n }\n\n return {\n ...station,\n distance,\n datums,\n harmonic_constituents,\n defaultDatum,\n getExtremesPrediction({\n datum = defaultDatum,\n units = defaultUnits,\n nodeCorrections,\n ...options\n }: ExtremesOptions) {\n const extremes = getPredictor({ datum, nodeCorrections })\n .getExtremesPrediction({ ...options, offsets: station.offsets })\n .map((e) => toPreferredUnits(e, units));\n\n return { datum, units, station, distance, extremes };\n },\n\n getTimelinePrediction({\n datum = defaultDatum,\n units = defaultUnits,\n nodeCorrections,\n ...options\n }: TimelineOptions) {\n const timeline = getPredictor({ datum, nodeCorrections })\n .getTimelinePrediction({ ...options, offsets: station.offsets })\n .map((e) => toPreferredUnits(e, units));\n\n return { datum, units, station, distance, timeline };\n },\n\n getWaterLevelAtTime({\n time,\n datum = defaultDatum,\n units = defaultUnits,\n nodeCorrections,\n }: WaterLevelOptions) {\n const prediction = toPreferredUnits(\n getPredictor({ datum, nodeCorrections }).getWaterLevelAtTime({\n time,\n offsets: station.offsets,\n }),\n units,\n );\n\n return { datum, units, station, distance, ...prediction };\n },\n };\n}\n\nfunction toPreferredUnits<T extends { level: number }>(prediction: T, units: Units): T {\n let { level } = prediction;\n if (units === \"feet\") level *= feetPerMeter;\n else if (units !== \"meters\") throw new Error(`Unsupported units: ${units}`);\n return { ...prediction, level };\n}\n"],"mappings":";;;AA0BA,MAAM,eAAe;AACrB,MAAM,eAAsB;;;;;;;;;;;;;;;;AAiB5B,SAAgB,sBAAsB,SAA2C;AAC/E,QAAO,eAAe,QAAQ,CAAC,sBAAsB,QAAQ;;;;;AAM/D,SAAgB,sBAAsB,SAA2C;AAC/E,QAAO,eAAe,QAAQ,CAAC,sBAAsB,QAAQ;;;;;AAM/D,SAAgB,oBAAoB,SAA6C;AAC/E,QAAO,eAAe,QAAQ,CAAC,oBAAoB,QAAQ;;;;;AAM7D,SAAgB,eAAe,SAAyB;CACtD,MAAM,OAAO,QAAQ,QAAQ;AAC7B,KAAI,CAAC,KAAM,OAAM,IAAI,MAAM,mCAAmC,KAAK,UAAU,QAAQ,GAAG;AACxF,QAAO,WAAW,GAAG,KAAK;;;;;;AAO5B,SAAgB,aAAa,SAAsB;AACjD,QAAO,KAAK,QAAQ,CAAC,KAAK,CAAC,SAAS,cAAc,WAAW,SAAS,SAAS,CAAC;;;;;AAMlF,SAAgB,YAAY,OAAe;CACzC,MAAM,WAAW,EAAE,MAAe,EAAE,OAAO,QAAQ,MAAe,EAAE,OAAO,OAAO,MAAM;CAExF,IAAI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AO;IAAO;IAAS;IAAU,UAJzB,aAAa;KAAE;KAAO;KAAiB,CAAC,CACtD,sBAAsB;KAAE,GAAG;KAAS,SAAS,QAAQ;KAAS,CAAC,CAC/D,KAAK,MAAM,iBAAiB,GAAG,MAAM,CAEU;IAAE;;EAGtD,oBAAoB,EAClB,MACA,QAAQ,cACR,QAAQ,cACR,mBACoB;AASpB,UAAO;IAAE;IAAO;IAAO;IAAS;IAAU,GARvB,iBACjB,aAAa;KAAE;KAAO;KAAiB,CAAC,CAAC,oBAAoB;KAC3D;KACA,SAAS,QAAQ;KAClB,CAAC,EACF,MAGqD;IAAE;;EAE5D;;AAGH,SAAS,iBAA8C,YAAe,OAAiB;CACrF,IAAI,EAAE,UAAU;AAChB,KAAI,UAAU,OAAQ,UAAS;UACtB,UAAU,SAAU,OAAM,IAAI,MAAM,sBAAsB,QAAQ;AAC3E,QAAO;EAAE,GAAG;EAAY;EAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neaps",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
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.7",
|
|
38
|
+
"@neaps/tide-predictor": "^0.9.0"
|
|
39
39
|
}
|
|
40
40
|
}
|