wms-support.rst 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. .. _app-schema.wms-support:
  2. WMS Support
  3. ===========
  4. App-schema supports WMS requests as well as WFS requests.
  5. This page provides some useful examples for configuring the WMS service to work with complex features.
  6. Note that the rendering performance of WMS can be significantly slower when using app-schema data stores. We strongly recommend employing :ref:`app-schema.joining` when using WMS with feature chaining, which can make response time for large data requests several orders of magnitude faster.
  7. Configuration
  8. -------------
  9. For WMS to be applicable to complex feature data, it is necessary that the complex feature types are recognised by GeoServer as layers. This must be configured by adding an extra configuration file named 'layer.xml' in the data directory of each feature type that we want to use as a WMS layer.
  10. This will expand the structure of the ``workspaces`` folder in the GeoServer data directory as follows (``workspaces``) (see :ref:`app-schema.configuration`): ::
  11. workspaces
  12. - gsml
  13. - SomeDataStore
  14. - SomeFeatureType
  15. - featuretype.xml
  16. - layer.xml
  17. - datastore.xml
  18. - SomeFeatureType-mapping-file.xml
  19. The file layer.xml must have the following contents: ::
  20. <layer>
  21. <id>[mylayerid]</id>
  22. <name>[mylayername]</name>
  23. <path>/</path>
  24. <type>VECTOR</type>
  25. <defaultStyle>
  26. <name>[mydefaultstyle]</name>
  27. </defaultStyle>
  28. <resource class="featureType">
  29. <id>[myfeaturetypeid]</id>
  30. </resource>
  31. <enabled>true</enabled>
  32. <attribution>
  33. <logoWidth>0</logoWidth>
  34. <logoHeight>0</logoHeight>
  35. </attribution>
  36. </layer>
  37. Replace the fields in between brackets with the following values:
  38. * **[mylayerid]** must be a custom id for the layer.
  39. * **[mylayername]** must be a custom name for the layer.
  40. * **[mydefaultstyle]** the default style used for this layer (when a style is not specified in the wms request). The style must exist in the GeoServer configuration.
  41. * **[myfeaturetypeid]** is the id of the feature type. This *must* the same as the id specified in the file featuretype.xml of the same directory.
  42. GetMap
  43. -------
  44. Read :ref:`wms_getmap` for general information on the GetMap request.
  45. Read :ref:`styling` for general information on how to style WMS maps with SLD files.
  46. When styling complex features, you can use XPaths to specify nested properties in your filters, as explained in :ref:`app-schema.filtering-nested`. However, in WMS styling filters X-paths do not support handling referenced features (see :ref:`app-schema.feature-chaining-by-reference`) as if they were actual nested features (because the filters are applied after building the features rather than before.)
  47. The prefix/namespace context that is used in the XPath expression is defined locally in the XML tags of the style file.
  48. This is an example of a Style file for complex features:
  49. .. code-block:: xml
  50. :linenos:
  51. <?xml version="1.0" encoding="UTF-8"?>
  52. <StyledLayerDescriptor version="1.0.0"
  53. xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
  54. xmlns:ogc="http://www.opengis.net/ogc"
  55. xmlns:xlink="http://www.w3.org/1999/xlink"
  56. xmlns:gml="http://www.opengis.net/gml"
  57. xmlns:gsml="urn:cgi:xmlns:CGI:GeoSciML:2.0"
  58. xmlns:sld="http://www.opengis.net/sld"
  59. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  60. <sld:NamedLayer>
  61. <sld:Name>geology-lithology</sld:Name>
  62. <sld:UserStyle>
  63. <sld:Name>geology-lithology</sld:Name>
  64. <sld:Title>Geological Unit Lithology Theme</sld:Title>
  65. <sld:Abstract>The colour has been creatively adapted from Moyer,Hasting
  66. and Raines, 2005 (http://pubs.usgs.gov/of/2005/1314/of2005-1314.pdf)
  67. which provides xls spreadsheets for various color schemes.
  68. plus some creative entries to fill missing entries.
  69. </sld:Abstract>
  70. <sld:IsDefault>1</sld:IsDefault>
  71. <sld:FeatureTypeStyle>
  72. <sld:Rule>
  73. <sld:Name>acidic igneous material</sld:Name>
  74. <sld:Abstract>Igneous material with more than 63 percent SiO2.
  75. (after LeMaitre et al. 2002)
  76. </sld:Abstract>
  77. <ogc:Filter>
  78. <ogc:PropertyIsEqualTo>
  79. <ogc:PropertyName>gsml:specification/gsml:GeologicUnit/gsml:composition/
  80. gsml:CompositionPart/gsml:lithology/@xlink:href</ogc:PropertyName>
  81. <ogc:Literal>urn:cgi:classifier:CGI:SimpleLithology:200811:
  82. acidic_igneous_material</ogc:Literal>
  83. </ogc:PropertyIsEqualTo>
  84. </ogc:Filter>
  85. <sld:PolygonSymbolizer>
  86. <sld:Fill>
  87. <sld:CssParameter name="fill">#FFCCB3</sld:CssParameter>
  88. </sld:Fill>
  89. </sld:PolygonSymbolizer>
  90. </sld:Rule>
  91. <sld:Rule>
  92. <sld:Name>acidic igneous rock</sld:Name>
  93. <sld:Abstract>Igneous rock with more than 63 percent SiO2.
  94. (after LeMaitre et al. 2002)
  95. </sld:Abstract>
  96. <ogc:Filter>
  97. <ogc:PropertyIsEqualTo>
  98. <ogc:PropertyName>gsml:specification/gsml:GeologicUnit/gsml:composition/
  99. gsml:CompositionPart/gsml:lithology/@xlink:href</ogc:PropertyName>
  100. <ogc:Literal>urn:cgi:classifier:CGI:SimpleLithology:200811:
  101. acidic_igneous_rock</ogc:Literal>
  102. </ogc:PropertyIsEqualTo>
  103. </ogc:Filter>
  104. <sld:PolygonSymbolizer>
  105. <sld:Fill>
  106. <sld:CssParameter name="fill">#FECDB2</sld:CssParameter>
  107. </sld:Fill>
  108. </sld:PolygonSymbolizer>
  109. </sld:Rule>
  110. ...
  111. </sld:FeatureTypeStyle>
  112. </sld:UserStyle>
  113. </sld:NamedLayer>
  114. </sld:StyledLayerDescriptor>
  115. GetFeatureInfo
  116. --------------
  117. Read :ref:`wms_getfeatureinfo` for general information on the GetFeatureInfo request.
  118. Read the tutorial on :ref:`tutorials_getfeatureinfo` for information on how to template the html output.
  119. If you want to store a separate standard template for complex feature collections, save it under the filename
  120. ``complex_content.ftl`` in the template directory.
  121. Read the tutorial on :ref:`tutorial_freemarkertemplate` for more information on how to use the freemarker templates.
  122. Freemarker templates support recursive calls, which can be useful for templating complex content.
  123. For example, the following freemarker template creates a table of features with a column for each property,
  124. and will create another table inside each cell that contains a feature as property: ::
  125. <#--
  126. Macro's used for content
  127. -->
  128. <#macro property node>
  129. <#if !node.isGeometry>
  130. <#if node.isComplex>
  131. <td> <@feature node=node.rawValue type=node.type /> </td>
  132. <#else>
  133. <td>${node.value?string}</td>
  134. </#if>
  135. </#if>
  136. </#macro>
  137. <#macro header typenode>
  138. <caption class="featureInfo">${typenode.name}</caption>
  139. <tr>
  140. <th>fid</th>
  141. <#list typenode.attributes as attribute>
  142. <#if !attribute.isGeometry>
  143. <#if attribute.prefix == "">
  144. <th >${attribute.name}</th>
  145. <#else>
  146. <th >${attribute.prefix}:${attribute.name}</th>
  147. </#if>
  148. </#if>
  149. </#list>
  150. </tr>
  151. </#macro>
  152. <#macro feature node type>
  153. <table class="featureInfo">
  154. <@header typenode=type />
  155. <tr>
  156. <td>${node.fid}</td>
  157. <#list node.attributes as attribute>
  158. <@property node=attribute />
  159. </#list>
  160. </tr>
  161. </table>
  162. </#macro>
  163. <#--
  164. Body section of the GetFeatureInfo template, it's provided with one feature collection, and
  165. will be called multiple times if there are various feature collections
  166. -->
  167. <table class="featureInfo">
  168. <@header typenode=type />
  169. <#assign odd = false>
  170. <#list features as feature>
  171. <#if odd>
  172. <tr class="odd">
  173. <#else>
  174. <tr>
  175. </#if>
  176. <#assign odd = !odd>
  177. <td>${feature.fid}</td>
  178. <#list feature.attributes as attribute>
  179. <@property node=attribute />
  180. </#list>
  181. </tr>
  182. </#list>
  183. </table>
  184. <br/>