Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support properties and skipGeometry filters for single item queriess #1918

Open
webb-ben opened this issue Feb 2, 2025 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@webb-ben
Copy link
Member

webb-ben commented Feb 2, 2025

Is your feature request related to a problem? Please describe.
The properties and skipGeometry filters are applied when querying /items but are ignored when retrieving a single item via the /items/{id} endpoint. Extending this functionality would improve consistency and efficiency when retrieving specific attributes for a single feature.

Describe the solution you'd like
I would like to be able to use pygeoapi to return minimal bytes possible when doing a transaction. Say I want to use the id of pygeoapi demo Lakes collections to resolve it's wikipedia url. The following query allows me to return only the pertinent information: https://demo.pygeoapi.io/master/collections/lakes/items?f=json&properties=name_alt&skipGeometry=true&id=0

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "name_alt": "https://en.wikipedia.org/wiki/Lake_Baikal"
      },
      "geometry": null,
      "id": 0
    }
  ],
  "numberMatched": 1,
  "numberReturned": 1,
  "links": [...],
  "timeStamp": "2025-02-02T16:40:33.964949Z"
}

However, when making the same request for a single item, there is no way to minimize the size of the payload: https://demo.pygeoapi.io/master/collections/lakes/items/0?f=json&properties=name_alt&skipGeometry=true

{
  "type": "Feature",
  "properties": {
    "id": 0,
    "scalerank": 0,
    "name": "Lake Baikal",
    "name_alt": "https://en.wikipedia.org/wiki/Lake_Baikal",
    "admin": null,
    "featureclass": "Lake"
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [...]
  },
  "id": 0,
  "links": [...]
}

Describe alternatives you've considered
It is possible to configure geometry and properties via pygeoapi configuration, but I would like to make these values conditionally available.

Additional context
Naively you could implement the this within pygeoapi/api/itemtypes.py but that feels like an incorrect solution. A variety of providers have a flexible enough implementation of the select properties and skipGeometry options it might be easy to port the logic used in p.query(select_properties=[], skip_geometry=False): logic into p.get(identifier, select_properties=[], skip_geometry=False, **kwargs):

@webb-ben webb-ben added the enhancement New feature or request label Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant