-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 tiled vector data and Mapbox vector tiles #4219
Conversation
4349b85
to
d8e43e6
Compare
goog.require('ol.style.Text'); | ||
|
||
|
||
// Mapbox access token - request your own at http://mabobox.com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little typo here - http://mapbox.com
Awesome work. Very impressive! |
@@ -37,9 +37,11 @@ | |||
"metalsmith": "1.6.0", | |||
"metalsmith-templates": "0.7.0", | |||
"nomnom": "1.8.0", | |||
"pbf": "1.3.4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor but version 1.3.5 was release yesterday
f17c381
to
7a92f1f
Compare
* A function that takes an {@link ol.Feature} and an {@link ol.layer.Layer} | ||
* and returns `true` if the feature may be selected or `false` otherwise. | ||
* @typedef {function(ol.Feature, ol.layer.Layer): boolean} | ||
* A function that takes an {@link ol.Feature} or {@link ol.Feature} and an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo:
…takes an {@link ol.Feature} or {@link ol.render.Feature}…
dd5e934
to
6a7da55
Compare
0447b5f
to
aefd028
Compare
LGTM @ahocevar please merge once Travis gives the final okay |
Thanks @bartvde for this thorough review - the code is much simpler, cleaner and smaller now. |
Support tiled vector data and Mapbox vector tiles
Some metrics regarding build size. Configuration used: "exports": [
"ol.Map", "ol.Map#*",
"ol.View", "ol.View#*",
"ol.layer.Vector", "ol.layer.Vector#*",
"ol.source.Vector", "ol.source.Vector#*",
"ol.format.GeoJSON",
"ol.style.*"
],
"compile": {
"define": [
"ol.ENABLE_VECTOR_TILE=false",
]
}
} So no vector tiles in this configuration. Before:
After:
The increase of 818 bytes in code size comes mostly from performance optimisations in the canvas replay, and the support for array buffers in vector formats. |
@tonio I saw it only on Linux. Did you observe this on other platforms as well? |
How do you guys feel about the performance of http://openlayers.org/en/master/examples/mapbox-vector-tiles-advanced.html?q=vectortile using the canvas renderer? On my machine its suboptimale compared to the mapbox GL render. Dont get me wrong - its really amazing work. |
Right I observed the same performance "issue", especially on pan. |
@s093294 @bartvde In the process of working on this pull request, I spent a long time profiling and optimizing. The bottleneck is now in the renderer code itself. The majority of the time is spent applying strokes and fills. If the canvas renderer did a better job combining geometries and stroking/filling them at once, performance would be better. But that's a separate issue, as it affects all canvas rendering in OpenLayers. The goal is to reduce the number of stroke and fill instructions. |
@ahocevar should we at least open up a new issue for this? So we don't loose your valuable information here? |
@bartvde Please do so. |
@ahocevar yep, I reproduce on win 7 & 10, too (browserstack). |
@tonio Please create a ticket for that. |
Thanks @tonio. |
@ahocevar is it possible to read tiles from a local folder and not from over the web e.g for offline use? |
Hi @NathanW2 I don't think this is possible as there are security issues with accessing files using AJAX, see http://stackoverflow.com/a/18137280 |
@NathanW2 You can define a custom |
Hello, Can anyone help me with how to create simple vector tile and how to add layers in it, how to add structures in it. |
This pull request adds support for rendering tiled vector data. The key elements to achieve this are
ol.layer.VectorTile
. A simple layer to hint renderers that a tiled renderer is to be used, instead of a viewport renderer like forol.layer.Vector
.ol.source.VectorTile
andol.VectorTile
. Features are handled by the tile, not the source. Like image tiles, vector tiles can be cached. The existingol.source.TileVector
is removed, and its functionality is integrated intool.source.VectorTile
. To improve the inheritance chain,ol.source.UrlTile
was added. Bothol.source.ImageTile
andol.source.VectorTile
inherit common functionality related to url loading from that new class.ol.renderer.canvas.VectorTileLayer
. This renderer gets tiles fromol.source.VectorTile
, creates a replay group for each tile, and stores the replay group on the tile for rendering. Tiles are clipped at the tile boundary, so stroked polygons won't have a stroke at the tile boundary when a buffer is used on the server that creates the vector tiles.Support for Mapbox vector tiles is provided by the new
ol.format.MVT
format, which relies on https://www.npmjs.com/package/pbf to read the protobuffers and https://www.npmjs.com/package/vector-tile to parse layers and features. To support pixel relative coordinates,ol.proj.Units.TILE_PIXELS
was introduced. For efficient feature and geometry creation, a lightweight, read-onlyol.render.Feature
was added, which does not register any event listeners. Another performance improvement was achieved by skipping lineTo/moveTo calls for repeated coordinates when replaying vector batches at a lower resolution than it was created for.