Hinweise optimiert
This commit is contained in:
@@ -268,8 +268,6 @@ describe("route guidance", () => {
|
||||
distanceNm: 1,
|
||||
eta: null,
|
||||
warnings: [],
|
||||
minKnownDepthM: null,
|
||||
unknownDepthRatio: 1,
|
||||
dataSources: []
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
buildRoute,
|
||||
FairwayRoutingSearchLimitError,
|
||||
haversineDistanceNm,
|
||||
requiredDepthM,
|
||||
type FairwayEdge,
|
||||
type FairwayGraph
|
||||
} from "../src/index.js";
|
||||
@@ -14,6 +13,14 @@ import {
|
||||
const EMDEN_AUSSENHAFEN = { lat: 53.344167, lon: 7.186111 };
|
||||
const BORKUM_REEDE = { lat: 53.563776, lon: 6.750562 };
|
||||
const HAMM_INNENSTADT_MARINA = { lat: 51.6814536, lon: 7.8042615 };
|
||||
const REMOVED_AUTOMATIC_ROUTE_WARNING_CODES = new Set([
|
||||
"FAIRWAY_ROUTE",
|
||||
"FAIRWAY_DATA_NOT_OFFICIAL",
|
||||
"DEPTH_UNKNOWN",
|
||||
"DEPTH_PARTIAL",
|
||||
"NO_KNOWN_DEPTH",
|
||||
"DEPTH_TOO_SHALLOW"
|
||||
]);
|
||||
|
||||
const ALTERNATIVE_GRAPH: FairwayGraph = {
|
||||
id: "alternative-test",
|
||||
@@ -92,7 +99,6 @@ function edge(
|
||||
from,
|
||||
to,
|
||||
coordinates,
|
||||
minDepthM: 4,
|
||||
source: "synthetic-test",
|
||||
...restrictions
|
||||
};
|
||||
@@ -119,32 +125,17 @@ function singleEdgeGraph(restrictions: Partial<FairwayEdge>): FairwayGraph {
|
||||
};
|
||||
}
|
||||
|
||||
describe("route assessment", () => {
|
||||
it("marks routes with no depth data as unknown", () => {
|
||||
describe("route building", () => {
|
||||
it("builds manual routes without synthesizing a depth status", () => {
|
||||
const result = buildManualRoute({
|
||||
start: { lat: 54.18, lon: 12.08 },
|
||||
destination: { lat: 54.32, lon: 12.22 },
|
||||
vesselProfile: { draughtM: 1.4, safetyReserveM: 0.5 }
|
||||
});
|
||||
|
||||
expect(result.unknownDepthRatio).toBe(1);
|
||||
expect(result.warnings.some((warning) => warning.code === "DEPTH_UNKNOWN")).toBe(true);
|
||||
});
|
||||
|
||||
it("flags known shallow samples as critical", () => {
|
||||
const result = buildManualRoute({
|
||||
start: { lat: 54.18, lon: 12.08 },
|
||||
destination: { lat: 54.32, lon: 12.22 },
|
||||
vesselProfile: { draughtM: 1.4, safetyReserveM: 0.5 },
|
||||
depthSamples: [
|
||||
{ coordinate: { lat: 54.2, lon: 12.1 }, depthM: 1.6 },
|
||||
{ coordinate: { lat: 54.25, lon: 12.16 }, depthM: 2.4 }
|
||||
]
|
||||
});
|
||||
|
||||
expect(requiredDepthM({ draughtM: 1.4, safetyReserveM: 0.5 })).toBe(1.9);
|
||||
expect(result.minKnownDepthM).toBe(1.6);
|
||||
expect(result.warnings.some((warning) => warning.severity === "critical")).toBe(true);
|
||||
expect(result.warnings.map((warning) => warning.code)).toEqual(["MANUAL_ROUTE"]);
|
||||
expect(result).not.toHaveProperty("minKnownDepthM");
|
||||
expect(result).not.toHaveProperty("unknownDepthRatio");
|
||||
});
|
||||
|
||||
it("routes Emden Außenhafen to Borkum Reede along the Ems fairway graph", () => {
|
||||
@@ -175,8 +166,14 @@ describe("route assessment", () => {
|
||||
|
||||
expect(result.routingMode).toBe("fairway");
|
||||
expect(result.dataSources).toContain("fairway-graph:ems-borkum-seed");
|
||||
expect(result.warnings.some((warning) => warning.code === "FAIRWAY_ROUTE")).toBe(true);
|
||||
expect(result.warnings.some((warning) => warning.code === "MANUAL_ROUTE")).toBe(false);
|
||||
expect(
|
||||
result.warnings.some((warning) =>
|
||||
REMOVED_AUTOMATIC_ROUTE_WARNING_CODES.has(warning.code)
|
||||
)
|
||||
).toBe(false);
|
||||
expect(result).not.toHaveProperty("minKnownDepthM");
|
||||
expect(result).not.toHaveProperty("unknownDepthRatio");
|
||||
expect(coordinates.length).toBeGreaterThan(20);
|
||||
expect(result.distanceNm).toBeGreaterThan(directDistanceNm * 1.2);
|
||||
expect(largestSegmentNm).toBeLessThan(6);
|
||||
@@ -606,7 +603,11 @@ describe("route assessment", () => {
|
||||
expect(result?.dataSources).toContain("fairway-graph:emden-hamm-inland-seed");
|
||||
expect(result?.dataSources).toContain("openstreetmap-geofabrik-curated-seed");
|
||||
expect(result?.dataSources).toContain("openstreetmap-nominatim-curated-seed");
|
||||
expect(result?.warnings.some((warning) => warning.code === "FAIRWAY_DATA_NOT_OFFICIAL")).toBe(true);
|
||||
expect(
|
||||
result?.warnings.some((warning) =>
|
||||
REMOVED_AUTOMATIC_ROUTE_WARNING_CODES.has(warning.code)
|
||||
)
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("uses the requested departure time as the basis for duration and ETA", () => {
|
||||
|
||||
Reference in New Issue
Block a user