我尝试使用 MapFish Print 3 打印图像层。我尝试了几种不同的打印请求绝对图像路径、相对路径和 URL,但从未成功。打印成功完成,但没有显示图像。
我的要求是这样的:
{
"outputFormat": "pdf",
"layout": "A4 landscape",
"outputFilename": "file",
"attributes": {
"map": {
"dpi": "300",
"rotation": 0,
"bbox": [
1617602.8915079264,
5888215.094869674,
1622199.0367374036,
5890693.644391326
],
"projection": "EPSG:3857",
"layers": [
{
"baseURL": "http://mapsNEU.wien.gv.at/basemap/bmapoverlay/normal/google3857/{TileMatrix}/{TileRow}/{TileCol}.png",
"imageFormat": "image/png",
"layer": "bmapoverlay",
"type": "WMTS",
"version": "1.0.0",
"requestEncoding": "REST",
"matrixSet": "google3857",
"matrices": [ ... ]
},
{
"type": "image",
"baseURL": "https://github.com/geotools/geotools/raw/main/geotools-logo.png",
"extent": [
1617602.8915079264,
5888215.094869674,
1622199.0367374036,
5890693.644391326
],
"name": "test",
"opacity": 1,
"imageFormat": "image/png"
}
]
}
}
}
我的 config.yaml 看起来
templates:
# default
A4 landscape: !template
reportTemplate: default/A4LandscapeReport.jrxml
attributes:
abteilung: !string {}
title: !string {}
user: !string {}
zweck: !string {}
myScale: !string {}
kunde: !string {}
img: !string {}
map: !map
maxDpi: 400
width: 814
height: 439
scalebar: !scalebar
width: 200
height: 40
default:
align: "left"
intervals: 3
type: "bar"
unit: "m"
northArrowDef: !northArrow
size: 30
default:
graphic: "file://NorthArrow_10.svg"
processors:
- !reportBuilder
directory: 'default/.'
- !createMap
inputMapper: {map: map}
outputMapper: {mapSubReport: mapSubReport, mapContext: mapContext}
- !createScalebar {}
- !createNorthArrow
inputMapper: {map: map, northArrowDef: northArrow}
结果: 没有任何图像迹象的地图
摆弄之后,我意识到层的顺序被搞乱了,请参阅这个Bug。解决方案是更改顺序,直到达到期望的结果 - 遗憾的是没有发现规律性,感觉很随机,幸运的是它每次打印的顺序都是相同的。