分享

GIS 如何选择GeoServer WMS GetFeatureInfo请求返回的字段?

 primivite_ 2017-09-11

问题描述

我运行基于PostGIS /GeoServer /OpenLayers堆栈的简单本地映射服务。

关于opengeo tutorial我把OpenLayers中的点击事件绑定到WMS GetFeatureInfo调用,使用:

    map.events.register('click', map, function (e) {
        var url = "http://localhost:1979/geoserver/wms" 
          + "?REQUEST=GetFeatureInfo"
          + "&EXCEPTIONS=application/vnd.ogc.se_xml"
          + "&BBOX=" + map.getExtent().toBBOX()
          + "&X=" + e.xy.x
          + "&Y=" + e.xy.y
          + "&INFO_FORMAT=text/html"
          + "&QUERY_LAYERS=MYDATA:MYLAYER"
          + "&LAYERS=MYDATA:MYLAYER"
          + "&FEATURE_COUNT=5"
          + "&SRS=EPSG:3857"
          + "&STYLES="
          + "&WIDTH=" + map.size.w
          + "&HEIGHT=" + map.size.h;
        window.open(url,
          "getfeatureinfo",
          "location=0,status=0,scrollbars=1,width=800,height=125"
        );
      });

我使用GeoServer的FreeMarker templates来正确格式化响应。我遇到的问题是我得到的响应将返回图层中的所有字段。

有没有办法选择与用户相关的那些?

最佳解决思路

看起来不好(source):

… GetFeatureInfo […] is a WMS request and WFS. […] One difference in their behaviour is that Geoserver sends always all the attributes with GetFeatureInfo but with WFS the list of attributes can be given in the request.

您可以创建一个视图,其中仅包含用户希望/应该看到并通过Geoserver提供的属性。

另一种选择是adjust die GetFeatureInfo template

次佳解决思路

只需不要在您的freemarker模板中添加不需要的字段。见http://docs./trunk/en/user/tutorials/GetFeatureInfo/index.html#custom-templates

第三种解决思路

您可以使用GeoServer propertyName WMS请求参数来执行此操作:

http://docs./stable/en/user/services/wms/vendor.html#propertyname

参考文献

注:本文内容整合自google/baidu/bing辅助翻译的英文资料结果。如果您对结果不满意,可以加入我们改善翻译效果:gxnotes#qq.com(#替换为@)。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多