Parse the style in the constructor.

This detects errors earlier and allows the caller to handle the thrown exception.
Remove assertion 65 as it should no longer be needed.
This commit is contained in:
Maximilian Krög
2019-10-03 14:24:31 +02:00
parent d0cd1064ff
commit b1a9f765fc
2 changed files with 10 additions and 15 deletions

View File

@@ -4,7 +4,6 @@
import {assign} from '../obj.js';
import WebGLPointsLayerRenderer from '../renderer/webgl/PointsLayer.js';
import {getSymbolFragmentShader, getSymbolVertexShader, parseSymbolStyle} from '../webgl/ShaderBuilder.js';
import {assert} from '../asserts.js';
import Layer from './Layer.js';
@@ -72,24 +71,24 @@ class WebGLPointsLayer extends Layer {
super(baseOptions);
/**
* @type {import('../style/LiteralStyle.js').LiteralStyle}
* @private
* @type {import('../webgl/ShaderBuilder.js').StyleParseResult}
*/
this.style = options.style;
assert(this.style.symbol !== undefined, 65);
this.parseResult_ = parseSymbolStyle(
/** @type {import('../style/LiteralStyle.js').LiteralStyle} */
(options.style).symbol
);
}
/**
* @inheritDoc
*/
createRenderer() {
const parseResult = parseSymbolStyle(this.style.symbol);
return new WebGLPointsLayerRenderer(this, {
vertexShader: getSymbolVertexShader(parseResult.params),
fragmentShader: getSymbolFragmentShader(parseResult.params),
uniforms: parseResult.uniforms,
attributes: parseResult.attributes
vertexShader: getSymbolVertexShader(this.parseResult_.params),
fragmentShader: getSymbolFragmentShader(this.parseResult_.params),
uniforms: this.parseResult_.uniforms,
attributes: this.parseResult_.attributes
});
}
}