Performance: fix stuttering at low zoom

This commit is contained in:
Pieter Vander Vennet 2023-11-15 03:59:02 +01:00
parent 4f4b60afd8
commit e9a511e5bd
4 changed files with 13 additions and 2 deletions

View file

@ -39,7 +39,7 @@ export default class LayoutSource extends FeatureSourceMerger {
const osmLayers = layers.filter((layer) => layer.source.geojsonSource === undefined)
const fromCache = osmLayers.map(
(l) =>
new LocalStorageFeatureSource(backend, l.id, 15, mapProperties, {
new LocalStorageFeatureSource(backend, l, 15, mapProperties, {
isActive: isDisplayed(l.id),
maxAge: l.maxAgeOfCache,
})

View file

@ -66,6 +66,7 @@ export default class DynamicGeoJsonTileSource extends DynamicTileSource {
const blackList = new Set<string>()
super(
source.geojsonZoomLevel,
layer.minzoom,
(zxy) => {
if (whitelist !== undefined) {
const isWhiteListed = whitelist.get(zxy[1])?.has(zxy[2])

View file

@ -11,6 +11,7 @@ import FeatureSourceMerger from "../Sources/FeatureSourceMerger"
export default class DynamicTileSource extends FeatureSourceMerger {
constructor(
zoomlevel: number,
minzoom: number,
constructSource: (tileIndex) => FeatureSource,
mapProperties: {
bounds: Store<BBox>
@ -26,6 +27,12 @@ export default class DynamicTileSource extends FeatureSourceMerger {
mapProperties.bounds
.mapD(
(bounds) => {
if (options?.isActive && !options?.isActive.data) {
return undefined
}
if (mapProperties.zoom.data < minzoom) {
return undefined
}
const tileRange = Tiles.TileRangeBetween(
zoomlevel,
bounds.getNorth(),

View file

@ -4,11 +4,12 @@ import { BBox } from "../../BBox"
import TileLocalStorage from "../Actors/TileLocalStorage"
import { Feature } from "geojson"
import StaticFeatureSource from "../Sources/StaticFeatureSource"
import LayerConfig from "../../../Models/ThemeConfig/LayerConfig"
export default class LocalStorageFeatureSource extends DynamicTileSource {
constructor(
backend: string,
layername: string,
layer: LayerConfig,
zoomlevel: number,
mapProperties: {
bounds: Store<BBox>
@ -19,6 +20,7 @@ export default class LocalStorageFeatureSource extends DynamicTileSource {
maxAge?: number // In seconds
}
) {
const layername = layer.id
const storage = TileLocalStorage.construct<Feature[]>(
backend,
layername,
@ -26,6 +28,7 @@ export default class LocalStorageFeatureSource extends DynamicTileSource {
)
super(
zoomlevel,
layer.minzoom,
(tileIndex) =>
new StaticFeatureSource(
storage.getTileSource(tileIndex).mapD((features) => {