Remove theme import layers from ElementsInViewDetector, fix #1485

This commit is contained in:
Pieter Vander Vennet 2023-06-29 01:44:38 +02:00
parent 7b3d07e5c4
commit 031c4048a6

View file

@ -16,6 +16,7 @@ export default class NoElementsInViewDetector {
const minZoom = Math.min( const minZoom = Math.min(
...themeViewState.layout.layers ...themeViewState.layout.layers
.filter((l) => Constants.priviliged_layers.indexOf(<any>l.id) < 0) .filter((l) => Constants.priviliged_layers.indexOf(<any>l.id) < 0)
.filter((l) => !l.id.startsWith("note_import"))
.map((l) => l.minzoom) .map((l) => l.minzoom)
) )
const mapProperties = themeViewState.mapProperties const mapProperties = themeViewState.mapProperties
@ -24,28 +25,33 @@ export default class NoElementsInViewDetector {
this.hasFeatureInView = state.mapProperties.bounds.stabilized(100).map( this.hasFeatureInView = state.mapProperties.bounds.stabilized(100).map(
(bbox) => { (bbox) => {
if (!bbox) {
return undefined
}
if (mapProperties.zoom.data < minZoom) { if (mapProperties.zoom.data < minZoom) {
// Not a single layer will display anything as the zoom is to low // Not a single layer will display anything as the zoom is to low
return "zoom-to-low" return "zoom-to-low"
} }
let minzoomWithData = 9999
for (const [layerName, source] of themeViewState.perLayerFiltered) { for (const [layerName, source] of themeViewState.perLayerFiltered) {
if (priviliged.has(layerName)) { if (priviliged.has(layerName)) {
continue continue
} }
if (
mapProperties.zoom.data < themeViewState.layout.getLayer(layerName).minzoom
) {
continue
}
if (!state.layerState.filteredLayers.get(layerName).isDisplayed.data) {
continue
}
const feats = source.features.data const feats = source.features.data
if (!(feats?.length > 0)) { if (!(feats?.length > 0)) {
// Nope, no data loaded // Nope, no data loaded
continue continue
} }
const layer = themeViewState.layout.getLayer(layerName)
if (mapProperties.zoom.data < layer.minzoom) {
minzoomWithData = Math.min(layer.minzoom)
continue
}
if (!state.layerState.filteredLayers.get(layerName).isDisplayed.data) {
continue
}
for (const feat of feats) { for (const feat of feats) {
if (BBox.get(feat).overlapsWith(bbox)) { if (BBox.get(feat).overlapsWith(bbox)) {
@ -56,13 +62,14 @@ export default class NoElementsInViewDetector {
} }
// If we arrive here, data might have been filtered away // If we arrive here, data might have been filtered away
for (const [layerName, source] of themeViewState.perLayer) {
for (const [layerName, source] of themeViewState.perLayerFiltered) {
if (priviliged.has(layerName)) { if (priviliged.has(layerName)) {
continue continue
} }
if (
mapProperties.zoom.data < themeViewState.layout.getLayer(layerName).minzoom const layer = themeViewState.layout.getLayer(layerName)
) { if (mapProperties.zoom.data < layer.minzoom) {
continue continue
} }
const feats = source.features.data const feats = source.features.data