geopython / geopython/pygeoapi

Mapscript provider configuration parser not use storage_crs as defined in the documentation

Open
#2,400 0 comments 0 reactions 1 assignee Claimed by @doublebyte1 View on GitHub
bug
Dominant language
Python
Stars
624
Forks
326
Avg merge
8h 25m
Merged PRs (30d)
2

Description

**Description**
Mapscript provider not use storage_crs as defined in the documentation but expect a number representing the ESPG in options.projection
So maps based on data not using EPSG:4326 projection are not working if we respect the documentation syntax

**Steps to Reproduce**
Configure an OGC API Maps Collection based on a geoTIFF or Shapefile having a projection other than EPSG:4326

**Expected behavior**
Generated Mapfile layer shoud use the storage_crs projection, currently it always use EPSG:4326, so genrated images are often empty due to bad data reprojection

**Screenshots/Tracebacks**

**Environment**
- OS: Ubuntu 24.04.4 LTS (Noble Numbat)
- Python version: 3.12.3
- pygeoapi version: 0.24

**Additional context**
based on Mapscript documentation, we should use storage_crs to define the data projection :

```
providers:
- type: map
name: MapScript
data: /maps/PARCELLES.shp
options:
type: MS_LAYER_POLYGON
layer: PARCELLES
style: /maps/PARCELLES.sld
format:
name: png
mimetype: image/png
storage_crs: http://www.opengis.net/def/crs/EPSG/0/2169
```

But then the generated mapfile layer uses :

```
PROJECTION
"proj=longlat"
"datum=WGS84"
"no_defs"
END # PROJECTION
```

one bypass solution is to use the "options.projection" parameter :

```
providers:
- type: map
name: MapScript
data: /maps/PARCELLES.shp
options:
type: MS_LAYER_POLYGON
layer: PARCELLES
style: /maps/PARCELLES.sld
projection: 2169
format:
name: png
mimetype: image/png
```

then the generated mapfile layer projection is EPSG:2169

Based on the following code snippet inside "pygeoapi/provider/mapscript_.py"

```
try:
self.crs = int(self.options['projection'])
except KeyError:
self.crs = 4326

self._layer.setProjection(self._epsg2projstring(self.crs))
```

I think there are 2 solutions :

- adapting the Mapscript documentation so we know that we have to define the "options.projection" parameter
- changing the code so it stops using option.projection and uses the CRS defined by storage_crs

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.