pygeoapi icon indicating copy to clipboard operation
pygeoapi copied to clipboard

Custom Formatter plugin issues

Open webb-ben opened this issue 8 months ago • 3 comments

Description The Formatter Plugin architecture does not appear to be fully integrated. Following the documentation in https://docs.pygeoapi.io/en/latest/plugins.html#example-custom-pygeoapi-formatter, but there is no way for me to use the formatter plugin as an output in pygeoapi.

Steps to Reproduce Steps to reproduce the behavior:

  1. Produce custom formatter plugin
  2. Add plugin to pygeoapi.plugins.PLUGINS.formatters
  3. Query using custom format
  4. Results are JSON.

Expected behavior I would expect for there to be a clear way to deploy a custom formatter plugin in pygeoapi. I would expect appropriately registered formatters to be loaded consistent with pygeaopi's plugin architecture.

Screenshots/Tracebacks Unlike the provider, the formatters are never specified in the configuration to load an external plugin. It appears the formatters are only ever validated to ensure against the keys in pygeoapi.plugins.PLUGINS.formatters, see https://github.com/search?q=repo:geopython/pygeoapi+PLUGINS['formatter']&type=code

Image

Furthermore the only formatter plugin in core, CSV is hardcoded https://github.com/geopython/pygeoapi/blob/a90f545978028f029331c115f90e8dc5d93c1239/pygeoapi/api/itemtypes.py#L650-L652

Environment

  • OS: All
  • Python version: 3.10
  • pygeoapi version: 0.21.dev0

Additional context It seems a large portion of the formatting can be also done in a Jinja2 template. I think it would benefit pygeoapi to have a clearer picture of how the different ways to format outputs between the Formatter architecture and Jinja2 templates.

webb-ben avatar Apr 17 '25 21:04 webb-ben

I have the same problem, I am creating a custom provider :

example ->

providers:
            - type: feature
              name: pygeoapi.pygeoapi_complementos.Vector_provider.OGR_DataProvider.OGR_DataProvider
              data: https://......zip
            #   id_field: id
            #   title_field: id

and a custom output format, defined in the same level as server, metadata, logging,...:

example ->


format:
  topojson:
    mimetype: application/topo+json
    name: pygeoapi.pygeoapi_complementos.Vector_format.topojson_DataFormat.TopoJSON_DataFormatter
    title: TopoJSON

and I can't register it from the configuration yml

IngenieroGeomatico avatar Jul 14 '25 17:07 IngenieroGeomatico

This Issue has been inactive for 90 days. As per RFC4, in order to manage maintenance burden, it will be automatically closed in 7 days.

github-actions[bot] avatar Oct 19 '25 03:10 github-actions[bot]

I've started work on a branch (with focus on item types), and will put forth a PR in the next few weeks once ready.

tomkralidis avatar Oct 22 '25 02:10 tomkralidis