fix(prediction): correct lon mapping
This commit is contained in:
parent
eb7698e034
commit
7b7282c3c9
4 changed files with 271 additions and 17 deletions
|
|
@ -1,18 +1,6 @@
|
|||
import { api } from './client';
|
||||
import type { FlightParameters, RawPrediction } from '$domain';
|
||||
|
||||
/**
|
||||
* GFS datasets are published every 6 hours with a ~6 hour processing lag.
|
||||
* Round down to the most recent available slot.
|
||||
*/
|
||||
export function getLatestDataset(now: Date = new Date()): string {
|
||||
// const rounded = new Date(now);
|
||||
// rounded.setUTCHours(Math.floor(rounded.getUTCHours() / 6) * 6, 0, 0, 0);
|
||||
// rounded.setUTCHours(rounded.getUTCHours() - 6);
|
||||
// return rounded.toISOString();
|
||||
return "2025-04-06T00:00:00Z";
|
||||
}
|
||||
|
||||
export function buildLaunchDateTime(date: string, time: string): string {
|
||||
const fullTime = time.split(':').length === 2 ? `${time}:00` : time;
|
||||
return new Date(`${date}T${fullTime}Z`).toISOString();
|
||||
|
|
@ -24,11 +12,17 @@ export interface PredictionResponse {
|
|||
|
||||
export const predictionsApi = {
|
||||
run: (params: FlightParameters, launchDateTime: string) => {
|
||||
const payload: FlightParameters & { launch_datetime: string } = {
|
||||
...params,
|
||||
dataset: params.dataset || getLatestDataset(),
|
||||
// `dataset` carries only what the operator actually chose. It used to fall
|
||||
// back to a client-side guess at which GFS run the server holds — and the
|
||||
// guess had degenerated into a hardcoded 2025-04-06, over a year stale. The
|
||||
// client cannot know which runs are stored; the predictor refuses one it
|
||||
// does not have, so an unset value must stay unset and let the server pick.
|
||||
const { dataset, ...rest } = params;
|
||||
const payload = {
|
||||
...rest,
|
||||
...(dataset ? { dataset } : {}),
|
||||
launch_datetime: launchDateTime,
|
||||
};
|
||||
} as FlightParameters & { launch_datetime: string };
|
||||
if (payload.start_point === -1) delete payload.start_point;
|
||||
return api.post<PredictionResponse>('/predictions/', payload);
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue