qwc2
Version:
QGIS Web Client
50 lines (49 loc) • 1.69 kB
JavaScript
/**
* Copyright 2020-2024 Sourcepole AG
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
import { createSelector } from 'reselect';
import ConfigUtils from '../utils/ConfigUtils';
import LocaleUtils from '../utils/LocaleUtils';
import MapUtils from '../utils/MapUtils';
import { collectSearchProviders } from '../utils/SearchProviders';
import ThemeUtils from '../utils/ThemeUtils';
export default createSelector([function (state) {
return state.theme.current;
}, function (state) {
return state.theme;
}, function (state) {
return state.layers.flat;
}, function (state) {
return state.map.scales;
}, function (state) {
return state.map.zoom;
}], function (theme, themes, layers, scales, zoom) {
// Collect active layers/search terms
var mapScale = MapUtils.computeForZoom(scales, zoom);
var availableProviders = collectSearchProviders(theme, layers, mapScale);
if (ConfigUtils.getConfigProp("searchThemes", theme)) {
availableProviders.themes = {
labelmsgid: LocaleUtils.trmsg("search.themes"),
onSearch: function onSearch(text, options, callback) {
callback({
results: ThemeUtils.searchThemes(themes.themes, text)
});
}
};
}
if (ConfigUtils.getConfigProp("searchThemeLayers", theme)) {
availableProviders.themelayers = {
labelmsgid: LocaleUtils.trmsg("search.themelayers"),
onSearch: function onSearch(text, options, callback) {
callback({
results: ThemeUtils.searchThemeLayers(themes.themes, text)
});
}
};
}
return availableProviders;
});