Hinweise optimiert
This commit is contained in:
+1
-10
@@ -56,16 +56,7 @@ const routeRequestSchema = z.object({
|
||||
airDraftM: z.number().positive().max(80).optional(),
|
||||
beamM: z.number().positive().max(80).optional(),
|
||||
cruiseSpeedKn: z.number().positive().max(80).optional()
|
||||
}),
|
||||
depthSamples: z
|
||||
.array(
|
||||
z.object({
|
||||
coordinate: coordinateSchema,
|
||||
depthM: z.number().nullable()
|
||||
})
|
||||
)
|
||||
.max(500)
|
||||
.optional()
|
||||
})
|
||||
}) satisfies z.ZodType<RouteRequest>;
|
||||
|
||||
const coordinateQuerySchema = z.object({
|
||||
|
||||
@@ -54,7 +54,6 @@ export type FairwayRow = {
|
||||
source: string;
|
||||
source_id: string | null;
|
||||
name: string | null;
|
||||
min_depth_m: string | number | null;
|
||||
properties?: Record<string, unknown> | null;
|
||||
geometry: {
|
||||
type: "LineString";
|
||||
@@ -165,7 +164,6 @@ export class FairwayService {
|
||||
source,
|
||||
source_id,
|
||||
name,
|
||||
min_depth_m,
|
||||
properties,
|
||||
ST_AsGeoJSON(geom)::json AS geometry
|
||||
FROM marine_fairway_edges
|
||||
@@ -328,7 +326,6 @@ export function fairwayRowsToGraph(rows: FairwayRow[], bbox: [number, number, nu
|
||||
id: `postgis-edge-${row.id}`,
|
||||
name: row.name ?? row.source_id ?? `PostGIS ${row.id}`,
|
||||
coordinates: row.geometry.coordinates.map(([lon, lat]) => ({ lon, lat })),
|
||||
minDepthM: parseNumeric(row.min_depth_m),
|
||||
source: `postgis-${row.source}`,
|
||||
...edgeRestrictions(tags)
|
||||
};
|
||||
@@ -352,7 +349,6 @@ export function overpassToGraph(response: OverpassResponse, bbox: [number, numbe
|
||||
id: `osm-way-${element.id}`,
|
||||
name: tags.name ?? tags.ref ?? `OSM ${element.id}`,
|
||||
coordinates,
|
||||
minDepthM: parseDepth(tags),
|
||||
source: sourceFor(tags),
|
||||
...edgeRestrictions(tags)
|
||||
};
|
||||
@@ -386,7 +382,6 @@ export function localFairwaysToGraph(
|
||||
id: `local-osm-way-${way.id}`,
|
||||
name: tags.name ?? tags.ref ?? `OSM ${way.id}`,
|
||||
coordinates,
|
||||
minDepthM: parseDepth(tags),
|
||||
source: `local-geofabrik-${source}`,
|
||||
...edgeRestrictions(tags)
|
||||
};
|
||||
@@ -443,7 +438,6 @@ function waysToGraph(
|
||||
id: string;
|
||||
name: string;
|
||||
coordinates: Coordinate[];
|
||||
minDepthM: number | null;
|
||||
source: string;
|
||||
maxAirDraftM?: number | null;
|
||||
maxBeamM?: number | null;
|
||||
@@ -473,7 +467,6 @@ function waysToGraph(
|
||||
from,
|
||||
to,
|
||||
coordinates: [start, end],
|
||||
minDepthM: way.minDepthM,
|
||||
source: way.source,
|
||||
maxAirDraftM: way.maxAirDraftM,
|
||||
maxBeamM: way.maxBeamM,
|
||||
@@ -579,28 +572,6 @@ function nodeIdFor(nodes: Map<string, FairwayNode>, coordinate: Coordinate) {
|
||||
return id;
|
||||
}
|
||||
|
||||
function parseDepth(tags: Record<string, string>) {
|
||||
const candidates = [
|
||||
tags["seamark:fairway:minimum_depth"],
|
||||
tags["seamark:recommended_track:minimum_depth"],
|
||||
tags["seamark:navigation_line:minimum_depth"],
|
||||
tags["depth"],
|
||||
tags["min_depth"]
|
||||
];
|
||||
|
||||
for (const candidate of candidates) {
|
||||
if (!candidate) {
|
||||
continue;
|
||||
}
|
||||
const parsed = parseNumeric(candidate);
|
||||
if (Number.isFinite(parsed)) {
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function edgeRestrictions(tags: Record<string, string>) {
|
||||
return {
|
||||
maxAirDraftM: firstNumericTag(tags, [
|
||||
|
||||
Reference in New Issue
Block a user