fix(sensor-placement): stabilize engineering drawing export

Render the OpenLayers basemap at the final A3 map-box resolution with pixelRatio 1, carry provider attribution into the drawing, and keep the linework/basemap export path covered by regression tests.
This commit is contained in:
2026-07-30 16:21:30 +08:00
parent d643f09fcf
commit 6114e76735
5 changed files with 115 additions and 16 deletions
@@ -13,6 +13,7 @@ interface DrawingOptions {
network: string;
networkData: NetworkDrawingData;
mapCanvas?: HTMLCanvasElement | null;
mapAttribution?: string | null;
dirty: boolean;
width?: number;
}
@@ -123,6 +124,7 @@ export const renderEngineeringDrawing = async ({
network,
networkData,
mapCanvas,
mapAttribution,
dirty,
width = A3_LANDSCAPE_WIDTH,
}: DrawingOptions): Promise<HTMLCanvasElement> => {
@@ -261,6 +263,20 @@ export const renderEngineeringDrawing = async ({
context.strokeStyle = "#111827";
context.lineWidth = px(4);
context.strokeRect(mapBox.x, mapBox.y, mapBox.width, mapBox.height);
if (mapCanvas && mapAttribution) {
context.fillStyle = "#334155";
drawText(
context,
`底图来源:${mapAttribution}`,
mapBox.x + mapBox.width - px(16),
mapBox.y + mapBox.height - px(18),
px(18),
500,
"right",
"rgba(255,255,255,0.96)",
px(6),
);
}
for (let index = 0; index <= 4; index += 1) {
const ratio = index / 4;