Skip to content

Commit 7096af2

Browse files
authored
Added support to tileindexing on MapScript provider (#1931)
* - Added support to tileindexing on MapScript provider * - updated MapScript provider to use str2bool to extract boolean from string * - remove comment * - fixed typos and styling in MapScript documentation * - simplified condition * - removed brackets on import
1 parent fb39098 commit 7096af2

2 files changed

Lines changed: 31 additions & 6 deletions

File tree

docs/source/data-publishing/ogcapi-maps.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,26 @@ Projections are supported through EPSG codes (`options.projection`):
7373
7474
This parameter is optional, defaulting to WGS84 (4236).
7575

76+
This provider also supports `tile indexing <https://mapserver.org/optimization/tileindex.html>`_,
77+
which lets MapScript create a mosaic on the fly, piecing together a set of files.
78+
In order to enable it, set `options.tileindex` to `True` and set the location of the index file on the `data` path.
79+
80+
.. code-block:: yaml
81+
82+
providers:
83+
- type: map
84+
name: MapScript
85+
data: /data/index.shp
86+
options:
87+
type: MS_LAYER_RASTER
88+
tileindex: True
89+
layer: index
90+
format:
91+
name: png
92+
mimetype: image/png
93+
94+
The `options.tileindex` parameter is optional, defaulting to `False`.
95+
7696
WMSFacade
7797
^^^^^^^^^
7898

pygeoapi/provider/mapscript_.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
from pygeoapi.provider.base import (BaseProvider, ProviderConnectionError,
3737
ProviderQueryError)
38+
from pygeoapi.util import str2bool
3839

3940
LOGGER = logging.getLogger(__name__)
4041

@@ -74,13 +75,17 @@ def __init__(self, provider_def):
7475

7576
file_extension = self.data.split('.')[-1]
7677

77-
if file_extension in ['shp', 'tif']:
78-
LOGGER.debug('Setting built-in MapServer driver')
79-
self._layer.data = self.data
78+
if str2bool(self.options.get('tileindex', False)):
79+
LOGGER.debug('Setting tileindex')
80+
self._layer.tileindex = self.data
8081
else:
81-
LOGGER.debug('Setting OGR driver')
82-
self._layer.setConnectionType(mapscript.MS_OGR, 'OGR')
83-
self._layer.connection = self.data
82+
if file_extension in ['shp', 'tif']:
83+
LOGGER.debug('Setting built-in MapServer driver')
84+
self._layer.data = self.data
85+
else:
86+
LOGGER.debug('Setting OGR driver')
87+
self._layer.setConnectionType(mapscript.MS_OGR, 'OGR')
88+
self._layer.connection = self.data
8489

8590
self._layer.type = getattr(mapscript, self.options['type'])
8691

0 commit comments

Comments
 (0)