feat: load remote map config and constrain tile bounds
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { buildTileUrl, type TileItem } from '../../utils/tile'
|
||||
import { isTileWithinBounds, type TileZoomBounds } from '../../utils/remoteMapConfig'
|
||||
import { getTilePersistentCache, type TilePersistentCache } from '../renderer/tilePersistentCache'
|
||||
|
||||
const MAX_PARENT_FALLBACK_DEPTH = 2
|
||||
@@ -51,6 +52,7 @@ export interface TileStoreScene {
|
||||
viewportHeight: number
|
||||
translateX: number
|
||||
translateY: number
|
||||
tileBoundsByZoom: Record<number, TileZoomBounds> | null
|
||||
}
|
||||
|
||||
export interface TileStoreCallbacks {
|
||||
@@ -241,6 +243,9 @@ export class TileStore {
|
||||
const scale = Math.pow(2, depth)
|
||||
const fallbackX = Math.floor(tile.x / scale)
|
||||
const fallbackY = Math.floor(tile.y / scale)
|
||||
if (!isTileWithinBounds(scene.tileBoundsByZoom, fallbackZoom, fallbackX, fallbackY)) {
|
||||
continue
|
||||
}
|
||||
const fallbackUrl = buildTileUrl(scene.tileSource, fallbackZoom, fallbackX, fallbackY)
|
||||
const fallbackPriority = priority / (depth + 1)
|
||||
const existingPriority = parentPriorityMap.get(fallbackUrl)
|
||||
@@ -486,7 +491,10 @@ export class TileStore {
|
||||
const scale = Math.pow(2, depth)
|
||||
const fallbackX = Math.floor(tile.x / scale)
|
||||
const fallbackY = Math.floor(tile.y / scale)
|
||||
const fallbackUrl = buildTileUrl(scene.tileSource, fallbackZoom, fallbackX, fallbackY)
|
||||
if (!isTileWithinBounds(scene.tileBoundsByZoom, fallbackZoom, fallbackX, fallbackY)) {
|
||||
continue
|
||||
}
|
||||
const fallbackUrl = buildTileUrl(scene.tileSource, fallbackZoom, fallbackX, fallbackY)
|
||||
const fallbackEntry = this.tileCache.get(fallbackUrl)
|
||||
|
||||
if (fallbackEntry && fallbackEntry.status === 'ready' && fallbackEntry.image) {
|
||||
@@ -540,6 +548,9 @@ export class TileStore {
|
||||
for (let offsetX = 0; offsetX < division; offsetX += 1) {
|
||||
const childX = tile.x * division + offsetX
|
||||
const childY = tile.y * division + offsetY
|
||||
if (!isTileWithinBounds(scene.tileBoundsByZoom, childZoom, childX, childY)) {
|
||||
continue
|
||||
}
|
||||
const childUrl = buildTileUrl(scene.tileSource, childZoom, childX, childY)
|
||||
const childEntry = this.tileCache.get(childUrl)
|
||||
if (!childEntry || childEntry.status !== 'ready' || !childEntry.image) {
|
||||
@@ -565,3 +576,5 @@ export class TileStore {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user