koopjs / koop

Transform, query, and download geospatial data on the web.
http://koopjs.github.io
Other
651 stars 125 forks source link

Features are filtered out when query params objectIds and outFields are specified #601

Closed despainm closed 9 months ago

despainm commented 1 year ago

When executing a query that specifies objectIds=1&outFields=MY_FIELD the featureserver filters out features if the OBJECTID attribute is not provided in the data attributes.

Our provider supplies the featureserver with data attributes based on the outFields list. If OBJECTID is not part of the outFields list all the data attributes do not include the OBJECTID so all features are filtered out. To workaround this our provider checks for the condition where objectIds and outFields is specified and the outFields does not include the OBJECTID field. The provider modifies the req.query to add the OBJECTID field to the outFields, and provide the OBJECTID attribute in the data. The features that match the objectIds are returned, but the result also includes the OBJECTID attribute.

It seems like the provider should provide featureserver with the OBJECTID attribute in the data so it can filter results, but featureserver should honor the outFields list and not return the OBJECTID in the result unless it is part of the original request outFields.

rgwozdz commented 1 year ago

Thanks for bringing this in @despainm, and for the great write up and code link. We'll address ASAP.

schmidtk commented 1 year ago

@rgwozdz When fixing this, it might be helpful to add a objectIds flag to the filtersApplied object so providers can indicate if they have already filtered features by that parameter. This would help reduce post processing for providers like Elastic that can do this filtering in the data query.

rgwozdz commented 1 year ago

Fix in progress.

rgwozdz commented 1 year ago

in PR, https://github.com/koopjs/koop/pull/610.

rgwozdz commented 1 year ago

@despainm - try @koopjs/koop-core@8.0.10

despainm commented 1 year ago

Thanks @rgwozdz! koop-core 8.0.10 worked for us (we are setting the featureCollection.filtersApplied.objectIds = true;). It appears to have fixed this issue and https://github.com/koopjs/koop/issues/605.