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:
@@ -16,24 +16,38 @@ jest.mock("ol/layer/Tile.js", () => ({
|
||||
__esModule: true,
|
||||
default: class MockTileLayer {
|
||||
private readonly source: unknown;
|
||||
private readonly properties = new Map<string, unknown>();
|
||||
constructor(options: any) {
|
||||
this.source = options.source;
|
||||
}
|
||||
getSource() {
|
||||
return this.source;
|
||||
}
|
||||
set(key: string, value: unknown) {
|
||||
this.properties.set(key, value);
|
||||
}
|
||||
get(key: string) {
|
||||
return this.properties.get(key);
|
||||
}
|
||||
},
|
||||
}));
|
||||
jest.mock("ol/layer/Group", () => ({
|
||||
__esModule: true,
|
||||
default: class MockGroup {
|
||||
private readonly layers: unknown[];
|
||||
private readonly properties = new Map<string, unknown>();
|
||||
constructor(options: any) {
|
||||
this.layers = options.layers;
|
||||
}
|
||||
getLayers() {
|
||||
return { getArray: () => this.layers };
|
||||
}
|
||||
set(key: string, value: unknown) {
|
||||
this.properties.set(key, value);
|
||||
}
|
||||
get(key: string) {
|
||||
return this.properties.get(key);
|
||||
}
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -70,6 +84,7 @@ describe("base layer resources", () => {
|
||||
expect(getLeafSources(entry.layer)).toEqual(
|
||||
getLeafSources(compare[index].layer),
|
||||
);
|
||||
expect(entry.layer.get("exportAttribution")).toBe(entry.attribution);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,16 +18,42 @@ import { markMapResourcePersistent } from "../mapLifecycle";
|
||||
|
||||
const INITIAL_LAYER = "mapbox-light";
|
||||
const BASE_LAYER_METADATA = [
|
||||
{ id: "mapbox-light", name: "默认地图", img: mapboxLight.src },
|
||||
{ id: "mapbox-satellite", name: "卫星地图", img: mapboxSatellite.src },
|
||||
{
|
||||
id: "mapbox-light",
|
||||
name: "默认地图",
|
||||
img: mapboxLight.src,
|
||||
attribution: "© Mapbox © OpenStreetMap",
|
||||
},
|
||||
{
|
||||
id: "mapbox-satellite",
|
||||
name: "卫星地图",
|
||||
img: mapboxSatellite.src,
|
||||
attribution: "© Mapbox",
|
||||
},
|
||||
{
|
||||
id: "mapbox-satellite-streets",
|
||||
name: "卫星街道地图",
|
||||
img: mapboxSatelliteStreet.src,
|
||||
attribution: "© Mapbox © OpenStreetMap",
|
||||
},
|
||||
{
|
||||
id: "mapbox-streets",
|
||||
name: "街道地图",
|
||||
img: mapboxStreets.src,
|
||||
attribution: "© Mapbox © OpenStreetMap",
|
||||
},
|
||||
{
|
||||
id: "tianditu-vector",
|
||||
name: "天地图矢量",
|
||||
img: mapboxOutdoors.src,
|
||||
attribution: "© 天地图",
|
||||
},
|
||||
{
|
||||
id: "tianditu-image",
|
||||
name: "天地图影像",
|
||||
img: mapboxSatellite.src,
|
||||
attribution: "© 天地图",
|
||||
},
|
||||
{ id: "mapbox-streets", name: "街道地图", img: mapboxStreets.src },
|
||||
{ id: "tianditu-vector", name: "天地图矢量", img: mapboxOutdoors.src },
|
||||
{ id: "tianditu-image", name: "天地图影像", img: mapboxSatellite.src },
|
||||
] as const;
|
||||
|
||||
const createTileSource = (url: string, attributions: string) =>
|
||||
@@ -123,10 +149,11 @@ export const createBaseLayerEntries = (sources: BaseLayerSources) => {
|
||||
],
|
||||
}),
|
||||
},
|
||||
].map((entry) => ({
|
||||
...entry,
|
||||
layer: markMapResourcePersistent(entry.layer),
|
||||
}));
|
||||
].map((entry) => {
|
||||
const layer = markMapResourcePersistent(entry.layer);
|
||||
layer.set("exportAttribution", entry.attribution);
|
||||
return { ...entry, layer };
|
||||
});
|
||||
};
|
||||
|
||||
const BaseLayers: React.FC = () => {
|
||||
|
||||
Reference in New Issue
Block a user