2012-03-30 94 views
3

我正在使用GeoServer(2.1.1),GeoWebCache(1.2.6),OpenLayers(2.11),GeoExt开发webGIS应用程序。我所有的图层都通过GeoWebCache作为wms服务。对于任何层的样本定义如下:如何将MapFish打印模块用于GeoServer-GeoWebCache图层?

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异常:错误(状态= 400),而从........

读取图像 我寻觅了许多。根据this一个选项是访问我的图层作为TMS层。但我不想要一个静态图像层,而不是一个GeoServer WMS地图图层。

再次发现另一个选项here正在使用OpenLayers.Control.ExportMap()。 但由于我的数据范围太大,限制使用不同的比例。因此,如果用户想要打印整个地图区域(可能在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 
+0

mapfish配置是否正确?你可以发布config.yaml吗? – igorti 2012-03-30 13:49:16

回答

2

没有进一步的调试,400错误太模糊了很多帮助。根据经验,我可以告诉你我在geowebcache服务器不喜欢服务你请求的wms层之前就已经看到了一个问题。 Mapfish试图用不同的瓷砖尺寸做怪异的事情(最终你会得到10%的阈值错误)。你的日志显示它正在请求的图像吗?你可以在我们的浏览器中查看该服务器的实际内容吗?这就是我最终暴露我的问题的方式。

为了便于调试,我还创建了一个单独的mapfish日志,以便更容易地找到我的mapfish问题。使用Geoserver管理员屏幕找出您正在使用的日志配置文件,然后在该log4j.properties文件中,为mapfish添加一个单独的文件appender,并将所有org.mapfish活动指向它。这使得调试更容易。

而且FINALLY,我个人的讨伐:在你的config.yaml,不使用 outputFormats:[PDF], 而是使用格式: 'PDF'。

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