Skip to content

Commit

Permalink
Merge pull request #246 from Dataport/feature/bgw-custom-search-function
Browse files Browse the repository at this point in the history
Feature/bgw custom search function
  • Loading branch information
jedi-of-the-sea authored Feb 24, 2025
2 parents 0b34595 + cc66663 commit 46439af
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
6 changes: 5 additions & 1 deletion packages/clients/bgw/src/addPlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -75,6 +78,7 @@ export default (core) => {
merge({}, defaultOptions, {
addLoading: 'plugin/loadingIndicator/addLoadingKey',
removeLoading: 'plugin/loadingIndicator/removeLoadingKey',
customSearchMethods: { badestellenSearch },
customSelectResult: { badestellen: badestellenSearchResult },
})
),
Expand Down
2 changes: 1 addition & 1 deletion packages/clients/bgw/src/mapConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
29 changes: 27 additions & 2 deletions packages/clients/bgw/src/utils/badestellenSearch.ts
Original file line number Diff line number Diff line change
@@ -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<CoreState, CoreGetters>,
signal: AbortSignal,
url: string,
inputValue: string,
queryParameters: WfsParameters
) {
const searchString = replaceUmlauts(inputValue.toUpperCase())
return getWfsFeatures(signal, url, `*${searchString}*`, queryParameters)
}

export const badestellenSearchResult: SelectResultFunction<
AddressSearchState,
Expand Down

0 comments on commit 46439af

Please sign in to comment.