Closed vpicavet closed 5 years ago
I'm currently working on integrating vector tiles, and I identified a few step ahead:
pbf
/mvt
file and parse itpbf
/mvt
loading for TMS, WMS, WFS and WMTSFirst I'm concentrating on solving one way, and then the others (that should be smooth).
Below are a list of PR related to this work (will be updated):
Let's lay a solid basis, with the aim to easily iterate later on this subject (for example when expanding style possibilities). Here's a more detailed point of view I got.
Vector tiles are accessible through TMS, WMTS, WMS and WFS. Currently, no provider can fetch pbf
files. A method needs to be added for this, that could be used like OGCWebServiceHelper.getColorTextureByUrl
for example.
Question: do we add all the methods related to vector tiles in a new file, like VectorTile_Provider.js
? I don't think it's a good idea to create a new single provider, as it would be a pain to add support for all protocols in it. I was thinking more of adding a VectorTileHelper.js
, featuring some public methods:
getVectorTileRawByUrl
: would return a "raw" vector tile, not the loaded pbf
but a Mapbox VectorTile.getVectorTileGeoJSONByUrl
: would return a vector tile as a GeoJSON (needed for next methods, so why not making it available)getVectorTileTextureByUrl
: if the layer.type
is color
, would return a texture, using the Feature2Texture
class.getVectorTileMeshByUrl
: if the layer.type
is geometry
, would return a mesh, using the Feature2Mesh
class.Those methods could be used in each Provider, using the supportedFormats
array: a new entry with application/x-protobuf;type=mapbox-vector
needs to specify the calling of a method above.
The style
argument in Feature2Texture.createTextureFromFeature
could be improved:
The same reasoning can be applied to Feature2Mesh
, but more limited.
Let's discuss it further !
We should start rethinking other Providers / Drivers as well. For instance WMTS_Provider does different things for elevation and color textures while it's completely unrelated to the WMTS protocol.
An option is to reorganize providers: ImageryProvider, ElevationProvider, VectorProvider for instance. They would then use some protocol aware code (WMTSProtocolHandler ? TMSProtocoHandler?) that would simply build the correct url and fetch the result.
And maybe VectorProvider isn't even useful, since it'll provide textures or meshes. You could declare an imagery layer using the xyz protocol and a vector-tiles data source.
Then ImageryProvider would do:
return tmsProtocolHandler.fetch(params).then(tile => VectorTile.toImageryTexture(tile)
For a layer using a raster data source ImageryProvider would do:
return tmsProtocolHandler.fetch(params).then(tile => Raster.toImageryTexture(tile)
return tmsProtocolHandler.fetch(params).then(tile => Raster.toElevationTexture(tile)
WDYT?
Please allow me to jump in, as this discussion is very much related to recent experience with students having a really hard time to customize itowns with new datasources, new data formats or new portraying styles (without even talking about interaction) and facing monolithic providers that they have a hard time to customize.
We definitely need this discussion and clarification of the roles of providers/protocolhandlers, loaders/drivers and feature_transformer/stylizers. Current providers are basically responsible for orchestrating the whole transformation from datasources/servers to Three.js objects, so it is very cumbersome to mix and match different protocols, formats and styles.
This discussion has multiple facets, my proposition, definitely up to discussion, would be that :
I quite agree with you @mbredif on the role of providers. For the rest, no opinion yet :-)
could enable the the coding of each provider and loader as independant npm packages
Note that this is already possible with providers, at least. Also, if you import iTowns with a module bundler, you can already customize a lot of things (but I do agree that this process still requires too much inner knowledge of iTowns :-/ ).
@mbredif I agree - it's more or less what I wrote in my comment, but yours is way clearer :)
Solved in multiple PRs
iTowns should support vector tiles at some point.
Vector tiles are an efficient vector format for rendering of 2D data. Vector tile services start to be available, and server-side components do exist.
Implementing vector tiles support suppose having Clamping available first ( #181 ).
We could use the following services for testing purposes :