Fix: Correctly calculate available levels, reselect last_click automatically

This commit is contained in:
Pieter Vander Vennet 2023-05-01 01:12:04 +02:00
parent 6d9a984f32
commit 4c962eab21

View file

@ -263,7 +263,10 @@ export default class ThemeViewState implements SpecialVisualizationState {
for (const feature of features) { for (const feature of features) {
const level = feature.properties["level"] const level = feature.properties["level"]
if (level) { if (level) {
floors.add(level) const levels = level.split(";")
for (const l of levels) {
floors.add(l)
}
} }
} }
const sorted = Array.from(floors) const sorted = Array.from(floors)
@ -378,18 +381,22 @@ export default class ThemeViewState implements SpecialVisualizationState {
) )
} }
/** private addLastClick(last_click: LastClickFeatureSource) {
* Add the special layers to the map // The last_click gets a _very_ special treatment as it interacts with various parts
*/
private drawSpecialLayers(last_click: LastClickFeatureSource) {
type AddedByDefaultTypes = typeof Constants.added_by_default[number]
const empty = []
{
// The last_click gets a _very_ special treatment
const last_click_layer = this.layerState.filteredLayers.get("last_click") const last_click_layer = this.layerState.filteredLayers.get("last_click")
this.featureProperties.trackFeatureSource(last_click) this.featureProperties.trackFeatureSource(last_click)
this.indexedFeatures.addSource(last_click) this.indexedFeatures.addSource(last_click)
last_click.features.addCallbackAndRunD((features) => {
if (this.selectedLayer.data?.id === "last_click") {
// The last-click location moved, but we have selected the last click of the previous location
// So, we update _after_ clearing the selection to make sure no stray data is sticking around
this.selectedElement.setData(undefined)
this.selectedElement.setData(features[0])
}
})
new ShowDataLayer(this.map, { new ShowDataLayer(this.map, {
features: new FilteringFeatureSource(last_click_layer, last_click), features: new FilteringFeatureSource(last_click_layer, last_click),
doShowLayer: new ImmutableStore(true), doShowLayer: new ImmutableStore(true),
@ -414,6 +421,13 @@ export default class ThemeViewState implements SpecialVisualizationState {
}) })
} }
/**
* Add the special layers to the map
*/
private drawSpecialLayers(last_click: LastClickFeatureSource) {
type AddedByDefaultTypes = typeof Constants.added_by_default[number]
const empty = []
this.addLastClick(last_click)
/** /**
* A listing which maps the layerId onto the featureSource * A listing which maps the layerId onto the featureSource
*/ */
@ -494,7 +508,19 @@ export default class ThemeViewState implements SpecialVisualizationState {
if (!found) { if (!found) {
return return
} }
if (found.properties.id === "last_click") {
return
}
const layer = this.layout.getMatchingLayer(found.properties) const layer = this.layout.getMatchingLayer(found.properties)
console.log(
"Setting selected element based on hash",
hash,
"; found",
found,
"got matching layer",
layer.id,
""
)
this.selectedElement.setData(found) this.selectedElement.setData(found)
this.selectedLayer.setData(layer) this.selectedLayer.setData(layer)
}, },