Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/src/layer/tile_layer/tile_range.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,12 @@ class DiscreteTileRange extends TileRange {
/// Check if a [Point] is inside of the bounds of the [DiscreteTileRange].
///
/// We use a modulo in order to prevent side-effects at the end of the world.
/// [TileCoordinates] at another zoom level are never contained.
bool contains(
Point<int> point, {
bool replicatesWorldLongitude = false,
}) {
if (point is TileCoordinates && point.z != zoom) return false;
if (!replicatesWorldLongitude) {
return _bounds.contains(point);
}
Expand Down
22 changes: 22 additions & 0 deletions test/layer/tile_layer/tile_image_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,28 @@ void main() {
});

group('renderTiles', () {
test('a tile of another zoom level is not rendered as visible', () {
// Every visible z10 tile is ready: no fallback is needed. The z9 tile
// has x/y inside the z10 visible range but belongs to another level.
final tileImages = tileImagesMappingFrom([
MockTileImage(2, 2, 10),
MockTileImage(3, 2, 10),
MockTileImage(2, 3, 10),
MockTileImage(3, 3, 10),
MockTileImage(2, 2, 9),
]);
final tileImageView = TileImageView(
tileImages: tileImages,
positionCoordinates: Set<TileCoordinates>.from(tileImages.keys),
visibleRange: discreteTileRange(2, 2, 3, 3, zoom: 10),
keepRange: discreteTileRange(2, 2, 3, 3, zoom: 10),
);
expect(
tileImageView.renderTiles,
isNot(contains(const TileCoordinates(2, 2, 9))),
);
});

test('%.retainChildren uses correct coordinates for z+2 fallback', () {
// This test verifies that _retainChildren correctly calculates
// descendant coordinates when recursing to z+2 level.
Expand Down
1 change: 1 addition & 0 deletions test/layer/tile_layer/tile_range_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ void main() {
expect(tileRange.contains(const Point(2, 4)), isFalse);
expect(tileRange.contains(const Point(3, 4)), isFalse);
expect(tileRange.contains(const Point(4, 4)), isFalse);
expect(tileRange.contains(const TileCoordinates(3, 3, 0)), isFalse);
});
});
}