在地理服务器上添加图例

adding legend on GeoServer

我是 GeoServer 的新手,我想在现有地图上添加图例。我不确定在哪里添加图例 XML 文件?

在GeoServer 的用户手册中,他们简单地谈到了图例,但不是很清楚:http://docs.geoserver.org/stable/en/user/advanced/wmsdecoration.html 我认为应该在网络地图服务页面 (WMS) 中添加图例 XML 文件。但是我试图在页面上搜索诸如图例之类的关键字,但找不到。我的方向正确吗?

我认为您正在寻找的请求是 GetLegendGraphic。通过此请求,您请求 Geoserver return 与图层的默认 SLD 或请求中指定的 SLD 相对应的图像。

这是一个示例请求,您可以在 Geoserver 文档中找到它:

http://localhost:8080/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=topp:states&legend_options=fontName:Times%20New%20Roman;fontAntiAliasing:true;fontColor:0x000033;fontSize:14;bgColor:0xFFFFEE;dpi:180

有关更多信息以及您可以在请求中指定的所有参数: http://docs.geoserver.org/latest/en/user/services/wms/get_legend_graphic/legendgraphic.html

如果您正在寻找获取 SLD 文件内容而不是图像的请求以在应用程序中处理它,您将需要执行 GetStyle 请求。

希望对您有所帮助。

您指的是 WMS 覆盖装饰。

在您包含在 post 中的 link http://docs.geoserver.org/stable/en/user/advanced/wmsdecoration.html 中,它提供了模仿您引用的屏幕截图所需的说明。

To use decorations in a GetMap request, the administrator must first configure a decoration layout. These layouts are stored in a subdirectory called layouts in the GeoServer Data Directory as XML files, one file per layout. Each layout file must have the extension .xml. Once a layout foo.xml is defined, users can request it by adding &format_options=layout:foo to the request parameters.

本质上,你:

  1. 像 post
  2. 中提供的那样创建一个描述符文件
  3. 将此文件复制到数据目录中的 layouts 文件夹 Geoserver(具体路径因安装而异)
  4. 使用查询字符串参数来指示 wms 层的工艺请求 您要查看具有指定图层的服务器 覆盖。即 &format_options=layout:foo 到请求参数。

这会将叠加层嵌入图层本身。这与何塞的回答形成对比,后者涉及额外的 HTTP 请求(可以在 <img href=""/> 标记中引用)。

在任何一种情况下,图例组件都可以通过在图层请求中应用样式来影响。这些通常用 SLD 编码。有关这方面的信息可用 here

== 编辑 01 == 作为参考,可以在此处找到数据目录的路径: 这是安装 geoserver 的服务器上数据目录所在的路径。 Structure of Data Directory link 详细介绍了此文件夹中的内容以及每个项目的用途。