UNPKG

@geogirafe/lib-geoportal

Version:

GeoGirafe is a flexible application to build online geoportals.

54 lines (53 loc) • 2.33 kB
import AbstractSearchClient from './abstractsearchclient.js'; import IGirafeContext from '../context/icontext.js'; import GirafeSingleton from '../../base/GirafeSingleton.js'; import Feature from 'ol/Feature.js'; import { Extent } from 'ol/extent.js'; export type SearchProviderConfig = { type: 'geomapfish' | 'geoadminch'; providerName: string; [key: string]: unknown; }; export interface SearchCategories { [provider: string]: string[]; } declare class SearchManager extends GirafeSingleton { protected readonly clients: Map<string, AbstractSearchClient>; private abortController; private defaultSrid; private defaultMaxExtent?; readonly minSearchTermLength = 3; constructor(context: IGirafeContext); initializeSingleton(): Promise<void>; protected createClient(providerConfig: SearchProviderConfig): void; /** * Returns available search categories per provider. */ getSearchCategories(): Promise<SearchCategories | null>; hasFilterShortcutsEnabled(): boolean; /** * Detects whether a search filter shortcut is present in the provided search term. * Updates the search state with the extracted prefix and shortcut if applicable. */ detectSearchFilterShortcut(term: string): boolean; private extractFilterPrefixFromTerm; private extractFilterShortcutFromTerm; abortSearch(): void; /** * Performs a search operation with all available clients based on the provided term and optional search filters. * Returns results grouped by provider name and result category. */ doSearch(term: string, searchFilter?: SearchCategories | null): Promise<Record<string, Record<string, Feature[]>> | null>; private createCoordinateSearchResult; /** * Detects and parses a coordinate search term into an array of two numerical values. * The method attempts to identify valid coordinate pairs from the given term, * using different separators such as `;`, `/`, `,`, or whitespace. */ detectCoordinatesInTerm(term: string): [number, number] | null; private parseCoordinateFromString; private isCoordinatePairValid; getZoomToBbox(feature: Feature): Extent | undefined; getI18nKeyForCategory(providerName: string, category: string): string; } export default SearchManager;