index.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. .. _ogcapi-features:
  2. OGC API - Features
  3. ==================
  4. An `OGC Features API <https://github.com/opengeospatial/ogcapi-features>`_ publishing feature data using an OpenAPI web service.
  5. Features Implementation status
  6. ------------------------------
  7. .. list-table::
  8. :widths: 30, 20, 50
  9. :header-rows: 1
  10. * - `OGC API - Features <https://github.com/opengeospatial/ogcapi-features>`__
  11. - Version
  12. - Implementation status
  13. * - Part 1: Core
  14. - `1.0.0 <https://docs.opengeospatial.org/is/17-069r4/17-069r4.html>`__
  15. - Passes compliance tests
  16. * - Part 2: Coordinate Systems by Reference
  17. - `1.0.0 <https://docs.opengeospatial.org/is/18-058r1/18-058r1.htmll>`__
  18. - Passes compliance tests
  19. * - Part 3: Filtering
  20. - `Draft <http://docs.ogc.org/DRAFTS/19-079r1.html>`__
  21. - Draft implemented (mind, the draft does not include a filtering language)
  22. * - Part 4: Create, Replace, Update and Delete
  23. - `Draft <http://docs.ogc.org/DRAFTS/20-002.html>`__
  24. - Not implemented (volunteers/sponsoring wanted)
  25. * - Common Query Language (CQL2)
  26. - `Draft <https://docs.ogc.org/DRAFTS/21-065.html>`__
  27. - Implements an earlier draft for for both text and JSON encodings. To be updated.
  28. * - Part n: Query by IDs
  29. - `Proposal <https://github.com/opengeospatial/ogcapi-features/tree/master/proposals/query-by-ids>`__
  30. - Proposal implemented, but syntax and semantic is subject to change in a future release. Thus said, usage should be carefully considered.
  31. Installing the GeoServer OGC API Features module
  32. ------------------------------------------------
  33. #. Download the OGC API nightly GeoServer community module from :download_community:`ogcapi-features`.
  34. .. warning:: Verify that the version number in the filename corresponds to the version of GeoServer you are running (for example geoserver-|release|-ogcapi-features-plugin.zip above).
  35. #. Extract the contents of the archive into the ``WEB-INF/lib`` directory of the GeoServer installation.
  36. #. On restart the services are listed at http://localhost:8080/geoserver
  37. Use of OGC API - Features service
  38. ---------------------------------
  39. The OGC API Features Service is accessed via the :guilabel:`FEATURES` version :guilabel:`1.0` link on the home page.
  40. Capabilities
  41. ''''''''''''
  42. The service is self described using:
  43. * ``html``: A collection of web pages, with links for navigation between content (and that can be indexed by search engines for discoverability).
  44. .. figure:: img/features.png
  45. OGC API Features service
  46. * `application/json`: A collection of :file:`json` documents, with reference between each document for programmatic access by web developers.
  47. .. code-block:: json
  48. {
  49. "title": "GeoServer Web Feature Service",
  50. "description": "This is the reference implementation of WFS 1.0.0 and WFS 1.1.0, supports all WFS operations including Transaction.",
  51. "links": [
  52. {
  53. "href": "http://localhost:8080/geoserver/ogc/features/?f=application%2Fx-yaml",
  54. "rel": "alternate",
  55. "type": "application/x-yaml",
  56. "title": "This document as application/x-yaml"
  57. },
  58. {
  59. "href": "http://localhost:8080/geoserver/ogc/features/?f=application%2Fjson",
  60. "rel": "self",
  61. "type": "application/json",
  62. "title": "This document"
  63. },
  64. {
  65. "href": "http://localhost:8080/geoserver/ogc/features/?f=text%2Fhtml",
  66. "rel": "alternate",
  67. "type": "text/html",
  68. "title": "This document as text/html"
  69. }
  70. * ``application/x-yaml``: A collection of :file:`yaml` documents, with references between each document for programmatic access.
  71. .. code-block:: yaml
  72. title: GeoServer Web Feature Service
  73. description: This is the reference implementation of WFS 1.0.0 and WFS 1.1.0, supports
  74. all WFS operations including Transaction.
  75. links:
  76. - href: http://localhost:8080/geoserver/ogc/features/?f=application%2Fx-yaml
  77. rel: self
  78. type: application/x-yaml
  79. title: This document
  80. - href: http://localhost:8080/geoserver/ogc/features/?f=application%2Fjson
  81. rel: alternate
  82. type: application/json
  83. title: This document as application/json
  84. - href: http://localhost:8080/geoserver/ogc/features/?f=text%2Fhtml
  85. rel: alternate
  86. type: text/html
  87. title: This document as text/html
  88. The service title and description are provided by the existing :ref:`wfs` settings.
  89. Open API
  90. ''''''''
  91. For programmatic access an `OpenAPI <https://www.openapis.org/>`__ description of the service is provided, that may be browsed as documentation, or used to generate a client to access the web services.
  92. .. figure:: img/features-api.png
  93. OGC API Features OpenAPI Document
  94. Collections
  95. '''''''''''
  96. The collection of feature types being published by the service.
  97. Each collection entry is described using the layer details of title, description, geographic extent.
  98. Data can be browsed as web pages, or downloaded in a range of formats such as :file:`GeoJSON` and :file:`GML` documents.
  99. .. figure:: img/collection.png
  100. Collection sf:roads download formats
  101. Conformance
  102. '''''''''''
  103. Lists the operations this service can perform, each "conformance class" documents supported functionality.
  104. .. figure:: img/conformance.png
  105. OGC API Features Conformance
  106. Contact information
  107. '''''''''''''''''''
  108. Advertises contact information for the service.
  109. Defined by defined in by :ref:`config_contact`.
  110. Configuration of OGC API - Features module
  111. ------------------------------------------
  112. The service does not require any additional configuration to use. The service is configured using:
  113. * The existing :ref:`wfs` settings to define title, abstract, and output formats.
  114. This is why the service page is titled ``GeoServer Web Feature Service`` by default.
  115. * Built-in templates used for html generation
  116. * Extra links can be added on a per-service or per-collection basis as indicated in :ref:`ogcapi_links`.
  117. HTML Templates
  118. ''''''''''''''
  119. To override an OGC API Features template:
  120. #. Create a directory :file:`ogc/features` in the location you wish to override:
  121. * :file:`GEOSERVER_DATA_DIR/templates/ogc/features/v1`
  122. * :file:`GEOSERVER_DATA_DIR/workspace/{workspace}/ogc/features/v1`
  123. * :file:`GEOSERVER_DATA_DIR/workspace/{workspace}/{datastore}/ogc/features/v1`
  124. * :file:`GEOSERVER_DATA_DIR/workspace/{workspace}/{datastore}/{featuretype}/ogc/features/v1`
  125. #. Create a file in this location, using the GeoServer |release| examples below:
  126. * :download:`ogc/features/v1/collection.ftl </../../../../src/community/ogcapi/ogcapi-features/src/main/resources/org/geoserver/ogcapi/v1/features/collection.ftl>`
  127. * :download:`ogc/features/v1/collection_include.ftl </../../../../src/community/ogcapi/ogcapi-features/src/main/resources/org/geoserver/ogcapi/v1/features/collection_include.ftl>`
  128. * :download:`ogc/features/v1/collections.ftl </../../../../src/community/ogcapi/ogcapi-features/src/main/resources/org/geoserver/ogcapi/v1/features/collections.ftl>`
  129. * :download:`ogc/features/v1/queryables.ftl </../../../../src/community/ogcapi/ogcapi-core/src/main/resources/org/geoserver/ogcapi/queryables.ftl>`
  130. * :download:`ogc/features/v1/functions.ftl </../../../../src/community/ogcapi/ogcapi-features/src/main/resources/org/geoserver/ogcapi/v1/features/functions.ftl>`
  131. The above built-in examples are for GeoServer |release|, please check for any changes when upgrading GeoServer.
  132. The templates for listing feature content are shared between OGC API services. To override a template used to list features:
  133. #. Use the directory in the location you wish to override:
  134. * :file:`GEOSERVER_DATA_DIR/templates`
  135. * :file:`GEOSERVER_DATA_DIR/workspace/{workspace}`
  136. * :file:`GEOSERVER_DATA_DIR/workspace/{workspace}/{datastore}`
  137. * :file:`GEOSERVER_DATA_DIR/workspace/{workspace}/{datastore}/{featuretype}`
  138. * :download:`ogc/features/landingPage.ftl </../../../../src/community/ogcapi/ogcapi-features/src/main/resources/org/geoserver/ogcapi/v1/features/landingPage.ftl>`
  139. #. Create a file in this location, using the GeoServer |release| examples below:
  140. * :download:`ogc/features/getfeature-complex-content.ftl </../../../../src/community/ogcapi/ogcapi-features/src/main/resources/org/geoserver/ogcapi/v1/features/getfeature-complex-content.ftl>`
  141. * :download:`ogc/features/getfeature-content.ftl </../../../../src/community/ogcapi/ogcapi-features/src/main/resources/org/geoserver/ogcapi/v1/features/getfeature-content.ftl>`
  142. * :download:`ogc/features/getfeature-empty.ftl </../../../../src/community/ogcapi/ogcapi-features/src/main/resources/org/geoserver/ogcapi/v1/features/getfeature-empty.ftl>`
  143. * :download:`ogc/features/getfeature-footer.ftl </../../../../src/community/ogcapi/ogcapi-features/src/main/resources/org/geoserver/ogcapi/v1/features/getfeature-footer.ftl>`
  144. * :download:`ogc/features/getfeature-header.ftl </../../../../src/community/ogcapi/ogcapi-features/src/main/resources/org/geoserver/ogcapi/v1/features/getfeature-header.ftl>`
  145. The above built-in examples are for GeoServer |release|, please check for any changes when upgrading GeoServer.
  146. As an example customize how collections are listed:
  147. #. The file :file:`ogc/features/collections.ftl` lists published collection:
  148. .. literalinclude:: /../../../../src/community/ogcapi/ogcapi-features/src/main/resources/org/geoserver/ogcapi/v1/features/collections.ftl
  149. #. Save file to :file:`GEOSERVER_DATA_DIR/workspace/templates/ogc/collections.ftl`, and rewrite as:
  150. .. code-block::
  151. <#include "common-header.ftl">
  152. <h2>OGC API Feature Collections</h2>
  153. <p>List of collections published.</p>
  154. <p>See also: <#list model.getLinksExcept(null, "text/html") as link>
  155. <a href="${link.href}">${link.type}</a><#if link_has_next>, </#if></#list>.</p>
  156. <#list model.collections as collection>
  157. <h2><a href="${serviceLink("collections/${collection.id}")}">${collection.id}</a></h2>
  158. <#include "collection_include.ftl">
  159. </#list>
  160. <#include "common-footer.ftl">
  161. #. Many templates are constructed using ``#include``, for example :file:`collection.ftl` above uses ``<#include "common-header.ftl">`` located next to :file:`collections.ftl`.
  162. Presently each family of templates manages its own :file:`common-header.ftl` (as shown in the difference between :file:`ogc/features` service templates, and getfeature templates above).
  163. #. A restart is required, as templates are cached.
  164. .. figure:: img/template_override.png
  165. Template collections.ftl override applied
  166. #. Language codes are appended for internationalization. For French create the file :file:`GEOSERVER_DATA_DIR/workspace/{workspace}/ogc/collections_fr.ftl` and translate contents:
  167. .. code-block::
  168. <#include "common-header.ftl">
  169. <h2>OGC API Feature Service</h2>
  170. <p>Liste des collections publiées.</p>
  171. <p>Voir également: <#list model.getLinksExcept(null, "text/html") as link>
  172. <a href="${link.href}">${link.type}</a><#if link_has_next>, </#if></#list>.</p>
  173. <#list model.collections as collection>
  174. <h2><a href="${serviceLink("collections/${collection.id}")}">${collection.id}</a></h2>
  175. <#include "collection_include.ftl">
  176. </#list>
  177. <#include "common-footer.ftl">
  178. #. For details on how to write templates see :ref:`tutorial_freemarkertemplate` tutorial.
  179. The following functions are specific to OGC API templates:
  180. * ``serviceLink(path*, format)`` generates a link back to the same service.
  181. The first argument, mandatory, is the extra path after the service landing page, the second argument, optional, is the format to use for the link.
  182. * ``genericServiceLink(path*, k1, v1, k2, v2, ....)`` generates a link back to any GeoServer OGC service, with additional query parameters.
  183. The first argument, mandatory, is the extra path after the GeoServer context path (usually ``/geoserver``),
  184. the following arguments are key-value pairs to be added as query parameters to the link.
  185. * ``resourceLink(path)`` links to a static resource, such as a CSS file or an image.
  186. The argument is the path to the resource, relative to the GeoServer context path (usually ``/geoserver``).
  187. *