src/renderer/Renderer.js
/**
     * Run aggregation functions over the visible features.
     */
Run aggregation functions over the visible features.
Run aggregation functions over the visible features .
_runViewportAggregations (renderLayer) {
        const dataframes = renderLayer.getActiveDataframes();
        const viz = renderLayer.viz;
        const viewportExpressions = this._getViewportExpressions(viz._getRootExpressions());
        if (!viewportExpressions.length) {
            return;
        }
        const metadata = dataframes.length ? dataframes[0].metadata : null;
        viewportExpressions.forEach(expr => expr._resetViewportAgg(metadata));
        const viewportExpressionsLength = viewportExpressions.length;
        const processedFeaturesIDs = new Set();
        const aspect = this.gl.canvas.width / this.gl.canvas.height;
        const scale = 1 / this._zoom;
        dataframes.forEach(dataframe => {
            const aabb = dataframe.getViewportAABB(scale, this._center, aspect);
            for (let i = 0; i < dataframe.numFeatures; i++) {
                const featureId = dataframe.properties[metadata.idProperty][i];
                if (processedFeaturesIDs.has(featureId)) {
                    continue;
                }
                if (!dataframe.inViewport(i, viz, aabb)) {
                    continue;
                }
                processedFeaturesIDs.add(featureId);
                const feature = this._featureFromDataFrame(dataframe, i, metadata);
                if (viz.filter.eval(feature) < FILTERING_THRESHOLD) {
                    continue;
                }
                for (let j = 0; j < viewportExpressionsLength; j++) {
                    viewportExpressions[j].accumViewportAgg(feature);
                }
            }
        });
    }
_runViewportAggregations ( renderLayer ) { const dataframes = renderLayer . getActiveDataframes ( ) ; const viz = renderLayer . viz ; const viewportExpressions = this . _getViewportExpressions ( viz . _getRootExpressions ( ) ) ; if ( ! viewportExpressions . length ) { return ; } const metadata = dataframes . length ? dataframes [ 0 ] . metadata : null ; viewportExpressions . forEach ( expr => expr . _resetViewportAgg ( metadata ) ) ; const viewportExpressionsLength = viewportExpressions . length ; const processedFeaturesIDs = new Set ( ) ; const aspect = this . gl . canvas . width / this . gl . canvas . height ; const scale = 1 / this . _zoom ; dataframes . forEach ( dataframe => { const aabb = dataframe . getViewportAABB ( scale , this . _center , aspect ) ; for ( let i = 0 ; i < dataframe . numFeatures ; i ++ ) { const featureId = dataframe . properties [ metadata . idProperty ] [ i ] ; if ( processedFeaturesIDs . has ( featureId ) ) { continue ; } if ( ! dataframe . inViewport ( i , viz , aabb ) ) { continue ; } processedFeaturesIDs . add ( featureId ) ; const feature = this . _featureFromDataFrame ( dataframe , i , metadata ) ; if ( viz . filter . eval ( feature ) < FILTERING_THRESHOLD ) { continue ; } for ( let j = 0 ; j < viewportExpressionsLength ; j ++ ) { viewportExpressions [ j ] . accumViewportAgg ( feature ) ; } } } ) ; }
Run aggregation functions over the visible features.
Run aggregation functions over the visible features .
// Performance optimization to avoid doing DFS at each feature iteration // Assume that all dataframes of a renderLayer share the same metadata // Avoid acumulating the same feature multiple times keeping a set of processed features (same feature can belong to multiple dataframes). // If feature has been acumulated ignore it // Ignore features outside viewport // Ignore filtered features