Skip to content

Commit bbe6238

Browse files
authored
Add documentation for RFC140 (#1039)
* Add documentation for RFC140 * Update terminology used in the RFC and set to adopted
1 parent 7c227e6 commit bbe6238

File tree

6 files changed

+195
-30
lines changed

6 files changed

+195
-30
lines changed

conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,8 @@ class WKTLexer(RegexLexer):
408408
r'SMALL|SQUARE|TINY|TRIANGLE|TRUE|TRUETYPE|UC|UL|UNION|UR|UV_ANGLE|UV_MINUS_ANGLE|UV_LENGTH|UV_LENGTH_2|UVRASTER|VECTOR|'
409409
r'WFS|WMS|ALPHA|'
410410
r'GIF|JPEG|JPG|PNG|WBMP|SWF|PDF|GTIFF|PC256|RGB|RGBA|INT16|FLOAT32|GD|'
411-
r'AGG|CAIRO|PNG8|SVG|KML|KMZ|GDAL|UTFGRID|MIXED'
411+
r'AGG|CAIRO|PNG8|SVG|KML|KMZ|GDAL|UTFGRID|MIXED|'
412+
r'MS_INDEX_TEMPLATE_DIRECTORY|TEST_MAPFILE'
412413
r')\b')
413414

414415
keywords = (r'(ALIGN|'

en/development/rfc/ms-rfc-140.txt

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
.. _rfc140:
22

33
================================================
4-
MS RFC 140: MapServer Homepage
4+
MS RFC 140: MapServer Index Page
55
================================================
66

77
:Author: Seth Girvin
88
:Contact: sethg@geographika.co.uk
9-
:Last Updated: 2025-05-09
9+
:Last Updated: 2025-17-10
1010
:Version: MapServer 8.6
11-
:Status: Draft
11+
:Status: Adopted
1212

1313
1. Overview
1414
===========
1515

16-
This RFC proposes adding functionality to MapServer for dynamically generating a homepage that lists all map services available in a given deployment.
16+
This RFC proposes adding functionality to MapServer for dynamically generating a index page that lists all map services available in a given deployment.
1717
This feature would enable the creation of pages like https://maps.isric.org/ directly from a MapServer deployment, without requiring
1818
additional scripting. While scripting can achieve this, integrating the capability into MapServer itself
1919
would offer greater convenience and maintainability.
2020

2121
With the introduction of the :ref:`CONFIG file <config>` in MapServer 8.0, it is now possible to centrally manage information about all Mapfiles in a deployment.
22-
This would ensure that the homepage remains automatically synchronised with both the CONFIG file and the capabilities of the Mapfiles it references.
22+
This would ensure that the index page remains automatically synchronised with both the CONFIG file and the capabilities of the Mapfiles it references.
2323

24-
The homepage would be a "superset" of all available Mapfiles in a MapServer deployment, as listed in the CONFIG file.
25-
Each individual Mapfile would still have its own OGC API landing page, so the homepage is best described as a directory of all landing pages.
24+
The index page would be a "superset" of all available Mapfiles in a MapServer deployment, as listed in the CONFIG file.
25+
Each individual Mapfile would still have its own OGC API landing page, so the index page is best described as a directory of all landing pages.
2626

2727
As most MapServer deployments will likely be serving out a combination of WxS and new OGC API services for some time to come,
2828
it will allow both types to be listed together.
2929

3030
2.1 Proposed Solution
3131
=====================
3232

33-
A new MapServer :ref:`CGI mode <cgi>` - ``mode=config`` will be added to allow details of the MapServer services to be returned. The ``MAPS`` block
34-
in the :ref:`CONFIG file <config>` will be read to return a list of available services. By default the homepage service will be disabled unless a new
35-
``ENV`` option ``MS_HOMEPAGE_TEMPLATE`` has been set. This should be set to a folder containing a ``homepage.html`` value. However if only JSON
36-
responses are required it can be set to any value to enable the homepage service.
33+
New MapServer functionality will be added to allow details of the MapServer services to be returned. The ``MAPS`` block
34+
in the :ref:`CONFIG file <config>` will be read to return a list of available services. By default the index page service will be disabled unless a new
35+
``ENV`` option ``MS_INDEX_TEMPLATE_DIRECTORY`` has been set. This should be set to a folder containing a ``landing.html`` value. However if only JSON
36+
responses are required it can be set to any value to enable the index page service.
3737

3838
.. code-block:: mapfile
3939

4040
ENV
41-
MS_HOMEPAGE_TEMPLATE_DIRECTORY "share/ogcapi/templates/homepage/" # REQUIRED
41+
MS_INDEX_TEMPLATE_DIRECTORY "/mapserver/share/ogcapi/templates/html-index-bootstrap/" # REQUIRED
4242
...
4343
END
4444
# Example MAPS block in the CONFIG file
@@ -55,19 +55,19 @@ Requests will look as follows:
5555
.. code-block:: bat
5656

5757
# example web requests
58-
# http://localhost/cgi-bin/mapserv.exe?mode=config&f=json
59-
# http://localhost/cgi-bin/mapserv.exe?mode=config&f=html
58+
# http://localhost/cgi-bin/mapserv.exe?f=json
59+
# http://localhost/cgi-bin/mapserv.exe?f=html
6060

6161
# from the command line
62-
mapserv -nh "QUERY_STRING=mode=config&f=json" -conf "/usr/local/etc/mapserver.conf"
63-
mapserv -nh "QUERY_STRING=mode=config&f=html" -conf "C:\MapServer\apps\mapserver.conf"
62+
mapserv -nh "QUERY_STRING=f=json" -conf "/usr/local/etc/mapserver.conf"
63+
mapserv -nh "QUERY_STRING=f=html" -conf "C:\MapServer\apps\mapserver.conf"
6464

6565
As the service returns JSON any client-side library can be used to render the output. However a default HTML template will be provided
6666
following the same approach as in OGC Features API.
6767

6868
.. note::
6969

70-
Even though the JSON format is based on the OGC API, the homepage JSON service will still be generated for a Mapfile even if it only supports
70+
Even though the JSON format is based on the OGC API, the index page JSON service will still be generated for a Mapfile even if it only supports
7171
older WxS services.
7272

7373
JSON Structure
@@ -104,7 +104,7 @@ https://demo.pygeoapi.io/api-catalog.json. An extract is shown below:
104104

105105
The api-catalog specification allows for an additional ``service-meta`` property *"used to link to additional metadata about the API,
106106
and is primarily intended for machine consumption."* This can be used to add any additional properties from Mapfiles
107-
required to generate a MapServer homepage. ``service-doc`` isn't mandatory property, so WxS service links can ignore this.
107+
required to generate a MapServer index page. ``service-doc`` isn't mandatory property, so WxS service links can ignore this.
108108

109109
An example of the proposed JSON and metadata is shown below:
110110

@@ -181,7 +181,7 @@ that the URLs will return valid XML if the Mapfile is not configured correctly.
181181

182182
This new feature will make services more discoverable, but with this comes the risk of leaking information.
183183
The service will be opt-in, and up to the administrators of the deployment if they want this information to be
184-
visible by setting the ``MS_HOMEPAGE_TEMPLATE_DIRECTORY`` value in the ``CONFIG`` file.
184+
visible by setting the ``MS_INDEX_TEMPLATE_DIRECTORY`` value in the ``CONFIG`` file.
185185

186186
2.5 MapScript
187187
=============
@@ -194,12 +194,7 @@ None of the current MapServer ``mode`` functionality is supported in MapScript,
194194

195195
This section contains notes from prototyping a possible solution. The final approach may differ.
196196

197-
A requests will be checked for ``mode=config`` in mapserv.c to return JSON and exit.
198-
A new mode will be added to ``mapservutil.c``
199-
200-
.. code-block:: c
201-
202-
static char *const modeStrings[23]
197+
Requests will be checked in mapserv.c to return JSON and exit.
203198

204199
To list services supported in a Mapfile ``msOWSRequestIsEnabled`` will be used:
205200

@@ -219,16 +214,17 @@ if ``ows_onlineresource`` (or ``wms_``, ``wfs_`` etc.) is not set.
219214
+ mapserv.c
220215
+ mapservutil.c
221216
+ mapserver.h
217+
+ mapserv-config.cpp
222218

223219
3.2 Ticket Reference
224220
--------------------
225221

226-
+ TODO
222+
+ https://github.com/MapServer/MapServer/pull/7350
227223

228224
3.3 Documentation
229225
-----------------
230226

231-
TODO
227+
See https://github.com/MapServer/MapServer-documentation/pull/1039
232228

233229
4. Voting History
234230
=================

en/images/index-map-page.png

113 KB
Loading

en/images/index-page.png

83.2 KB
Loading

en/output/index-page.txt

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
.. index::
2+
single: INDEX
3+
4+
.. _index-page:
5+
6+
*****************************************************************************
7+
Index Page
8+
*****************************************************************************
9+
10+
:Author: Seth Girvin
11+
:Contact: sethg at geographika.net
12+
:Last Updated: 2025-09-19
13+
14+
15+
Background
16+
==========
17+
18+
MapServer 8.6 introduces an index page, proposed in :ref:`rfc140`.
19+
This feature provides a single HTML page that lists all Mapfiles available in a deployment.
20+
From this page, users can select an individual Mapfile to open a dedicated page containing useful links,
21+
such as WMS capabilities documents and OGC Features API landing pages.
22+
23+
In addition to the HTML pages, the same information is also available as JSON services, enabling programmatic access.
24+
25+
The index pages are driven by the MapServer :ref:`config` file, and use the same template-based approach as the :ref:`OGC APIs <ogcapi>`.
26+
27+
The index pages improves service discoverability for users and gives system administrators better visibility
28+
into which services are exposed by their MapServer instances, making it easier to restrict or disable unneeded options.
29+
30+
Configuration
31+
=============
32+
33+
The index pages require a :ref:`config` file. MapServer uses this file to locate and list all Mapfiles available in the system.
34+
35+
To activate the index pages, the config file needs to set a new ``MS_INDEX_TEMPLATE_DIRECTORY`` parameter.
36+
This parameter specifies the folder containing the HTML templates used to render the index pages.
37+
38+
.. code-block:: mapfile
39+
40+
CONFIG
41+
ENV
42+
MS_INDEX_TEMPLATE_DIRECTORY "/mapserver/share/ogcapi/templates/html-index-bootstrap/"
43+
END
44+
45+
MapServer provides two sets of templates, which may already be included with your deployment (depending on the package source).
46+
If not, they are available in the MapServer repository under `share/ogcapi/templates <https://github.com/MapServer/MapServer/tree/main/share/ogcapi/templates>`__.
47+
48+
- ``html-index-bootstrap`` - HTML templates styled using the Bootstrap framework.
49+
- ``html-index-plain`` - plain HTML templates with no styling.
50+
51+
If your system will only be serving JSON output, the ``MS_INDEX_TEMPLATE_DIRECTORY`` value can be set to an empty string.
52+
53+
.. code-block:: mapfile
54+
55+
CONFIG
56+
ENV
57+
MS_INDEX_TEMPLATE_DIRECTORY ""
58+
END
59+
60+
In this case JSON output remains accessible by appending ``?f=json`` to the request URL,
61+
but if you attempt to access the HTML output MapServer will return the following error.
62+
63+
.. code-block:: json
64+
65+
{"code":"ConfigError","description":"Template directory not set."}
66+
67+
If the configured template folder cannot be found, or if the account running MapServer does not have permission to read it, the following error will be returned:
68+
69+
.. code-block:: json
70+
71+
{"code":"ConfigError","description":"InjaError error. [inja.exception.file_error]
72+
failed accessing file at 'C:\\Missing\\landing.html' (landing.html). (C:\\Missing\\)."}
73+
74+
If ``MS_INDEX_TEMPLATE_DIRECTORY`` is not set, MapServer will behave as in previous versions and return standard messages when accessed without a query:
75+
76+
.. code-block:: bat
77+
78+
loadParams(): Web application error. No query information to decode. QUERY_STRING is set, but empty.
79+
mapserv(): Web application error. Traditional BROWSE mode requires a TEMPLATE in the WEB section, but none was provided.
80+
81+
MapServer Homepage
82+
==================
83+
84+
The homepage is available at the root of your MapServer deployment, for example:
85+
86+
- http://localhost:8080/cgi-bin/mapserv.exe/
87+
- https://example.com/mapserver/
88+
- https://demo.mapserver.org/cgi-bin/mapserv/
89+
90+
The page lists all Mapfiles defined in the :ref:`MAPS <mapfile-config-maps>` section of your ``CONFIG`` file.
91+
For each Mapfile, the page provides:
92+
93+
- the map name
94+
- the number of layers
95+
- links to the Mapfile's individual index page (available in both HTML and JSON formats)
96+
97+
.. image:: ../images/index-page.png
98+
99+
If any Mapfiles referenced in the CONFIG file cannot be loaded, they will be displayed with an error message - "Error loading the map".
100+
In the JSON output, these Mapfiles will include a flag: ``"has-error":true``. This makes it possible to monitor the service programmatically and quickly identify problems with Mapfiles.
101+
102+
The HTML output can be customized using the landing.html template file located in the configured template folder.
103+
104+
Individual Mapfile Homepages
105+
============================
106+
107+
When the index page functionality is enabled, each Mapfile listed in the :ref:`MAPS <mapfile-config-maps>` section of the config file
108+
has its own dedicated index page.
109+
110+
These pages can be accessed directly by appending the Mapfile's key to the MapServer URL.
111+
For example, the ``test.map`` referenced by the ``TEST_MAPFILE`` key in the configuration below can be accessed using URLs such as (keys are not case-sensitive):
112+
113+
- http://localhost:8080/cgi-bin/mapserv.exe/TEST_MAPFILE/
114+
- https://example.com/mapserver/test_mapfile/
115+
- https://demo.mapserver.org/cgi-bin/mapserv/TEST_MAPFILE/
116+
117+
.. code-block:: mapfile
118+
119+
CONFIG
120+
...
121+
MAPS
122+
TEST_MAPFILE "/opt/mapserver/test/test.map"
123+
124+
Each Mapfile homepage lists the services enabled for that Mapfile. The following links may be available:
125+
126+
- **CGI** - link to the inbuilt :ref:`openlayers`.
127+
128+
- Always available unless explicitly disabled via the ``ms_enable_modes`` setting in :ref:`mapfile-web-metadata`.
129+
130+
- **OGC API** - links to the :ref:`OGC APIs <ogcapi>`.
131+
132+
- "OGC API Landing Page" (HTML)
133+
- Root JSON service
134+
- Available if MapServer was compiled with the ``-DWITH_OGCAPI`` option and one of the following :ref:`mapfile-web-metadata` settings is present:
135+
136+
- ``"oga_enable_request" "*"``
137+
- ``"ows_enable_request" "*"``
138+
139+
- **WMS** - links to the :ref:`WMS <wms_server>` GetCapabilities documents for supported versions:
140+
141+
- 1.0.0, 1.1.0, 1.1.1 and 1.3.0
142+
- Available if MapServer was compiled with the ``-DUSE_WMS_SVR`` option, and one of the following :ref:`mapfile-web-metadata` settings:
143+
144+
- ``"wms_enable_request" "*"``
145+
- ``"ows_enable_request" "*"``
146+
147+
- **WFS** - links to the :ref:`WFS <wfs_server>` GetCapabilities documents for supported versions:
148+
149+
- 1.0.0, 1.1.0, and 2.0
150+
- Available if MapServer was compiled with the ``-DUSE_WFS_SVR`` option, and one of the following :ref:`mapfile-web-metadata` settings:
151+
152+
- ``"wfs_enable_request" "*"``
153+
- ``"ows_enable_request" "*"``
154+
155+
- **WCS** - links to the :ref:`WCS <wcs_server>` GetCapabilities documents for supported versions:
156+
157+
- 1.0.0, 1.1.0, 2.0.0, and 2.0.1
158+
- Available if MapServer was compiled with the ``-DUSE_WCS_SVR`` option, and one of the following :ref:`mapfile-web-metadata` settings:
159+
160+
- ``"wcs_enable_request" "*"``
161+
- ``"ows_enable_request" "*"``
162+
163+
.. image:: ../images/index-map-page.png
164+
165+
The HTML output can be customized using the map.html template file located in the configured template folder.
166+
167+
168+

en/output/index.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
idw
1717
imagemaps
1818
kerneldensity
19-
ogr_output
19+
ogr_output
2020
pdf
2121
svg
2222
tile_mode
2323
template_output
2424
kml_output
2525
utfgrid_output
26-
26+
index-page

0 commit comments

Comments
 (0)