Skip to content

Commit 42add60

Browse files
committed
- Added support to tileindexing on MapScript provider
1 parent cafddc8 commit 42add60

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

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 `tileindexing <https://mapserver.org/optimization/tileindex.html>`_,
77+
which let 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: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from mapscript import MapServerError
3535

3636
from pygeoapi.provider.base import (BaseProvider, ProviderConnectionError,
37-
ProviderQueryError)
37+
ProviderGenericError, ProviderQueryError)
3838

3939
LOGGER = logging.getLogger(__name__)
4040

@@ -74,13 +74,22 @@ def __init__(self, provider_def):
7474

7575
file_extension = self.data.split('.')[-1]
7676

77-
if file_extension in ['shp', 'tif']:
78-
LOGGER.debug('Setting built-in MapServer driver')
79-
self._layer.data = self.data
77+
tileindex = False
78+
if 'tileindex' in self.options:
79+
if (self.options['tileindex'] is not True and self.options['tileindex'] is not False): # noqa
80+
raise ProviderGenericError('Invalid tileindex parameter')
81+
tileindex = bool(self.options['tileindex'])
82+
83+
if tileindex is True:
84+
self._layer.tileindex = self.data
8085
else:
81-
LOGGER.debug('Setting OGR driver')
82-
self._layer.setConnectionType(mapscript.MS_OGR, 'OGR')
83-
self._layer.connection = self.data
86+
if file_extension in ['shp', 'tif']:
87+
LOGGER.debug('Setting built-in MapServer driver')
88+
self._layer.data = self.data
89+
else:
90+
LOGGER.debug('Setting OGR driver')
91+
self._layer.setConnectionType(mapscript.MS_OGR, 'OGR')
92+
self._layer.connection = self.data
8493

8594
self._layer.type = getattr(mapscript, self.options['type'])
8695

0 commit comments

Comments
 (0)