Refactoring: tweak some featuresources to allow them to run in the tests
This commit is contained in:
parent
ad1178df6c
commit
39aff86c76
3 changed files with 15 additions and 4 deletions
|
@ -14,6 +14,7 @@ export default class TileLocalStorage<T> {
|
||||||
private readonly inUse = new UIEventSource(false)
|
private readonly inUse = new UIEventSource(false)
|
||||||
private readonly cachedSources: Record<number, UIEventSource<T> & { flush: () => void }> = {}
|
private readonly cachedSources: Record<number, UIEventSource<T> & { flush: () => void }> = {}
|
||||||
|
|
||||||
|
private static readonly useIndexedDb = typeof indexedDB !== "undefined"
|
||||||
private constructor(layername: string) {
|
private constructor(layername: string) {
|
||||||
this._layername = layername
|
this._layername = layername
|
||||||
}
|
}
|
||||||
|
@ -49,6 +50,9 @@ export default class TileLocalStorage<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async SetIdb(tileIndex: number, data: any): Promise<void> {
|
private async SetIdb(tileIndex: number, data: any): Promise<void> {
|
||||||
|
if(!TileLocalStorage.useIndexedDb){
|
||||||
|
return
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await this.inUse.AsPromise((inUse) => !inUse)
|
await this.inUse.AsPromise((inUse) => !inUse)
|
||||||
this.inUse.setData(true)
|
this.inUse.setData(true)
|
||||||
|
@ -69,6 +73,9 @@ export default class TileLocalStorage<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private GetIdb(tileIndex: number): Promise<any> {
|
private GetIdb(tileIndex: number): Promise<any> {
|
||||||
|
if(!TileLocalStorage.useIndexedDb){
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
return IdbLocalStorage.GetDirectly(this._layername + "_" + tileIndex)
|
return IdbLocalStorage.GetDirectly(this._layername + "_" + tileIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { FeatureSource, IndexedFeatureSource } from "./FeatureSource"
|
import {FeatureSource} from "./FeatureSource"
|
||||||
import FilteredLayer from "../../Models/FilteredLayer"
|
import FilteredLayer from "../../Models/FilteredLayer"
|
||||||
import SimpleFeatureSource from "./Sources/SimpleFeatureSource"
|
import SimpleFeatureSource from "./Sources/SimpleFeatureSource"
|
||||||
import { Feature } from "geojson"
|
import {Feature} from "geojson"
|
||||||
import { UIEventSource } from "../UIEventSource"
|
import {UIEventSource} from "../UIEventSource"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In some rare cases, some elements are shown on multiple layers (when 'passthrough' is enabled)
|
* In some rare cases, some elements are shown on multiple layers (when 'passthrough' is enabled)
|
||||||
|
@ -59,6 +59,10 @@ export default class PerLayerFeatureSourceSplitter<T extends FeatureSource = Fea
|
||||||
let foundALayer = false
|
let foundALayer = false
|
||||||
for (let i = 0; i < layers.length; i++) {
|
for (let i = 0; i < layers.length; i++) {
|
||||||
const layer = layers[i]
|
const layer = layers[i]
|
||||||
|
if(!layer.layerDef?.source){
|
||||||
|
console.error("PerLayerFeatureSourceSplitter got a layer without a source:", layer.layerDef.id)
|
||||||
|
continue
|
||||||
|
}
|
||||||
if (layer.layerDef.source.osmTags.matchesProperties(f.properties)) {
|
if (layer.layerDef.source.osmTags.matchesProperties(f.properties)) {
|
||||||
const id = f.properties.id
|
const id = f.properties.id
|
||||||
// We have found our matching layer!
|
// We have found our matching layer!
|
||||||
|
|
|
@ -32,7 +32,7 @@ export class LastClickFeatureSource implements WritableFeatureSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderings = Utils.Dedup(
|
const renderings = Utils.Dedup(
|
||||||
allPresets.map((uiElem) => uiElem.ConstructElement().innerHTML)
|
allPresets.map((uiElem) => Utils.runningFromConsole ? "" : uiElem.ConstructElement().innerHTML)
|
||||||
)
|
)
|
||||||
|
|
||||||
const properties = {
|
const properties = {
|
||||||
|
|
Loading…
Reference in a new issue