fix: close California play and asset acceptance gaps
This commit is contained in:
@@ -168,15 +168,23 @@ function checkedEnvelope(value: CaliforniaFlightEnvelope | undefined): Californi
|
||||
return envelope;
|
||||
}
|
||||
|
||||
function checkedRoute(route: readonly AircraftWaypoint[] | undefined): readonly AircraftWaypoint[] {
|
||||
function checkedRoute(
|
||||
route: readonly AircraftWaypoint[] | undefined,
|
||||
envelope: CaliforniaFlightEnvelope,
|
||||
): readonly AircraftWaypoint[] {
|
||||
if (!route) return [];
|
||||
const ids = new Set<string>();
|
||||
return route.map((point) => {
|
||||
if (
|
||||
typeof point.id !== "string" || point.id.length === 0 || ids.has(point.id) ||
|
||||
!Number.isFinite(point.lat) || !Number.isFinite(point.lng) ||
|
||||
!Number.isFinite(point.altitudeM)
|
||||
) throw new RangeError("aircraft route waypoints must be finite with unique ids");
|
||||
!Number.isFinite(point.altitudeM) ||
|
||||
point.lat < envelope.minLat || point.lat > envelope.maxLat ||
|
||||
point.lng < envelope.minLng || point.lng > envelope.maxLng ||
|
||||
point.altitudeM < envelope.minAltitudeM || point.altitudeM > envelope.maxAltitudeM
|
||||
) throw new RangeError(
|
||||
"aircraft route waypoints must be finite, unique, and inside the flight envelope",
|
||||
);
|
||||
ids.add(point.id);
|
||||
return { ...point };
|
||||
});
|
||||
@@ -200,7 +208,7 @@ function resolveOptions(value: AircraftControllerOptions): ResolvedOptions {
|
||||
initialHeadingDeg: wrapDegrees(finiteOr(value.initialHeadingDeg, 320)),
|
||||
initialSpeedMps: clamp(finiteOr(value.initialSpeedMps, 55), minimumSpeedMps, maximumSpeedMps),
|
||||
mode: value.mode === "manual" ? "manual" : "assisted",
|
||||
route: checkedRoute(value.route),
|
||||
route: checkedRoute(value.route, envelope),
|
||||
envelope,
|
||||
minimumSpeedMps,
|
||||
maximumSpeedMps,
|
||||
|
||||
Reference in New Issue
Block a user