Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
(HARP-11087): Evaluate Tiles from removed DataSources as not visible (#…
Browse files Browse the repository at this point in the history
…1676)

Signed-off-by: Frauke Fritz <frauke.fritz@here.com>
  • Loading branch information
FraukeF committed Jul 9, 2020
1 parent fe093f8 commit d4f7a27
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
10 changes: 9 additions & 1 deletion @here/harp-mapview/lib/Tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,15 @@ export class Tile implements CachedResource {
// This happens in order to prevent that, during VisibleTileSet visibility evaluation,
// visible tiles that haven't yet been evaluated for the current frame are preemptively
// removed from [[DataSourceCache]].
return this.frameNumLastRequested >= this.dataSource.mapView.frameNumber - 1;
// There is cases when a tile was already removed from the MapView, i.e. the PolaCaps
// Datasource might get remove on a change of projection, in this case
// this.dataSource.mapView will throw an error
try {
return this.frameNumLastRequested >= this.dataSource.mapView.frameNumber - 1;
} catch (error) {
logger.debug(error);
return false;
}
}

set isVisible(visible: boolean) {
Expand Down
16 changes: 15 additions & 1 deletion @here/harp-mapview/test/TileTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ function createFakeTextElement(): TextElement {
describe("Tile", function() {
const tileKey = TileKey.fromRowColumnLevel(0, 0, 0);
const stubDataSource = new TileTestStubDataSource({ name: "test-data-source" });
const mapView = { projection: mercatorProjection };
const mapView = {
projection: mercatorProjection,
frameNumber: 0
};
stubDataSource.attach(mapView as MapView);

it("set empty decoded tile forces hasGeometry to be true", function() {
Expand Down Expand Up @@ -256,4 +259,15 @@ describe("Tile", function() {
expect(tile.geoBox).deep.equals(expectedGeoBox);
expect(tile.boundingBox).deep.equals(expectedBBox);
});

it("doesnt throw on isVisble if not attached to a MapView", function() {
const tile = new Tile(stubDataSource, tileKey);
mapView.frameNumber = 2;
tile.frameNumLastRequested = 2;
expect(tile.isVisible).not.throw;
expect(tile.isVisible).is.true;
stubDataSource.detach(mapView as MapView);
expect(tile.isVisible).not.throw;
expect(tile.isVisible).is.false;
});
});

0 comments on commit d4f7a27

Please sign in to comment.