Refacto provider and add Sources#798
Conversation
There was a problem hiding this comment.
It looks better than the current state IMHO.
Some remarks after a quick review :
layer.source || layerlooks odd, is it temporary ? can't we get rid of it ?- converts and parsers are 2 different things (eg: WMTS source -> Geojson parser -> Mesh converter)
I however feel that tiledCRS version of extents should be an implementation detail of quadtree-based sources and that other parts of itowns should only handle extents as a (BBox3 + CRS).
Likewise instead of relative pitches / offsetscales, we could use absolute coordinates (BBox2 + CRS) for textures so that downscaling a texture would be a noop and uvs in the shader would be well defined coordinates with a proper crs instead of normalized coordinates.
src/Core/TileMesh.js
Outdated
| @@ -205,8 +204,9 @@ TileMesh.prototype.changeSequenceLayers = function changeSequenceLayers(sequence | |||
|
|
|||
| TileMesh.prototype.getCoordsForLayer = function getCoordsForLayer(layer) { | |||
| if (layer.protocol.indexOf('wmts') == 0) { | |||
src/Core/View.js
Outdated
|
|
||
| // probably not the best place to do this | ||
| if (layer.type == 'color') { | ||
| layer.fx = layer.fx || 0.0; |
There was a problem hiding this comment.
why not a defineLayerProperty as for other properties?
There was a problem hiding this comment.
defineLayerProperty is a bad practice imho, and achieves nothing besides reducing a little the duplicated code, executing a callback in really rare usecases and emitting events on properties change. But I wouldn't change it here, and in the meantime keep this property declaration as it is.
zarov
left a comment
There was a problem hiding this comment.
I think this is a good idea. The introduction of a Source object (kind of like OpenLayers ?) is a good step towards decluttering providers. Could you add a more accurate description (maybe documentation like the current Provider interface ?) to this object ?
However I don't really like a few things:
- the fetching in
geoFileSource: no operation like should happen in aSource - the
convertmethod inlayer: what about your initials thoughts withsource, processing, styleonly ?
src/Parser/textureConverter.js
Outdated
| }; | ||
|
|
||
| export default { | ||
| textureColorLayer(texture, extent, layer) { |
There was a problem hiding this comment.
I wouldn't call this textureColorLayer. Why not have two methods, color and elevation, which gives textureConverter.color and textureConverter.elevation calls.
Also by introducing this you could drop the getColor/XBilTextureByUrl in OGCWebServiceHelper which have nothing to do with OGC.
src/Provider/Fetcher.js
Outdated
| @@ -1,14 +1,24 @@ | |||
| import { TextureLoader } from 'three'; | |||
| import { TextureLoader, DataTexture, AlphaFormat, FloatType, LinearFilter } from 'three'; | |||
There was a problem hiding this comment.
My opinion: we should always import * as THREE, I don't get the appeal behind selecting what we are importing.
| checkResponse(response); | ||
| return response.arrayBuffer(); | ||
| arrayBuffer, | ||
| textureFloat(url, options = {}) { |
There was a problem hiding this comment.
This part should be in the elevationTexture part imho. Let's keep the Fetcher simple.
src/Core/Scheduler/Scheduler.js
Outdated
| if (typeof (provider.preprocessDataLayer) !== 'function') { | ||
| throw new Error(`Can't add provider for ${protocol}: missing a preprocessDataLayer function.`); | ||
| } | ||
| // if (typeof (provider.preprocessDataLayer) !== 'function') { |
src/Core/View.js
Outdated
|
|
||
| // temp | ||
| // devrait etre supprime et placer dans source | ||
| if (provider && !layer.source) { |
There was a problem hiding this comment.
Yep, a provider shouldn't be the one defining the limit.
| if (!(providerPreprocessing && providerPreprocessing.then)) { | ||
| providerPreprocessing = Promise.resolve(); | ||
| } | ||
| } else if (layer.source) { |
There was a problem hiding this comment.
I don't like having this here, as much as I don't like having all other things below (conditions on type of layer). I know though that you hope to move it to the layer itself, so I'm ok with this here for now.
src/Core/View.js
Outdated
|
|
||
| // probably not the best place to do this | ||
| if (layer.type == 'color') { | ||
| layer.fx = layer.fx || 0.0; |
There was a problem hiding this comment.
defineLayerProperty is a bad practice imho, and achieves nothing besides reducing a little the duplicated code, executing a callback in really rare usecases and emitting events on properties change. But I wouldn't change it here, and in the meantime keep this property declaration as it is.
|
I'm all for refactoring this part, and the chosen solution looks similar to what was previously discussed. Random notes:
The last point is important. For instance, if this PR doesn't help implement vector-tiles support easily, then something is wrong. |
86a4f54 to
a69dd40
Compare
|
Sounds like the way to go! |
3506ba2 to
7592921
Compare
1a22624 to
24adf87
Compare
|
I tested the examples, here's what I saw: |
|
@zarov all examples are fixed New change:
|
d6fcdb4 to
dd1006a
Compare
| */ | ||
| class Source { | ||
| /** | ||
| * @param {sourceParams} source object to set source |
There was a problem hiding this comment.
You should remove the @class declaration above, and write a @constructor here, to avoid duplication in the generated page of the documentation.
You should also write an example of declaring a random Source. Best would be to have it for all Sources files.
bcb8f07 to
15c1612
Compare
zarov
left a comment
There was a problem hiding this comment.
Added some comments on the Sources files !
src/Source/FileSource.js
Outdated
| */ | ||
| constructor(source, crsOut) { | ||
| super(source); | ||
| if (!source.url) { |
There was a problem hiding this comment.
No need to repeat this as it is already been checked in Source.
| throw new Error('source.url is required in FileSource'); | ||
| } | ||
|
|
||
| if (!source.projection) { |
There was a problem hiding this comment.
You should specify in the documentation above that the projection is mandatory for this type of Source. This check can also be moved before calling super(source).
| * @param {Extent} extent extent to convert in url | ||
| * @return {string} url from extent | ||
| */ | ||
| // eslint-disable-next-line |
There was a problem hiding this comment.
This is a problem I encountered as well, there is three solutions:
eslint-disable-next-line- declaring this method as
static:static urlFromExtent(extent), that can still be called withthis.urlFromExtent(extent)orsource.urlFromExtent(extent) - removing the
class-method-use-thiseslint check from the configuration
There was a problem hiding this comment.
yes, there are errors lint too for jsdoc
| constructor(source) { | ||
| super(source); | ||
|
|
||
| if (!source.extent) { |
There was a problem hiding this comment.
Same as above, you can move this check before calling the parent constructor and specify in the documentation that the extent is required here.
src/Source/WFSSource.js
Outdated
| * @param {Object} [source.zoom] | ||
| * @param {number} [source.zoom.min] layer's zoom minimum | ||
| * @param {number} [source.zoom.max] layer's zoom maximum | ||
| * @param {string} [source.zoom.max] layer's zoom maximum |
There was a problem hiding this comment.
Did you mean something else ?
| */ | ||
| constructor(source) { | ||
| super(source); | ||
| if (!source.typeName) { |
src/Source/WMSSource.js
Outdated
| } | ||
| } | ||
|
|
||
| let crsPropName = 'SRS'; |
There was a problem hiding this comment.
Why not directly const crsPropName = (this.version === '1.3.0') ? 'CRS' : 'SRS'; ?
src/Source/WMTSSource.js
Outdated
|
|
||
| /** | ||
| * Options to wtms protocol | ||
| * @typedef {Object} OptionsWmts |
c8cecb8 to
228116e
Compare
Add new object source: - Source have the properties to fetch the data to display - Remove all source abstractions from provider
|
@zarov PR updated |
zarov
left a comment
There was a problem hiding this comment.
OK let's validate this, I think I didn't see any problem.
For fixing your failing test, either remove it, or install a polyfill for URL (like this one https://github.com/webcomponents/URL) as it is not a component supported in nodejs.
|
It is even occurring because the |


Description
add
Sourcein layer : all the parameters to get the data from a sourceadd
convertin layer : fonction to convert data from source to layer's elementsThe layer does
The provider does
Motivation
sourcesandconverters/parsersfrom providers and use them for other layers