Coveralls logob
Coveralls logo
  • Home
  • Features
  • Pricing
  • Docs
  • Sign In

uber / deck.gl / 13779

18 Sep 2019 - 0:00 coverage decreased (-2.9%) to 79.902%
13779

Pull #3623

travis-ci-com

9181eb84f9c35729a3bad740fb7f9d93?size=18&default=identiconweb-flow
beta.2
Pull Request #3623: Bump dependency versions

3405 of 4619 branches covered (73.72%)

Branch coverage included in aggregate %.

7031 of 8442 relevant lines covered (83.29%)

5687.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.7
/modules/geo-layers/src/tile-layer/tile-layer.js
1
import {CompositeLayer} from '@deck.gl/core';
7×
2
import {GeoJsonLayer} from '@deck.gl/layers';
3
import TileCache from './utils/tile-cache';
4

5
const defaultProps = {
1×
6
  renderSubLayers: {type: 'function', value: props => new GeoJsonLayer(props)},
8×
7
  getTileData: {type: 'function', value: ({x, y, z}) => Promise.resolve(null)},
4×
8
  onViewportLoaded: {type: 'function', value: () => {}},
9
  // eslint-disable-next-line
UNCOV
10
  onTileError: {type: 'function', value: err => console.error(err)},
!
11
  maxZoom: null,
12
  minZoom: 0,
13
  maxCacheSize: null
14
};
15

16
export default class TileLayer extends CompositeLayer {
17
  initializeState() {
18
    const {maxZoom, minZoom, getTileData, onTileError} = this.props;
1×
19
    this.state = {
1×
20
      tiles: [],
21
      tileCache: new TileCache({getTileData, maxZoom, minZoom, onTileError}),
22
      isLoaded: false
23
    };
24
  }
25

26
  shouldUpdateState({changeFlags}) {
27
    return changeFlags.somethingChanged;
5×
28
  }
29

30
  updateState({props, oldProps, context, changeFlags}) {
31
    const {onViewportLoaded, onTileError} = props;
2×
32
    if (
Branches [[0, 0]] missed. 2×
33
      changeFlags.updateTriggersChanged &&
Branches [[1, 1], [1, 2]] missed.
34
      (changeFlags.updateTriggersChanged.all || changeFlags.updateTriggersChanged.getTileData)
35
    ) {
UNCOV
36
      const {getTileData, maxZoom, minZoom, maxCacheSize} = props;
!
UNCOV
37
      this.state.tileCache.finalize();
!
38
      this.setState({
!
39
        tileCache: new TileCache({
40
          getTileData,
41
          maxSize: maxCacheSize,
42
          maxZoom,
43
          minZoom,
44
          onTileError
45
        })
46
      });
47
    }
48
    if (changeFlags.viewportChanged) {
2×
49
      const {viewport} = context;
1×
50
      const z = this.getLayerZoomLevel();
1×
51
      if (viewport.id !== 'DEFAULT-INITIAL-VIEWPORT') {
Branches [[3, 1]] missed. 1×
52
        this.state.tileCache.update(viewport, tiles => {
1×
53
          const currTiles = tiles.filter(tile => tile.z === z);
4×
54
          const allCurrTilesLoaded = currTiles.every(tile => tile.isLoaded);
1×
55
          this.setState({tiles, isLoaded: allCurrTilesLoaded});
1×
56
          if (!allCurrTilesLoaded) {
Branches [[4, 1]] missed. 1×
57
            Promise.all(currTiles.map(tile => tile.data)).then(() => {
4×
58
              this.setState({isLoaded: true});
1×
59
              onViewportLoaded(currTiles.filter(tile => tile._data).map(tile => tile._data));
4×
60
            });
61
          } else {
UNCOV
62
            onViewportLoaded(currTiles.filter(tile => tile._data).map(tile => tile._data));
!
63
          }
64
        });
65
      }
66
    }
67
  }
68

69
  getPickingInfo({info, sourceLayer}) {
UNCOV
70
    info.sourceLayer = sourceLayer;
!
UNCOV
71
    info.tile = sourceLayer.props.tile;
!
UNCOV
72
    return info;
!
73
  }
74

75
  getLayerZoomLevel() {
76
    const z = Math.floor(this.context.viewport.zoom);
3×
77
    const {maxZoom, minZoom} = this.props;
3×
78
    if (maxZoom && parseInt(maxZoom, 10) === maxZoom && z > maxZoom) {
Branches [[5, 0], [6, 1], [6, 2]] missed. 3×
79
      return maxZoom;
!
80
    } else if (minZoom && parseInt(minZoom, 10) === minZoom && z < minZoom) {
Branches [[7, 0]] missed. 3×
81
      return minZoom;
!
82
    }
83
    return z;
3×
84
  }
85

86
  renderLayers() {
87
    const {renderSubLayers, visible} = this.props;
2×
88
    const z = this.getLayerZoomLevel();
2×
89
    return this.state.tiles.map(tile => {
2×
90
      return renderSubLayers(
8×
91
        Object.assign({}, this.props, {
92
          id: `${this.id}-${tile.x}-${tile.y}-${tile.z}`,
93
          data: tile.data,
94
          visible: visible && (!this.state.isLoaded || tile.z === z),
Branches [[9, 2]] missed.
95
          tile
96
        })
97
      );
98
    });
99
  }
100
}
101

102
TileLayer.layerName = 'TileLayer';
1×
103
TileLayer.defaultProps = defaultProps;
1×
Troubleshooting · Open an Issue · Sales · Support · ENTERPRISE · CAREERS · STATUS
BLOG · TWITTER · Legal & Privacy · Supported CI Services · What's a CI service? · Automated Testing

© 2019 Coveralls, LLC