Skip to content

Conversation

@tomkralidis
Copy link
Member

Overview

This PR updates formatters support to allow for custom formatters for item types.

Related Issue / discussion

#1997

Additional information

Dependency policy (RFC2)

  • I have ensured that this PR meets RFC2 requirements

Updates to public demo

Contributions and licensing

(as per https://github.com/geopython/pygeoapi/blob/master/CONTRIBUTING.md#contributions-and-licensing)

  • I'd like to contribute [feature X|bugfix Y|docs|something else] to pygeoapi. I confirm that my contributions to pygeoapi will be compatible with the pygeoapi license guidelines at the time of contribution
  • I have already previously agreed to the pygeoapi Contributions and Licensing Guidelines

@tomkralidis tomkralidis changed the title [WIP] add support for custom formatters [WIP] fix support for custom formatters Oct 24, 2025
@tomkralidis tomkralidis force-pushed the formatters branch 2 times, most recently from dbbce65 to b364419 Compare October 27, 2025 00:07
@tomkralidis tomkralidis added this to the 0.22.0 milestone Oct 27, 2025
@tomkralidis tomkralidis added the bug Something isn't working label Oct 27, 2025
@tomkralidis tomkralidis modified the milestones: 0.22.0, 0.23.0 Nov 4, 2025
@tomkralidis tomkralidis changed the title [WIP] fix support for custom formatters fix support for custom formatters (#1997) Jan 9, 2026
@webb-ben webb-ben self-requested a review January 9, 2026 13:20
Copy link
Member

@webb-ben webb-ben left a comment

Choose a reason for hiding this comment

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

Looks good to me. I will test later today. Some small questions / comments.

  • This implements custom formatters for OAFeat and OARec GeoJSON responses. Can we add some additional documentation to clarify this? Is support for EDR CovJSON Formatters an entirely different issue? I have a simple Point-based CovJSON -> CSV formatter that I would like to synchronize these changes with.

  • After this is merged I will migrate our OGR Formatter to https://github.com/cgs-earth/pygeoapi-plugins. I will want to figure out how much of this can be offloaded to the configuration options introduced. Depending on the path this takes, a general OGR formatter could subsume #2136 and our custom formatter.

self.mimetype = None
self.geom = False

self.name = formatter_def['name']
Copy link
Member

Choose a reason for hiding this comment

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

Should this be in a try/catch?

Copy link
Member

Choose a reason for hiding this comment

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

For some reason this is formatted to the wrong line. In the base provider, all required fields are in a try/catch. Should

        self.name = formatter_def['name']

follow suit?

super().__init__({'name': 'cooljson', 'geom': None})
self.mimetype = 'application/json; subtype:mycooljson'
self.f = 'cooljson' # f= value
Copy link
Member

Choose a reason for hiding this comment

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

Does the formatter need to response both f= and the Accept Header?

formatter = load_plugin('formatter',
{'name': 'CSV', 'geom': True})
elif request.format in [df.f for df in dataset_formatters.values()]:
formatter = [v for k, v in dataset_formatters.items() if
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
formatter = [v for k, v in dataset_formatters.items() if
formatter = [v for v in dataset_formatters.values() if

Are we using the key in this?

@webb-ben webb-ben requested a review from a team January 9, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants