Skip to content

fix(mapscript): fall back to storage_crs when options.projection is absent - #2430

Closed
C1-BA-B1-F3 wants to merge 4 commits into
geopython:masterfrom
C1-BA-B1-F3:fix/mapscript-storage-crs
Closed

C1-BA-B1-F3 wants to merge 4 commits into
geopython:masterfrom
C1-BA-B1-F3:fix/mapscript-storage-crs

Conversation

@C1-BA-B1-F3

Copy link
Copy Markdown
Contributor

Summary

The MapScriptProvider only read options['projection'], ignoring the documented storage_crs configuration that every other provider honours. Deployments that set storage_crs (e.g. http://www.opengis.net/def/crs/EPSG/0/2169) silently got EPSG:4326, producing empty or mis-projected images for data in any other projection.

Fix

When options.projection is absent, fall back to storage_crs.to_epsg(). The legacy options.projection override still wins when present, so existing workarounds keep working.

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

# After
try:
    self.crs = int(self.options['projection'])
except (KeyError, ValueError):
    crs_epsg = self.storage_crs.to_epsg()
    self.crs = crs_epsg if crs_epsg is not None else 4326

Behaviour matrix

options.projection storage_crs result
3857 — 3857 (unchanged)
3857 EPSG:2169 3857 (backward compat)
— EPSG:2169 2169 (fixed)
— — 4326 (unchanged)

Test plan

  • Verified with mocked mapscript/osgeo: all four combinations produce the expected EPSG code.

Fixes #2400

PostgreSQL and MongoDB managers ignored the limit and offset
parameters, returning all jobs regardless of the query string.

Apply offset before limit in both backends, matching the existing
TinyDB behaviour.

Fixes geopython#2426
…ints

The tilematrixsets and tilematrixset HTML handlers passed api.tpl_config
as the template configuration, but that dict carries the full server
config (including 'server') and lacks the 'path' key that
render_j2_template expects. The lookup therefore always fell back to
the default templates, ignoring any custom theme.

Pass api.config['server']['templates'] instead, matching every other
render_j2_template call site.

Fixes geopython#2422
…DBAPI

A provider configured with a bare connection string (e.g.
"postgresql://user@host/db") resolved to SQLAlchemy's default DBAPI
for that backend — psycopg (v3) for PostgreSQL. Deployments that only
install psycopg2 then fail with 'ModuleNotFoundError: No module named
psycopg' even though the provider pins 'postgresql+psycopg2'.

When the caller's URL has no '+driver' suffix and the provider's
driver_name does, rewrite the URL's drivername to the pinned one.

Fixes geopython#2424
…bsent

The MapScript provider only read options.projection, ignoring the
documented storage_crs configuration. Deployments that set storage_crs
(like every other provider) silently got EPSG:4326, producing empty
images for data in any other projection.

Use storage_crs when options.projection is not set; the legacy
options.projection override still wins when present so existing
workarounds keep working.

Fixes geopython#2400
@C1-BA-B1-F3

Copy link
Copy Markdown
Contributor Author

Correcting the CI evidence in my earlier comment: the Build failure has a single root cause, it is not caused by this PR, and my earlier pointer to the 2026-09-29 templating run was wrong (that run failed only on test_postgresql_provider with ModuleNotFoundError: No module named 'psycopg', not on these two tests).

Root cause

The usgs-prism collection fails to load:

WARNING pygeoapi.provider.xarray_:xarray_.py:114
        open_group() got an unexpected keyword argument 'zarr_format'
WARNING pygeoapi.api:__init__.py:956
        Error generating collection usgs-prism: open_group() got an unexpected
        keyword argument 'zarr_format'

That single failure produces both red tests: describe_collections sees 9 collections instead of 10, and every EDR query against usgs-prism returns 500 (ProviderNoDataError -> test_get_collection_edr_query).

Why it is environmental, not this PR

  • The last green Build runs — master (2026-09-22) and the psycopg branch (2026-09-29) — installed xarray 2026.7.0.
  • The runs from 2026-10-03 install xarray 2026.9.0. zarr is unchanged at 2.18.7 (pinned <3).
  • requirements-provider.txt leaves xarray unpinned, and 2026.9.0 changes the Zarr open path, which breaks pygeoapi/provider/xarray_.py for the usgs-prism Zarr store.

This PR only touches pygeoapi/provider/mapscript_.py; it does not touch the EDR/xarray provider or the collection config. Happy to rebase once the environment (or the xarray pin) is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants