diff --git a/packages/clients/bgw/src/addPlugins.ts b/packages/clients/bgw/src/addPlugins.ts index 73f5cff32..5b3a8cc08 100644 --- a/packages/clients/bgw/src/addPlugins.ts +++ b/packages/clients/bgw/src/addPlugins.ts @@ -13,7 +13,10 @@ import Scale from '@polar/plugin-scale' import Toast from '@polar/plugin-toast' import Zoom from '@polar/plugin-zoom' import merge from 'lodash.merge' -import { badestellenSearchResult } from './utils/badestellenSearch' +import { + badestellenSearch, + badestellenSearchResult, +} from './utils/badestellenSearch' const defaultOptions = { displayComponent: true, @@ -75,6 +78,7 @@ export default (core) => { merge({}, defaultOptions, { addLoading: 'plugin/loadingIndicator/addLoadingKey', removeLoading: 'plugin/loadingIndicator/removeLoadingKey', + customSearchMethods: { badestellenSearch }, customSelectResult: { badestellen: badestellenSearchResult }, }) ), diff --git a/packages/clients/bgw/src/mapConfiguration.ts b/packages/clients/bgw/src/mapConfiguration.ts index 142a84642..693e4e5f0 100644 --- a/packages/clients/bgw/src/mapConfiguration.ts +++ b/packages/clients/bgw/src/mapConfiguration.ts @@ -126,7 +126,7 @@ const mapConfig = { { groupId: 'badestellenSearch', categoryId: 'badestellen', - type: 'wfs', + type: 'badestellenSearch', url: 'https://umweltgeodienste.schleswig-holstein.de/WFS_BGW', queryParameters: { srsName: 'EPSG:25832', diff --git a/packages/clients/bgw/src/utils/badestellenSearch.ts b/packages/clients/bgw/src/utils/badestellenSearch.ts index a93a1157d..79b31e57f 100644 --- a/packages/clients/bgw/src/utils/badestellenSearch.ts +++ b/packages/clients/bgw/src/utils/badestellenSearch.ts @@ -1,10 +1,35 @@ -import { SelectResultFunction } from '@polar/lib-custom-types' +import { Feature } from 'geojson' +import { + CoreGetters, + CoreState, + PolarStore, + SelectResultFunction, +} from '@polar/lib-custom-types' import { SearchResultSymbols, AddressSearchGetters, AddressSearchState, } from '@polar/plugin-address-search' -import { Feature } from 'geojson' +import { WfsParameters, getWfsFeatures } from '@polar/lib-get-features' + +function replaceUmlauts(input: string): string { + return input + .replace(/Ä/g, 'AE') + .replace(/Ö/g, 'OE') + .replace(/Ü/g, 'UE') + .replace(/ß/g, 'SS') +} + +export function badestellenSearch( + this: PolarStore, + signal: AbortSignal, + url: string, + inputValue: string, + queryParameters: WfsParameters +) { + const searchString = replaceUmlauts(inputValue.toUpperCase()) + return getWfsFeatures(signal, url, `*${searchString}*`, queryParameters) +} export const badestellenSearchResult: SelectResultFunction< AddressSearchState,