-
-
Notifications
You must be signed in to change notification settings - Fork 439
Adds plugin support for style filtering, tile data reading and custom protocol handlers #3703
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
Draft
AtlasProgramming
wants to merge
66
commits into
maplibre:main
Choose a base branch
from
HudHud-Maps:maplibre/feature/2025-08-plugins
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Adds plugin support for style filtering, tile data reading and custom protocol handlers #3703
AtlasProgramming
wants to merge
66
commits into
maplibre:main
from
HudHud-Maps:maplibre/feature/2025-08-plugins
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for more information, see https://pre-commit.ci
…ing/maplibre-native into feature/2025-07-raw-bucket # Conflicts: # src/mbgl/tile/geometry_tile_worker.cpp
for more information, see https://pre-commit.ci
…amming/maplibre-native into feature/2025-07-style-filters # Conflicts: # src/mbgl/style/style_impl.cpp
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…amming/maplibre-native into feature/2025-07-style-filters
for more information, see https://pre-commit.ci
Feature Collections
# Conflicts: # CMakeLists.txt # bazel/core.bzl # platform/ios/src/MLNMapView.mm
…ters Add Style Filters
# Conflicts: # CMakeLists.txt # bazel/core.bzl # platform/BUILD.bazel # platform/darwin/bazel/files.bzl # platform/darwin/darwin.cmake # platform/ios/app/MBXViewController.mm # platform/ios/src/MLNMapView.h # platform/ios/src/MLNMapView.mm
…otocol Add custom protocols
for more information, see https://pre-commit.ci
…re-native into maplibre-plugins
for more information, see https://pre-commit.ci
Bloaty Results (iOS) 🐋Compared to main Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results-ios/pr-3703-compared-to-main.txt |
Bloaty Results 🐋Compared to main Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-3703-compared-to-main.txtCompared to d387090 (legacy) Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-3703-compared-to-legacy.txt |
|
Benchmark Results ⚡ Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/benchmark-results/pr-3703-compared-to-main.txt |
51e3eed to
7f96a34
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is a collection of plug-in capability. This was originally multiple PRs, but due to the complexity of trying to keep the PRs open while they were being developed, it became clear we needed to combine into a single PR for the community to review and we can use this to build consensus on how plugins can work and then if specific categories of plug-ins are going to be used, we can always create a separate PR to pull in a specific set of plugins.
The different types of plugin supported in this PR are:
Feature Geometry
This adds the ability to latch into the tile loading and receive the geometry and properties for features in the tiles. This is just a natural extension of the plug in layers. The only thing the plugin implementor needs to do is add a new override to the plugin layer class to support receiving the geometry. Then the geometry features that are passed to the method is filtered using the same paradigm as all the other layer types. Just set a source, source layer and filter in the style.
For the layer definition, the supportsReadingTileFeatures property needs to be set to true.
The layer is then inserted into the style with the type, source and source-layer.
Simple handler just logging all the features that pass the filter, their properties and coordinates.
Protocol Handler
This adds support similar to plugin-layers and style filters by exposing a data loading paradigm via a plug-in class and lambda implementation. This does not create or implement a way to chain FileSources together.
To add a custom handler, descend from MLNPluginProtocolHandler and implement the two methods to let the system know if this handler can handle the request and then return data when the system asks for it. There's a sample implementation which just loads the local test style file when the url starts with "pluginProtocol"
Like other plug in items, these handlers are added to the map view at runtime with a single call.
Supported on Android as well. Just descend from the PluginProtocolHandler class and implement the two methods, one for if this handler can support the request and returning the actual data for the request.
and register the plugin using the mapview
Style Filters
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.
Like all the plugins, the style filters are coupled to the engine at runtime using the addStyleFilter method on the map view.