Skip to content

Commit

Permalink
CARTO: Handle DEFAULT-INITIAL-VIEWPORT in H3Tileset2D (#7924)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixpalmer committed May 31, 2023
1 parent cfa79d8 commit a55b9d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions modules/carto/src/layers/h3-tileset-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export default class H3Tileset2D extends Tileset2D {
*/
// @ts-expect-error Tileset2D should be generic over TileIndex
getTileIndices({viewport, minZoom, maxZoom}): H3TileIndex[] {
if (viewport.latitude === undefined) return [];
const [east, south, west, north] = viewport.getBounds();

let z = getHexagonResolution(viewport);
Expand Down
11 changes: 10 additions & 1 deletion test/modules/carto/layers/h3-tileset-2d.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'tape-promise/tape';
import H3Tileset2D from '@deck.gl/carto/layers/h3-tileset-2d';
import {WebMercatorViewport} from '@deck.gl/core';
import {Viewport, WebMercatorViewport} from '@deck.gl/core';
import {equals} from '@math.gl/core';

test('H3Tileset2D', async t => {
Expand Down Expand Up @@ -112,3 +112,12 @@ test('H3Tileset2D max zoom', async t => {
t.equal(indices.length, 7, 'max zoom added');
t.end();
});

test('H3Tileset2D default viewport', async t => {
const tileset = new H3Tileset2D({});
// See layer-manager.ts
const viewport = new Viewport({id: 'DEFAULT-INITIAL-VIEWPORT'});
let indices = tileset.getTileIndices({viewport});
t.equal(indices.length, 0, 'Empty initial viewport');
t.end();
});

0 comments on commit a55b9d1

Please sign in to comment.