printing - 如何使用GeoServer-GeoWebCache层的MapFish打印模块?

标签 printing openlayers geoserver

我正在使用 GeoServer (2.1.1)、GeoWebCache(1.2.6)、OpenLayers(2.11)、GeoExt 开发 webGIS 应用程序。我的所有图层都通过 GeoWebCache 作为 wms 提供服务。任意层的示例定义如下:

 var My_Layer = new OpenLayers.Layer.WMS( "My_Layer",
            "http://my-ip + my-port/geoserver/gwc/service/wms",
            {layers: 'layer-name',transparent: "true",format: "image/png",
             tileSize: new OpenLayers.Size(256,256),
             tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom },
            { isBaseLayer: false, visibility:false} );

到目前为止,一切都运行良好。但是,当我计划继续前进并尝试实现 MapFish 打印模块时......输出的 pdf 是空白的!我收到以下错误消息:

java.io.IOException: Error (status=400) while reading the image from........

我已经搜索了很多。根据this一种选择是将我的图层作为 TMS 图层进行访问。但我不需要静态图像层,而是 GeoServer WMS map 层。

再次找到另一个选项 here正在使用OpenLayers.Control.ExportMap()。 但这限制了使用不同的比例,因为我的数据范围太大。因此,在特定比例下,如果用户想要打印整个 map 区域(可能是在 A0 纸中),而在 Openlayers div 中不完全可见,则无法解决目的。

所以问题是如何在不使用 TMS 或 GeoWebCache 层的情况下实现这一目标?

编辑#1: 抱歉我迟到了,因为我不在办公室。以下是我的 config.yaml 文件。我觉得没有错误,这可以打印我的 WMS 图层,直接来自 GeoServer。

dpis: [75, 150, 300]

outputFormats:
  - pdf

scales:
  - 10000
  - 25000
  - 50000
  - 100000

hosts:
  - !localMatch
    dummy: true
  - !ipMatch
    ip: www.camptocamp.org
  - !dnsMatch
    host: labs.metacarta.com
    port: 80
  - !dnsMatch
    host: terraservice.net
    port: 80
  - !dnsMatch
    host: sigma.openplans.org
  - !dnsMatch
    host: demo.mapfish.org

layouts:
  A4 portrait:
    metaData:
      title: 'Arunava TopoMap PDF'
      author: 'Arunava print module'
      subject: 'Map layout'
      keywords: 'map,print'
      creator: 'Arunava'
    mainPage:
      pageSize: A4
      rotation: true
      items:
        - !text
          text: '${mapTitle}  ${now MM.dd.yyyy}'
          fontSize: 20
          spacingAfter: 30
        - !map
          spacingAfter: 30
          width: 440
          height: 600
        - !scalebar
          type: bar
          maxSize: 100
          barBgColor: white
          fontSize: 8
          align: right
        - !text
          font: Helvetica
          fontSize: 9
          align: right
          text: '1:${scale}'
      footer: *commonFooter

  A2 portrait:
    metaData:
      title: 'Arunava TopoMap PDF'
      author: 'Arunava print module'
      subject: 'Map layout'
      keywords: 'map,print'
      creator: 'Arunava'
    mainPage:
      pageSize: A2
      rotation: true
      items:
        - !text
          text: '${mapTitle}  ${now MM.dd.yyyy}'
          fontSize: 20
          spacingAfter: 30
        - !map
          spacingAfter: 30
          width: 880
          height: 1200
        - !scalebar
          type: bar
          maxSize: 100
          barBgColor: white
          fontSize: 8
          align: right
        - !text
          font: Helvetica
          fontSize: 9
          align: right
          text: '1:${scale}'
      footer: *commonFooter

最佳答案

如果没有进一步调试,400 错误就太模糊了,没有多大帮助。根据经验,我可以告诉您我之前遇到过一个问题,即 geowebcache 服务器不喜欢为您请求的 wms 图层提供服务。 Mapfish 尝试用不同的图 block 大小做奇怪的事情(最终会得到 10% 的阈值错误)。您的日志是否显示了它所请求的图像?您可以转到浏览器中的该图 block 来查看服务器实际显示的内容吗?这就是我最终暴露我的问题的方式。

为了更轻松地进行调试,我还创建了一个单独的 Mapfish 日志,以便更轻松地查找 Mapfish 问题。使用 Geoserver 管理屏幕找出您正在使用的日志记录配置文件,然后在该 log4j.properties 文件中,为 mapfish 添加单独的文件附加程序,并将所有 org.mapfish 事件定向到它。这使得调试更加容易。

最后,我个人的改革:在你的 config.yaml 中,不要使用输出格式:[pdf], 相反,请使用格式:['pdf']。

尽管所有文档都描述了outputFormat(这就是客户端“规范”中所要求的),但实际的服务器配置是使用“formats”变量。我已经提交了一个补丁,以便在文档中更清楚地说明这一点,但在此之前,让我们将此注释作为指南。如果你想进入图像输出,这是关键。

关于printing - 如何使用GeoServer-GeoWebCache层的MapFish打印模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9937811/

相关文章:

java - 使用maven构建geoserver(monitor-hibernate)

javascript - 如何在不调整浏览器页面设置的情况下打印背景图像/样式?

java - KeyListener 在 Java 中不起作用

javascript - openlayers、decarta 和 google maps 之间的性能差异

javascript - 在 OpenLayers (KML) 网络链接自动刷新中刷新/重绘图层

javascript - 将文本添加到 openlayers map 的最简单示例?

postgresql - 地理服务器问题

css - IE 从 CSS Boilerplate 打印空白页

java - 打印 Java 2D 数组的最佳方法?

java - 从geoserver获取 map 到argis sdk android