ResourceProvider: Add support to filter ResourceSet features #1838
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
Resources defined in the Signal K specification support only one GeoJSON feature per resource entry i.e.
To enable the use of more than one feature per resource entry Freeboard-SK supports the use of ResourceSets.
ResourceSets employ GeoJSON
FeatureCollections
to allow the definition of multiple features of varied geometry types.Issue
When providing a filter to a resource request, the operation only supports single feature resource types (e.g. waypoints, routes) so when the request is targeting a
ResourceSet
, it's features are not correctly processed and an empty result is returned.e.g. /signalk/v2/api/resources/<my_resource_type>?position=[109.5711467220878,-9.33075032178624]&distance=185200
Noting that a ResourceSet is not currently part of the Signal K specification, there is an opportunity to define and formalise a JSON schema to support a resource entry containing more than one feature.
Implementation
This PR adds the necessary support to filter features in a ResourceSet and return only those that match the query based on the current ResourceSet definition.
If no features match then the ResourceSet is returned with an empty feature array.