WMS支持¶
应用程序模式支持WMS请求和WFS请求。本页提供一些有用的示例,用于配置WMS服务以使用复杂功能。
请注意,在使用应用程序模式数据存储时,WMS的渲染性能可能会显著降低。我们强烈建议雇用 加入性能支持 当使用具有特征链的WMS时,可以使大数据请求的响应时间更快几个数量级。
配置¶
为了使WMS适用于复杂特征数据,需要由GeoServer将复杂特征类型识别为层。必须通过在每个要用作WMS层的功能类型的数据目录中添加一个名为“layer.xml”的额外配置文件来配置此文件。
这将扩展 workspaces
地理服务器数据目录中的文件夹如下 (workspaces
)(参见 配置 )::
workspaces
- gsml
- SomeDataStore
- SomeFeatureType
- featuretype.xml
- layer.xml
- datastore.xml
- SomeFeatureType-mapping-file.xml
文件layer.xml必须包含以下内容:::
<layer>
<id>[mylayerid]</id>
<name>[mylayername]</name>
<path>/</path>
<type>VECTOR</type>
<defaultStyle>
<name>[mydefaultstyle]</name>
</defaultStyle>
<resource class="featureType">
<id>[myfeaturetypeid]</id>
</resource>
<enabled>true</enabled>
<attribution>
<logoWidth>0</logoWidth>
<logoHeight>0</logoHeight>
</attribution>
</layer>
将括号之间的字段替换为以下值:
[[mylayerid]] 必须是层的自定义ID。
[[mylayername]] 必须是层的自定义名称。
[[mydefaultstyle]] 用于此层的默认样式(在WMS请求中未指定样式时)。样式必须存在于geoserver配置中。
[[myfeaturetypeid]] 是功能类型的ID。这个 must 与同一目录的featureType.xml文件中指定的ID相同。
GetMap¶
读 GetMap 有关getmap请求的常规信息。阅读 造型 有关如何使用SLD文件设置WMS地图样式的常规信息。为复杂功能设置样式时,可以使用xpaths在过滤器中指定嵌套属性,如中所述。 过滤链接特征上的嵌套属性 .但是,在WMS样式过滤器中,X路径不支持处理引用的功能(请参见 引用的多值属性( XLink:链接 ) )就好像它们是实际的嵌套特性(因为过滤器是在构建特性之后应用的,而不是在之前应用的。)xpath表达式中使用的前缀/命名空间上下文是在样式文件的XML标记中本地定义的。这是复杂功能的样式文件示例:
1<?xml version="1.0" encoding="UTF-8"?>
2<StyledLayerDescriptor version="1.0.0"
3 xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
4 xmlns:ogc="http://www.opengis.net/ogc"
5 xmlns:xlink="http://www.w3.org/1999/xlink"
6 xmlns:gml="http://www.opengis.net/gml"
7 xmlns:gsml="urn:cgi:xmlns:CGI:GeoSciML:2.0"
8 xmlns:sld="http://www.opengis.net/sld"
9 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
10 <sld:NamedLayer>
11 <sld:Name>geology-lithology</sld:Name>
12 <sld:UserStyle>
13 <sld:Name>geology-lithology</sld:Name>
14 <sld:Title>Geological Unit Lithology Theme</sld:Title>
15 <sld:Abstract>The colour has been creatively adapted from Moyer,Hasting
16 and Raines, 2005 (http://pubs.usgs.gov/of/2005/1314/of2005-1314.pdf)
17 which provides xls spreadsheets for various color schemes.
18 plus some creative entries to fill missing entries.
19 </sld:Abstract>
20 <sld:IsDefault>1</sld:IsDefault>
21 <sld:FeatureTypeStyle>
22 <sld:Rule>
23 <sld:Name>acidic igneous material</sld:Name>
24 <sld:Abstract>Igneous material with more than 63 percent SiO2.
25 (after LeMaitre et al. 2002)
26 </sld:Abstract>
27 <ogc:Filter>
28 <ogc:PropertyIsEqualTo>
29 <ogc:PropertyName>gsml:specification/gsml:GeologicUnit/gsml:composition/
30 gsml:CompositionPart/gsml:lithology/@xlink:href</ogc:PropertyName>
31 <ogc:Literal>urn:cgi:classifier:CGI:SimpleLithology:200811:
32 acidic_igneous_material</ogc:Literal>
33 </ogc:PropertyIsEqualTo>
34 </ogc:Filter>
35 <sld:PolygonSymbolizer>
36 <sld:Fill>
37 <sld:CssParameter name="fill">#FFCCB3</sld:CssParameter>
38 </sld:Fill>
39 </sld:PolygonSymbolizer>
40 </sld:Rule>
41 <sld:Rule>
42 <sld:Name>acidic igneous rock</sld:Name>
43 <sld:Abstract>Igneous rock with more than 63 percent SiO2.
44 (after LeMaitre et al. 2002)
45 </sld:Abstract>
46 <ogc:Filter>
47 <ogc:PropertyIsEqualTo>
48 <ogc:PropertyName>gsml:specification/gsml:GeologicUnit/gsml:composition/
49 gsml:CompositionPart/gsml:lithology/@xlink:href</ogc:PropertyName>
50 <ogc:Literal>urn:cgi:classifier:CGI:SimpleLithology:200811:
51 acidic_igneous_rock</ogc:Literal>
52 </ogc:PropertyIsEqualTo>
53 </ogc:Filter>
54 <sld:PolygonSymbolizer>
55 <sld:Fill>
56 <sld:CssParameter name="fill">#FECDB2</sld:CssParameter>
57 </sld:Fill>
58 </sld:PolygonSymbolizer>
59 </sld:Rule>
60 ...
61 </sld:FeatureTypeStyle>
62 </sld:UserStyle>
63 </sld:NamedLayer>
64</sld:StyledLayerDescriptor>
GetFeatureInfo¶
读 GetFeatureInfo 有关GetFeatureInfo请求的常规信息。阅读教程 获取功能信息模板 有关如何为HTML输出设置模板的信息。如果要为复杂功能集合存储单独的标准模板,请将其保存在文件名下 complex_content.ftl
在模板目录中。
阅读教程 自由标记模板 有关如何使用自由标记模板的详细信息。FreeMarker模板支持递归调用,这对于模板化复杂内容很有用。例如,以下FreeMarker模板将创建一个功能表,其中每个属性都有一列,并将在每个单元格内创建另一个表,其中包含一个功能作为属性:::
<#--
Macro's used for content
-->
<#macro property node>
<#if !node.isGeometry>
<#if node.isComplex>
<td> <@feature node=node.rawValue type=node.type /> </td>
<#else>
<td>${node.value?string}</td>
</#if>
</#if>
</#macro>
<#macro header typenode>
<caption class="featureInfo">${typenode.name}</caption>
<tr>
<th>fid</th>
<#list typenode.attributes as attribute>
<#if !attribute.isGeometry>
<#if attribute.prefix == "">
<th >${attribute.name}</th>
<#else>
<th >${attribute.prefix}:${attribute.name}</th>
</#if>
</#if>
</#list>
</tr>
</#macro>
<#macro feature node type>
<table class="featureInfo">
<@header typenode=type />
<tr>
<td>${node.fid}</td>
<#list node.attributes as attribute>
<@property node=attribute />
</#list>
</tr>
</table>
</#macro>
<#--
Body section of the GetFeatureInfo template, it's provided with one feature collection, and
will be called multiple times if there are various feature collections
-->
<table class="featureInfo">
<@header typenode=type />
<#assign odd = false>
<#list features as feature>
<#if odd>
<tr class="odd">
<#else>
<tr>
</#if>
<#assign odd = !odd>
<td>${feature.fid}</td>
<#list feature.attributes as attribute>
<@property node=attribute />
</#list>
</tr>
</#list>
</table>
<br/>