Skip to content

Add support for non-EPSG projections for WCS and WFS protocols#7457

Merged
geographika merged 32 commits intoMapServer:mainfrom
geographika:wcs-custom-projections
Apr 7, 2026
Merged

Add support for non-EPSG projections for WCS and WFS protocols#7457
geographika merged 32 commits intoMapServer:mainfrom
geographika:wcs-custom-projections

Conversation

@geographika
Copy link
Copy Markdown
Member

@geographika geographika commented Mar 11, 2026

This pull request adds support for using non-EPSG projection codes in WCS and WFS services. This includes both accessing the data in a non-EPSG projection and advertising the projections in GetCapabilities requests. For example the wcs_custom_projection_capabilities201.xml response includes:

  <crs:CrsMetadata>
    <crs:crsSupported>http://www.opengis.net/def/crs/ESRI/0/54052</crs:crsSupported>
    <crs:crsSupported>http://www.opengis.net/def/crs/EPSG/0/4326</crs:crsSupported>
    <crs:crsSupported>http://www.opengis.net/def/crs/ESRI/0/53009</crs:crsSupported>
    <crs:crsSupported>http://www.opengis.net/def/crs/epsg2/0/42304</crs:crsSupported>
  </crs:CrsMetadata>

And any of these projections can be used to request a coverage e.g. &SERVICE=WCS&VERSION=2.0.1&REQUEST=GetCoverage&COVERAGEID=test&SUBSETTINGCRS=urn:ogc:def:crs:ESRI::53009&SUBSET=x(-3276599.0027238373,-3258457.2498260457)&SUBSET=y(8498088.094072288,8507095.190921152)&SCALESIZE=x(512),y(254)&OUTPUTCRS=urn:ogc:def:crs:ESRI::53009&FORMAT=image/png

A full test suite for WCS 1.0.0, 1.1.1, and 2.0.1 is added in wcs_custom_projection.map.

As several functions were shared with the WFS code, WFS was also updated, and a full test suite found in wfs_custom_projection.map.

WMS had already been updated to handle custom CRSs in #6795.

Note - OGC Features API was not updated, and does not support handling non-EPSG projections. This can be dealt with in a subsequent PR.

Other notes:

  • The majority of code changes were to msLoadProjectionString - which is used by several MapServer service protocols.
  • The various projection formats which can be handled by the updated are tested in a new Python MapScript test file msautotest/mspython/test_projections.py. In summary any code in the format AUTH:CODE that is in proj.db will be handled, and any authorities not in proj.db can be added using init=CUSTOMAUTH:CODE and search PROJ_DATA for a file with a Proj string.
  • This PR fixed a few existing tests which used the newer EPSG:3857 rather than init=EPSG:3857, removing CRS warnings in WMS GetCapabilities

This PR fixes the following issues:

@jmckenna jmckenna added this to the 8.8.0 Release milestone Mar 11, 2026
Comment thread src/mapfile.c
Comment thread msautotest/mspython/test_projections.py Outdated
Comment thread src/mapfile.c Outdated
Comment thread msautotest/mspython/test_projections.py Outdated
Comment thread src/mapows.cpp
}
strlcpy(auth, tokens[i], authlen + 1);
code = sep + 1;
snprintf(urn, sizeof(urn), "%s%s/0/%s", OGC_CRS_PREFIX, auth, code);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should likely have a special case to turn "http://www.opengis.net/def/crs/IAU_2015/0/code" as "http://www.opengis.net/def/crs/IAU/2015/code".
The IAU_2015 authority is a bit of a hack, that captures both the authority and version

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look at the IAU_2015 again when adding tests for the OGC Features API and non-ESPG projections. I was trying (and not really succeeding!) in keeping the scope of this PR to a minimum. It would be nice to get a lunar Mapfile working as a MapServer demo.

Comment thread src/mapwfs.cpp Outdated
Copy link
Copy Markdown
Contributor

@rouault rouault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@geographika geographika force-pushed the wcs-custom-projections branch from 547a3f8 to 428b785 Compare March 12, 2026 13:42
@geographika
Copy link
Copy Markdown
Member Author

Thanks for the review @rouault - much appreciated!
Having gone through lots of the projection code I think there are quite a few changes it would be good to add as part of a MapServer 9.0, including a requirement for PROJ9+. In addition:

  • try and get rid of the custom MapServer +epsgaxis=ne parmaeter and use PROJ to get axis order
  • review and update all the references to init= checks in the codebase

@geographika geographika merged commit eb2d8af into MapServer:main Apr 7, 2026
17 checks passed
rouault pushed a commit that referenced this pull request Apr 10, 2026
Follow-up to #7457 to add a test and guard for invalid projection strings in a Mapfile.

Fixes: Reference Info: 500975699 mapserver:mapfuzzer: Null-dereference READ in msProcessProjection https://oss-fuzz.com/testcase-detail/6167937613627392
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.

4 participants