forked from MapComplete/MapComplete
Refactoring: use theme instead of layout in a lot of places
This commit is contained in:
parent
9427083939
commit
bdc9ba52a6
104 changed files with 445 additions and 449 deletions
|
|
@ -1,17 +1,17 @@
|
|||
import SearchUtils from "./SearchUtils"
|
||||
import ThemeSearch from "./ThemeSearch"
|
||||
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
|
||||
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig"
|
||||
import ThemeConfig from "../../Models/ThemeConfig/ThemeConfig"
|
||||
import { Utils } from "../../Utils"
|
||||
|
||||
export default class LayerSearch {
|
||||
|
||||
private readonly _layout: LayoutConfig
|
||||
private readonly _theme: ThemeConfig
|
||||
private readonly _layerWhitelist: Set<string>
|
||||
|
||||
constructor(layout: LayoutConfig) {
|
||||
this._layout = layout
|
||||
this._layerWhitelist = new Set(layout.layers
|
||||
constructor(theme: ThemeConfig) {
|
||||
this._theme = theme
|
||||
this._layerWhitelist = new Set(theme.layers
|
||||
.filter(l => l.isNormal())
|
||||
.map(l => l.id))
|
||||
}
|
||||
|
|
@ -29,8 +29,7 @@ export default class LayerSearch {
|
|||
continue
|
||||
}
|
||||
const keywords = ThemeSearch.officialThemes.layers[id]
|
||||
const distance = Math.min(...queryParts.map(q => SearchUtils.scoreKeywords(q, keywords)))
|
||||
result[id] = distance
|
||||
result[id] = Math.min(...queryParts.map(q => SearchUtils.scoreKeywords(q, keywords)))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
@ -44,7 +43,7 @@ export default class LayerSearch {
|
|||
const asList: ({ layer: LayerConfig, score: number })[] = []
|
||||
for (const layer in scores) {
|
||||
asList.push({
|
||||
layer: this._layout.getLayer(layer),
|
||||
layer: this._theme.getLayer(layer),
|
||||
score: scores[layer],
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue