Adds Style Preprocessor Plugin Capability #3957
Open
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.
Style Preprocessor
This will add the ability to latch into the style loading and modify the style before it gets to the actual style parsing. There are two parts to this functionality. The first is a C++ based latch into the actual style that will allow a lambda to be assigned to each filter that will receive (in order of add) the data after it's loaded from the source (e.g. http/file/etc). Each filter is passed the output of the previous filter.
The second part is a platform implementation of this for iOS that creates a base filter class that the user can descend from, override a single method and then get the input data and return the data to pass along the filter chain. Since the filters are added at runtime, this will allow run-time filter plugins to be registered and utilized.
Potential uses for this are libraries of different filter types (e.g. uncompressing a compressed/encrypted format, filtering or translating layer properties before they are parsed, injecting specific layer types for all styles, etc).
An example implementation is included in the PR. This filter gets the style passed to it before it's parsed and it adjusts the style to remove some layer types. Since the plug-in receives the style before it goes to the parser, any transformation of the style could happen in the filter.
The style preprocessors are coupled to the engine at runtime using the addStyleFilter method on the map view.